http://www.jpicedt.org

jpicedt.format.input.util
Class WordExpression

java.lang.Object
  extended by jpicedt.format.input.util.AbstractRegularExpression
      extended by jpicedt.format.input.util.WordExpression
Direct Known Subclasses:
PicArrowTypeExpression

public class WordExpression
extends AbstractRegularExpression

A RegExp that parses a word, that is, a string:

Since:
jpicedt 1.3
Version:
$Id: WordExpression.java,v 1.8 2013/03/31 06:57:59 vincentb1 Exp $
Author:
Sylvain Reynal

Constructor Summary
WordExpression()
          Parse an expression containing letters only, and stops when a non-letter char is found.
WordExpression(String postfix, boolean swallowPostFix)
          Constructor with allowsDigit=false (i.e. only alphabetic character are swallowed if postfix = null), and which allows linefeeds.
WordExpression(String postfix, boolean swallowPostFix, boolean allowDigit)
          Allow line-feed's, i.e. expression may span more than one line.
WordExpression(String postfix, boolean swallowPostFix, boolean allowDigit, boolean noLineFeed)
           
 
Method Summary
 String getValue()
          Return the parsed content of this expression after a successfull parsing.
 boolean interpret(Context context)
          If parsing was successfull, sends a ParserEvent with value=string found (this may be an empty string) You may then use Context.removeLineFeeds(String) to remove CR from "value".
 String toString()
           
 
Methods inherited from class jpicedt.format.input.util.AbstractRegularExpression
action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WordExpression

public WordExpression(String postfix,
                      boolean swallowPostFix,
                      boolean allowDigit,
                      boolean noLineFeed)
Parameters:
postfix - a String that signals the end of the word (if NULL, swallows as many letters as possible)
swallowPostFix - if TRUE, move cursor JUST BEHIND the postfix; else move it TO THE POSTFIX POSITION
allowDigit - if TRUE, and postfix=NULL, swallows as many "letter-or-digit" as possible (i.e. alphanumeric expression)
noLineFeed - if true, expression must fit on a single line. Otherwise, it may span several lines.

WordExpression

public WordExpression(String postfix,
                      boolean swallowPostFix,
                      boolean allowDigit)
Allow line-feed's, i.e. expression may span more than one line.

Parameters:
postfix - a String that signals the end of the word (if NULL, swallows as many letters as possible)
swallowPostFix - if TRUE, move cursor JUST BEHIND the postfix; else move it TO THE POSTFIX POSITION
allowDigit - if TRUE, and postfix=NULL, swallows as many "letter-or-digit" as possible (i.e. alphanumeric expression)

WordExpression

public WordExpression(String postfix,
                      boolean swallowPostFix)
Constructor with allowsDigit=false (i.e. only alphabetic character are swallowed if postfix = null), and which allows linefeeds.

Parameters:
postfix - a String that signals the end of the word (if NULL, swallows as many letters as possible)
swallowPostFix - if TRUE, move cursor JUST BEHIND the postfix; else move it TO THE POSTFIX POSITION

WordExpression

public WordExpression()
Parse an expression containing letters only, and stops when a non-letter char is found. Allows line-feed's, which can be removed later on using Context.removeLineFeeds (static method).

Method Detail

interpret

public boolean interpret(Context context)
                  throws REParserException
If parsing was successfull, sends a ParserEvent with value=string found (this may be an empty string)

You may then use Context.removeLineFeeds(String) to remove CR from "value".

Specified by:
interpret in class AbstractRegularExpression
Returns:
TRUE if expr has been found
Throws:
REParserException - if an error occur during parsing

getValue

public String getValue()
Return the parsed content of this expression after a successfull parsing.


toString

public String toString()
Overrides:
toString in class Object

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org