Author: veithen
Date: Fri Jul 11 21:18:53 2014
New Revision: 1609841
URL: http://svn.apache.org/r1609841
Log:
Start to merge the OMText implementations.
Added:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IText.java
(with props)
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMTextSupport.aj
Modified:
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
Modified:
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java?rev=1609841&r1=1609840&r2=1609841&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
(original)
+++
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
Fri Jul 11 21:18:53 2014
@@ -80,6 +80,7 @@ public interface OMText extends OMNode {
Object getDataHandler();
/** @return Returns boolean flag saying whether the node contains an
optimized text or not. */
+ // TODO: inconsistent naming
boolean isOptimized();
/**
@@ -94,6 +95,9 @@ public interface OMText extends OMNode {
/**
* Sets the isBinary flag.
+ * Receiving binary can happen as either MTOM attachments or as Base64
Text In the case of
+ * Base64 user has to explicitly specify that the content is binary,
before calling
+ * getDataHandler(), getInputStream()....
*
* @param value true if the content is binary
*/
Added:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IText.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IText.java?rev=1609841&view=auto
==============================================================================
---
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IText.java
(added)
+++
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IText.java
Fri Jul 11 21:18:53 2014
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. 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.
+ */
+package org.apache.axiom.om.impl.common;
+
+import org.apache.axiom.om.OMText;
+
+public interface IText extends OMText, INode {
+
+}
Propchange:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/IText.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMTextSupport.aj
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMTextSupport.aj?rev=1609841&view=auto
==============================================================================
---
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMTextSupport.aj
(added)
+++
webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMTextSupport.aj
Fri Jul 11 21:18:53 2014
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. 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.
+ */
+package org.apache.axiom.om.impl.common;
+
+import org.apache.axiom.om.OMText;
+
+public aspect OMTextSupport {
+ declare parents: (InformationItem+ && OMText+) implements IText;
+
+ private boolean IText.optimize;
+ private boolean IText.binary;
+
+ public final boolean IText.isBinary() {
+ return binary;
+ }
+
+ public final void IText.setBinary(boolean binary) {
+ this.binary = binary;
+ }
+
+ public final boolean IText.isOptimized() {
+ return optimize;
+ }
+
+ public final void IText.setOptimize(boolean optimize) {
+ this.optimize = optimize;
+ if (optimize) {
+ binary = true;
+ }
+ }
+}
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java?rev=1609841&r1=1609840&r2=1609841&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
Fri Jul 11 21:18:53 2014
@@ -45,10 +45,6 @@ import java.io.IOException;
public abstract class TextNodeImpl extends CharacterImpl implements Text,
OMText {
private String mimeType;
- private boolean optimize;
-
- private boolean isBinary;
-
private String contentID;
protected char[] charArray;
@@ -96,9 +92,9 @@ public abstract class TextNodeImpl exten
}
// Copy the optimized related settings.
- this.optimize = source.optimize;
+ setOptimize(source.isOptimized());
this.mimeType = source.mimeType;
- this.isBinary = source.isBinary;
+ setBinary(source.isBinary());
// TODO
// Do we need a deep copy of the data-handler
@@ -115,8 +111,8 @@ public abstract class TextNodeImpl exten
boolean isBinary, OMFactory factory) {
this(text, factory);
this.mimeType = mimeType;
- this.optimize = optimize;
- this.isBinary = isBinary;
+ setOptimize(optimize);
+ setBinary(isBinary());
}
/**
@@ -127,8 +123,8 @@ public abstract class TextNodeImpl exten
OMFactory factory) {
super(factory);
this.dataHandlerObject = dataHandler;
- this.isBinary = true;
- this.optimize = optimize;
+ setBinary(true);
+ setOptimize(optimize);
}
/**
@@ -144,8 +140,8 @@ public abstract class TextNodeImpl exten
super(factory);
this.contentID = contentID;
dataHandlerObject = dataHandlerProvider;
- isBinary = true;
- this.optimize = optimize;
+ setBinary(true);
+ setOptimize(optimize);
}
/**
@@ -205,17 +201,6 @@ public abstract class TextNodeImpl exten
// /OMNode methods
// /
- public boolean isOptimized() {
- return this.optimize;
- }
-
- public void setOptimize(boolean value) {
- this.optimize = value;
- if (value) {
- isBinary = true;
- }
- }
-
public String getText() {
if (this.charArray != null || this.textValue != null) {
return getTextFromProperPlace();
@@ -270,7 +255,7 @@ public abstract class TextNodeImpl exten
* this should return a DataHandler containing the binary data
* reperesented by the Base64 strings stored in OMText
*/
- if ((textValue != null || charArray != null) & isBinary) {
+ if ((textValue != null || charArray != null) & isBinary()) {
return
DataHandlerUtils.getDataHandlerFromText(getTextFromProperPlace(), mimeType);
} else {
@@ -288,12 +273,12 @@ public abstract class TextNodeImpl exten
}
public void internalSerialize(Serializer serializer, OMOutputFormat
format, boolean cache) throws OutputException {
- if (!this.isBinary) {
+ if (!isBinary()) {
serializer.writeText(getType(), getText());
} else if (dataHandlerObject instanceof DataHandlerProvider) {
-
serializer.writeDataHandler((DataHandlerProvider)dataHandlerObject, contentID,
optimize);
+
serializer.writeDataHandler((DataHandlerProvider)dataHandlerObject, contentID,
isOptimized());
} else {
- serializer.writeDataHandler((DataHandler)getDataHandler(),
contentID, optimize);
+ serializer.writeDataHandler((DataHandler)getDataHandler(),
contentID, isOptimized());
}
}
@@ -347,20 +332,6 @@ public abstract class TextNodeImpl exten
}
}
- public boolean isBinary() {
- return isBinary;
- }
-
- /**
- * Receiving binary can happen as either MTOM attachments or as Base64
Text In the case of Base64
- * user has to explicitly specify that the content is binary, before
calling getDataHandler(),
- * getInputStream()....
- */
- public void setBinary(boolean value) {
- this.isBinary = value;
-
- }
-
public OMNamespace getNamespace() {
// Note: efficiency is not important here; the method is deprecated
anyway
QName qname = getTextAsQName();
@@ -377,7 +348,7 @@ public abstract class TextNodeImpl exten
}
void beforeClone(OMCloneOptions options) {
- if (isBinary && options.isFetchDataHandlers()) {
+ if (isBinary() && options.isFetchDataHandlers()) {
// Force loading of the reference to the DataHandler and ensure
that its content is
// completely fetched into memory (or temporary storage).
((DataHandler)getDataHandler()).getDataSource();
Modified:
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java?rev=1609841&r1=1609840&r2=1609841&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
Fri Jul 11 21:18:53 2014
@@ -54,10 +54,6 @@ public class OMTextImpl extends OMLeafNo
protected String mimeType;
- protected boolean optimize;
-
- protected boolean isBinary;
-
/** Field contentID for the mime part used when serializing Binary stuff
as MTOM optimized. */
private String contentID;
@@ -116,9 +112,9 @@ public class OMTextImpl extends OMLeafNo
}
// Copy the optimized related settings.
- this.optimize = source.optimize;
+ setOptimize(source.isOptimized());
this.mimeType = source.mimeType;
- this.isBinary = source.isBinary;
+ setBinary(source.isBinary());
// TODO
// Do we need a deep copy of the data-handler
@@ -173,8 +169,8 @@ public class OMTextImpl extends OMLeafNo
boolean optimize, OMFactory factory) {
this(parent, s, factory);
this.mimeType = mimeType;
- this.optimize = optimize;
- this.isBinary = true;
+ setOptimize(optimize);
+ setBinary(true);
}
/** @param dataHandler To send binary optimised content Created
programatically. */
@@ -189,8 +185,8 @@ public class OMTextImpl extends OMLeafNo
public OMTextImpl(OMContainer parent, Object dataHandler, boolean
optimize, OMFactory factory, boolean fromBuilder) {
super(parent, factory, fromBuilder);
this.dataHandlerObject = dataHandler;
- this.isBinary = true;
- this.optimize = optimize;
+ setBinary(true);
+ setOptimize(optimize);
this.nodeType = TEXT_NODE;
}
@@ -206,8 +202,8 @@ public class OMTextImpl extends OMLeafNo
super(factory);
this.contentID = contentID;
dataHandlerObject = dataHandlerProvider;
- isBinary = true;
- this.optimize = optimize;
+ setBinary(true);
+ setOptimize(optimize);
nodeType = TEXT_NODE;
}
@@ -269,32 +265,8 @@ public class OMTextImpl extends OMLeafNo
}
}
- public boolean isOptimized() {
- return optimize;
- }
-
- public void setOptimize(boolean value) {
- this.optimize = value;
- if (value) {
- isBinary = true;
- }
- }
-
- /**
- * Receiving binary can happen as either MTOM attachments or as Base64
Text In the case of
- * Base64 user has to explicitly specify that the content is binary,
before calling
- * getDataHandler(), getInputStream()....
- */
- public void setBinary(boolean value) {
- isBinary = value;
- }
-
- public boolean isBinary() {
- return isBinary;
- }
-
public Object getDataHandler() {
- if ((value != null || charArray != null) && isBinary) {
+ if ((value != null || charArray != null) && isBinary()) {
String text = getTextFromProperPlace();
return org.apache.axiom.attachments.utils.DataHandlerUtils
.getDataHandlerFromText(text, mimeType);
@@ -322,12 +294,12 @@ public class OMTextImpl extends OMLeafNo
public void internalSerialize(Serializer serializer, OMOutputFormat
format, boolean cache) throws OutputException {
- if (!this.isBinary) {
+ if (!isBinary()) {
serializer.writeText(getType(), getText());
} else if (dataHandlerObject instanceof DataHandlerProvider) {
-
serializer.writeDataHandler((DataHandlerProvider)dataHandlerObject, contentID,
optimize);
+
serializer.writeDataHandler((DataHandlerProvider)dataHandlerObject, contentID,
isOptimized());
} else {
- serializer.writeDataHandler((DataHandler)getDataHandler(),
contentID, optimize);
+ serializer.writeDataHandler((DataHandler)getDataHandler(),
contentID, isOptimized());
}
}
@@ -343,7 +315,7 @@ public class OMTextImpl extends OMLeafNo
}
OMNode clone(OMCloneOptions options, OMContainer targetParent) {
- if (isBinary && options.isFetchDataHandlers()) {
+ if (isBinary() && options.isFetchDataHandlers()) {
// Force loading of the reference to the DataHandler and ensure
that its content is
// completely fetched into memory (or temporary storage).
((DataHandler)getDataHandler()).getDataSource();