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 Type
    Method
    Description
    int
    If the actual element is an array, return the size.
    void
    getData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, String name, int... indexes)
    Returns the value of the data field for the given field name or with via the given index.
    getData(String name, int... indexes)
    Returns the value of the data field for the given field name or with via the given index.
    int
    Returns the number of parsed data fields.
    default String
    getFieldName(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.
    void
    getLocalData(de.iip_ecosphere.platform.support.function.IOConsumer<T> ifPresent, String name, int... indexes)
    Returns the value of the data field for the given field name or with via the given index.
    getLocalData(String name, int... indexes)
    Returns the value of the data field for the given field name or with via the given index.
    stepInto(String name, int index)
    Sets the hierarchical substructure denoted by name as current scope for further resolution.
    Steps out of the actual context set by stepInto(String, int).
  • Method Details

    • getDataCount

      int getDataCount()
      Returns the number of parsed data fields.
      Returns:
      the number of data fields (non-negative)
    • getData

      T getData(String name, int... indexes) throws IOException
      Returns the value of the data field for the given field name or with via the given index. 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 by InputParser.SEPARATOR, may be based on the scope set by stepInto(String, int)
      indexes - the path of (nested) 0-based indexes to the field, the sum must be less than getDataCount()
      Returns:
      the data value
      Throws:
      IOException - if the mapped index or the given index<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 field name or with via the given index. 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 to ifPresent for further processing
      name - the name of the data field, may contain hierarchical names separated by InputParser.SEPARATOR, may be based on the scope set by stepInto(String, int)
      indexes - the path of (nested) 0-based indexes to the field, the sum must be less than getDataCount()
      Throws:
      IOException - if an
    • getLocalData

      T getLocalData(String name, int... indexes) throws IOException
      Returns the value of the data field for the given field name or with via the given index. 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 with stepInto(String, int), this method shall be faster than getData(String, int...).
      Parameters:
      name - the name of the data field
      indexes - the path of (nested) 0-based indexes to the field, the sum must be less than getDataCount()
      Returns:
      the data value
      Throws:
      IOException - if the mapped index or the given index<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 field name or with via the given index. 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 with stepInto(String, int), this method shall be faster than getData(IOConsumer, String, int...).
      Parameters:
      ifPresent - consumer called if a data value was found. The value is passed to ifPresent for further processing
      name - the name of the data field
      indexes - the path of (nested) 0-based indexes to the field, the sum must be less than getDataCount()
      Throws:
      IOException - if an exception occurred in ifPresent
    • stepInto

      InputParser.ParseResult<T> stepInto(String name, int index) throws IOException
      Sets the hierarchical substructure denoted by name as current scope for further resolution. When overriding, declare the actual type as result type.
      Parameters:
      name - non-hierarchical name of contained substructure
      index - the 0-based indexes to the field, must be less than getDataCount()
      Returns:
      the sub parse-result taking name as context, use #stepOut() to leave that context
      Throws:
      IOException - if stepping into fails for some reason
    • stepOut

      Steps out of the actual context set by stepInto(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 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 than getDataCount()
      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 none
      indexes - the path of (nested) 0-based indexes to the field, the sum must be less than getDataCount()
      Returns:
      the name of the field or empty if not known
      Throws:
      IOException - if applying valueCons leads to an exception