Package com.attivio.sdk.util
Class StringParser
- java.lang.Object
-
- com.attivio.sdk.util.StringParser
-
public final class StringParser extends java.lang.ObjectSimple parser for parsing string values into more complex objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStringParser.TokenTypeType for a token.
-
Field Summary
Fields Modifier and Type Field Description protected intendOffsetprotected intnextStartOffsetprotected intstartOffset
-
Constructor Summary
Constructors Modifier Constructor Description protectedStringParser(java.lang.String source, long flags, CgiRequest cgi, MessageMetadata metas)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidencodeVariableName(java.lang.StringBuilder buffer, java.lang.String name)booleaneos()Returnstrueif end of stream has been reached.booleanexpect(StringParser.TokenType type)booleanexpect(StringParser.TokenType a, StringParser.TokenType b)booleanexpectBinary()booleanexpectDate()java.math.BigDecimalexpectDecimal()booleanexpectInteger()booleanexpectKeyword()Expect an unquoted string.booleanexpectKeyword(java.lang.String keyword)booleanexpectNumber()booleanexpectParameterName()booleanexpectQuotedString()Expect a quoted string.booleanexpectSingleQuotedString()booleanexpectVariable()byte[]getBinary()Get the current token's text as abyte[].java.util.DategetDate(java.util.TimeZone timeZone)Get the current token as a Date.java.math.BigDecimalgetDecimal()Get the current token as aBigDecimal.doublegetDouble()Get the current token as a double.intgetEndOffset()floatgetFloat()Get the current token as a float.intgetInteger()Get the current token as an integer.longgetLong()Get the current token as a long integer.intgetNextStartOffset()doublegetParameter(java.lang.String key, double defaultValue)Get the first value for a CGI Parameter as adouble.intgetParameter(java.lang.String key, int defaultValue)Get the first value for a CGI Parameter as anint.java.lang.StringgetParameter(java.lang.String key, java.lang.String defaultValue)Get the first value for a CGI Parameter.intgetStartOffset()java.lang.StringgetString()Get the current token's text as a String.java.lang.StringgetVariableName()Get the variable name for a VAR token.booleanhasNext()Returnstrueif there another token is available.booleanisNextQuoted()booleanisQuoted()Was the current token text quoted.java.lang.StringnextToken()The text for the next unconsumed token.StringParser.TokenTypenextType()static java.lang.Stringquote(java.lang.String text)Conditionally wraptextin double quotes if it contains reserved characters or is an empty string.byte[]readBinary()booleanreadBoolean()java.util.DatereadDate(java.util.TimeZone timeZone)java.math.BigDecimalreadDecimal()doublereadDouble()FieldExpressionreadFieldExpression()floatreadFloat()intreadInteger()java.util.DatereadIsoDate(java.util.TimeZone timeZone)java.lang.StringreadKeyword()longreadLong()PointreadPoint()java.lang.StringreadString()intreadUnsigned()StringParserrequire(StringParser.TokenType type)StringParserrequire(StringParser.TokenType a, StringParser.TokenType b)StringParserrequireEx(StringParser.TokenType type)StringParserrequireKeyword(java.lang.String keyword)static StringParservalueOf(java.lang.String value)static StringParservalueOf(java.lang.String value, CgiRequest cgi)static StringParservalueOf(java.lang.String value, MessageMetadata metas)
-
-
-
Constructor Detail
-
StringParser
protected StringParser(java.lang.String source, long flags, CgiRequest cgi, MessageMetadata metas)
-
-
Method Detail
-
isQuoted
public boolean isQuoted()
Was the current token text quoted.
-
nextToken
public java.lang.String nextToken()
The text for the next unconsumed token.
-
nextType
public StringParser.TokenType nextType()
-
isNextQuoted
public boolean isNextQuoted()
-
getParameter
public java.lang.String getParameter(java.lang.String key, java.lang.String defaultValue)Get the first value for a CGI Parameter.
-
getParameter
public double getParameter(java.lang.String key, double defaultValue)Get the first value for a CGI Parameter as adouble.
-
getParameter
public int getParameter(java.lang.String key, int defaultValue)Get the first value for a CGI Parameter as anint.
-
eos
public boolean eos()
Returnstrueif end of stream has been reached.
-
hasNext
public boolean hasNext()
Returnstrueif there another token is available.
-
expect
public boolean expect(StringParser.TokenType type)
-
expect
public boolean expect(StringParser.TokenType a, StringParser.TokenType b)
-
expectParameterName
public boolean expectParameterName()
-
expectSingleQuotedString
public boolean expectSingleQuotedString()
-
expectNumber
public boolean expectNumber()
-
expectInteger
public boolean expectInteger()
-
expectDate
public boolean expectDate()
-
expectBinary
public boolean expectBinary()
-
expectVariable
public boolean expectVariable()
-
expectQuotedString
public boolean expectQuotedString()
Expect a quoted string.
-
expectKeyword
public boolean expectKeyword()
Expect an unquoted string.
-
expectKeyword
public boolean expectKeyword(java.lang.String keyword)
-
require
public StringParser require(StringParser.TokenType a, StringParser.TokenType b)
-
require
public StringParser require(StringParser.TokenType type)
-
requireEx
public StringParser requireEx(StringParser.TokenType type) throws java.text.ParseException
- Throws:
java.text.ParseException
-
requireKeyword
public StringParser requireKeyword(java.lang.String keyword)
-
getStartOffset
public int getStartOffset()
-
getEndOffset
public int getEndOffset()
-
getNextStartOffset
public int getNextStartOffset()
-
getString
public java.lang.String getString()
Get the current token's text as a String.
-
getVariableName
public java.lang.String getVariableName()
Get the variable name for a VAR token.
-
getBinary
public byte[] getBinary()
Get the current token's text as abyte[].
-
getFloat
public float getFloat()
Get the current token as a float.
-
getDouble
public double getDouble()
Get the current token as a double.
-
getInteger
public int getInteger()
Get the current token as an integer.
-
getLong
public long getLong()
Get the current token as a long integer.
-
getDecimal
public java.math.BigDecimal getDecimal()
Get the current token as aBigDecimal.
-
getDate
public java.util.Date getDate(java.util.TimeZone timeZone)
Get the current token as a Date.
-
readFieldExpression
public FieldExpression readFieldExpression()
-
readBinary
public byte[] readBinary()
-
readString
public java.lang.String readString()
-
readKeyword
public java.lang.String readKeyword()
-
readFloat
public float readFloat()
-
readDouble
public double readDouble()
-
readPoint
public Point readPoint()
-
expectDecimal
public java.math.BigDecimal expectDecimal()
-
readDecimal
public java.math.BigDecimal readDecimal()
-
readInteger
public int readInteger()
-
readLong
public long readLong()
-
readUnsigned
public int readUnsigned()
-
readBoolean
public boolean readBoolean()
-
readIsoDate
public java.util.Date readIsoDate(java.util.TimeZone timeZone)
-
readDate
public java.util.Date readDate(java.util.TimeZone timeZone)
-
quote
public static java.lang.String quote(java.lang.String text)
Conditionally wraptextin double quotes if it contains reserved characters or is an empty string.
-
encodeVariableName
public static void encodeVariableName(java.lang.StringBuilder buffer, java.lang.String name)
-
valueOf
public static StringParser valueOf(java.lang.String value)
-
valueOf
public static StringParser valueOf(java.lang.String value, MessageMetadata metas)
-
valueOf
public static StringParser valueOf(java.lang.String value, CgiRequest cgi)
-
-