Class CharactersEventBase

java.lang.Object
com.topologi.diffx.event.impl.DiffXEventBase
com.topologi.diffx.event.impl.CharactersEventBase
All Implemented Interfaces:
DiffXEvent, TextEvent, XMLFormattable, XMLWritable
Direct Known Subclasses:
CharactersEvent, SpaceEvent, WordEvent

public abstract class CharactersEventBase extends DiffXEventBase implements TextEvent
A base class for all the characters events "characters" SAX event.
Version:
28 March 2010
  • Field Details

    • characters

      private final String characters
      The characters for this event.
    • hashCode

      private final int hashCode
      A suitable hashCode for this event.
  • Constructor Details

  • Method Details

    • hashCode

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

      public final boolean equals(DiffXEvent e)
      Returns true if the event is a character event and its content is equivalent.
      Specified by:
      equals in interface DiffXEvent
      Specified by:
      equals in class DiffXEventBase
      Parameters:
      e - The event to compare with this event.
      Returns:
      true if considered equal; false otherwise.
    • getCharacters

      public final String getCharacters()
      Returns the characters that this event represents.

      Note: this method will return the characters as used by Java (ie. Unicode), they may not be suitable for writing to an XML string.

      Specified by:
      getCharacters in interface TextEvent
      Returns:
      The characters that this event represents.
    • toXML

      public final 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 final 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(CharSequence s)
      Calculates the hashcode value from a string.
      Parameters:
      s - A string from which to calculate the hashcode.
      Returns:
      a suitable hashcode value.