Class IgnorableSpaceEvent

java.lang.Object
com.topologi.diffx.event.impl.IgnorableSpaceEvent
All Implemented Interfaces:
DiffXEvent, TextEvent, XMLFormattable, XMLWritable

public final class IgnorableSpaceEvent extends Object implements TextEvent
A particular type of event reserved for ignored white spaces.

This class can be used to ignore whitespaces for processing but preserve them for formatting. This event keeps the exact formatting of the white space henceby preserving it, but will consider any instances of this class to be equal regardless of their actual formatting so that the algorithm ignores the differences.

Version:
28 March 2010
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The characters for this event.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new ignorable white space event.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the event is an ignorable white space, regardless of the characters that it matches.
    boolean
    Returns true if the event is an ignorable white space, regardless of the characters that it matches.
    Returns the characters that this event represents.
    int
    Returns the weight of this event.
    int
    Always returns the same value.
    void
    setWeight(int weight)
    Ignored.
    Returns "ignorable-space".
    Returns a xml representation of the object of the implementing class.
    void
    Writes the XML representation of the implementing instance using the specified XMLWriter.
    Appends the XML representation of the object of the implementing class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • characters

      private final String characters
      The characters for this event.
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Returns "ignorable-space".
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Always returns the same value.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Returns true if the event is an ignorable white space, regardless of the characters that it matches.
      Overrides:
      equals in class Object
      Parameters:
      o - The event to compare with this event.
      Returns:
      true if considered equal; false otherwise.
    • equals

      public boolean equals(DiffXEvent e)
      Returns true if the event is an ignorable white space, regardless of the characters that it matches.
      Specified by:
      equals in interface DiffXEvent
      Parameters:
      e - The event to compare with this event.
      Returns:
      true if considered equal; false otherwise.
    • getCharacters

      public 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 void toXML(XMLWriter xml) throws IOException
      Description copied from interface: XMLWritable
      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 String toXML()
      Description copied from interface: XMLFormattable

      Returns a xml representation of the object of the implementing class.

      Most implementation should use the following code to ensure consistent data with the other toXML method:

      return this.toXML(new StringBuffer()).toString();
      Specified by:
      toXML in interface XMLFormattable
      Returns:
      a XML representation of the object of the implementing class.
    • toXML

      public StringBuffer toXML(StringBuffer xml) throws NullPointerException
      Description copied from interface: XMLFormattable
      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.
    • getWeight

      public int getWeight()
      Description copied from interface: DiffXEvent
      Returns the weight of this event.

      The default weight should be 1.

      Specified by:
      getWeight in interface DiffXEvent
      Returns:
      The weight of this event.
    • setWeight

      public void setWeight(int weight)
      Ignored. Sets the weight of this event.

      This method is intended for use by algorithms, optimisers and loaders in order to adjust the importance of an event.

      Specified by:
      setWeight in interface DiffXEvent
      Parameters:
      weight - The weight of this event.