org.ws4d.java.types
Interface Attributable

All Known Implementing Classes:
AttributableSupport, DefaultEventSource, Element, Fault, IOType, Operation, OperationCommons, OperationStub, ServiceCommons.PortType, WSDLOperation, WSDLPortType

public interface Attributable

A simple annotation-like interface which adds arbitrary XML attribute support to a given structure.


Method Summary
 CustomAttributeValue getAttribute(QName name)
          Returns the value of the attribute with the given name or null, if this attribute is not available (or if its value is actually explicitly set to null).
 HashMap getAttributes()
          Returns all attributes explicitly set for this Attributable instance.
 boolean hasAttributes()
          Returns true only if this instance has at least one attribute set.
 void serializeAttributes(org.xmlpull.v1.XmlSerializer serializer)
          Serializes the attributes stored within this instance, if any.
 void setAttribute(QName name, CustomAttributeValue value)
          Sets the value for the attribute with the specified name.
 void setAttribute(QName name, java.lang.String value)
          Sets the value for the attribute with the specified name.
 void setAttributes(HashMap attributes)
          Sets all attributes at once to those contained within argument attributes.
 

Method Detail

getAttribute

CustomAttributeValue getAttribute(QName name)
Returns the value of the attribute with the given name or null, if this attribute is not available (or if its value is actually explicitly set to null).

Parameters:
name - the name of the attribute of which to query the value
Returns:
the value of the named attribute or null

setAttribute

void setAttribute(QName name,
                  CustomAttributeValue value)
Sets the value for the attribute with the specified name. Throws a java.lang.IllegalArgumentException in case name is null.

Parameters:
name - the name of the attribute to set, must not be null
value - the value to set the named attribute to (may be null
Throws:
java.lang.IllegalArgumentException - if name is null

setAttribute

void setAttribute(QName name,
                  java.lang.String value)
Sets the value for the attribute with the specified name. The value will be represented as plain String. It will be wrapped within a new instance of StringAttributeValue. This method throws a java.lang.IllegalArgumentException in case name is null.

This is a shorthand for setAttribute(name, new StringAttributeValue(value)).

Parameters:
name - the name of the attribute to set, must not be null
value - the value to set the named attribute to (may be null
Throws:
java.lang.IllegalArgumentException - if name is null

getAttributes

HashMap getAttributes()
Returns all attributes explicitly set for this Attributable instance. Note that depending on the actual implementation the returned reference may point at the 'life map', i .e. the actual storage for the attributes. Thus, modifications to that map should be performed with care and keeping this in mind.

Returns:
all already set attributes

setAttributes

void setAttributes(HashMap attributes)
Sets all attributes at once to those contained within argument attributes. Note that depending on the actual implementation it is possible that the map attributes points at may be used for the actual internal storage of the attributes (i.e. without copying it). That is why, after passing it to this method, modifications to this map should be made with care. This method throws a java.lang.IllegalArgumentException in cases where attributes is null.

Parameters:
attributes - the new attributes to set
Throws:
java.lang.IllegalArgumentException - if attributes is null

hasAttributes

boolean hasAttributes()
Returns true only if this instance has at least one attribute set. Returns false in any other case.

Returns:
true only if there is at least one attribute set within this instance

serializeAttributes

void serializeAttributes(org.xmlpull.v1.XmlSerializer serializer)
                         throws java.io.IOException
Serializes the attributes stored within this instance, if any.

Parameters:
serializer - the serializer to which to send output
Throws:
java.io.IOException - in case writing to serializer fails for any reason