public class TokenizerProperty
extends java.lang.Object
This class is mainly used by TokenizerProperties
implementations to
return Iterator
objects of their various properties (keywords,
special sequences etc.). Moreover, it can be used whereever information about
a lexical element description is needed, for instance when firing a
TokenizerPropertyEvent
.
This class replaces the older de.susebox.java.util.TokenizerProperty
class which is deprecated.
TokenizerProperties
Modifier and Type | Field and Description |
---|---|
static byte |
PARSE_FLAG_MASK
The property describes a parse flag mask.
|
Constructor and Description |
---|
TokenizerProperty()
Default constructor.
|
TokenizerProperty(int type)
Constructs a
TokenizerProperty where only the type is known so
far. |
TokenizerProperty(int type,
java.lang.String[] images)
Constructs a
TokenizerProperty with type and image(s). |
TokenizerProperty(int type,
java.lang.String[] images,
java.lang.Object companion)
Constructs a
TokenProperty object with a set of type, image(s)
and companion. |
TokenizerProperty(int type,
java.lang.String[] images,
java.lang.Object companion,
int flags)
Constructs a
TokenProperty object with a set of type, image(s),
companion object and flags. |
TokenizerProperty(int type,
java.lang.String[] images,
java.lang.Object companion,
int flags,
int flagMask)
Constructs a
TokenProperty object with a set of type, image(s),
companion object and flags with an associated flag mask (setFlags(int, int)
for details). |
Modifier and Type | Method and Description |
---|---|
boolean |
containsFlag(int flag)
Checks wether a given flag is in the current flag mask.
|
boolean |
equals(java.lang.Object that)
Redefinition of the well-known
Object.equals(java.lang.Object) method. |
java.lang.Object |
getCompanion()
Obtaining the associated information of the token.
|
int |
getFlagMask()
Retrieving the current flag mask containing the bits that are valid in the
return value of
getFlags() . |
int |
getFlags()
Retrieving the flags of this property.
|
java.lang.String[] |
getImages()
Retrieving the one or more images a lexical element description has.
|
int |
getType()
Retrieving the type of this property.
|
boolean |
isFlagSet(int flag,
boolean defVal)
Checks wether a given flag is set or cleared for this property.
|
void |
setCompanion(java.lang.Object companion)
Some token may have associated informations for the user of the
Token . |
void |
setFlags(int flags)
Setting flags.
|
void |
setFlags(int flags,
int flagMask)
Setting the values for the flags contained in the flag mask.
|
void |
setImages(java.lang.String[] images)
Images of lexical elements are quite different.
|
void |
setType(int type)
Setting the type of the
TokenizerProperty . |
java.lang.String |
toString()
Redefinition of the well-known
Object.toString() method. |
public static final byte PARSE_FLAG_MASK
TokenizerProperties
implementations.public TokenizerProperty()
Token.UNKNOWN
and no images or flags.public TokenizerProperty(int type)
TokenizerProperty
where only the type is known so
far. For the type, one of the constants defined in Token
must be
used.type
- the property typepublic TokenizerProperty(int type, java.lang.String[] images)
TokenizerProperty
with type and image(s). For the
type, one of the constants defined in Token
must be used.type
- the property typeimages
- the characterising images of a lexical elementpublic TokenizerProperty(int type, java.lang.String[] images, java.lang.Object companion)
TokenProperty
object with a set of type, image(s)
and companion.type
- the property typeimages
- the characterising images of a lexical elementcompanion
- the associated information for the lexical elementpublic TokenizerProperty(int type, java.lang.String[] images, java.lang.Object companion, int flags)
TokenProperty
object with a set of type, image(s),
companion object and flags.type
- the property typeimages
- the characterising images of a lexical elementcompanion
- the associated information for the lexical elementflags
- the specific parse flags for this lexical elementpublic TokenizerProperty(int type, java.lang.String[] images, java.lang.Object companion, int flags, int flagMask)
TokenProperty
object with a set of type, image(s),
companion object and flags with an associated flag mask (setFlags(int, int)
for details).type
- the property typeimages
- the characterising images of a lexical elementcompanion
- the associated information for the lexical elementflags
- the specific parse flags for this lexical elementflagMask
- which bits of the parse flags are actually validpublic void setType(int type)
TokenizerProperty
. Usually, one of the
constants defined in Token
is passed to this method, for instance
Token.NORMAL
, Token.KEYWORD
or Token.WHITESPACE
.
de.susebox.jtopas
may define, set and return their own type
constants.public int getType()
Token
is returned, for instance Token.NORMAL
, Token.KEYWORD
or Token.WHITESPACE
. However, implementations and subclasses of the
interfaces and classes in the package de.susebox.jtopas
may define,
set and return their own type constants.setType(int)
public void setFlags(int flags)
TokenizerProperties
F_...
constants is used here.
setFlags(int, int)
(flags, flags)
.flags
- a bitmaskgetFlags()
public void setFlags(int flags, int flagMask)
TokenizerProperties
F_...
constants is used here.
TokenizerProperty
. Flags that are not contained in the flag mask,
have an "unknown" value in this instance.
flag = 0
and flagMask = TokenizerProperties.F_CASE
means that the property
is case-insensitive, but there are no other characteristics explicitely set
for this property.
flags
- a bitmask of flags to be set or clearflagMask
- a bitmask containing the flags that are valid in flags
getFlags()
public int getFlags()
setFlags(int)
,
#getFlags(int)
public int getFlagMask()
getFlags()
. The return value -1 means that all bits
in getFlags
are explicitely set for this property.getFlags()
,
setFlags(int, int)
public boolean isFlagSet(int flag, boolean defVal)
getFlagMask()
) does
not contain the given flag. This is the case if containsFlag(int)
would
return false
for the given flag.
containsFlag
returns true
for the given flag,
isFlagSet
returns true
only if the all bits in the
given flag are in the current flags.flag
- the flag to checkdefVal
- the default value if the flag is not contained in the
current flag masktrue
if the given flag is explicitely set or the default
value is true
, false
if the given flag is
explicitely cleared or the default value is false
.public boolean containsFlag(int flag)
isFlagSet(int, boolean)
to determine
wether the return value of isFlagSet
is actually the default
value given to that method, or the flag value of the property itself.
true
only if the all bits in the given flag
are in the current flag mask.flag
- the flag to checkdefVal
- the default value if the flag is not contained in the
current flag masktrue
if the given flag is explicitely set or the default
value is true
, false
if the given flag is
explicitely cleared or the default value is false
.public void setImages(java.lang.String[] images) throws java.lang.IllegalArgumentException
images
- the characterising images of a lexical elementjava.lang.IllegalArgumentException
public java.lang.String[] getImages()
setImages(java.lang.String[])
public void setCompanion(java.lang.Object companion)
Token
.
A popular thing would be the association of an integer constant to a special
sequence or keyword to be used in fast switch
statetents.companion
- the associated information for the lexical elementpublic java.lang.Object getCompanion()
null
. See
setCompanion(java.lang.Object)
for details.public boolean equals(java.lang.Object that)
Object.equals(java.lang.Object)
method.equals
in class java.lang.Object
that
- compare this instance with that objecttrue
if the two object describe the same property,
false
otherwisepublic java.lang.String toString()
Object.toString()
method.toString
in class java.lang.Object
TokenizerProperty