Class AttributeEventNSImpl

java.lang.Object
com.topologi.diffx.event.impl.DiffXEventBase
com.topologi.diffx.event.impl.AttributeEventNSImpl
All Implemented Interfaces:
AttributeEvent, DiffXEvent, XMLFormattable, XMLWritable

public final class AttributeEventNSImpl extends DiffXEventBase implements AttributeEvent
A namespace aware implementation of the attribute event.
Version:
28 March 2010
  • Field Details

    • uri

      private final String uri
      The namespace URI this attribute belongs to.
    • name

      private final String name
      The name of the attribute.
    • value

      private final String value
      The value of the attribute.
    • hashCode

      private final int hashCode
      A suitable hashcode value.
  • Constructor Details

    • AttributeEventNSImpl

      public AttributeEventNSImpl(String name, String value) throws NullPointerException
      Creates a new attribute event.
      Parameters:
      name - The local name of the attribute.
      value - The value of the attribute.
      Throws:
      NullPointerException - if any of the argument is null.
    • AttributeEventNSImpl

      public AttributeEventNSImpl(String uri, String name, String value) throws NullPointerException
      Creates a new attribute event.
      Parameters:
      uri - The uri of the attribute.
      name - The local name of the attribute.
      value - The value of the attribute.
      Throws:
      NullPointerException - if any of the argument is null.
  • Method Details

    • getName

      public String getName()
      Returns the local name of the attribute.

      This method should never return null.

      Specified by:
      getName in interface AttributeEvent
      Returns:
      The local name of the attribute.
    • getURI

      public String getURI()
      Returns the namespace URI the attribute belongs to.

      This method should return null if the implementation is not namespace aware or if the attribute is not bound to any namespace.

      Specified by:
      getURI in interface AttributeEvent
      Returns:
      The namespace URI the attribute belongs to or null.
    • getValue

      public String getValue()
      Returns the value of the attribute.

      This method should never return null.

      Specified by:
      getValue in interface AttributeEvent
      Returns:
      The value of the attribute.
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class DiffXEventBase
    • equals

      public boolean equals(DiffXEvent e)
      Returns true if the event is an attribute event.
      Specified by:
      equals in interface DiffXEvent
      Specified by:
      equals in class DiffXEventBase
      Parameters:
      e - The event to compare with this event.
      Returns:
      true if this event is equal to the specified event; false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toXML

      public void toXML(XMLWriter xml) throws IOException
      Writes the XML representation of the implementing instance using the specified XMLWriter.
      Specified by:
      toXML in interface XMLWritable
      Parameters:
      xml - The XMLWriter to use.
      Throws:
      IOException - IF an I/O exception occurs whilst writing.
    • toXML

      public StringBuffer toXML(StringBuffer xml) throws NullPointerException
      Appends the XML representation of the object of the implementing class.

      Implementations must ensure that the returned string buffer is the same object as the specified string buffer.

      Specified by:
      toXML in interface XMLFormattable
      Parameters:
      xml - The string buffer to which the XML representation is appended to.
      Returns:
      The modified string buffer.
      Throws:
      NullPointerException - if the specified character sequence is null.
    • equals

      private static boolean equals(String uri1, String uri2)
      Returns true if both namespace URI are null or equal.
      Parameters:
      uri1 - The first namespace URI.
      uri2 - The second namespace URI.
      Returns:
      true if both null or equal; false otherwise.
    • toHashCode

      private static int toHashCode(String uri, String name, String value)
      Calculates the hashcode for this event.
      Parameters:
      uri - The URI.
      name - The attribute name.
      value - The attribute value.
      Returns:
      a number suitable as a hashcode.