org.argouml.util
Class QuotedStringSeparator

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

class QuotedStringSeparator
extends CustomSeparator

A descendent of CustomSeparator that recognizes tokens on one of two forms:

The first form is suited for quoted strings, like

"...\"...."
or
'...\'...'
.

The second form is suited for expressions, like

(a+(b*c)-15*eq(a, b))
.

This is in fact the class currently used for the public separators in MyTokenizer, except PAREN_EXPR_STRING_SEPARATOR and LINE_SEPARATOR.


Field Summary
private  char escChr
           
private  boolean esced
           
private  int level
           
private  char startChr
           
private  char stopChr
           
private  int tokLen
           
 
Fields inherited from class org.argouml.util.CustomSeparator
 
Constructor Summary
QuotedStringSeparator(char q, char esc)
          Creates a separator of the first form (see above) where 'chr' = q and 'esc' = esc.
QuotedStringSeparator(char sq, char eq, char esc)
          Creates a separator of the second form (see above) where 'lchr' = sq, 'rchr' = eq and 'esc' = esc.
 
Method Summary
 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 the token.
 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. Overridden to return true.

 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. Overridden to return the entire length of the token.
 
Methods inherited from class org.argouml.util.CustomSeparator
addChar, getPeekCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

escChr

private final char escChr

startChr

private final char startChr

stopChr

private final char stopChr

esced

private boolean esced

tokLen

private int tokLen

level

private int level
Constructor Detail

QuotedStringSeparator

public QuotedStringSeparator(char q,
                             char esc)
Creates a separator of the first form (see above) where 'chr' = q and 'esc' = esc.

Parameters:
q - The delimiter character.
esc - The escape character.

QuotedStringSeparator

public QuotedStringSeparator(char sq,
                             char eq,
                             char esc)
Creates a separator of the second form (see above) where 'lchr' = sq, 'rchr' = eq and 'esc' = esc.

Parameters:
sq - The left delimiter character.
eq - The right delimiter character.
esc - The escape character.
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. Overridden to return the entire length of the token.

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

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. Overridden to return true.

Overrides:
hasFreePart in class CustomSeparator
Returns:
true

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 the token.

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