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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intgetArraySize()If the actual element is an array, return the size.voidgetData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, java.lang.String name, int... indexes)Returns the value of the data field for the given fieldnameor with via the givenindex.TgetData(java.lang.String name, int... indexes)Returns the value of the data field for the given fieldnameor with via the givenindex.intgetDataCount()Returns the number of parsed data fields.default java.lang.StringgetFieldName(int... indexes)Returns the name of the field.java.lang.StringgetFieldName(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, java.lang.String name, int... indexes)Returns the value of the data field for the given fieldnameor with via the givenindex.TgetLocalData(java.lang.String name, int... indexes)Returns the value of the data field for the given fieldnameor with via the givenindex.InputParser.ParseResult<T>stepInto(java.lang.String name, int index)Sets the hierarchical substructure denoted bynameas current scope for further resolution.InputParser.ParseResult<T>stepOut()Steps out of the actual context set bystepInto(String, int).
-
-
-
Method Detail
-
getDataCount
int getDataCount()
Returns the number of parsed data fields.- Returns:
- the number of data fields (non-negative)
-
getData
T getData(java.lang.String name, int... indexes) throws java.io.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.- 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:
java.io.IOException- if the mapped index or the givenindex<0 || index >=getDataCount()
-
getData
void getData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, java.lang.String name, int... indexes) throws java.io.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:
java.io.IOException- if an
-
getLocalData
T getLocalData(java.lang.String name, int... indexes) throws java.io.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(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:
java.io.IOException- if the mapped index or the givenindex<0 || index >=getDataCount()
-
getLocalData
void getLocalData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, java.lang.String name, int... indexes) throws java.io.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:
java.io.IOException- if an exception occurred inifPresent
-
stepInto
InputParser.ParseResult<T> stepInto(java.lang.String name, int index) throws java.io.IOException
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:
java.io.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
default java.lang.String getFieldName(int... indexes)
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
java.lang.String getFieldName(de.iip_ecosphere.platform.support.function.IOConsumer<T> valueCons, int... indexes) throws java.io.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:
java.io.IOException- if applyingvalueConsleads to an exception
-
-