Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * This file is part of the DiffX library.
   *
   * For licensing information please see the file license.txt included in the release.
   * A copy of this licence can also be found at
   *   http://www.opensource.org/licenses/artistic-license-2.0.php
   */
  package com.topologi.diffx.event.impl;
  
 
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.

Author(s):
Christophe Lauret
Version:
28 March 2010
 
 public final class IgnorableSpaceEvent implements TextEvent {

  
The characters for this event.
 
   private final String characters;

  
Creates a new ignorable white space event.

Parameters:
seq The char sequence.
Throws:
java.lang.NullPointerException If the given String is null.
 
     if (seq == null)
       throw new NullPointerException("The characters cannot be null, use \"\"");
     this. = seq.toString();
   }

  
Returns "ignorable-space".
 
   @Override
   public String toString() {
     return "ignorable-space";
   }

  
Always returns the same value.
 
   @Override
   public int hashCode() {
     return 71;
   }

  
Returns true if the event is an ignorable white space, regardless of the characters that it matches.

Parameters:
o The event to compare with this event.
Returns:
true if considered equal; false otherwise.
 
   @Override
   public boolean equals(Object o) {
     return o.getClass() == this.getClass();
   }

  
Returns true if the event is an ignorable white space, regardless of the characters that it matches.

Parameters:
e The event to compare with this event.
Returns:
true if considered equal; false otherwise.
 
   @Override
   public boolean equals(DiffXEvent e) {
     if (this == e)
       return true;
     if (e.getClass() != this.getClass())
       return false;
     // always return true
     return true;
   }

  
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.

Returns:
The characters that this event represents.
  public String getCharacters() {
    return this.;
  }
  public void toXML(XMLWriter xmlthrows IOException {
    // we don't need to parse the whitespace characters.
    xml.writeXML(this.);
  }
  public String toXML() {
    return this.;
  }
    xml.append(this.);
    return xml;
  }
  public int getWeight() {
    return 1;
  }

  
Ignored.
  public void setWeight(int weight) {
  }
New to GrepCode? Check out our FAQ X