org.das2.datum.TimeParser

TimeParser designed to quickly parse strings with a known format. This parser has been shown to perform around 20 times faster than the discovery parser. This class is not thread-safe, so clients must make sure that only one thread accesses the class at a time.


TIMEFORMAT_Z

$Y-$m-$dT$H:$M:$S.$(subsec;places=3)Z


IGNORE_FIELD_HANDLER

handy FieldHandler that ignores the contents. For example,

tp= TimeParser.create(sagg,"v", TimeParser.IGNORE_FIELD_HANDLER );


getFieldHandlerByCode

getFieldHandlerByCode( String code ) → FieldHandler

return the field handler for the id. For example, enum returns the field handler handling enumerations. Note there is currently only one field handler for each type, so for example two enumerations are not allowed.

Parameters

code -

Returns:

the field handler.

search for examples view on GitHub view source


getFieldHandlerById

getFieldHandlerById( String id ) → FieldHandler

return the field handler for the id. For example, enum returns the field handler handling enumerations. Note there is currently only one field handler for each type, so for example two enumerations are not allowed.

Parameters

id - the field handler id

Returns:

the field handler.

search for examples view on GitHub view source


getPad

getPad( java.util.Map args ) → char

return the pad for the spec, like "underscore" "space" "zero" or "none" For "none", space is returned, and clients allowing special behavior should check for this.

Parameters

args -

Returns:

the char, or (char)0.

search for examples view on GitHub view source


getTime

getTime( Units units ) → double

return the parsed time in the given units. Here Autoplot Jython code shows how this is used: from org.virbo.dataset import SemanticOps tp= TimeParser.create("$Y-$m-$dT$H") u= SemanticOps.lookupTimeUnits("seconds since 2014-01-01T00:00") print tp.parse("2014-01-06T02").getTime( u )

Parameters

units - as in Units.us2000

Returns:

the value in the given units.

search for examples view on GitHub view source


getTimeDatum

getTimeDatum( ) → Datum

return the parsed time as a Datum. For years less than 1990, Units.us1980 is used, otherwise Units.us2000 is used.

Returns:

a datum representing the parsed time.

search for examples view on GitHub view source


isIso8601String

isIso8601String( String exampleTime ) → boolean

return true if the string appears to be an ISO8601 time. This requires that the string contain a "T" or space and the hours and minutes components.

Parameters

exampleTime - string like "1992-353T02:00"

Returns:

true if the string appears to be an ISO8601 time.

search for examples view on GitHub view source


isNested

isNested( ) → boolean

return true if each successive field is nested within the previous, e.g. $Y$m/$d is nested, but $Y$m/$Y$m$d is not because of the second $Y.

Returns:

true if the spec is nested.

search for examples view on GitHub view source


isSpec

isSpec( String spec ) → boolean

Provide standard means of indicating this appears to be a spec by looking for something that would assert the year.

Parameters

spec -

Returns:

true if the string appears to be a spec.

search for examples view on GitHub view source


isStartTimeOnly

isStartTimeOnly( ) → boolean

true if the flag (startTimeOnly) was set in the spec. This is a hint to clients (FileStorageModel) using the time that it shouldn't infer that the time is bounded.

Returns:

boolean

search for examples view on GitHub view source


iso8601String

iso8601String( String exampleTime ) → String

must contain T or space to delimit date and time.

Parameters

exampleTime - "1992-353T02:00"

Returns:

"$Y-$jT$H$M" etc.

search for examples view on GitHub view source


setDigit

setDigit( String format, double value ) → void

set the digit with the integer part, and move the fractional part to the less significant digits. Format should contain just one field, see setDigit( String format, int value ) to break up fields.

Parameters

format - like "Y"
value - like 2014

Returns:

void (returns nothing)

search for examples view on GitHub view source


sloppyColumns

sloppyColumns( ) → void

force the parser to look for delimiters. This should be called immediately after

Returns:

void (returns nothing)

search for examples view on GitHub view source


testTimeParser

testTimeParser( ) → void

test time parsing when the format is known. This time parser is much faster than the time parser of Test009, which must infer the format as it parses.

Returns:

void (returns nothing)

search for examples view on GitHub view source