public final class Parsers extends Object
Parser
s.StandardParserFactory
Modifier and Type | Method and Description |
---|---|
static Optional<NumericalValue> |
parseNumerical(Source source)
Parses a
NumericalValue at the beginning of the given source. |
static Optional<NumericalValue> |
parseNumerical(String source)
Parses a
NumericalValue at the beginning of the given string. |
static <T extends Broadcastable> |
parseSimple(Source source,
Parser parser,
Class<T> klass)
Uses the given parser to parse an instance of the given class at the beginning of the given source.
|
static <T extends Broadcastable> |
parseSimple(String source,
Parser parser,
Class<T> klass)
Uses the given parser to parse an instance of the given class at the beginning of the given source.
|
public static Optional<NumericalValue> parseNumerical(String source)
NumericalValue
at the beginning of the given string.source
- Parse this string.NumericalValue
, or an empty Optional
if not present.public static Optional<NumericalValue> parseNumerical(Source source)
NumericalValue
at the beginning of the given source.source
- Parse this source.NumericalValue
, or an empty Optional
if not present.public static <T extends Broadcastable> Optional<T> parseSimple(String source, Parser parser, Class<T> klass)
The parser must find and broadcast an instance of the given type, and it must be at the beginning of the source.
Example:
Parsers.parseSimple("10px solid red", ParserFactory.numericalValueParser(), NumericalValue.class);
T
- Type of the object to parse.source
- The source to parse.parser
- The parser to use.klass
- The class of the object to parse.Optional
if not present.public static <T extends Broadcastable> Optional<T> parseSimple(Source source, Parser parser, Class<T> klass)
The parser must find and broadcast an instance of the given type, and it must be at the beginning of the source.
Example:
Parsers.parseSimple(source, ParserFactory.numericalValueParser(), NumericalValue.class);
T
- Type of the object to parse.source
- The source to parse.parser
- The parser to use.klass
- The class of the object to parse.Optional
if not present.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.