Author: veithen
Date: Fri Jul 18 21:31:26 2014
New Revision: 1611812
URL: http://svn.apache.org/r1611812
Log:
Clean up the DOMException code and move it to dom-aspects.
Added:
webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
- copied, changed from r1611509,
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMMessageFormatter.java
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/dom/
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/dom/DOMExceptionUtil.properties
- copied, changed from r1611509,
webservices/axiom/trunk/modules/axiom-dom/src/main/resources/org/apache/axiom/om/impl/dom/msg/DOMMessages.properties
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/DOMExceptionUtilTest.java
(with props)
Removed:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMMessageFormatter.java
webservices/axiom/trunk/modules/axiom-dom/src/main/resources/org/apache/axiom/om/impl/dom/msg/DOMMessages.properties
Modified:
webservices/axiom/trunk/aspects/dom-aspects/pom.xml
webservices/axiom/trunk/aspects/pom.xml
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextNodeImpl.java
Modified: webservices/axiom/trunk/aspects/dom-aspects/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/pom.xml?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/dom-aspects/pom.xml (original)
+++ webservices/axiom/trunk/aspects/dom-aspects/pom.xml Fri Jul 18 21:31:26 2014
@@ -37,5 +37,10 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Copied:
webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
(from r1611509,
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMMessageFormatter.java)
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java?p2=webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java&p1=webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMMessageFormatter.java&r1=1611509&r2=1611812&rev=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMMessageFormatter.java
(original)
+++
webservices/axiom/trunk/aspects/dom-aspects/src/main/java/org/apache/axiom/dom/DOMExceptionUtil.java
Fri Jul 18 21:31:26 2014
@@ -16,25 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.axiom.dom;
-package org.apache.axiom.om.impl.dom;
-
-import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
-/** Used to format DOM error messages, using the system locale. */
-public class DOMMessageFormatter {
- private static final ResourceBundle resourceBundle;
-
- public static final String LEVEL3_NOT_SUPPORTED =
- "DOM Level 3 operations are not supported";
+import org.w3c.dom.DOMException;
- public static final String NOT_REQUIRED_FOR_XMLSEC_OR_WSS4J =
- "This method is not required by Apache XML-Security Impl or WSS4J";
+public final class DOMExceptionUtil {
+ private static final ResourceBundle resourceBundle =
+ PropertyResourceBundle.getBundle(DOMExceptionUtil.class.getName());
- private static final String[] exceptionKeys = {
+ private static final String[] codeStrings = {
// Note: order is determined by the constants defined in DOMException
"INDEX_SIZE_ERR",
"DOMSTRING_SIZE_ERR",
@@ -54,60 +48,21 @@ public class DOMMessageFormatter {
"VALIDATION_ERR",
"TYPE_MISMATCH_ERR",
};
-
- static {
- resourceBundle = PropertyResourceBundle.getBundle(
- "org.apache.axiom.om.impl.dom.msg.DOMMessages",
Locale.getDefault());
- }
-
- /**
- * Formats a message with the specified arguments using the given locale
information.
- * @param key The message key.
- * @param arguments The message replacement text arguments. The order of
the arguments must
- * match that of the placeholders in the actual message.
- *
- * @return Returns the formatted message.
- * @throws MissingResourceException Thrown if the message with the
specified key cannot be
- * found.
- */
- public static String formatMessage(String key, Object[] arguments) throws
MissingResourceException {
- // format message
- String msg;
+
+ private DOMExceptionUtil() {}
+
+ public static DOMException newDOMException(short code) {
+ String key = codeStrings[code-1];
+ String message;
try {
- msg = key + ": " + resourceBundle.getString(key);
- if (arguments != null) {
- try {
- msg = java.text.MessageFormat.format(msg, arguments);
- } catch (Exception e) {
- msg = resourceBundle.getString("FormatFailed");
- msg += " " + resourceBundle.getString(key);
- }
- }
- } // error
- catch (MissingResourceException e) {
- msg = resourceBundle.getString("BadMessageKey");
- throw new MissingResourceException(key, msg, key);
+ message = resourceBundle.getString(key);
+ } catch (MissingResourceException ex) {
+ message = null;
}
-
- // no message
- if (msg == null) {
- msg = key;
- if (arguments.length > 0) {
- StringBuffer str = new StringBuffer(msg);
- str.append('?');
- for (int i = 0; i < arguments.length; i++) {
- if (i > 0) {
- str.append('&');
- }
- str.append(String.valueOf(arguments[i]));
- }
- }
+ if (message == null) {
+ return new DOMException(code, key);
+ } else {
+ return new DOMException(code, key + ": " + message);
}
-
- return msg;
- }
-
- public static String formatMessage(int exceptionId, Object[] arguments)
throws MissingResourceException {
- return formatMessage(exceptionKeys[exceptionId-1], arguments);
}
}
Copied:
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/dom/DOMExceptionUtil.properties
(from r1611509,
webservices/axiom/trunk/modules/axiom-dom/src/main/resources/org/apache/axiom/om/impl/dom/msg/DOMMessages.properties)
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/dom/DOMExceptionUtil.properties?p2=webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/dom/DOMExceptionUtil.properties&p1=webservices/axiom/trunk/modules/axiom-dom/src/main/resources/org/apache/axiom/om/impl/dom/msg/DOMMessages.properties&r1=1611509&r2=1611812&rev=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/resources/org/apache/axiom/om/impl/dom/msg/DOMMessages.properties
(original)
+++
webservices/axiom/trunk/aspects/dom-aspects/src/main/resources/org/apache/axiom/dom/DOMExceptionUtil.properties
Fri Jul 18 21:31:26 2014
@@ -16,20 +16,6 @@
# specific language governing permissions and limitations
# under the License.
#
-
-# This file stores localized messages for the Xerces
-# DOM implementation.
-#
-# The messages are arranged in key and value tuples in a ListResourceBundle.
-#
-# @version $Id: DOMMessages.properties,v 1.10 2004/07/05 22:36:53 mrglavas Exp
$
-
- BadMessageKey = The error message corresponding to the message key can
not be found.
- FormatFailed = An internal error occurred while formatting the
following message:\n
-
-# DOM Core
-
-# exception codes
DOMSTRING_SIZE_ERR = The specified range of text does not fit into a
DOMString.
HIERARCHY_REQUEST_ERR = An attempt was made to insert a node where it is not
permitted.
INDEX_SIZE_ERR = The index or size is negative, or greater than the allowed
value.
@@ -47,39 +33,3 @@ SYNTAX_ERR = An invalid or illegal strin
VALIDATION_ERR = A call to a method such as insertBefore or removeChild would
make the Node invalid with respect to document grammar.
WRONG_DOCUMENT_ERR = A node is used in a different document than the one that
created it.
TYPE_MISMATCH_ERR = The value type for this parameter name is incompatible
with the expected value type.
-
-#error messages or exceptions
-FEATURE_NOT_SUPPORTED = The parameter {0} is recognized but the requested
value cannot be set.
-FEATURE_NOT_FOUND = The parameter {0} is not recognized.
-STRING_TOO_LONG = The resulting string is too long to fit in a DOMString:
''{0}''.
-
-#DOM Level 3 DOMError codes
-wf-invalid-character = The text {0} of the {1} node contains invalid XML
characters.
-wf-invalid-character-in-node-name = The {0} node named {1} contains invalid
XML characters.
-cdata-sections-splitted = CDATA sections containing the CDATA section
termination marker '']]>''
-doctype-not-allowed = DOCTYPE declaration is not allowed.
-unsupported-encoding = The encoding {0} is not supported.
-
-#Error codes used in DOM Normalizer
-InvalidXMLCharInDOM = An invalid XML character (Unicode: 0x{0}) was found in
the DOM during normalization.
-UndeclaredEntRefInAttrValue = The attribute \"{0}\" value \"{1}\" referenced
an entity that was not declared.
-NullLocalElementName = A null local name was encountered during namespace
normalization of element {0}.
-NullLocalAttrName = A null local name was encountered during namespace
normalization of attribute {0}.
-
-#Error codes used in DOMParser
-InvalidDocumentClassName = The class name of the document factory \"{0}\" used
to construct the DOM tree is not of type org.w3c.dom.Document.
-MissingDocumentClassName = The class name of the document factory \"{0}\" used
to construct the DOM tree could not be found.
-CannotCreateDocumentClass = The class named \"{0}\" could not be constructed
as a org.w3c.dom.Document.
-
-# Error codes used by JAXP DocumentBuilder
-jaxp-order-not-supported = Property ''{0}'' must be set before setting
property ''{1}''.
-jaxp-null-input-source = The source specified cannot be null.
-
-#Ranges
-BAD_BOUNDARYPOINTS_ERR = The boundary-points of a Range do not meet specific
requirements.
-INVALID_NODE_TYPE_ERR = The container of a boundary-point of a Range is being
set to either a node of an invalid type or a node with an ancestor of an
invalid type.
-
-
-#Events
-UNSPECIFIED_EVENT_TYPE_ERR = The Event's type was not specified by
initializing the event before the method was called.
-
Added:
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/DOMExceptionUtilTest.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/DOMExceptionUtilTest.java?rev=1611812&view=auto
==============================================================================
---
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/DOMExceptionUtilTest.java
(added)
+++
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/DOMExceptionUtilTest.java
Fri Jul 18 21:31:26 2014
@@ -0,0 +1,35 @@
+/*
+ * 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.dom;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+import org.w3c.dom.DOMException;
+
+public class DOMExceptionUtilTest {
+ @Test
+ public void testMessage() {
+ DOMException ex =
DOMExceptionUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ assertThat(ex.getMessage(), is(equalTo(
+ "NOT_FOUND_ERR: An attempt is made to reference a node in a
context where it does not exist.")));
+ }
+}
Propchange:
webservices/axiom/trunk/aspects/dom-aspects/src/test/java/org/apache/axiom/dom/DOMExceptionUtilTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/aspects/pom.xml
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/pom.xml?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/pom.xml (original)
+++ webservices/axiom/trunk/aspects/pom.xml Fri Jul 18 21:31:26 2014
@@ -41,6 +41,10 @@
<phase>none</phase>
</execution>
</executions>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import javax.xml.XMLConstants;
import org.apache.axiom.core.NonDeferringParentNode;
@@ -258,7 +260,7 @@ public class AttrImpl extends RootNode i
final void checkInUse() {
if (coreGetOwnerElement() != null) {
- throw DOMUtil.newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ throw newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
}
}
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttributeMap.java
Fri Jul 18 21:31:26 2014
@@ -19,12 +19,14 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
+import java.util.Vector;
+
import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import java.util.Vector;
-
/** Most of the implementation is taken from
org.apache.xerces.dom.NamedNodeMapImpl */
public class AttributeMap implements NamedNodeMap {
private Vector nodes;
@@ -77,7 +79,7 @@ public class AttributeMap implements Nam
int i = findNamePoint(name, 0);
if (i < 0) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
NodeImpl n = (NodeImpl) nodes.elementAt(i);
@@ -91,7 +93,7 @@ public class AttributeMap implements Nam
int i = findNamePoint(namespaceURI, name);
if (i < 0) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
NodeImpl n = (NodeImpl) nodes.elementAt(i);
@@ -105,7 +107,7 @@ public class AttributeMap implements Nam
ownerNode.checkSameOwnerDocument(attribute);
if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
AttrImpl attr = (AttrImpl) attribute;
@@ -113,7 +115,7 @@ public class AttributeMap implements Nam
if (attr.getOwnerElement() != this.ownerNode) // the owner must be
// the owner of this
// list
- throw
DOMUtil.newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ throw newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
else
return attr; // No point adding the 'same' attr again to the
// same element
@@ -155,14 +157,14 @@ public class AttributeMap implements Nam
/** Almost a copy of the Xerces impl. */
Node setAttribute(Node attribute, boolean useDomSemantics) throws
DOMException {
if (attribute.getNodeType() != Node.ATTRIBUTE_NODE) {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
AttrImpl attr = (AttrImpl) attribute;
if (attr.getOwnerElement() != null) { // If the attribute is owned
then:
//the owner must be the owner of this list
if (attr.getOwnerElement() != this.ownerNode)
- throw
DOMUtil.newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ throw newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
else
return attr; // No point adding the 'same' attr again to the
// same element
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/CharacterImpl.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.impl.OMNodeEx;
import org.w3c.dom.CharacterData;
@@ -70,7 +72,7 @@ public abstract class CharacterImpl exte
int length = this.textValue.length();
if (offset < 0 || offset > length - 1 || count < 0) {
- throw DOMUtil.newDOMException(DOMException.INDEX_SIZE_ERR);
+ throw newDOMException(DOMException.INDEX_SIZE_ERR);
} else {
int end = Math.min(count + offset, length);
@@ -95,7 +97,7 @@ public abstract class CharacterImpl exte
int length = this.getLength();
if (offset < 0 || offset > length) {
- throw DOMUtil.newDOMException(DOMException.INDEX_SIZE_ERR);
+ throw newDOMException(DOMException.INDEX_SIZE_ERR);
}
this.textValue = (new StringBuilder(textValue)).insert(offset,
data).toString();
@@ -114,7 +116,7 @@ public abstract class CharacterImpl exte
*/
public String substringData(int offset, int count) throws DOMException {
if (offset < 0 || offset > this.getLength() || count < 0) {
- throw DOMUtil.newDOMException(DOMException.INDEX_SIZE_ERR);
+ throw newDOMException(DOMException.INDEX_SIZE_ERR);
}
int end = Math.min(count + offset, textValue.length());
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ChildNode.java
Fri Jul 18 21:31:26 2014
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.CoreChildNode;
import org.apache.axiom.dom.DOMChildNode;
import org.apache.axiom.om.OMCloneOptions;
@@ -103,7 +105,7 @@ public abstract class ChildNode extends
}
public final void setPrefix(String prefix) throws DOMException {
- throw DOMUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ throw newDOMException(DOMException.NAMESPACE_ERR);
}
public final String getLocalName() {
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DOMUtil.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import javax.xml.XMLConstants;
import org.w3c.dom.DOMException;
@@ -35,11 +37,11 @@ class DOMUtil {
private static void validateName(String namespaceURI, String localName,
String prefix) {
if (prefix != null && !XMLChar.isValidNCName(prefix)
|| !XMLChar.isValidNCName(localName)) {
- throw DOMUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ throw newDOMException(DOMException.INVALID_CHARACTER_ERR);
}
if (namespaceURI == null && prefix != null
|| XMLConstants.XML_NS_PREFIX.equals(prefix) &&
!XMLConstants.XML_NS_URI.equals(namespaceURI)) {
- throw DOMUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ throw newDOMException(DOMException.NAMESPACE_ERR);
}
}
@@ -52,7 +54,7 @@ class DOMUtil {
if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix != null ? prefix :
localName)
!= XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
- throw DOMUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ throw newDOMException(DOMException.NAMESPACE_ERR);
}
}
@@ -87,9 +89,4 @@ class DOMUtil {
return qualifiedName.substring(0, idx);
}
}
-
- public static DOMException newDOMException(short code) {
- return new DOMException(code, DOMMessageFormatter.formatMessage(
- code, null));
- }
}
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentFragmentImpl.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.NonDeferringParentNode;
import org.apache.axiom.dom.DOMDocumentFragment;
import org.apache.axiom.om.OMCloneOptions;
@@ -106,7 +108,7 @@ public class DocumentFragmentImpl extend
}
public final void setPrefix(String prefix) throws DOMException {
- throw DOMUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ throw newDOMException(DOMException.NAMESPACE_ERR);
}
public final String getLocalName() {
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.CoreChildNode;
import org.apache.axiom.dom.DOMDocument;
import org.apache.axiom.om.OMCloneOptions;
@@ -98,7 +100,7 @@ public class DocumentImpl extends RootNo
public Attr createAttribute(String name) throws DOMException {
if (!DOMUtil.isQualifiedName(name)) {
- throw DOMUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ throw newDOMException(DOMException.INVALID_CHARACTER_ERR);
}
return new AttrImpl(this, name, getOMFactory());
}
@@ -306,7 +308,7 @@ public class DocumentImpl extends RootNo
case Node.DOCUMENT_NODE: // Can't import document nodes
default:
- throw DOMUtil.newDOMException(DOMException.NOT_SUPPORTED_ERR);
+ throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
}
// If deep, replicate and attach the kids.
@@ -557,6 +559,6 @@ public class DocumentImpl extends RootNo
}
public final void setPrefix(String prefix) throws DOMException {
- throw DOMUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ throw newDOMException(DOMException.NAMESPACE_ERR);
}
}
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.CoreChildNode;
import org.apache.axiom.dom.DOMConfigurationImpl;
import org.apache.axiom.dom.DOMElement;
@@ -207,7 +209,7 @@ public class ElementImpl extends ParentN
*/
public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
if (oldAttr.getOwnerElement() != this) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
attributes.remove((AttrImpl)oldAttr, true);
return oldAttr;
@@ -321,7 +323,7 @@ public class ElementImpl extends ParentN
public void setAttribute(String name, String value) throws DOMException {
// Check for invalid charaters
if (!DOMUtil.isQualifiedName(name)) {
- throw DOMUtil.newDOMException(DOMException.INVALID_CHARACTER_ERR);
+ throw newDOMException(DOMException.INVALID_CHARACTER_ERR);
}
if (name.startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) {
// This is a ns declaration
@@ -819,7 +821,7 @@ public class ElementImpl extends ParentN
//find the attr
AttrImpl tempAttr = (AttrImpl) this.getAttributeNode(name);
if (tempAttr == null) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
this.updateIsId(isId, tempAttr);
@@ -830,7 +832,7 @@ public class ElementImpl extends ParentN
//find the attr
AttrImpl tempAttr = (AttrImpl) this.getAttributeNodeNS(namespaceURI,
localName);
if (tempAttr == null) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
this.updateIsId(isId, tempAttr);
@@ -849,7 +851,7 @@ public class ElementImpl extends ParentN
}
if (tempAttr == null) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
this.updateIsId(isId, tempAttr);
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/EntityReferenceImpl.java
Fri Jul 18 21:31:26 2014
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.om.OMEntityReference;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNode;
@@ -80,19 +82,19 @@ public class EntityReferenceImpl extends
}
public final Node appendChild(Node newChild) throws DOMException {
- throw
DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ throw newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
public final Node removeChild(Node oldChild) throws DOMException {
- throw
DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ throw newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
public final Node insertBefore(Node newChild, Node refChild) throws
DOMException {
- throw
DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ throw newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
public final Node replaceChild(Node newChild, Node oldChild) throws
DOMException {
- throw
DOMUtil.newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
+ throw newDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
}
public String getTextContent() throws DOMException {
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/LeafNode.java
Fri Jul 18 21:31:26 2014
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.om.OMFactory;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
@@ -41,19 +43,19 @@ public abstract class LeafNode extends C
}
public final Node appendChild(Node newChild) throws DOMException {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
public final Node removeChild(Node oldChild) throws DOMException {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
public final Node insertBefore(Node newChild, Node refChild) throws
DOMException {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
public final Node replaceChild(Node newChild, Node oldChild) throws
DOMException {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
public final String getTextContent() throws DOMException {
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
Fri Jul 18 21:31:26 2014
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.w3c.dom.DOMException;
@@ -30,7 +32,7 @@ aspect NamedNodeSupport {
OMNamespace ns = getNamespace();
if (ns == null) {
if (prefix.length() > 0) {
- throw DOMUtil.newDOMException(DOMException.NAMESPACE_ERR);
+ throw newDOMException(DOMException.NAMESPACE_ERR);
} else {
// No need to set a new OMNamespace in this case
}
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.CoreChildNode;
import org.apache.axiom.core.CoreDocument;
import org.apache.axiom.core.CoreParentNode;
@@ -132,7 +134,7 @@ public abstract class NodeImpl extends I
// This is not yet implemented. In the meantime, we throw a
DOMException
// and not an UnsupportedOperationException, since this works better
with
// some other libraries (such as Saxon 8.9).
- throw DOMUtil.newDOMException(DOMException.NOT_SUPPORTED_ERR);
+ throw newDOMException(DOMException.NOT_SUPPORTED_ERR);
}
// internal method taking a StringBuffer in parameter
@@ -397,7 +399,7 @@ public abstract class NodeImpl extends I
if (ownerDocument() != (otherNode instanceof AttrImpl
? ((AttrImpl)otherNode).getOwnerDocument()
: ((NodeImpl)otherNode).ownerDocument())) {
- throw DOMUtil.newDOMException(DOMException.WRONG_DOCUMENT_ERR);
+ throw newDOMException(DOMException.WRONG_DOCUMENT_ERR);
}
}
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java?rev=1611812&r1=1611811&r2=1611812&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ParentNode.java
Fri Jul 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.core.CoreChildNode;
import org.apache.axiom.dom.DOMParentNode;
import org.apache.axiom.om.OMCloneOptions;
@@ -110,7 +112,7 @@ public abstract class ParentNode extends
}
if (isAncestorOrSelf(newChild)) {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
if (newDomChild.parentNode() != null) {
@@ -122,7 +124,7 @@ public abstract class ParentNode extends
if (newDomChild instanceof ElementImpl) {
if (((DocumentImpl) this).getOMDocumentElement(false) != null)
{
// Throw exception since there cannot be two document
elements
- throw
DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
if (newDomChild.parentNode() == null) {
newDomChild.setParent(this, useDomSemantics);
@@ -131,7 +133,7 @@ public abstract class ParentNode extends
|| newDomChild instanceof ProcessingInstructionImpl
|| newDomChild instanceof DocumentFragmentImpl
|| newDomChild instanceof DocumentTypeImpl)) {
- throw
DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
}
@@ -230,7 +232,7 @@ public abstract class ParentNode extends
}
if (!found) {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
if (!(newDomChild instanceof DocumentFragmentImpl) &&
newDomChild.parentNode() == null) {
@@ -256,7 +258,7 @@ public abstract class ParentNode extends
}
if (isAncestorOrSelf(newChild)) {
- throw DOMUtil.newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
+ throw newDOMException(DOMException.HIERARCHY_REQUEST_ERR);
}
checkSameOwnerDocument(newDomChild);
@@ -319,7 +321,7 @@ public abstract class ParentNode extends
}
if (!found)
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
return oldChild;
}
@@ -330,7 +332,7 @@ public abstract class ParentNode extends
((NodeImpl)oldChild).detach(true);
return oldChild;
} else {
- throw DOMUtil.newDOMException(DOMException.NOT_FOUND_ERR);
+ throw newDOMException(DOMException.NOT_FOUND_ERR);
}
}
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=1611812&r1=1611811&r2=1611812&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 18 21:31:26 2014
@@ -19,6 +19,8 @@
package org.apache.axiom.om.impl.dom;
+import static org.apache.axiom.dom.DOMExceptionUtil.newDOMException;
+
import org.apache.axiom.attachments.utils.DataHandlerUtils;
import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
import org.apache.axiom.om.OMCloneOptions;
@@ -40,6 +42,7 @@ import org.w3c.dom.Text;
import javax.activation.DataHandler;
import javax.xml.namespace.QName;
+
import java.io.IOException;
public abstract class TextNodeImpl extends CharacterImpl implements Text,
OMText {
@@ -179,7 +182,7 @@ public abstract class TextNodeImpl exten
*/
public Text splitText(int offset) throws DOMException {
if (offset < 0 || offset > this.textValue.length()) {
- throw DOMUtil.newDOMException(DOMException.INDEX_SIZE_ERR);
+ throw newDOMException(DOMException.INDEX_SIZE_ERR);
}
String newValue = this.textValue.substring(offset);
this.deleteData(offset, this.textValue.length());