abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r417890 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/Text.java parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java
Date Wed, 28 Jun 2006 22:30:05 GMT
Author: jmsnell
Date: Wed Jun 28 15:30:05 2006
New Revision: 417890

URL: http://svn.apache.org/viewvc?rev=417890&view=rev
Log:
Forgot to add the getWrappedValue/setWrappedValue on Text

Also, modified getBaseUri/getResolvedBaseUri/getLanguage on FOMContent and FOMText to 
do the right thing with xml:lang and xml:base when dealing with XHTML content -- 
specifically, if the container div has xml:lang, Content.getLanguage will return it's 
value.  If the container div has xml:base, Content.getBaseUri will return it's value
resolved against the Content element's own xml:base (if present).  Things just kind of
work themselves out from there.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Text.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Text.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Text.java?rev=417890&r1=417889&r2=417890&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Text.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Text.java Wed Jun
28 15:30:05 2006
@@ -89,4 +89,8 @@
   
   void setValueElement(Div value);
   
+  String getWrappedValue();
+  
+  void setWrappedValue(String wrappedValue);
+  
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java?rev=417890&r1=417889&r2=417890&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
Wed Jun 28 15:30:05 2006
@@ -279,4 +279,45 @@
     }
   }
 
+  @Override
+  public URI getBaseUri()
+    throws URISyntaxException {
+      if (Type.XHTML.equals(type)) {
+        Element el = getValueElement();
+        if (el != null) {
+          if (el.getAttributeValue(BASE) != null) {
+            if (getAttributeValue(BASE) != null)
+              return super.getBaseUri().resolve(
+                el.getAttributeValue(BASE));
+            else
+              return _getUriValue(el.getAttributeValue(BASE));
+          }
+        }
+      }
+      return super.getBaseUri();
+  }
+
+  @Override
+  public URI getResolvedBaseUri()
+    throws URISyntaxException {
+      if (Type.XHTML.equals(type)) {
+        Element el = getValueElement();
+        if (el != null) {
+          if (el.getAttributeValue(BASE) != null) {
+            return super.getResolvedBaseUri().resolve(
+              el.getAttributeValue(BASE));
+          }
+        }
+      }
+      return super.getResolvedBaseUri();
+  }
+  
+  @Override
+  public String getLanguage() {
+    return (!Type.XHTML.equals(type)) ?
+      super.getLanguage() : 
+      (getValueElement() != null) ? 
+         getValueElement().getLanguage() : 
+         super.getLanguage();
+  }
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java?rev=417890&r1=417889&r2=417890&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java
Wed Jun 28 15:30:05 2006
@@ -18,6 +18,7 @@
 package org.apache.abdera.parser.stax;
 
 import java.net.URI;
+import java.net.URISyntaxException;
 
 import javax.xml.namespace.QName;
 
@@ -33,7 +34,6 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 
-
 public class FOMText 
   extends FOMElement 
   implements Text {
@@ -141,6 +141,70 @@
       }
     } else 
       _removeAllChildren();
+  }
+
+  public String getWrappedValue() {
+    if (Type.XHTML.equals(type)) {
+      return this.getFirstChildWithName(Constants.DIV).toString();
+    } else {
+      return getValue();
+    }
+  }
+
+  public void setWrappedValue(String wrappedValue) {
+    if (Type.XHTML.equals(type)) {
+      URI baseUri = null;
+      try {
+        baseUri = getResolvedBaseUri();
+      } catch (Exception e) {}
+      Element element = _parse(wrappedValue, baseUri);
+      if (element != null && element instanceof Div)
+        setValueElement((Div)element);
+    } else {
+      setValue(wrappedValue);
+    }
+  }
+
+  @Override
+  public URI getBaseUri()
+    throws URISyntaxException {
+      if (Type.XHTML.equals(type)) {
+        Element el = getValueElement();
+        if (el != null) {
+          if (el.getAttributeValue(BASE) != null) {
+            if (getAttributeValue(BASE) != null)
+              return super.getBaseUri().resolve(
+                el.getAttributeValue(BASE));
+            else
+              return _getUriValue(el.getAttributeValue(BASE));
+          }
+        }
+      }
+      return super.getBaseUri();
+  }
+
+  @Override
+  public URI getResolvedBaseUri()
+    throws URISyntaxException {
+      if (Type.XHTML.equals(type)) {
+        Element el = getValueElement();
+        if (el != null) {
+          if (el.getAttributeValue(BASE) != null) {
+            return super.getResolvedBaseUri().resolve(
+              el.getAttributeValue(BASE));
+          }
+        }
+      }
+      return super.getResolvedBaseUri();
+  }
+  
+  @Override
+  public String getLanguage() {
+    return (!Type.XHTML.equals(type)) ?
+      super.getLanguage() : 
+      (getValueElement() != null) ? 
+         getValueElement().getLanguage() : 
+         super.getLanguage();
   }
 
 }



Mime
View raw message