Class RowProcessor

java.lang.Object
de.iip_ecosphere.platform.configuration.aas.RowProcessor

class RowProcessor extends Object
Processes individual rows in an IDTA specification table.
Author:
Holger Eichelberger, SSE
  • Field Details

    • CFG_REMOVE_NOTES

      private static final boolean CFG_REMOVE_NOTES
      See Also:
    • titlePattern

      private static Pattern titlePattern
    • langStringEnd

      private static Pattern langStringEnd
    • seeSection

      private static Pattern seeSection
    • extensionDesc

      private static Pattern extensionDesc
    • aasTypes

      private List<AasType> aasTypes
    • aasEnums

      private List<AasEnum> aasEnums
    • enumsHandler

      private ParsingUtils.AasEnumResultHandler enumsHandler
    • current

      private List<AasType> current
    • rawData

      private String[] rawData
    • lastRawData

      private String[] lastRawData
    • maxRawIndex

      private int maxRawIndex
    • column

      private int column
    • lastHeader1Row

      private int lastHeader1Row
    • lastHeader2Row

      private int lastHeader2Row
    • row

      private int row
    • version

      private de.iip_ecosphere.platform.support.Version version
    • versionIdentifier

      private String versionIdentifier
    • versionedName

      private String versionedName
    • projectName

      private String projectName
    • specNumber

      private String specNumber
    • lastField

      private AasField lastField
    • lastEnum

      private List<AasEnum> lastEnum
    • lastSemanticIdRaw

      private String lastSemanticIdRaw
    • deferredTypes

      private Map<String,String> deferredTypes
    • genericFields

      private List<AasField> genericFields
    • genericTypeCount

      private int genericTypeCount
    • currentTypeIsAspect

      private boolean currentTypeIsAspect
    • currentMultiSemIdProcessed

      private boolean currentMultiSemIdProcessed
    • lastEnum1Row

      private int lastEnum1Row
    • lastEnum2Row

      private int lastEnum2Row
  • Constructor Details

    • RowProcessor

      RowProcessor()
  • Method Details

    • startRow

      void startRow()
      Notifies about starting a data row. Further data passed in through addDataToRow(String) is collected for the actual row until endRow() is called.
    • addDataToRow

      void addDataToRow(String data)
      Adds (cell) data for the actual row.
      Parameters:
      data - the data, may be null
    • enumAdded

      private void enumAdded(AasEnum en)
      Is called as an ParsingUtils.AasEnumResultHandler if a new enumeration instance was added.
      Parameters:
      en - the enumeration
    • stripTitleDate

      private static String stripTitleDate(String value)
      If there is a date given at the end of the title, remove that.
      Parameters:
      value - the title string value
      Returns:
      value or a shortened version
    • setOnCurrent

      private void setOnCurrent(Consumer<AasType> setter, String field)
      Calls setter on the current AasType. Logs a warning if there is no current instance.
      Parameters:
      setter - the setter
      field - the field name
    • hasRawData

      private boolean hasRawData(int untilIndex)
      Returns whether collect data for a row contains data until the given index.
      Parameters:
      untilIndex - the index to check for until
      Returns:
      true for relevant data, false else
    • endRow

      void endRow()
      Notifies that collecting data for a row has ended and the collected information shall be classified and processed.
      See Also:
    • addLastEnumLiteral

      private void addLastEnumLiteral(AasEnumLiteral literal)
      Adds enum literals.
      Parameters:
      literal - the literal to add
    • getEnumLiteralIdentifier

      private static String getEnumLiteralIdentifier(String idShort)
      Returns the identifier to be used for an enum literal.
      Parameters:
      idShort - the idShort
      Returns:
      the identifier or null
    • endSection

      void endSection()
      Notifies that the end of a specification section has been reached and that temporary information for the last section shall be cleared for the next section.
    • processTwoColumns

      private void processTwoColumns()
      Processes two column tables usually indicating a submodel or a submodel element collection.
    • toIdsBySeparator

      private static String[] toIdsBySeparator(String idShort)
      Splits idShort into multiple ids if certain (varying) conditions/formats apply.
      Parameters:
      idShort - the idShort(s) to split
      Returns:
      the splitted idShort(s)
    • parseMappedSemanticIds

      private Map<String,String> parseMappedSemanticIds(String value)
      Parses a mapping of semantic IDs in case of an aspect type (IDTA-02017-1-0).
      Parameters:
      value - the raw semanticID value of the type
      Returns:
      the mapped semantic ids or null
    • pruneIds

      private String[] pruneIds(String[] ids)
      Prunes the given ids for alternative markers.
      Parameters:
      ids - the ids
      Returns:
      the pruned ids
    • containsPlainType

      private boolean containsPlainType(List<AasType> types, String[] ids)
      Does types contains a plain non-aspect type with idShort from ids.
      Parameters:
      types - the types to search
      ids - the IDs to look for
      Returns:
      true if found, false else
    • preprocessSemanticIdSpec

      private static String preprocessSemanticIdSpec(String value)
      Preprocesses a semantic id specification.
      Parameters:
      value - the value to preprocess
      Returns:
      the preprocessed value
    • isSemanticIdSpec

      private static boolean isSemanticIdSpec(String value, boolean followedBySpace)
      Returns whether value seems to be a specification of a semantic id.
      Parameters:
      value - the value
      followedBySpace - whether a following whitespace (occurs in some cases) shall specifically be checked and be there
      Returns:
      true if value seems to be a semantic id, false else
    • setSemanticId

      private static void setSemanticId(Consumer<String> setter, String value, boolean considerFallback)
      Extracts, converts and finally sets a semantic id passed in from value through setter.
      Parameters:
      setter - the semanticId setter
      value - the actual value representing the semantic id (usually prefixed by [IRI] or [IRDI])
      considerFallback - in case that there is no semantic id type given, try a full resolution via SemanticIdRecognizer; may not be needed if a conceptdescription is supposed to override the semantic id
    • processFourColumns

      private void processFourColumns()
      Processes four data cells. This may detect the first/second head line of the specification field tables, pass on the following lines to processFourColumnsAsField() or ignore the lines in case of other four column tables.
      See Also:
    • postProcessFourColumns

      private void postProcessFourColumns()
      In case that field rows are split into two, post-process the last field by adding the field's description and example values.
      See Also:
    • processFourColumnsAsField

      private void processFourColumnsAsField()
      Turns four data cells into an AAS field.
      See Also:
    • processSmeTypeIdShort

      private String[] processSmeTypeIdShort(String data, AasField field)
      Processes the field part in the first cell, containing the SME type and the idShort.
      Parameters:
      data - the cell data
      field - the field to be modified as a side effect.
      Returns:
      additional fields in the same row, usually null
    • processSemanticIdDescription

      private void processSemanticIdDescription(String data, AasField field)
      Processes the second field cell containing the semantic id and the description, potentially with enums.
      Parameters:
      data - the cell data
      field - the field to be modified as a side effect
    • removeNote

      private static String removeNote(String data)
      Removes a note description text if CFG_REMOVE_NOTES.
      Parameters:
      data - the data to remove the text from
      Returns:
      data or modified data
    • setFieldDescription

      private void setFieldDescription(String description, AasField field)
      Sets the field description, considers in-place "isCaseOf" information and notes.
      Parameters:
      description - the raw description
      field - the target field to set the description on
      See Also:
    • isValueExampleIgnore

      private boolean isValueExampleIgnore(String data)
      Returns whether a value/example entry can be ignored.
      Parameters:
      data - the data
      Returns:
      true for ignore, false else
    • processValueTypeExample

      private void processValueTypeExample(String data, AasField field)
      Processes the third field cell containing the value type and an optional example.
      Parameters:
      data - the cell data
      field - the field to be modified as a side effect
      See Also:
    • processValueTypeExampleOneLine

      private void processValueTypeExampleOneLine(String line, AasField field)
      Processes a value type/example entry on a single line.
      Parameters:
      line - the line
      field - the target field
    • setExampleValues

      private void setExampleValues(String data, List<String> more, AasField field)
      Sets the example value(s).
      Parameters:
      data - the data representing the example(s),may be null
      more - optional more example values, may be null for none
      field - the field to set the values on
    • pruneExamples

      private static String[] pruneExamples(String[] data)
      Prunes examples for "see section" entries.
      Parameters:
      data - the example data
      Returns:
      the pruned data, may be null
    • retokenize

      private void retokenize(String sep, List<String> tokens, Predicate<String> condition)
      Retokenizes tokens for separator sep, if giving checking condition on follow-up strings after a new token. Currently applied only if tokens length is 1.
      Parameters:
      sep - the separator to look for
      tokens - the tokens (to be modified as a side effect)
      condition - optional next-token condition, may be null
    • splitMultiLanguageExample

      private void splitMultiLanguageExample(List<String> tokens)
      Tries to split the tokens into multi-language example strings. Shall be applied only if the field is a multi-language property field.
      Parameters:
      tokens - the tokens
    • processFieldCardinality

      private void processFieldCardinality(String data, AasField field)
      Processes the fourth field cell, potentially containing the field cardinality.
      Parameters:
      data - the cell data
      field - the field to be modified as side effect
    • toCardinality

      private int toCardinality(String data)
      Interprets data as a single cardinality value.
      Parameters:
      data - the data to be interpreted
      Returns:
      the cardinality value, -1 for "*", or the minimum integer value for none
    • storeAsCurrent

      private void storeAsCurrent(List<AasType> newCurrent)
      Stores newCurrent as the current type being processed. If there was a current type before, add that to the result, i.e., the list of detected types.
      Parameters:
      newCurrent - the new current type(s), may be null for none
    • mapPlainTypes

      private Map<String,AasType> mapPlainTypes(List<AasType> aasTypes)
      Collects and maps the plain non-aspect types into aasTypes.
      Parameters:
      aasTypes - the types to map
      Returns:
      the idShort-type-mapping
    • readingCompleted

      void readingCompleted()
      Notified when reading of the specification is completed.
      See Also:
    • getSummary

      AasSpecSummary getSummary()
      Returns the summary result.
      Returns:
      the summary
    • getLogger

      private static de.iip_ecosphere.platform.support.logging.Logger getLogger()
      Returns the logger of this class.
      Returns:
      the logger