abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r503586 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ parser/src/main/java/org/apache/abdera/parser/stax/ parser/src/test/java/org/apache/abdera/test/parser/stax/
Date Mon, 05 Feb 2007 08:25:26 GMT
Author: jmsnell
Date: Mon Feb  5 00:25:25 2007
New Revision: 503586

URL: http://svn.apache.org/viewvc?view=rev&rev=503586
Log:
Get xml:lang as a Lang object.
Add a test case for xml:lang

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
    incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.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?view=diff&rev=503586&r1=503585&r2=503586
==============================================================================
--- 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 Mon
Feb  5 00:25:25 2007
@@ -24,6 +24,8 @@
 
 import org.apache.abdera.util.iri.IRI;
 import org.apache.abdera.util.iri.IRISyntaxException;
+import org.apache.abdera.util.lang.InvalidLangTagSyntax;
+import org.apache.abdera.util.lang.Lang;
 
 /**
  * Root interface for all elements in the Feed Object Model
@@ -94,6 +96,11 @@
    * @return The xml:lang value
    */
   String getLanguage();
+  
+  /**
+   * Returns the value of the xml:lang attribute as a Lang object
+   */
+  Lang getLanguageTag() throws InvalidLangTagSyntax;
   
   /**
    * Returns a Locale object created from the <code>xml:lang</code> attribute

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java?view=diff&rev=503586&r1=503585&r2=503586
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ElementWrapper.java
Mon Feb  5 00:25:25 2007
@@ -28,6 +28,8 @@
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.util.iri.IRI;
 import org.apache.abdera.util.iri.IRISyntaxException;
+import org.apache.abdera.util.lang.InvalidLangTagSyntax;
+import org.apache.abdera.util.lang.Lang;
 
 public abstract class ElementWrapper 
   implements Element {
@@ -108,6 +110,10 @@
 
   public String getLanguage() {
     return internal.getLanguage();
+  }
+  
+  public Lang getLanguageTag() throws InvalidLangTagSyntax {
+    return internal.getLanguageTag();
   }
 
   public Locale getLocale() {

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?view=diff&rev=503586&r1=503585&r2=503586
==============================================================================
--- 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
Mon Feb  5 00:25:25 2007
@@ -52,6 +52,8 @@
 import org.apache.abdera.util.URIHelper;
 import org.apache.abdera.util.iri.IRI;
 import org.apache.abdera.util.iri.IRISyntaxException;
+import org.apache.abdera.util.lang.InvalidLangTagSyntax;
+import org.apache.abdera.util.lang.Lang;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
@@ -204,6 +206,11 @@
   @SuppressWarnings("unchecked")
   public <T extends Element>T getFirstChild(QName qname) {
     return (T)getWrapped((Element)this.getFirstChildWithName(qname));
+  }
+  
+  public Lang getLanguageTag() throws InvalidLangTagSyntax {
+    String lang = getLanguage();
+    return (lang != null) ? new Lang(lang) : null;
   }
   
   public String getLanguage() {

Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java?view=diff&rev=503586&r1=503585&r2=503586
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
(original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
Mon Feb  5 00:25:25 2007
@@ -63,6 +63,7 @@
 import org.apache.abdera.util.Version;
 import org.apache.abdera.util.filter.BlackListParseFilter;
 import org.apache.abdera.util.filter.WhiteListParseFilter;
+import org.apache.abdera.util.lang.Lang;
 import org.apache.abdera.writer.Writer;
 import org.apache.abdera.writer.WriterFactory;
 import org.apache.abdera.xpath.XPath;
@@ -739,5 +740,17 @@
     Entry entry = abdera.newEntry();    
     entry.setDraft(true);  // this will create an app:control element
     assertNull(entry.getControl().getSimpleExtension(new QName("urn:foo", "foo")));
+  }
+  
+  public void testLang() throws Exception {
+    Abdera abdera = new Abdera();
+    Entry entry = abdera.newEntry();
+    entry.setLanguage("en-US");
+    assertEquals(entry.getLanguage(),"en-US");
+    Lang lang = entry.getLanguageTag();
+    assertNotNull(lang);
+    assertEquals(lang.getPrimary(),"en");
+    assertEquals(lang.getSubtag(0), "US");
+    assertEquals(lang.getLocale(), java.util.Locale.US);
   }
 }



Mime
View raw message