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/06/14 18:16:06 UTC
svn commit: r1685419 - in /webservices/axiom/branches/attrs-aspects:
aspects/core-aspects/src/main/java/org/apache/axiom/core/
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/c...
Author: veithen
Date: Sun Jun 14 16:16:06 2015
New Revision: 1685419
URL: http://svn.apache.org/r1685419
Log:
Start rewriting the attribute support in axiom-impl.
Added:
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AbstractAttributeIterator.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributesByTypeIterator.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj (with props)
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java (with props)
Modified:
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AbstractAttributeIterator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AbstractAttributeIterator.java?rev=1685419&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AbstractAttributeIterator.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AbstractAttributeIterator.java Sun Jun 14 16:16:06 2015
@@ -0,0 +1,67 @@
+/*
+ * 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.core;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+abstract class AbstractAttributeIterator<T extends CoreAttribute,S> implements Iterator<S> {
+ private final CoreElement element;
+ private final Class<T> type;
+ private final Mapper<T,S> mapper;
+ private CoreAttribute attribute;
+ private boolean hasNext;
+
+ AbstractAttributeIterator(CoreElement element, Class<T> type, Mapper<T,S> mapper) {
+ this.element = element;
+ this.type = type;
+ this.mapper = mapper;
+ }
+
+ protected abstract boolean matches(T attribute);
+
+ public final boolean hasNext() {
+ if (!hasNext) {
+ CoreAttribute attribute = this.attribute;
+ do {
+ if (attribute == null) {
+ attribute = element.coreGetFirstAttribute();
+ } else {
+ attribute = attribute.coreGetNextAttribute();
+ }
+ } while (attribute != null && (!type.isInstance(attribute) || !matches(type.cast(attribute))));
+ this.attribute = attribute;
+ hasNext = true;
+ }
+ return attribute != null;
+ }
+
+ public final S next() {
+ if (hasNext()) {
+ hasNext = false;
+ return mapper.map(type.cast(attribute));
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+
+ public final void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AbstractAttributeIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributesByTypeIterator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributesByTypeIterator.java?rev=1685419&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributesByTypeIterator.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributesByTypeIterator.java Sun Jun 14 16:16:06 2015
@@ -0,0 +1,30 @@
+/*
+ * 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.core;
+
+final class AttributesByTypeIterator<T extends CoreAttribute,S> extends AbstractAttributeIterator<T,S> {
+ AttributesByTypeIterator(CoreElement element, Class<T> type, Mapper<T,S> mapper) {
+ super(element, type, mapper);
+ }
+
+ @Override
+ protected boolean matches(T attribute) {
+ return true;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/AttributesByTypeIterator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElement.java Sun Jun 14 16:16:06 2015
@@ -18,7 +18,9 @@
*/
package org.apache.axiom.core;
-public interface CoreElement extends CoreChildNode, CoreParentNode {
+import java.util.Iterator;
+
+public interface CoreElement extends CoreChildNode, CoreParentNode, DeferringParentNode {
/**
* Specifies the value that should be returned by
* {@link CoreElement#coreSetAttribute(AttributeMatcher, String, String, CoreAttribute, NodeMigrationPolicy, ReturnValue)}.
@@ -157,6 +159,8 @@ public interface CoreElement extends Cor
*/
boolean coreRemoveAttribute(AttributeMatcher matcher, String namespaceURI, String name);
+ <T extends CoreAttribute,S> Iterator<S> coreGetAttributesByType(Class<T> type, Mapper<T,S> mapper);
+
/**
* Look up the namespace URI associated to the given prefix.
*
Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj Sun Jun 14 16:16:06 2015
@@ -18,10 +18,13 @@
*/
package org.apache.axiom.core;
+import java.util.Iterator;
+
public aspect CoreElementSupport {
private CoreAttribute CoreElement.firstAttribute;
public final CoreAttribute CoreElement.coreGetFirstAttribute() {
+ forceExpand();
return firstAttribute;
}
@@ -170,6 +173,11 @@ public aspect CoreElementSupport {
}
}
+ public final <T extends CoreAttribute,S> Iterator<S> CoreElement.coreGetAttributesByType(Class<T> type, Mapper<T,S> mapper) {
+ // TODO: if we know that there are no attributes, don't create a new iterator, but return a constant
+ return new AttributesByTypeIterator<T,S>(this, type, mapper);
+ }
+
public abstract String CoreElement.getImplicitNamespaceURI(String prefix);
public final String CoreElement.coreLookupNamespaceURI(String prefix, boolean strict) {
Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj?rev=1685419&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj Sun Jun 14 16:16:06 2015
@@ -0,0 +1,31 @@
+/*
+ * 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.core;
+
+public aspect CoreTypedAttributeSupport {
+ private String CoreTypedAttribute.type;
+
+ public final String CoreTypedAttribute.coreGetType() {
+ return type;
+ }
+
+ public final void CoreTypedAttribute.coreSetType(String type) {
+ this.type = type;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreTypedAttributeSupport.aj
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java?rev=1685419&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java Sun Jun 14 16:16:06 2015
@@ -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.core;
+
+public final class IdentityMapper<T> implements Mapper<T,T> {
+ public T map(T object) {
+ return object;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/IdentityMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java?rev=1685419&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java Sun Jun 14 16:16:06 2015
@@ -0,0 +1,23 @@
+/*
+ * 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.core;
+
+public interface Mapper<T,S> {
+ S map(T object);
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/Mapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttribute.java Sun Jun 14 16:16:06 2015
@@ -18,9 +18,9 @@
*/
package org.apache.axiom.om.impl.common;
-import org.apache.axiom.core.CoreAttribute;
+import org.apache.axiom.core.CoreNSAwareAttribute;
import org.apache.axiom.om.OMAttribute;
-public interface AxiomAttribute extends OMAttribute, CoreAttribute, AxiomNamedInformationItem {
+public interface AxiomAttribute extends OMAttribute, CoreNSAwareAttribute, AxiomNamedInformationItem {
}
Modified: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomAttributeSupport.aj Sun Jun 14 16:16:06 2015
@@ -33,4 +33,12 @@ public aspect AxiomAttributeSupport {
public final void AxiomAttribute.setOMNamespace(OMNamespace omNamespace) {
internalSetNamespace(omNamespace);
}
+
+ public final String AxiomAttribute.getAttributeType() {
+ return coreGetType();
+ }
+
+ public final void AxiomAttribute.setAttributeType(String type) {
+ coreSetType(type);
+ }
}
Modified: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj Sun Jun 14 16:16:06 2015
@@ -32,6 +32,10 @@ import javax.xml.stream.XMLStreamExcepti
import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.core.CoreParentNode;
+import org.apache.axiom.core.IdentityMapper;
+import org.apache.axiom.core.NodeMigrationException;
+import org.apache.axiom.core.NodeMigrationPolicy;
+import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
@@ -285,4 +289,18 @@ public aspect AxiomElementSupport {
return namespace;
}
}
+
+ public final void AxiomElement.internalAppendAttribute(OMAttribute attr) {
+ try {
+ coreSetAttribute(Policies.ATTRIBUTE_MATCHER, (AxiomAttribute)attr, NodeMigrationPolicy.MOVE_ALWAYS, true, null, ReturnValue.NONE);
+ } catch (NodeMigrationException ex) {
+ AxiomExceptionUtil.translate(ex);
+ }
+ }
+ private static final IdentityMapper<AxiomAttribute> attributeIdentityMapper = new IdentityMapper<AxiomAttribute>();
+
+ @SuppressWarnings("rawtypes")
+ public final Iterator AxiomElement.getAllAttributes() {
+ return coreGetAttributesByType(AxiomAttribute.class, attributeIdentityMapper);
+ }
}
Added: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java?rev=1685419&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java Sun Jun 14 16:16:06 2015
@@ -0,0 +1,28 @@
+/*
+ * 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.core.CoreModelException;
+import org.apache.axiom.om.OMException;
+
+public class AxiomExceptionUtil {
+ public static OMException translate(CoreModelException ex) {
+ return new OMException(ex);
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomExceptionUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItem.java Sun Jun 14 16:16:06 2015
@@ -18,8 +18,9 @@
*/
package org.apache.axiom.om.impl.common;
+import org.apache.axiom.core.CoreNSAwareNamedNode;
import org.apache.axiom.om.OMNamedInformationItem;
-public interface AxiomNamedInformationItem extends OMNamedInformationItem, AxiomInformationItem {
+public interface AxiomNamedInformationItem extends OMNamedInformationItem, AxiomInformationItem, CoreNSAwareNamedNode {
}
Modified: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamedInformationItemSupport.aj Sun Jun 14 16:16:06 2015
@@ -20,6 +20,7 @@ package org.apache.axiom.om.impl.common;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.util.OMSerializerUtil;
@@ -159,4 +160,31 @@ public aspect AxiomNamedInformationItemS
return ns;
}
}
+
+ public final String AxiomNamedInformationItem.coreGetNamespaceURI() {
+ OMNamespace namespace = getNamespace();
+ return namespace == null ? "" : namespace.getNamespaceURI();
+ }
+
+ public final String AxiomNamedInformationItem.coreGetPrefix() {
+ OMNamespace namespace = getNamespace();
+ return namespace == null ? "" : namespace.getPrefix();
+ }
+
+ public final String AxiomNamedInformationItem.coreGetLocalName() {
+ return getLocalName();
+ }
+
+ public final void AxiomNamedInformationItem.coreSetPrefix(String prefix) {
+ OMNamespace ns = getNamespace();
+ if (ns == null) {
+ if (prefix.length() > 0) {
+ throw new OMException("Cannot set prefix on an information item without namespace");
+ } else {
+ // No need to set a new OMNamespace in this case
+ }
+ } else {
+ internalSetNamespace(new OMNamespaceImpl(ns.getNamespaceURI(), prefix));
+ }
+ }
}
Modified: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/Navigator.java Sun Jun 14 16:16:06 2015
@@ -302,6 +302,7 @@ final class Navigator extends PullSerial
}
private void loadAttributes() {
+ // TODO: use the core model API to do this without iterators
if (attributeCount == -1) {
attributeCount = 0;
for (Iterator it = ((OMElement)node).getAllAttributes(); it.hasNext(); ) {
@@ -323,6 +324,7 @@ final class Navigator extends PullSerial
}
private void loadNamespaces() {
+ // TODO: use the core model API to do this without iterators
if (namespaceCount == -1) {
namespaceCount = 0;
for (Iterator it = ((OMElement)node).getAllDeclaredNamespaces(); it.hasNext(); ) {
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Sun Jun 14 16:16:06 2015
@@ -32,8 +32,6 @@ import org.w3c.dom.TypeInfo;
/** Implementation of <code>org.w3c.dom.Attr</code> and <code>org.apache.axiom.om.OMAttribute</code> */
public abstract class AttrImpl extends RootNode implements DOMAttribute, NonDeferringParentNode {
- String type;
-
/** Flag used to mark an attribute as per the DOM Level 3 specification */
protected boolean isId;
@@ -119,10 +117,6 @@ public abstract class AttrImpl extends R
return getValue();
}
- public String getAttributeType() {
- return type;
- }
-
/**
* Sets the attribute value.
*
@@ -132,15 +126,6 @@ public abstract class AttrImpl extends R
setValue(value);
}
- /**
- * Sets the attribute value.
- *
- * @see org.apache.axiom.om.OMAttribute#setAttributeType(String)
- */
- public void setAttributeType(String attrType) {
- this.type = attrType;
- }
-
final void checkInUse() {
if (coreGetOwnerElement() != null) {
throw newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Sun Jun 14 16:16:06 2015
@@ -450,24 +450,6 @@ public class ElementImpl extends ParentN
return new NSDeclIterator(getAttributes());
}
- /** @see org.apache.axiom.om.OMElement#getAllAttributes() */
- public Iterator getAllAttributes() {
- if (!hasAttributes()) {
- return EMPTY_ITERATOR;
- }
- NamedNodeMap attributes = getAttributes();
- ArrayList list = new ArrayList();
- for (int i = 0; i < attributes.getLength(); i++) {
- AttrImpl item = (AttrImpl) attributes.item(i);
- // TODO: what about NS unaware attributes here?
- if (item instanceof TypedAttribute) {
- list.add(item);
- }
- }
-
- return list.iterator();
- }
-
public OMElement cloneOMElement() {
return (OMElement)clone(new OMCloneOptions());
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSAwareAttribute.java Sun Jun 14 16:16:06 2015
@@ -37,7 +37,7 @@ public final class NSAwareAttribute exte
super(null, factory);
internalSetLocalName(localName);
internalSetNamespace(namespace);
- this.type = type;
+ coreSetType(type);
}
public NSAwareAttribute(DocumentImpl ownerDocument, String localName,
@@ -47,7 +47,7 @@ public final class NSAwareAttribute exte
if (value != null && value.length() != 0) {
coreAppendChild((AxiomText)factory.createOMText(value), false);
}
- this.type = OMConstants.XMLATTRTYPE_CDATA;
+ coreSetType(OMConstants.XMLATTRTYPE_CDATA);
internalSetNamespace(ns);
}
@@ -147,7 +147,6 @@ public final class NSAwareAttribute exte
@Override
final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing) {
// Note: targetParent is always null here
- // TODO
- return new NSAwareAttribute(getLocalName(), getNamespace(), type, getOMFactory());
+ return new NSAwareAttribute(getLocalName(), getNamespace(), coreGetType(), getOMFactory());
}
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamedNodeSupport.aj Sun Jun 14 16:16:06 2015
@@ -25,6 +25,7 @@ import org.apache.axiom.om.impl.common.O
import org.w3c.dom.DOMException;
aspect NamedNodeSupport {
+ // TODO: rewrite this using coreSetPrefix
public final void NamedNode.setPrefix(String prefix) throws DOMException {
if (prefix == null) {
prefix = "";
@@ -40,22 +41,4 @@ aspect NamedNodeSupport {
internalSetNamespace(new OMNamespaceImpl(ns.getNamespaceURI(), prefix == null ? "" : prefix));
}
}
-
- public final String NamedNode.coreGetNamespaceURI() {
- String namespaceURI = getNamespaceURI();
- return namespaceURI == null ? "" : namespaceURI;
- }
-
- public final String NamedNode.coreGetPrefix() {
- String prefix = getPrefix();
- return prefix == null ? "" : prefix;
- }
-
- public final String NamedNode.coreGetLocalName() {
- return getLocalName();
- }
-
- public final void NamedNode.coreSetPrefix(String prefix) {
- setPrefix(prefix);
- }
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TypedAttribute.java Sun Jun 14 16:16:06 2015
@@ -24,14 +24,4 @@ public abstract class TypedAttribute ext
public TypedAttribute(DocumentImpl ownerDocument, OMFactory factory) {
super(ownerDocument, factory);
}
-
- public String coreGetType() {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
- }
-
- public void coreSetType(String type) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
- }
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java Sun Jun 14 16:16:06 2015
@@ -31,8 +31,6 @@ import org.apache.axiom.om.impl.common.A
public class OMAttributeImpl extends OMInformationItemImpl implements AxiomAttribute {
private String value;
- private String type;
-
/** <code>OMFactory</code> that created this <code>OMAttribute</code> */
private OMFactory factory;
@@ -63,7 +61,7 @@ public class OMAttributeImpl extends OMI
internalSetLocalName(localName);
this.value = value;
internalSetNamespace(ns);
- this.type = OMConstants.XMLATTRTYPE_CDATA;
+ coreSetType(OMConstants.XMLATTRTYPE_CDATA);
this.factory = factory;
}
@@ -86,19 +84,6 @@ public class OMAttributeImpl extends OMI
setAttributeValue(value);
}
- public String getAttributeType() {
- return type;
- }
-
- /**
- * Method setAttributeType.
- *
- * @param type
- */
- public void setAttributeType(String type) {
- this.type = type;
- }
-
public OMFactory getOMFactory() {
return this.factory;
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Sun Jun 14 16:16:06 2015
@@ -48,7 +48,6 @@ import javax.xml.stream.XMLStreamWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedHashMap;
/** Class OMElementImpl */
public class OMElementImpl extends OMNodeImpl
@@ -331,18 +330,6 @@ public class OMElementImpl extends OMNod
}
/**
- * Returns a List of OMAttributes.
- *
- * @return Returns iterator.
- */
- public Iterator getAllAttributes() {
- if (attributes == null) {
- return EMPTY_ITERATOR;
- }
- return attributes.values().iterator();
- }
-
- /**
* Returns a named attribute if present.
*
* @param qname the qualified name to search for
@@ -403,22 +390,9 @@ public class OMElementImpl extends OMNod
}
}
- appendAttribute(attr);
+ internalAppendAttribute(attr);
return attr;
}
-
- void appendAttribute(OMAttribute attr) {
- if (attributes == null) {
- this.attributes = new LinkedHashMap(5);
- }
- // Set the owner element of the attribute
- ((OMAttributeImpl)attr).internalSetOwnerElement(this);
- OMAttributeImpl oldAttr = (OMAttributeImpl)attributes.put(attr.getQName(), attr);
- // Did we replace an existing attribute?
- if (oldAttr != null) {
- oldAttr.internalUnsetOwnerElement(null);
- }
- }
public void removeAttribute(OMAttribute attr) {
if (attr.getOwner() != this) {
@@ -592,25 +566,5 @@ public class OMElementImpl extends OMNod
this.setComplete(true);
}
}
-
- public final String coreGetNamespaceURI() {
- // TODO
- throw new UnsupportedOperationException();
- }
-
- public final String coreGetPrefix() {
- // TODO
- throw new UnsupportedOperationException();
- }
-
- public final void coreSetPrefix(String prefix) {
- // TODO
- throw new UnsupportedOperationException();
- }
-
- public final String coreGetLocalName() {
- // TODO
- throw new UnsupportedOperationException();
- }
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Sun Jun 14 16:16:06 2015
@@ -408,10 +408,6 @@ public class OMSourcedElementImpl extend
return super.addAttribute(attributeName, value, namespace);
}
- void appendAttribute(OMAttribute attr) {
- super.appendAttribute(attr);
- }
-
public void removeAttribute(OMAttribute attr) {
forceExpand();
super.removeAttribute(attr);
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java?rev=1685419&r1=1685418&r2=1685419&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java Sun Jun 14 16:16:06 2015
@@ -148,7 +148,7 @@ public class PushOMBuilder extends Abstr
// Use the internal appendAttribute method instead of addAttribute in order to avoid
// automatic of a namespace declaration (the OMDataSource is required to produce well formed
// XML with respect to namespaces, so it will take care of the namespace declarations).
- ((OMElementImpl)parent).appendAttribute(attr);
+ ((OMElementImpl)parent).internalAppendAttribute(attr);
}
protected void doWriteAttribute(String localName, String value) throws XMLStreamException {