Author: scheu
Date: Fri Feb 1 15:18:35 2008
New Revision: 617700
URL: http://svn.apache.org/viewvc?rev=617700&view=rev
Log:
WSCOMMONS-300
Contributor:Takehide Nogayama
Committer:Rich Scheuerle
Added code to recognize that "isDataHandlerAware" is an immutable property of
the parser.
(Rich: I removed an extraneous import and I added some comments to the declared
property key).
Thanks for the patch !
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java?rev=617700&r1=617699&r2=617700&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
Fri Feb 1 15:18:35 2008
@@ -59,7 +59,11 @@
"xml";
String IS_BINARY = "Axiom.IsBinary";
String DATA_HANDLER = "Axiom.DataHandler";
- String IS_DATA_HANDLERS_AWARE = "IsDatahandlersAwareParsing";
+
+ // Indicates if the xmlstream reader is capable of handling data handlers.
+ // Thus it is an immutable property and will either be true of false for
the
+ // lifetime of that parser. @see OMStaxWrapper for an example
+ String IS_DATA_HANDLERS_AWARE = "IsDatahandlersAwareParsing";
/** No its not a mistake. This is the default nsURI of the default
namespace of a node */
static final String DEFAULT_DEFAULT_NAMESPACE = "\"\"";
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java?rev=617700&r1=617699&r2=617700&view=diff
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXBuilder.java
Fri Feb 1 15:18:35 2008
@@ -91,6 +91,8 @@
protected Map customBuilders = null;
protected int maxDepthForCustomBuilders = -1;
+ protected Boolean isDataHandlerAware = null; // property of parser,
https://issues.apache.org/jira/browse/WSCOMMONS-300
+
/**
* Element level is the depth of the element.
* The root element (i.e. envelope) is defined as 1.
@@ -247,7 +249,7 @@
*/
private OMNode createOMText(OMContainer omContainer, int textType) {
try {
- if (isDataHandlerAware(parser) &&
+ if (isDataHandlerAware() &&
Boolean.TRUE.equals(parser.getProperty(OMConstants.IS_BINARY))) {
Object dataHandler =
parser.getProperty(OMConstants.DATA_HANDLER);
OMText text = omfactory.createOMText(dataHandler, true);
@@ -649,19 +651,31 @@
* @param parser
* @return
*/
- private boolean isDataHandlerAware(XMLStreamReader parser) {
- // check whether data handlers are treated seperately
- try {
- if (parser != null &&
- (Boolean.TRUE ==
parser.getProperty(OMConstants.IS_DATA_HANDLERS_AWARE))) {
- return true;
+ private boolean isDataHandlerAware() {
+
+ // Is datahandler is immutable for a parser's lifetime. Thus it should
+ // only be checked one time.
+ if (isDataHandlerAware == null) {
+ // check whether data handlers are treated seperately
+ try {
+ if (parser != null &&
+ (Boolean.TRUE ==
parser.getProperty(OMConstants.IS_DATA_HANDLERS_AWARE))) {
+ isDataHandlerAware = Boolean.TRUE;
+ } else {
+ isDataHandlerAware = Boolean.FALSE;
+ }
+ } catch (IllegalArgumentException e) {
+ // according to the parser api, get property will return
IllegalArgumentException, when that
+ // property is not found.
+ } catch (IllegalStateException e) {
+ // it will also throw illegalStateExceptions if in wrong
state, ignore
}
- } catch (IllegalArgumentException e) {
- // according to the parser api, get property will return
IllegalArgumentException, when that
- // property is not found.
- } catch (IllegalStateException e) {
- // it will also throw illegalStateExceptions if in wrong state,
ignore
}
+
+ if (Boolean.TRUE.equals(isDataHandlerAware)) {
+ return true;
+ }
+
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]