Interface InputParser.ParseResult<T>
- Type Parameters:
T- the type of data produced by parsing
- All Known Implementing Classes:
ArrayParseResult,JsonInputParser.JsonParseResult,TextLineParser.TextLineParseResult
- Enclosing interface:
InputParser<T>
public static interface InputParser.ParseResult<T>
Result of parsing data.
- Author:
- Holger Eichelberger, SSE
-
Method Summary
Modifier and TypeMethodDescriptionintIf the actual element is an array, return the size.voidgetData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, String name, int... indexes) Returns the value of the data field for the given fieldnameor with via the givenindex.Returns the value of the data field for the given fieldnameor with via the givenindex.intReturns the number of parsed data fields.default StringgetFieldName(int... indexes) Returns the name of the field.getFieldName(de.iip_ecosphere.platform.support.function.IOConsumer<T> valueCons, int... indexes) Returns the name of the field.voidgetLocalData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, String name, int... indexes) Returns the value of the data field for the given fieldnameor with via the givenindex.getLocalData(String name, int... indexes) Returns the value of the data field for the given fieldnameor with via the givenindex.Sets the hierarchical substructure denoted bynameas current scope for further resolution.stepOut()Steps out of the actual context set bystepInto(String, int).
-
Method Details
-
getDataCount
int getDataCount()Returns the number of parsed data fields.- Returns:
- the number of data fields (non-negative)
-
getData
Returns the value of the data field for the given fieldnameor with via the givenindex. Primary index goes via name and if not given/mapped, index-based access shall be used as fallback. Names may be hierarchical. May be overridden if direct access to names is provided by the parsed structure, e.g., in JSON. Thus, no index-access is provided in the first place by this interface.- Parameters:
name- the name of the data field, may contain hierarchical names separated byInputParser.SEPARATOR, may be based on the scope set bystepInto(String, int)indexes- the path of (nested) 0-based indexes to the field, the sum must be less thangetDataCount()- Returns:
- the data value
- Throws:
IOException- if the mapped index or the givenindex<0 || index >=getDataCount()
-
getData
void getData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, String name, int... indexes) throws IOException Returns the value of the data field for the given fieldnameor with via the givenindex. Primary index goes via name and if not given/mapped, index-based access shall be used as fallback. Names may be hierarchical. May be overridden if direct access to names is provided by the parsed structure, e.g., in JSON. Thus, no index-access is provided in the first place by this interface. This method shall not throw any exception.- Parameters:
ifPresent- consumer called if a data value was found. The value is passed toifPresentfor further processingname- the name of the data field, may contain hierarchical names separated byInputParser.SEPARATOR, may be based on the scope set bystepInto(String, int)indexes- the path of (nested) 0-based indexes to the field, the sum must be less thangetDataCount()- Throws:
IOException- if an
-
getLocalData
Returns the value of the data field for the given fieldnameor with via the givenindex. Primary index goes via name and if not given/mapped, index-based access shall be used as fallback. No hierarchical name interpretation happens here (local). In combination withstepInto(String, int), this method shall be faster thangetData(String, int...).- Parameters:
name- the name of the data fieldindexes- the path of (nested) 0-based indexes to the field, the sum must be less thangetDataCount()- Returns:
- the data value
- Throws:
IOException- if the mapped index or the givenindex<0 || index >=getDataCount()
-
getLocalData
void getLocalData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, String name, int... indexes) throws IOException Returns the value of the data field for the given fieldnameor with via the givenindex. Primary index goes via name and if not given/mapped, index-based access shall be used as fallback. No hierarchical name interpretation happens here (local). In combination withstepInto(String, int), this method shall be faster thangetData(IOConsumer, String, int...).- Parameters:
ifPresent- consumer called if a data value was found. The value is passed toifPresentfor further processingname- the name of the data fieldindexes- the path of (nested) 0-based indexes to the field, the sum must be less thangetDataCount()- Throws:
IOException- if an exception occurred inifPresent
-
stepInto
Sets the hierarchical substructure denoted bynameas current scope for further resolution. When overriding, declare the actual type as result type.- Parameters:
name- non-hierarchical name of contained substructureindex- the 0-based indexes to the field, must be less thangetDataCount()- Returns:
- the sub parse-result taking
nameas context, use#stepOut()to leave that context - Throws:
IOException- if stepping into fails for some reason
-
stepOut
InputParser.ParseResult<T> stepOut()Steps out of the actual context set bystepInto(String, int). When overriding, declare the actual type as result type.- Returns:
- the actual (parent) context, may be null if this step out was illegal in a non-nested context
-
getArraySize
int getArraySize()If the actual element is an array, return the size.- Returns:
- the size, may be negative
-
getFieldName
Returns the name of the field. This operation may not be efficient on all input parsers, in particular if no index positions are recorded. However, for generically parsing back some structures, this operation is required.- Parameters:
indexes- the path of (nested) 0-based indexes to the field, the sum must be less thangetDataCount()- Returns:
- the name of the field or empty if not known
-
getFieldName
String getFieldName(de.iip_ecosphere.platform.support.function.IOConsumer<T> valueCons, int... indexes) throws IOException Returns the name of the field. This operation may not be efficient on all input parsers, in particular if no index positions are recorded. However, for generically parsing back some structures, this operation is required.- Parameters:
valueCons- a value consumer to handle the value of the field (if found) in the same step, may be null for noneindexes- the path of (nested) 0-based indexes to the field, the sum must be less thangetDataCount()- Returns:
- the name of the field or empty if not known
- Throws:
IOException- if applyingvalueConsleads to an exception
-