Package jpicedt.format.input.util
Class WordExpression
- java.lang.Object
-
- jpicedt.format.input.util.AbstractRegularExpression
-
- jpicedt.format.input.util.WordExpression
-
- All Implemented Interfaces:
ExpressionConstants
- Direct Known Subclasses:
PicArrowTypeExpression
public class WordExpression extends AbstractRegularExpression
A RegExp that parses a word, that is, a string :- either composed of letters only, or letters and digits only (see java.lang.Character.isLetter() for details),
- or terminated by the specified end-delimiter (in which case it may contain chars not restricted to letters)
- Since:
- jpicedt 1.3
- Version:
- $Id: WordExpression.java,v 1.4.2.1 2007/09/02 11:56:15 reynal Exp $
- Author:
- Sylvain Reynal
-
-
Field Summary
-
Fields inherited from interface jpicedt.format.input.util.ExpressionConstants
ANY_CHAR, ANY_CHAR_EOL, ANY_SIGN, AT_LEAST, AT_MOST, DEBUG, DOUBLE, EOL, EXACTLY, INTEGER, NEGATIVE, NON_NULL, POSITIVE, STRICTLY_NEGATIVE, STRICTLY_POSITIVE, WHITE_SPACES, WHITE_SPACES_OR_EOL
-
-
Constructor Summary
Constructors Constructor Description WordExpression()Parse an expression containing letters only, and stops when a non-letter char is found.WordExpression(java.lang.String postfix, boolean swallowPostFix)Constructor with allowsDigit=false (i.e.WordExpression(java.lang.String postfix, boolean swallowPostFix, boolean allowDigit)Allow line-feed's, i.e.WordExpression(java.lang.String postfix, boolean swallowPostFix, boolean allowDigit, boolean noLineFeed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetValue()Return the parsed content of this expression after a successfull parsing.booleaninterpret(Context context)If parsing was successfull, sends a ParserEvent with value=string found (this may be an empty string)java.lang.StringtoString()-
Methods inherited from class jpicedt.format.input.util.AbstractRegularExpression
action
-
-
-
-
Constructor Detail
-
WordExpression
public WordExpression(java.lang.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 POSITIONallowsDigit- 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(java.lang.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 POSITIONallowsDigit- if TRUE, and postfix=NULL, swallows as many "letter-or-digit" as possible (i.e. alphanumeric expression)
-
WordExpression
public WordExpression(java.lang.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:
interpretin classAbstractRegularExpression- Returns:
- TRUE if expr has been found
- Throws:
REParserException- if an error occur during parsing
-
getValue
public java.lang.String getValue()
Return the parsed content of this expression after a successfull parsing.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-