abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r431757 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/Element.java parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Date Wed, 16 Aug 2006 01:19:38 GMT
Author: jmsnell
Date: Tue Aug 15 18:19:37 2006
New Revision: 431757

URL: http://svn.apache.org/viewvc?rev=431757&view=rev
Log:
Add a method for returning an appropriate java.util.Locale based on the value of xml:base

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java?rev=431757&r1=431756&r2=431757&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java Tue
Aug 15 18:19:37 2006
@@ -21,6 +21,7 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.List;
+import java.util.Locale;
 
 import javax.xml.namespace.QName;
 
@@ -53,6 +54,11 @@
    * null if <code>xml:lang</code> is undefined.
    */
   String getLanguage();
+  
+  /**
+   * Returns a Locale object created from the <code>xml:lang</code> attribute
+   */
+  Locale getLocale();
   
   /**
    * Sets the value of this elements <code>xml:lang</code> attribute.

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=431757&r1=431756&r2=431757&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Tue Aug 15 18:19:37 2006
@@ -27,6 +27,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -563,5 +564,19 @@
   
   public void addComment(String value) {
     factory.createOMComment(this, value);
+  }
+  
+  public Locale getLocale() {
+    String tag = getLanguage();
+    if (tag == null || tag.length() == 0) return null;
+    String[] tokens = tag.split("-");
+    Locale locale = null;
+    switch(tokens.length) {
+      case 0:  break;
+      case 1:  locale = new Locale(tokens[0]); break;
+      case 2:  locale = new Locale(tokens[0],tokens[1]); break;
+      default: locale = new Locale(tokens[0],tokens[1],tokens[2]); break;
+    }
+    return locale;
   }
 }



Mime
View raw message