Interface InputParser.ParseResult<T>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      int getArraySize()
      If the actual element is an array, return the size.
      void getData​(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 field name or with via the given index.
      T getData​(java.lang.String name, int... indexes)
      Returns the value of the data field for the given field name or with via the given index.
      int getDataCount()
      Returns the number of parsed data fields.
      default java.lang.String getFieldName​(int... indexes)
      Returns the name of the field.
      java.lang.String 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, java.lang.String name, int... indexes)
      Returns the value of the data field for the given field name or with via the given index.
      T getLocalData​(java.lang.String name, int... indexes)
      Returns the value of the data field for the given field name or with via the given index.
      InputParser.ParseResult<T> stepInto​(java.lang.String name, int index)
      Sets the hierarchical substructure denoted by name as current scope for further resolution.
      InputParser.ParseResult<T> stepOut()
      Steps out of the actual context set by stepInto(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 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:
        java.io.IOException - if the mapped index or the given index<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 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:
        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 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:
        java.io.IOException - if the mapped index or the given index<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 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:
        java.io.IOException - if an exception occurred in ifPresent
      • stepInto

        InputParser.ParseResult<T> stepInto​(java.lang.String name,
                                            int index)
                                     throws java.io.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:
        java.io.IOException - if stepping into fails for some reason
      • stepOut

        InputParser.ParseResult<T> 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 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 than getDataCount()
        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 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:
        java.io.IOException - if applying valueCons leads to an exception