org.apache.muse.ws.addressing
Class EndpointReference

java.lang.Object
  extended by org.apache.muse.ws.addressing.EndpointReference
All Implemented Interfaces:
XmlSerializable

public class EndpointReference
extends Object
implements XmlSerializable

EndpointReference is a complete implementation of the EndpointReferenceType type defined in WS-Addressing 1.0.

This class is implemented as a wrapper for an XML representation of an EPR, providing methods that allow users to get and set values with regular Java types rather than DOM types. It also provides a number of copy and conversion constructors for creating EPRs from various sources.

Author:
Dan Jemiolo (danj)

Constructor Summary
EndpointReference(Element root)
          This is a convenience constructor that creates a new EPR from the given XML, making a deep copy of it in the process.
EndpointReference(Element root, boolean makeDeepCopyOfXML)
          Creates a new EPR from the given XML definition.
EndpointReference(EndpointReference copy)
          This is a convenience constructor that is equivalent to calling the EndpointReference(EndpointReference, QName) constructor with the standard wsa:EndpointReference QName.
EndpointReference(EndpointReference copy, QName typeName)
          A copy constructor for EPRs - creates a deep copy of the given EPR.
EndpointReference(URI address)
          This is a convenience constructor that is the equivalent of calling EndpointReference(URI, QName) constructor with the standard wsa:EndpointReference QName.
EndpointReference(URI address, QName typeName)
          Creates a new EPR with the given wsa:Address URI; when the EPR is serialized to XML, its root element will have the given QName.
 
Method Summary
 void addParameter(Element parameter)
          Adds the given Element to the collection of reference parameters.
 void addParameter(QName qname)
          This is a convenience method that calls addParameter(QName, Object) with a null parameter value.
 void addParameter(QName qname, Object value)
          Creates a new reference parameter with the given name and value.
 boolean equals(Object obj)
           
 URI getAddress()
           
 int getNumberOfParameters()
           
 Element getParameter(QName qname)
           
 Element getParameter(QName qname, int index)
           
 Element[] getParameters()
           
 Element[] getParameters(QName qname)
           
 String getParameterString(QName qname)
           
 String getParameterString(QName qname, int index)
           
 QName getRootTypeName()
           
 int hashCode()
          This method has been properly overridden to account for the change to equals(Object).
 void removeParameter(QName qname)
          This is a convenience method that removes the first instance of a reference parameter with the given name.
 void removeParameter(QName qname, int index)
          Removes the n-th instance of the parameter with the given name.
 void removeParameters(QName qname)
          Removes all instances of the parameter with the given name.
 void setAddress(URI address)
           
 String toString()
           
 Element toXML()
          Converts this object into an XML representation, as defined by its related schema or specification.
 Element toXML(Document doc)
          Converts this object into an XML representation, as defined by its related schema or specification.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EndpointReference

public EndpointReference(Element root)
                  throws SoapFault
This is a convenience constructor that creates a new EPR from the given XML, making a deep copy of it in the process. It is equivalent to calling the EndpointReference(Element, boolean) constructor with the second parameter set to "true".

Throws:
SoapFault
See Also:
EndpointReference(Element, boolean)

EndpointReference

public EndpointReference(Element root,
                         boolean makeDeepCopyOfXML)
                  throws SoapFault
Creates a new EPR from the given XML definition.

Parameters:
root - The XML definition of the EPR.
makeDeepCopyOfXML - True if you want the class to clone the given XML fragment so that it has an independent copy of the data. If a copy of the given XML is made, it will retain the same root element QName.
Throws:
SoapFault -
  • If the XML fragment is not valid according to the WS-A EPR type definition.

EndpointReference

public EndpointReference(EndpointReference copy)
This is a convenience constructor that is equivalent to calling the EndpointReference(EndpointReference, QName) constructor with the standard wsa:EndpointReference QName.

See Also:
EndpointReference(EndpointReference, QName), WsaConstants.EPR_QNAME

EndpointReference

public EndpointReference(EndpointReference copy,
                         QName typeName)
A copy constructor for EPRs - creates a deep copy of the given EPR. When serialized to XML, the given QName will be used as the name of the root element (regardless of the root QName of the copied EPR).

Parameters:
copy - The EPR to copy (deep copy).
typeName - The QName of the root element when this EPR is serialized to XML.

EndpointReference

public EndpointReference(URI address)
This is a convenience constructor that is the equivalent of calling EndpointReference(URI, QName) constructor with the standard wsa:EndpointReference QName.

See Also:
EndpointReference(URI, QName), WsaConstants.EPR_QNAME

EndpointReference

public EndpointReference(URI address,
                         QName typeName)
Creates a new EPR with the given wsa:Address URI; when the EPR is serialized to XML, its root element will have the given QName. The new EPR will have no reference parameters or properties elements.

Parameters:
address - The wsa:Address of the EPR.
typeName - The QName of the root element when the EPR is serialized to XML.
Method Detail

addParameter

public void addParameter(Element parameter)
Adds the given Element to the collection of reference parameters. The object will make a deep copy of the Element.

Parameters:
parameter -

addParameter

public void addParameter(QName qname)
This is a convenience method that calls addParameter(QName, Object) with a null parameter value.

See Also:
addParameter(QName, Object)

addParameter

public void addParameter(QName qname,
                         Object value)
Creates a new reference parameter with the given name and value.

Parameters:
qname - The name of the reference parameter's XML element.
value - The parameter value (can be null).

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
Returns:
True, if:
  • The argument is not null.
  • The wsa:Address values match.
  • The wsa:PortType values match (if present).
  • The wsa:ServiceName and PortName values match (if present).
The equality test does not compare the root element QNames used when serializing the EPRs to XML. It also does not compare any reference parameters or properties.

getAddress

public URI getAddress()
Returns:
The wsa:Address value.

getNumberOfParameters

public int getNumberOfParameters()
Returns:
The current number of elements in the wsa:ReferenceParameters section.

getParameter

public Element getParameter(QName qname)
Parameters:
qname - The name of the reference parameter to look up.
Returns:
The first instance of the given parameter, or null if no instances exist.

getParameter

public Element getParameter(QName qname,
                            int index)
Parameters:
qname - The name of the reference parameter to look up.
Returns:
The n-th instance of the given parameter, or null if no instances exist.

getParameters

public Element[] getParameters()
Returns:
All reference parameter instances (there is no guarantee as to the order of the elements). If there are no reference parameters, the array is empty.

getParameters

public Element[] getParameters(QName qname)
Returns:
All reference parameter instances with the given name. If there are no instances with that name, the array is empty.

getParameterString

public String getParameterString(QName qname)
Parameters:
qname - The name of the reference parameter to look up.
Returns:
The text value of the first instance of the parameter, or null if there was none.

getParameterString

public String getParameterString(QName qname,
                                 int index)
Parameters:
qname - The name of the reference parameter to look up.
Returns:
The text value of the n-th instance of the parameter, or null if there was none.

getRootTypeName

public QName getRootTypeName()
Returns:
The QName that is used for the root element when serializing this EPR to XML. The default value is wsa:EndpointReference, but this is not required.

hashCode

public int hashCode()
This method has been properly overridden to account for the change to equals(Object). Overriding equals(Object) and not hashCode() can cause incorrect behavior when storing objects in associative data structures.

Overrides:
hashCode in class Object

removeParameter

public void removeParameter(QName qname)
This is a convenience method that removes the first instance of a reference parameter with the given name. It is equivalent to calling removeParameter(QName, 0).

See Also:
removeParameter(QName, int)

removeParameter

public void removeParameter(QName qname,
                            int index)
Removes the n-th instance of the parameter with the given name. If the parameter was the last one in the reference parameters collection, the wsa:ReferenceParameters section will no longer be serialized into the EPR's XML.

Parameters:
qname - The name of the parameter instance to delete.
index - The instance of the parameter to delete.

removeParameters

public void removeParameters(QName qname)
Removes all instances of the parameter with the given name. If the parameters were the last in the reference parameters collection, the wsa:ReferenceParameters section will no longer be serialized into the EPR's XML.

Parameters:
qname - The name of the parameter(s) to delete.

setAddress

public void setAddress(URI address)
Parameters:
address - The wsa:Address of the EPR (cannot be null).

toString

public String toString()
Overrides:
toString in class Object
Returns:
A string with the XML representation of the EPR.

toXML

public Element toXML()
Description copied from interface: XmlSerializable
Converts this object into an XML representation, as defined by its related schema or specification. The format of the XML is dependent on the concrete type.

Specified by:
toXML in interface XmlSerializable
Returns:
The complete XML representation of the EPR. This is the actual underlying data structure of the EPR, so modifications should be made judiciously (if at all).
See Also:
toXML(Document)

toXML

public Element toXML(Document doc)
Description copied from interface: XmlSerializable
Converts this object into an XML representation, as defined by its related schema or specification. The format of the XML is dependent on the concrete type.

Specified by:
toXML in interface XmlSerializable
Parameters:
doc - The DOM Document that will be used to create all of the nodes in the resulting XML fragment.
Returns:
A copy of the EPR'S XML representation, created using the given Document.


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.