public final class FormatMarker
extends java.lang.Object
FormatMarker
class provides facilities to identify markers within a format string.
Currently, the following markers are supported: %b, %d, %x and %s.Modifier and Type | Class and Description |
---|---|
static class |
FormatMarker.Kind
The
FormatMarker.Kind enumeration describes supported types of format markers. |
Modifier and Type | Method and Description |
---|---|
static java.util.List<FormatMarker> |
extractMarkers(java.lang.String text)
Gets the list of format tokens for the specified format string.
|
int |
getEnd()
Returns the end position of the marker (first character after the marker)
in the format string.
|
FormatMarker.Kind |
getKind()
Returns the marker kind.
|
int |
getLength()
Returns the length specified in the marker.
|
java.lang.String |
getRegExpr()
Gets the regular expression describing the given marker type.
|
int |
getStart()
Returns the start position of the marker (first character of the marker)
in the format string.
|
java.lang.String |
getTokenId()
Returns the token identifier for the given marker type.
|
boolean |
isKind(FormatMarker.Kind kind)
Check whether the marker of the specified kind.
|
static java.util.List<ru.ispras.fortress.util.Pair<java.lang.String,java.lang.Integer>> |
tokenize(java.lang.String text,
java.util.List<FormatMarker> markers)
Tokenizes text using the specified list of markers previously extracted from it.
|
java.lang.String |
toString() |
public FormatMarker.Kind getKind()
public boolean isKind(FormatMarker.Kind kind)
kind
- Marker kind.true
if the marker is of the specified kind or false
otherwise.public int getLength()
0
if no length is specified.public int getStart()
public int getEnd()
public java.lang.String getTokenId()
public java.lang.String getRegExpr()
public static java.util.List<FormatMarker> extractMarkers(java.lang.String text)
text
- Format string to be parsed.java.lang.IllegalArgumentException
- if the parameter is null
.public static java.util.List<ru.ispras.fortress.util.Pair<java.lang.String,java.lang.Integer>> tokenize(java.lang.String text, java.util.List<FormatMarker> markers)
text
- Text to be tokenized.markers
- List of markers.java.lang.IllegalArgumentException
- if the parameter is null
.public java.lang.String toString()
toString
in class java.lang.Object