You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/05/02 14:15:24 UTC
svn commit: r1677310 - in /webservices/axiom/trunk:
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/
modules/axiom-api/src/main/java/org/apache/axiom/om/
Author: veithen
Date: Sat May 2 12:15:23 2015
New Revision: 1677310
URL: http://svn.apache.org/r1677310
Log:
Deprecate the capability to store a char[] (instead of a String) in an OMText. There is no known usage of that feature, there is no documentation and it is ill defined (e.g. is it legal to modify the array returned by getTextCharacters?).
Modified:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomTextSupport.aj
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMText.java
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomTextSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomTextSupport.aj?rev=1677310&r1=1677309&r2=1677310&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomTextSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomTextSupport.aj Sat May 2 12:15:23 2015
@@ -40,7 +40,6 @@ public aspect AxiomTextSupport {
// TODO: should be private
public String AxiomText.value;
- private char[] AxiomText.charArray;
private String AxiomText.mimeType;
@@ -75,46 +74,36 @@ public aspect AxiomTextSupport {
}
}
- /**
- * This OMText contains two data source:value and charArray. This method will return text from
- * correct place.
- */
- private String AxiomText.getTextFromProperPlace() {
- return charArray != null ? new String(charArray) : value;
- }
-
public final String AxiomText.getText() throws OMException {
- if (charArray != null || value != null) {
- return getTextFromProperPlace();
- } else {
+ if (dataHandlerObject != null) {
try {
return Base64Utils.encode((DataHandler)getDataHandler());
} catch (Exception e) {
throw new OMException(e);
}
+ } else {
+ return value;
}
}
public final char[] AxiomText.getTextCharacters() {
- if (charArray != null) {
- return charArray;
- } else if (value != null) {
- return value.toCharArray();
- } else {
+ if (dataHandlerObject != null) {
try {
return Base64Utils.encodeToCharArray((DataHandler)getDataHandler());
} catch (IOException ex) {
throw new OMException(ex);
}
+ } else {
+ return value.toCharArray();
}
}
public final boolean AxiomText.isCharacters() {
- return charArray != null;
+ return false;
}
public final QName AxiomText.getTextAsQName() throws OMException {
- return ((OMElement)getParent()).resolveQName(getTextFromProperPlace());
+ return ((OMElement)getParent()).resolveQName(getText());
}
public final OMNamespace AxiomText.getNamespace() {
@@ -130,13 +119,8 @@ public aspect AxiomTextSupport {
// TODO: should be final, but Abdera overrides this method
public Object AxiomText.getDataHandler() {
- if ((value != null || charArray != null) && isBinary()) {
- return new DataHandler(new ByteArrayDataSource(
- Base64Utils.decode(getTextFromProperPlace()), mimeType));
- } else {
- if (dataHandlerObject == null) {
- throw new OMException("No DataHandler available");
- } else if (dataHandlerObject instanceof DataHandlerProvider) {
+ if (dataHandlerObject != null) {
+ if (dataHandlerObject instanceof DataHandlerProvider) {
try {
dataHandlerObject = ((DataHandlerProvider)dataHandlerObject).getDataHandler();
} catch (IOException ex) {
@@ -144,6 +128,11 @@ public aspect AxiomTextSupport {
}
}
return dataHandlerObject;
+ } else if (isBinary()) {
+ return new DataHandler(new ByteArrayDataSource(
+ Base64Utils.decode(value), mimeType));
+ } else {
+ throw new OMException("No DataHandler available");
}
}
@@ -179,10 +168,6 @@ public aspect AxiomTextSupport {
this.value = value;
}
- public final void AxiomText.internalSetCharArray(char[] charArray) {
- this.charArray = charArray;
- }
-
public final void AxiomText.internalSetMimeType(String mimeType) {
this.mimeType = mimeType;
}
@@ -203,12 +188,6 @@ public aspect AxiomTextSupport {
AxiomText clone = createInstanceOfSameType();
clone.value = value;
- // Clone the charArray (if it exists)
- if (charArray != null) {
- clone.charArray = new char[charArray.length];
- System.arraycopy(charArray, 0, clone.charArray, 0, charArray.length);
- }
-
// Copy the optimized related settings.
clone.optimize = optimize;
clone.mimeType = mimeType;
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj?rev=1677310&r1=1677309&r2=1677310&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/factory/AxiomNodeFactorySupport.aj Sat May 2 12:15:23 2015
@@ -85,9 +85,7 @@ public aspect AxiomNodeFactorySupport {
}
public final OMText AxiomNodeFactory.createOMText(OMContainer parent, char[] charArray, int type) {
- AxiomText node = createAxiomText(parent, type, false);
- node.internalSetCharArray(charArray);
- return node;
+ return createOMText(parent, new String(charArray), type, false);
}
public final OMText AxiomNodeFactory.createOMText(OMContainer parent, QName text, int type) {
Modified: webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java?rev=1677310&r1=1677309&r2=1677310&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/main/java/org/apache/axiom/om/OMFactory.java Sat May 2 12:15:23 2015
@@ -255,6 +255,9 @@ public interface OMFactory {
*/
OMText createOMText(OMContainer parent, String text, int type);
+ /**
+ * @deprecated
+ */
OMText createOMText(OMContainer parent, char[] charArary, int type);
/**
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=1677310&r1=1677309&r2=1677310&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 Sat May 2 12:15:23 2015
@@ -55,8 +55,14 @@ public interface OMText extends OMNode {
*/
String getText();
+ /**
+ * @deprecated
+ */
char[] getTextCharacters();
+ /**
+ * @deprecated
+ */
boolean isCharacters();
/**