Package eu.bandm.tools.d2d2.infra
Class CharSet
java.lang.Object
eu.bandm.tools.d2d2.infra.CharSet
- All Implemented Interfaces:
CharSet
,Serializable
,Predicate<Character>
Implements Character Sets as an ordered sequence of ranges.
Behaves immutable.
Behaves immutable.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Realizes the ranges which make up the character sets. -
Field Summary
Modifier and TypeFieldDescriptionstatic final CharSet
All supported characters, currently MORE than unicode ! DOCMEstatic final CharSet
evidentstatic final char
Highest possible character value, needed for the definition ofnegate()
.static final char
Lowest possible character value, currently0x0000
, needed for the definition ofnegate()
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCalculates the intersection of both sets.boolean
contains
(char c) Evidentboolean
Evidentboolean
int
hashCode()
static CharSet
makeCharSet
(String chars) Constructs an instance which contains all characters contained in the string argument.negate()
Calculates the netation of this set, w.r.t.Calculates the union of the two sets.Evident.static String
Static variant ofstringRepD2d()
.Generate a numeric representation of the character ranges in the set.Convert back into the representation used in d2d-definition sources (="ddf").protected static String
xn
(char c) Generate a numeric representation of a character, whenever sensible.
-
Field Details
-
LOW
public static final char LOWLowest possible character value, currently0x0000
, needed for the definition ofnegate()
.- See Also:
-
HI
public static final char HIHighest possible character value, needed for the definition ofnegate()
.- See Also:
-
EMPTY_SET
evident -
ALL_CHARS
All supported characters, currently MORE than unicode ! DOCME
-
-
Constructor Details
-
CharSet
public CharSet(char l, char u) Construct an instance which ontains the range froml
tou
.- Throws:
IllegalArgumentException
- in case l is numerically larger than u.
-
CharSet
public CharSet(char l) Construct a singleton character set. -
CharSet
Construct an instance which contains the all characters contained in the string argument.
-
-
Method Details
-
equals
-
equals
Evident -
hashCode
public int hashCode() -
makeCharSet
Constructs an instance which contains all characters contained in the string argument. -
contains
public boolean contains(char c) Evident -
singletonContents
Evident.- Returns:
- the only member of
this
, if it is a singleton set, otherwisenull
.
-
and
Calculates the intersection of both sets. -
negate
-
or
Calculates the union of the two sets. Implemented by stepping through the ordered list of ranges and "zipping" them. -
xn
Generate a numeric representation of a character, whenever sensible. -
stringRep
Generate a numeric representation of the character ranges in the set.- Returns:
- a symbolic string representation, showing characters and decimal values.
-
stringRepD2d
Convert back into the representation used in d2d-definition sources (="ddf").- Returns:
- the un-parsed representation according to
D2d
module syntax.
-
staticStringRepD2d
Static variant ofstringRepD2d()
.
-