org.argouml.util
Class LineSeparator

java.lang.Object
  extended byorg.argouml.util.CustomSeparator
      extended byorg.argouml.util.LineSeparator

class LineSeparator
extends CustomSeparator

A descendent of CustomSeparator that recognizes "the tree line ends":

This is in fact the class currently used LINE_SEPARATOR in MyTokenizer.


Field Summary
private  boolean hasCr
           
private  boolean hasLf
           
private  boolean hasPeeked
           
 
Fields inherited from class org.argouml.util.CustomSeparator
 
Constructor Summary
LineSeparator()
          Creates a LineSeparator.
 
Method Summary
 boolean addChar(char c)
          Called to allow you to decide if you want to capure control of the matching process. If you return true, then hasFreePart will be checked to see if you expect more things to follow.

The default behaviour is to return false until the character or String given as parameter to the constructor has been matched. Overridden to find the start of a line-end.

 boolean endChar(char c)
          Called to check if more characters are expected in the free part of the token. Overridden to find the end of a line-end.
 int getPeekCount()
          Called to how many characters the CustomSeparator read after the end of the separator. This allows them to see beyond the end, but these characters will be fed to the separators again when looking for the next token so be careful.
 boolean hasFreePart()
          Called to check if more characters are expected to follow after addChar has returned true. If true, then any following characters will be fed to endChar until endChar returns true.

The default behaviour is to return false.

 void reset()
          Called to reset the separator before staring to look for a new token.
 int tokenLength()
          Returns the length of the matched token. It is not required to be meaningful unless addChar has returned true and hasFreePart returned false or endChar returned true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasCr

private boolean hasCr

hasLf

private boolean hasLf

hasPeeked

private boolean hasPeeked
Constructor Detail

LineSeparator

public LineSeparator()
Creates a LineSeparator.

Method Detail

reset

public void reset()
Description copied from class: CustomSeparator
Called to reset the separator before staring to look for a new token.

Overrides:
reset in class CustomSeparator

tokenLength

public int tokenLength()
Returns the length of the matched token. It is not required to be meaningful unless addChar has returned true and hasFreePart returned false or endChar returned true.

Overrides:
tokenLength in class CustomSeparator
Returns:
The length of the matched token.

getPeekCount

public int getPeekCount()
Called to how many characters the CustomSeparator read after the end of the separator. This allows them to see beyond the end, but these characters will be fed to the separators again when looking for the next token so be careful.

Overrides:
getPeekCount in class CustomSeparator
Returns:
the number of characters that were read after the end of the token had been read.

hasFreePart

public boolean hasFreePart()
Called to check if more characters are expected to follow after addChar has returned true. If true, then any following characters will be fed to endChar until endChar returns true.

The default behaviour is to return false.

Overrides:
hasFreePart in class CustomSeparator
Returns:
true to continue feeding characters to endChar or false.

addChar

public boolean addChar(char c)
Called to allow you to decide if you want to capure control of the matching process. If you return true, then hasFreePart will be checked to see if you expect more things to follow.

The default behaviour is to return false until the character or String given as parameter to the constructor has been matched. Overridden to find the start of a line-end.

Overrides:
addChar in class CustomSeparator
Parameters:
c - The next character in the sequence being tokenized.
Returns:
true to gain control of the matching, false to continue matching.

endChar

public boolean endChar(char c)
Called to check if more characters are expected in the free part of the token. Overridden to find the end of a line-end.

Overrides:
endChar in class CustomSeparator
Parameters:
c - The next character in the sequence being tokenized.
Returns:
true to indicate that the token is complete, or false to continue feeding characters through endChar.


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook