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 2016/01/20 21:19:23 UTC
svn commit: r1725806 - in /webservices/axiom/trunk:
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/
axiom-api/src/main/java/org/apache/axiom/om/
axiom-api/src/main/java/org/apache/axiom/util/namespace/
src/site/markdown/release-notes/
Author: veithen
Date: Wed Jan 20 20:19:23 2016
New Revision: 1725806
URL: http://svn.apache.org/viewvc?rev=1725806&view=rev
Log:
Start introducing generics in the public API.
Modified:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMSourcedElement.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/AbstractNamespaceContext.java
webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/MapBasedNamespaceContext.java
webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomContainerSupport.aj Wed Jan 20 20:19:23 2016
@@ -190,19 +190,19 @@ public aspect AxiomContainerSupport {
coreRemoveChildren(AxiomSemantics.INSTANCE);
}
- public Iterator AxiomContainer.getChildren() {
+ public Iterator<OMNode> AxiomContainer.getChildren() {
return coreGetNodes(Axis.CHILDREN, OMNode.class, AxiomExceptionTranslator.INSTANCE, AxiomSemantics.INSTANCE);
}
- public Iterator AxiomContainer.getChildrenWithLocalName(String localName) {
+ public Iterator<OMElement> AxiomContainer.getChildrenWithLocalName(String localName) {
return new OMChildrenLocalNameIterator(getFirstOMChild(), localName);
}
- public Iterator AxiomContainer.getChildrenWithNamespaceURI(String uri) {
+ public Iterator<OMElement> AxiomContainer.getChildrenWithNamespaceURI(String uri) {
return new OMChildrenNamespaceIterator(getFirstOMChild(), uri);
}
- public Iterator AxiomContainer.getChildrenWithName(QName elementQName) {
+ public Iterator<OMElement> AxiomContainer.getChildrenWithName(QName elementQName) {
OMNode firstChild = getFirstOMChild();
Iterator it = new OMChildrenQNameIterator(firstChild, elementQName);
@@ -228,7 +228,7 @@ public aspect AxiomContainerSupport {
return it;
}
- public Iterator AxiomContainer.getDescendants(boolean includeSelf) {
+ public Iterator<OMSerializable> AxiomContainer.getDescendants(boolean includeSelf) {
return coreGetNodes(includeSelf ? Axis.DESCENDANTS_OR_SELF : Axis.DESCENDANTS, OMSerializable.class, AxiomExceptionTranslator.INSTANCE, AxiomSemantics.INSTANCE);
}
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj Wed Jan 20 20:19:23 2016
@@ -38,7 +38,7 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.core.CoreAttribute;
import org.apache.axiom.core.CoreParentNode;
import org.apache.axiom.core.ElementAction;
-import org.apache.axiom.core.IdentityMapper;
+import org.apache.axiom.core.Mapper;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMConstants;
import org.apache.axiom.om.OMContainer;
@@ -106,19 +106,19 @@ public aspect AxiomElementSupport {
return null;
}
- public final Iterator AxiomElement.getChildElements() {
+ public final Iterator<OMElement> AxiomElement.getChildElements() {
return new OMChildElementIterator(getFirstElement());
}
- public final Iterator AxiomElement.getNamespacesInScope() {
+ public final Iterator<OMNamespace> AxiomElement.getNamespacesInScope() {
return new NamespaceIterator(this);
}
public NamespaceContext AxiomElement.getNamespaceContext(boolean detached) {
if (detached) {
- Map namespaces = new HashMap();
- for (Iterator it = getNamespacesInScope(); it.hasNext(); ) {
- OMNamespace ns = (OMNamespace)it.next();
+ Map<String,String> namespaces = new HashMap<String,String>();
+ for (Iterator<OMNamespace> it = getNamespacesInScope(); it.hasNext(); ) {
+ OMNamespace ns = it.next();
namespaces.put(ns.getPrefix(), ns.getNamespaceURI());
}
return new MapBasedNamespaceContext(namespaces);
@@ -328,11 +328,14 @@ public aspect AxiomElementSupport {
return addAttribute(getOMFactory().createOMAttribute(localName, namespace, value));
}
- private static final IdentityMapper<AxiomAttribute> attributeIdentityMapper = new IdentityMapper<AxiomAttribute>();
+ private static final Mapper<AxiomAttribute,OMAttribute> attributeMapper = new Mapper<AxiomAttribute,OMAttribute>() {
+ public OMAttribute map(AxiomAttribute object) {
+ return object;
+ }
+ };
- @SuppressWarnings("rawtypes")
- public final Iterator AxiomElement.getAllAttributes() {
- return coreGetAttributesByType(AxiomAttribute.class, attributeIdentityMapper, AxiomSemantics.INSTANCE);
+ public final Iterator<OMAttribute> AxiomElement.getAllAttributes() {
+ return coreGetAttributesByType(AxiomAttribute.class, attributeMapper, AxiomSemantics.INSTANCE);
}
public final OMAttribute AxiomElement.getAttribute(QName qname) {
@@ -376,8 +379,7 @@ public aspect AxiomElementSupport {
coreSetAttribute(AxiomSemantics.NAMESPACE_DECLARATION_MATCHER, decl, AxiomSemantics.INSTANCE);
}
- @SuppressWarnings("rawtypes")
- public final Iterator AxiomElement.getAllDeclaredNamespaces() {
+ public final Iterator<OMNamespace> AxiomElement.getAllDeclaredNamespaces() {
return coreGetAttributesByType(AxiomNamespaceDeclaration.class, NamespaceDeclarationMapper.INSTANCE, AxiomSemantics.INSTANCE);
}
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomSourcedElementSupport.aj Wed Jan 20 20:19:23 2016
@@ -490,7 +490,7 @@ public aspect AxiomSourcedElementSupport
}
}
- public Object AxiomSourcedElement.getObject(Class dataSourceClass) {
+ public Object AxiomSourcedElement.getObject(Class<? extends OMDataSourceExt> dataSourceClass) {
if (dataSource == null || isExpanded || !dataSourceClass.isInstance(dataSource)) {
return null;
} else {
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java Wed Jan 20 20:19:23 2016
@@ -70,7 +70,7 @@ public interface OMContainer extends OMS
* @return Returns an iterator of {@link OMElement} items that match the given QName
*/
// TODO: specify whether a null elementQName is allowed; LLOM and DOOM seem to have different behavior
- Iterator getChildrenWithName(QName elementQName);
+ Iterator<OMElement> getChildrenWithName(QName elementQName);
/**
* Returns an iterator for child nodes matching the local name.
@@ -78,7 +78,7 @@ public interface OMContainer extends OMS
* @param localName
* @return Returns an iterator of {@link OMElement} items that match the given localName
*/
- Iterator getChildrenWithLocalName(String localName);
+ Iterator<OMElement> getChildrenWithLocalName(String localName);
/**
* Returns an iterator for child nodes matching the namespace uri.
@@ -86,7 +86,7 @@ public interface OMContainer extends OMS
* @param uri
* @return Returns an iterator of {@link OMElement} items that match the given uri
*/
- Iterator getChildrenWithNamespaceURI(String uri);
+ Iterator<OMElement> getChildrenWithNamespaceURI(String uri);
/**
@@ -110,7 +110,7 @@ public interface OMContainer extends OMS
* @see #getFirstChildWithName
* @see #getChildrenWithName
*/
- Iterator getChildren();
+ Iterator<OMNode> getChildren();
/**
* Get an iterator over all descendants of the container. The items are returned in document
@@ -122,7 +122,7 @@ public interface OMContainer extends OMS
* child of the container
* @return an iterator over the descendants of this container
*/
- Iterator getDescendants(boolean includeSelf);
+ Iterator<OMSerializable> getDescendants(boolean includeSelf);
/**
* Gets the first child.
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Wed Jan 20 20:19:23 2016
@@ -90,7 +90,7 @@ public interface OMElement extends OMNod
* @see #getChildren()
* @see #getChildrenWithName(javax.xml.namespace.QName)
*/
- Iterator getChildElements();
+ Iterator<OMElement> getChildElements();
/**
* Add a namespace declaration for the given namespace URI to this element, optionally
@@ -241,7 +241,7 @@ public interface OMElement extends OMNod
* {@link #declareDefaultNamespace(String)} or any other method that modifies the
* namespace declarations of this element.
*/
- Iterator getAllDeclaredNamespaces();
+ Iterator<OMNamespace> getAllDeclaredNamespaces();
/**
* Get an iterator that returns all namespaces in scope for this element. This method may be
@@ -260,7 +260,7 @@ public interface OMElement extends OMNod
*
* @return an iterator over all namespaces in scope for this element
*/
- Iterator getNamespacesInScope();
+ Iterator<OMNamespace> getNamespacesInScope();
/**
* Get the namespace context of this element, as determined by the namespace declarations
@@ -301,7 +301,7 @@ public interface OMElement extends OMNod
* @see #addAttribute(OMAttribute)
* @see #addAttribute(String, String, OMNamespace)
*/
- Iterator getAllAttributes();
+ Iterator<OMAttribute> getAllAttributes();
/**
* Returns a named attribute if present.
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMSourcedElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMSourcedElement.java?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMSourcedElement.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMSourcedElement.java Wed Jan 20 20:19:23 2016
@@ -81,5 +81,5 @@ public interface OMSourcedElement extend
* @return the backing Java object or <code>null</code> if the conditions specified above are
* not satisfied
*/
- Object getObject(Class dataSourceClass);
+ Object getObject(Class<? extends OMDataSourceExt> dataSourceClass);
}
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/AbstractNamespaceContext.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/AbstractNamespaceContext.java?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/AbstractNamespaceContext.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/AbstractNamespaceContext.java Wed Jan 20 20:19:23 2016
@@ -80,7 +80,7 @@ public abstract class AbstractNamespaceC
*/
protected abstract String doGetPrefix(String namespaceURI);
- public final Iterator getPrefixes(String namespaceURI) {
+ public final Iterator<String> getPrefixes(String namespaceURI) {
if (namespaceURI == null) {
throw new IllegalArgumentException("namespaceURI can't be null");
} else if (namespaceURI.equals(XMLConstants.XML_NS_URI)) {
@@ -103,5 +103,5 @@ public abstract class AbstractNamespaceC
* @return iterator for all prefixes bound to the namespace URI in the
* current scope
*/
- protected abstract Iterator doGetPrefixes(String namespaceURI);
+ protected abstract Iterator<String> doGetPrefixes(String namespaceURI);
}
Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/MapBasedNamespaceContext.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/MapBasedNamespaceContext.java?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/MapBasedNamespaceContext.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/namespace/MapBasedNamespaceContext.java Wed Jan 20 20:19:23 2016
@@ -31,7 +31,7 @@ import javax.xml.XMLConstants;
* Namespace context implementation that stores namespace bindings in a {@link Map}.
*/
public class MapBasedNamespaceContext extends AbstractNamespaceContext {
- private final Map namespaces;
+ private final Map<String,String> namespaces;
/**
* Constructor.
@@ -39,7 +39,7 @@ public class MapBasedNamespaceContext ex
* @param map
* a map containing the (prefix, namespace URI) entries
*/
- public MapBasedNamespaceContext(Map map) {
+ public MapBasedNamespaceContext(Map<String,String> map) {
namespaces = map;
}
@@ -49,12 +49,10 @@ public class MapBasedNamespaceContext ex
}
protected String doGetPrefix(String nsURI) {
- Iterator iter = namespaces.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- String uri = (String) entry.getValue();
+ for (Map.Entry<String,String> entry : namespaces.entrySet()) {
+ String uri = entry.getValue();
if (uri.equals(nsURI)) {
- return (String) entry.getKey();
+ return entry.getKey();
}
}
if (nsURI.length() == 0) {
@@ -63,15 +61,13 @@ public class MapBasedNamespaceContext ex
return null;
}
- protected Iterator doGetPrefixes(String nsURI) {
- Set prefixes = null;
- Iterator iter = namespaces.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
+ protected Iterator<String> doGetPrefixes(String nsURI) {
+ Set<String> prefixes = null;
+ for (Map.Entry<String,String> entry : namespaces.entrySet()) {
String uri = (String) entry.getValue();
if (uri.equals(nsURI)) {
if (prefixes == null) {
- prefixes = new HashSet();
+ prefixes = new HashSet<String>();
}
prefixes.add(entry.getKey());
}
@@ -81,7 +77,7 @@ public class MapBasedNamespaceContext ex
} else if (nsURI.length() == 0) {
return Collections.singleton("").iterator();
} else {
- return Collections.EMPTY_LIST.iterator();
+ return Collections.<String>emptyList().iterator();
}
}
}
\ No newline at end of file
Modified: webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md?rev=1725806&r1=1725805&r2=1725806&view=diff
==============================================================================
--- webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md (original)
+++ webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md Wed Jan 20 20:19:23 2016
@@ -0,0 +1,8 @@
+Apache Axiom 1.3.0 Release Note
+===============================
+
+Changes in this release
+-----------------------
+
+* The public API now uses generics. Note that this should in general not have
+ impact on binary compatibility with Axiom 1.2.x.