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/15 00:15:04 UTC
svn commit: r1685475 - 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/
implementations/axiom-dom/src/main/java/org/apache/axiom/om...
Author: veithen
Date: Sun Jun 14 22:15:03 2015
New Revision: 1685475
URL: http://svn.apache.org/r1685475
Log:
Lay the groundwork to unify namespace declaration handling.
Added:
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java (with props)
webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj (with props)
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java (with props)
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java (with props)
Modified:
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreElementSupport.aj
webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.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/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/NamespaceDeclaration.java
webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java?rev=1685475&r1=1685474&r2=1685475&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreAttribute.java Sun Jun 14 22:15:03 2015
@@ -68,5 +68,6 @@ public interface CoreAttribute extends C
*/
CoreAttribute coreGetPreviousAttribute();
+ String coreGetValue();
void coreSetValue(String value);
}
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=1685475&r1=1685474&r2=1685475&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 22:15:03 2015
@@ -191,7 +191,7 @@ public aspect CoreElementSupport {
if (attr instanceof CoreNamespaceDeclaration) {
CoreNamespaceDeclaration decl = (CoreNamespaceDeclaration)attr;
if (prefix.equals(decl.coreGetDeclaredPrefix())) {
- return decl.coreGetDeclaredNamespaceURI();
+ return decl.coreGetValue();
}
}
}
@@ -220,7 +220,7 @@ public aspect CoreElementSupport {
for (CoreAttribute attr = coreGetFirstAttribute(); attr != null; attr = attr.coreGetNextAttribute()) {
if (attr instanceof CoreNamespaceDeclaration) {
CoreNamespaceDeclaration decl = (CoreNamespaceDeclaration)attr;
- if (decl.coreGetDeclaredNamespaceURI().equals(namespaceURI)) {
+ if (decl.coreGetValue().equals(namespaceURI)) {
return decl.coreGetDeclaredPrefix();
}
}
Modified: webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java?rev=1685475&r1=1685474&r2=1685475&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java (original)
+++ webservices/axiom/branches/attrs-aspects/aspects/core-aspects/src/main/java/org/apache/axiom/core/CoreNamespaceDeclaration.java Sun Jun 14 22:15:03 2015
@@ -29,6 +29,4 @@ public interface CoreNamespaceDeclaratio
* namespace
*/
String coreGetDeclaredPrefix();
-
- String coreGetDeclaredNamespaceURI();
}
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=1685475&r1=1685474&r2=1685475&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 22:15:03 2015
@@ -34,6 +34,14 @@ public aspect AxiomAttributeSupport {
internalSetNamespace(omNamespace);
}
+ public final String AxiomAttribute.getAttributeValue() {
+ return coreGetValue();
+ }
+
+ public final void AxiomAttribute.setAttributeValue(String value) {
+ coreSetValue(value);
+ }
+
public final String AxiomAttribute.getAttributeType() {
return coreGetType();
}
Added: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java?rev=1685475&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java Sun Jun 14 22:15:03 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.om.impl.common;
+
+import org.apache.axiom.core.CoreNamespaceDeclaration;
+
+public interface AxiomNamespaceDeclaration extends AxiomInformationItem, CoreNamespaceDeclaration {
+
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclaration.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj?rev=1685475&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj (added)
+++ webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj Sun Jun 14 22:15:03 2015
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om.impl.common;
+
+import org.apache.axiom.om.OMNamespace;
+
+public aspect AxiomNamespaceDeclarationSupport {
+ private OMNamespace AxiomNamespaceDeclaration.declaredNamespace;
+
+ public final String AxiomNamespaceDeclaration.coreGetDeclaredPrefix() {
+ return declaredNamespace.getPrefix();
+ }
+
+ public final OMNamespace AxiomNamespaceDeclaration.getDeclaredNamespace() {
+ // TODO: what if the attribute value has been changed in the meantime?
+ return declaredNamespace;
+ }
+
+ public final void AxiomNamespaceDeclaration.setDeclaredNamespace(OMNamespace declaredNamespace) {
+ this.declaredNamespace = declaredNamespace;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomNamespaceDeclarationSupport.aj
------------------------------------------------------------------------------
svn:eol-style = native
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=1685475&r1=1685474&r2=1685475&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 22:15:03 2015
@@ -113,25 +113,6 @@ public abstract class AttrImpl extends R
coreSetSpecified(specified);
}
- public String getAttributeValue() {
- return getValue();
- }
-
- /**
- * Sets the attribute value.
- *
- * @see org.apache.axiom.om.OMAttribute#setAttributeValue(String)
- */
- public void setAttributeValue(String value) {
- setValue(value);
- }
-
- final void checkInUse() {
- if (coreGetOwnerElement() != null) {
- throw newDOMException(DOMException.INUSE_ATTRIBUTE_ERR);
- }
- }
-
/**
* Sets the value of the attribute.
*
@@ -141,6 +122,10 @@ public abstract class AttrImpl extends R
setTextContent(value);
}
+ public final String coreGetValue() {
+ return getValue();
+ }
+
public final void coreSetValue(String value) {
setValue(value);
}
Modified: webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java?rev=1685475&r1=1685474&r2=1685475&view=diff
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java (original)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceDeclaration.java Sun Jun 14 22:15:03 2015
@@ -23,10 +23,9 @@ import org.apache.axiom.dom.DOMNamespace
import org.apache.axiom.om.OMCloneOptions;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.common.AxiomNamespaceDeclaration;
-public final class NamespaceDeclaration extends AttrImpl implements DOMNamespaceDeclaration {
- private OMNamespace declaredNamespace;
-
+public final class NamespaceDeclaration extends AttrImpl implements DOMNamespaceDeclaration, AxiomNamespaceDeclaration {
private NamespaceDeclaration(OMFactory factory) {
super(null, factory);
}
@@ -34,31 +33,13 @@ public final class NamespaceDeclaration
public NamespaceDeclaration(DocumentImpl ownerDocument, OMNamespace namespace, OMFactory factory) {
super(ownerDocument, factory);
coreSetValue(namespace.getNamespaceURI());
- declaredNamespace = namespace;
- }
-
- public final NodeFactory coreGetNodeFactory() {
- return ((NodeFactory)getOMFactory());
- }
-
- public String coreGetDeclaredPrefix() {
- return declaredNamespace.getPrefix();
- }
-
- // TODO: should be part of a DOM aspect
- public String coreGetDeclaredNamespaceURI() {
- return getValue();
- }
-
- public final OMNamespace getDeclaredNamespace() {
- // TODO: what if the attribute value has been changed in the meantime?
- return declaredNamespace;
+ setDeclaredNamespace(namespace);
}
@Override
final ParentNode shallowClone(OMCloneOptions options, ParentNode targetParent, boolean namespaceRepairing) {
NamespaceDeclaration clone = new NamespaceDeclaration(getOMFactory());
- clone.declaredNamespace = getDeclaredNamespace();
+ clone.setDeclaredNamespace(getDeclaredNamespace());
return clone;
}
}
Added: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java?rev=1685475&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java (added)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java Sun Jun 14 22:15:03 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.llom;
+
+import org.apache.axiom.core.CoreAttribute;
+import org.apache.axiom.om.OMFactory;
+
+public abstract class Attribute extends OMInformationItemImpl implements CoreAttribute {
+ private OMFactory factory;
+ private String value;
+
+ public Attribute(OMFactory factory) {
+ this.factory = factory;
+ }
+
+ public final OMFactory getOMFactory() {
+ return factory;
+ }
+
+ public final String coreGetValue() {
+ return value;
+ }
+
+ public final void coreSetValue(String value) {
+ this.value = value;
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/Attribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java?rev=1685475&view=auto
==============================================================================
--- webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java (added)
+++ webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java Sun Jun 14 22:15:03 2015
@@ -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.om.impl.llom;
+
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMInformationItem;
+import org.apache.axiom.om.impl.common.AxiomNamespaceDeclaration;
+
+public final class NamespaceDeclaration extends Attribute implements AxiomNamespaceDeclaration {
+ public NamespaceDeclaration(OMFactory factory) {
+ super(factory);
+ }
+
+ public OMInformationItem clone(OMCloneOptions options) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+}
Propchange: webservices/axiom/branches/attrs-aspects/implementations/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/NamespaceDeclaration.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1685475&r1=1685474&r2=1685475&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 22:15:03 2015
@@ -28,12 +28,7 @@ import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.common.AxiomAttribute;
/** Class OMAttributeImpl */
-public class OMAttributeImpl extends OMInformationItemImpl implements AxiomAttribute {
- private String value;
-
- /** <code>OMFactory</code> that created this <code>OMAttribute</code> */
- private OMFactory factory;
-
+public class OMAttributeImpl extends Attribute implements AxiomAttribute {
/**
* Constructor OMAttributeImpl.
*
@@ -43,6 +38,7 @@ public class OMAttributeImpl extends OMI
*/
public OMAttributeImpl(String localName, OMNamespace ns, String value, OMFactory factory)
{
+ super(factory);
if (localName == null || localName.trim().length() == 0)
throw new IllegalArgumentException("Local name may not be null or empty");
@@ -59,33 +55,9 @@ public class OMAttributeImpl extends OMI
}
internalSetLocalName(localName);
- this.value = value;
+ coreSetValue(value);
internalSetNamespace(ns);
coreSetType(OMConstants.XMLATTRTYPE_CDATA);
- this.factory = factory;
- }
-
- // -------- Getters and Setters
-
- public String getAttributeValue() {
- return value;
- }
-
- /**
- * Method setAttributeValue.
- *
- * @param value
- */
- public void setAttributeValue(String value) {
- this.value = value;
- }
-
- public void coreSetValue(String value) {
- setAttributeValue(value);
- }
-
- public OMFactory getOMFactory() {
- return this.factory;
}
/**
@@ -111,6 +83,7 @@ public class OMAttributeImpl extends OMI
OMAttribute other = (OMAttribute)obj;
OMNamespace namespace = getNamespace();
String localName = getLocalName();
+ String value = getAttributeValue();
//first check namespace then localName then value to improve performance
return (namespace == null ? other.getNamespace() == null :
namespace.equals(other.getNamespace()) &&
@@ -123,11 +96,12 @@ public class OMAttributeImpl extends OMI
public int hashCode() {
OMNamespace namespace = getNamespace();
String localName = getLocalName();
+ String value = getAttributeValue();
return localName.hashCode() ^ (value != null ? value.hashCode() : 0) ^
(namespace != null ? namespace.hashCode() : 0);
}
public OMInformationItem clone(OMCloneOptions options) {
- return new OMAttributeImpl(getLocalName(), getNamespace(), value, factory);
+ return new OMAttributeImpl(getLocalName(), getNamespace(), getAttributeValue(), getOMFactory());
}
}