Class AttributeEventImpl

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

public final class AttributeEventImpl extends DiffXEventBase implements AttributeEvent
A basic implementation of the attribute event.

This implementation is not namespace aware.

Version:
28 March 2010
  • Field Details

    • 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

    • AttributeEventImpl

      public AttributeEventImpl(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.
  • 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()
      Always return null. 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.
    • toHashCode

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