Adapt to recent changes in Axiom.
git-svn-id: https://svn.apache.org/repos/asf/abdera/java/trunk@1677470 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/parser/src/main/java/org/apache/abdera/parser/stax/FOMCDATASection.java b/parser/src/main/java/org/apache/abdera/parser/stax/FOMCDATASection.java
new file mode 100644
index 0000000..4dad27d
--- /dev/null
+++ b/parser/src/main/java/org/apache/abdera/parser/stax/FOMCDATASection.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.parser.stax;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.TextValue;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.llom.CDATASectionImpl;
+
+@SuppressWarnings("unchecked")
+public class FOMCDATASection extends CDATASectionImpl implements TextValue {
+
+ public FOMCDATASection(OMFactory factory) {
+ super(factory);
+ }
+
+ public DataHandler getDataHandler() {
+ return (DataHandler)super.getDataHandler();
+ }
+
+ public InputStream getInputStream() {
+ try {
+ return getDataHandler().getInputStream();
+ } catch (IOException ex) {
+ throw new FOMException(ex);
+ }
+ }
+
+ public <T extends Base> T getParentElement() {
+ T parent = (T)super.getParent();
+ return (T)((parent instanceof Element) ? getWrapped((Element)parent) : parent);
+ }
+
+ protected Element getWrapped(Element internal) {
+ if (internal == null)
+ return null;
+ FOMFactory factory = (FOMFactory)getFactory();
+ return factory.getElementWrapper(internal);
+ }
+
+ public Factory getFactory() {
+ return (Factory)this.getOMFactory();
+ }
+
+ @Override
+ public String toString() {
+ return getText();
+ }
+
+}
diff --git a/parser/src/main/java/org/apache/abdera/parser/stax/FOMCharacterData.java b/parser/src/main/java/org/apache/abdera/parser/stax/FOMCharacterData.java
new file mode 100644
index 0000000..87b4941
--- /dev/null
+++ b/parser/src/main/java/org/apache/abdera/parser/stax/FOMCharacterData.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera.parser.stax;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.TextValue;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.llom.CharacterDataImpl;
+
+@SuppressWarnings("unchecked")
+public class FOMCharacterData extends CharacterDataImpl implements TextValue {
+
+ public FOMCharacterData(OMFactory factory) {
+ super(factory);
+ }
+
+ public DataHandler getDataHandler() {
+ return (DataHandler)super.getDataHandler();
+ }
+
+ public InputStream getInputStream() {
+ try {
+ return getDataHandler().getInputStream();
+ } catch (IOException ex) {
+ throw new FOMException(ex);
+ }
+ }
+
+ public <T extends Base> T getParentElement() {
+ T parent = (T)super.getParent();
+ return (T)((parent instanceof Element) ? getWrapped((Element)parent) : parent);
+ }
+
+ protected Element getWrapped(Element internal) {
+ if (internal == null)
+ return null;
+ FOMFactory factory = (FOMFactory)getFactory();
+ return factory.getElementWrapper(internal);
+ }
+
+ public Factory getFactory() {
+ return (Factory)this.getOMFactory();
+ }
+
+ @Override
+ public String toString() {
+ return getText();
+ }
+
+}
diff --git a/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java b/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
index 35d0350..efbf5e1 100644
--- a/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
+++ b/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
@@ -29,7 +29,7 @@
import org.apache.abdera.model.Element;
import org.apache.abdera.model.ElementWrapper;
import org.apache.abdera.util.Constants;
-import org.apache.axiom.attachments.utils.DataHandlerUtils;
+import org.apache.axiom.attachments.ByteArrayDataSource;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
@@ -37,6 +37,7 @@
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.util.base64.Base64Utils;
@SuppressWarnings("unchecked")
public class FOMContent extends FOMExtensibleElement implements Content {
@@ -179,9 +180,9 @@
}
DataHandler dh = null;
if (src == null) {
- dh =
- (DataHandler)DataHandlerUtils
- .getDataHandlerFromText(getText(), (type != null) ? type.toString() : null);
+ dh = new DataHandler(new ByteArrayDataSource(
+ Base64Utils.decode(getText()),
+ (type != null) ? type.toString() : null));
} else {
dh = new DataHandler(new URLDataSource(src));
}
diff --git a/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java b/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
index ae51400..bab1c72 100644
--- a/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
+++ b/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
@@ -54,6 +54,8 @@
import org.apache.abdera.util.Constants;
import org.apache.abdera.util.MimeTypeHelper;
import org.apache.abdera.util.Version;
+import org.apache.axiom.core.CoreCDATASection;
+import org.apache.axiom.core.CoreCharacterData;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMComment;
import org.apache.axiom.om.OMContainer;
@@ -62,7 +64,6 @@
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMProcessingInstruction;
-import org.apache.axiom.om.OMText;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
@@ -634,56 +635,6 @@
}
@Override
- public OMText createOMText(Object arg0, boolean arg1) {
- return new FOMTextValue(null, arg0, arg1, this, false);
- }
-
- @Override
- public OMText createOMText(OMContainer arg0, char[] arg1, int arg2) {
- return new FOMTextValue(arg0, arg1, arg2, this);
- }
-
- @Override
- public OMText createOMText(OMContainer arg0, QName arg1, int arg2) {
- return new FOMTextValue(arg0, arg1, arg2, this);
- }
-
- @Override
- public OMText createOMText(OMContainer arg0, QName arg1) {
- return new FOMTextValue(arg0, arg1, this);
- }
-
- @Override
- public OMText createOMText(OMContainer arg0, String arg1, int arg2) {
- return new FOMTextValue(arg0, arg1, arg2, this, false);
- }
-
- @Override
- public OMText createOMText(OMContainer arg0, String arg1, String arg2, boolean arg3) {
- return new FOMTextValue(arg0, arg1, arg2, arg3, this);
- }
-
- @Override
- public OMText createOMText(OMContainer arg0, String arg1) {
- return new FOMTextValue(arg0, arg1, this);
- }
-
- @Override
- public OMText createOMText(String arg0, int arg1) {
- return new FOMTextValue(arg0, arg1, this);
- }
-
- @Override
- public OMText createOMText(String arg0, String arg1, boolean arg2) {
- return new FOMTextValue(arg0, arg1, arg2, this);
- }
-
- @Override
- public OMText createOMText(String arg0) {
- return new FOMTextValue(arg0, this);
- }
-
- @Override
public OMComment createOMComment(OMContainer arg0, String arg1) {
return new FOMComment(arg0, arg1, this, false);
}
@@ -693,4 +644,13 @@
return new FOMProcessingInstruction(arg0, arg1, arg2, this, false);
}
+ @Override
+ public CoreCharacterData createCharacterData() {
+ return new FOMCharacterData(this);
+ }
+
+ @Override
+ public CoreCDATASection createCDATASection() {
+ return new FOMCDATASection(this);
+ }
}
diff --git a/parser/src/main/java/org/apache/abdera/parser/stax/FOMTextValue.java b/parser/src/main/java/org/apache/abdera/parser/stax/FOMTextValue.java
deleted file mode 100644
index fd5175a..0000000
--- a/parser/src/main/java/org/apache/abdera/parser/stax/FOMTextValue.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. The ASF licenses this file to You
- * under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.abdera.parser.stax;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Base;
-import org.apache.abdera.model.Element;
-import org.apache.abdera.model.TextValue;
-import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.impl.llom.OMTextImpl;
-
-@SuppressWarnings("unchecked")
-public class FOMTextValue extends OMTextImpl implements TextValue {
-
- public FOMTextValue(OMContainer parent, Object dataHandler,
- boolean optimize, OMFactory factory, boolean fromBuilder) {
- super(parent, dataHandler, optimize, factory, fromBuilder);
- }
-
- public FOMTextValue(Object dataHandler, OMFactory factory) {
- super(dataHandler, factory);
- }
-
- public FOMTextValue(OMContainer parent, char[] charArray, int nodeType, OMFactory factory) {
- super(parent, charArray, nodeType, factory);
- }
-
- public FOMTextValue(OMContainer parent, QName text, int nodeType, OMFactory factory) {
- super(parent, text, nodeType, factory);
- }
-
- public FOMTextValue(OMContainer parent, QName text, OMFactory factory) {
- super(parent, text, factory);
- }
-
- public FOMTextValue(OMContainer parent, String text, int nodeType,
- OMFactory factory, boolean fromBuilder) {
- super(parent, text, nodeType, factory, fromBuilder);
- }
-
- public FOMTextValue(OMContainer parent, String text, OMFactory factory) {
- super(parent, text, factory);
- }
-
- public FOMTextValue(OMContainer parent, String s, String mimeType, boolean optimize, OMFactory factory) {
- super(parent, s, mimeType, optimize, factory);
- }
-
- public FOMTextValue(String text, int nodeType, OMFactory factory) {
- super(text, nodeType, factory);
- }
-
- public FOMTextValue(String text, OMFactory factory) {
- super(text, factory);
- }
-
- public FOMTextValue(String s, String mimeType, boolean optimize, OMFactory factory) {
- super(s, mimeType, optimize, factory);
- }
-
- public DataHandler getDataHandler() {
- return (DataHandler)super.getDataHandler();
- }
-
- public InputStream getInputStream() {
- try {
- return getDataHandler().getInputStream();
- } catch (IOException ex) {
- throw new FOMException(ex);
- }
- }
-
- public <T extends Base> T getParentElement() {
- T parent = (T)super.getParent();
- return (T)((parent instanceof Element) ? getWrapped((Element)parent) : parent);
- }
-
- protected Element getWrapped(Element internal) {
- if (internal == null)
- return null;
- FOMFactory factory = (FOMFactory)getFactory();
- return factory.getElementWrapper(internal);
- }
-
- public Factory getFactory() {
- return (Factory)this.getOMFactory();
- }
-
- @Override
- public String toString() {
- return getText();
- }
-
-}