Class ParseToken

java.lang.Object
org.orekit.files.ccsds.utils.lexical.ParseToken

public class ParseToken extends Object
Token occurring during CCSDS file parsing.

Parse tokens correspond to:

  • bloc or entry start
  • entry content
  • bloc or entry end
  • raw lines
Since:
11.0
Author:
Luc Maisonobe
See Also:
  • Constructor Details

    • ParseToken

      public ParseToken(TokenType type, String name, String content, Unit units, int lineNumber, String fileName)
      Simple constructor.
      Parameters:
      type - type of the token
      name - name of the block or entry
      content - entry content
      units - units of the entry
      lineNumber - number of the line in the CCSDS data message
      fileName - name of the file
  • Method Details

    • getType

      public TokenType getType()
      Get the type of the token.
      Returns:
      type of the token
    • getName

      public String getName()
      Get the name of the block or entry.
      Returns:
      name of the block or entry
    • getRawContent

      public String getRawContent()
      Get the raw content of the entry.
      Returns:
      entry raw content
    • getContentAsNormalizedString

      public String getContentAsNormalizedString()
      Get the content of the entry.

      Free-text strings are normalized by replacing all occurrences of '_' with space, and collapsing several spaces as one space only.

      Returns:
      entry content
    • getContentAsFreeTextList

      public List<String> getContentAsFreeTextList()
      Get the content of the entry as a list of free-text strings.
      Returns:
      content of the entry as a list of free-test strings
      Since:
      12.0
    • getContentAsNormalizedList

      public List<String> getContentAsNormalizedList()
      Get the content of the entry as a list of normalized strings.

      Normalization is performed by replacing all occurrences of '_' with space, and collapsing several spaces as one space only.

      Returns:
      content of the entry as a list of free-test strings
    • getContentAsUppercaseString

      public String getContentAsUppercaseString()
      Get the content of the entry as normalized and uppercased.
      Returns:
      entry normalized and uppercased content
    • getContentAsUppercaseList

      public List<String> getContentAsUppercaseList()
      Get the content of the entry as a list of normalized and uppercased strings.
      Returns:
      content of the entry as a list of normalized and uppercased strings
    • getContentAsEnum

      public <T extends Enum<T>> T getContentAsEnum(Class<T> cls)
      Get the content of the entry as an enum.
      Type Parameters:
      T - type of the enum
      Parameters:
      cls - enum class
      Returns:
      entry content
    • getContentAsEnumList

      public <T extends Enum<T>> List<T> getContentAsEnumList(Class<T> cls)
      Get the content of the entry as a list of enum.
      Type Parameters:
      T - type of the enum
      Parameters:
      cls - enum class
      Returns:
      entry content
    • getContentAsDouble

      public double getContentAsDouble()
      Get the content of the entry as a double.
      Returns:
      content as a double
    • getContentAsVector

      public Vector3D getContentAsVector()
      Get the content of the entry as a vector.
      Returns:
      content as a vector
    • getContentAsBoolean

      public boolean getContentAsBoolean()
      Get the content of the entry as a boolean.
      Returns:
      content as a boolean
    • getContentAsInt

      public int getContentAsInt()
      Get the content of the entry as an integer.
      Returns:
      content as an integer
    • getContentAsUppercaseCharacter

      public char getContentAsUppercaseCharacter()
      Get the content of the entry as an uppercase character.
      Returns:
      content as an uppercase character
    • getUnits

      public Unit getUnits()
      Get the units.
      Returns:
      units of the entry (may be null)
    • getLineNumber

      public int getLineNumber()
      Get the number of the line in the CCSDS data message.
      Returns:
      number of the line in the CCSDS data message
    • getFileName

      public String getFileName()
      Get the name of the file.
      Returns:
      name of the file
    • processAsNormalizedString

      public boolean processAsNormalizedString(ParseToken.StringConsumer consumer)
      Process the content as a normalized string.
      Parameters:
      consumer - consumer of the normalized string
      Returns:
      always returns true
      See Also:
    • processAsUppercaseString

      public boolean processAsUppercaseString(ParseToken.StringConsumer consumer)
      Process the content as a normalized uppercase string.
      Parameters:
      consumer - consumer of the normalized uppercase string
      Returns:
      always returns true
      See Also:
    • processAsIndexedNormalizedString

      public boolean processAsIndexedNormalizedString(int index, ParseToken.IndexedStringConsumer consumer)
      Process the content as an indexed normalized string.
      Parameters:
      index - index
      consumer - consumer of the indexed normalized string
      Returns:
      always returns true
    • processAsIndexedUppercaseString

      public boolean processAsIndexedUppercaseString(int index, ParseToken.IndexedStringConsumer consumer)
      Process the content as an indexed normalized uppercase string.
      Parameters:
      index - index
      consumer - consumer of the indexed normalized uppercase string
      Returns:
      always returns true
    • processAsFreeTextList

      public boolean processAsFreeTextList(ParseToken.StringListConsumer consumer)
      Process the content as a list of free-text strings.
      Parameters:
      consumer - consumer of the free-text strings list
      Returns:
      always returns true
      Since:
      12.0
    • processAsNormalizedList

      public boolean processAsNormalizedList(ParseToken.StringListConsumer consumer)
      Process the content as a list of normalized strings.
      Parameters:
      consumer - consumer of the normalized strings list
      Returns:
      always returns true
    • processAsUppercaseList

      public boolean processAsUppercaseList(ParseToken.StringListConsumer consumer)
      Process the content as a list of normalized uppercase strings.
      Parameters:
      consumer - consumer of the normalized uppercase strings list
      Returns:
      always returns true
    • processAsEnum

      public <T extends Enum<T>> boolean processAsEnum(Class<T> cls, ParseToken.EnumConsumer<T> consumer)
      Process the content as an enum.
      Type Parameters:
      T - type of the enum
      Parameters:
      cls - enum class
      consumer - consumer of the enum
      Returns:
      always returns true
    • processAsEnumsList

      public <T extends Enum<T>> boolean processAsEnumsList(Class<T> cls, ParseToken.EnumListConsumer<T> consumer)
      Process the content as a list of enums.
      Type Parameters:
      T - type of the enum
      Parameters:
      cls - enum class
      consumer - consumer of the enums list
      Returns:
      always returns true
    • processAsBoolean

      public boolean processAsBoolean(ParseToken.BooleanConsumer consumer)
      Process the content as a boolean.
      Parameters:
      consumer - consumer of the boolean
      Returns:
      always returns true
    • processAsInteger

      public boolean processAsInteger(ParseToken.IntConsumer consumer)
      Process the content as an integer.
      Parameters:
      consumer - consumer of the integer
      Returns:
      always returns true
    • processAsIndexedInteger

      public boolean processAsIndexedInteger(int index, ParseToken.IndexedIntConsumer consumer)
      Process the content as an indexed integer.
      Parameters:
      index - index
      consumer - consumer of the integer
      Returns:
      always returns true
      Since:
      12.0
    • processAsIntegerArrayNoSpace

      public boolean processAsIntegerArrayNoSpace(ParseToken.IntegerArrayConsumer consumer)
      Process the content as an array of integers. No spaces between commas are allowed.
      Parameters:
      consumer - consumer of the array
      Returns:
      always returns true
    • processAsIntegerArray

      public boolean processAsIntegerArray(ParseToken.IntegerArrayConsumer consumer)
      Process the content as an array of integers. Spaces are replaced by commas.
      Parameters:
      consumer - consumer of the array
      Returns:
      always returns true
    • processAsNormalizedCharacter

      public boolean processAsNormalizedCharacter(ParseToken.CharConsumer consumer)
      Process the content as a normalized character.
      Parameters:
      consumer - consumer of the normalized character
      Returns:
      always returns true
    • processAsDouble

      public boolean processAsDouble(Unit standard, ParsedUnitsBehavior behavior, ParseToken.DoubleConsumer consumer)
      Process the content as a double.
      Parameters:
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the double
      Returns:
      always returns true
    • processAsLabeledDouble

      public boolean processAsLabeledDouble(char label, Unit standard, ParsedUnitsBehavior behavior, ParseToken.LabeledDoubleConsumer consumer)
      Process the content as a labeled double.
      Parameters:
      label - label
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the indexed double
      Returns:
      always returns true
    • processAsIndexedDouble

      public boolean processAsIndexedDouble(int i, Unit standard, ParsedUnitsBehavior behavior, ParseToken.IndexedDoubleConsumer consumer)
      Process the content as an indexed double.
      Parameters:
      i - index
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the indexed double
      Returns:
      always returns true
    • processAsDoublyIndexedDouble

      public boolean processAsDoublyIndexedDouble(int i, int j, Unit standard, ParsedUnitsBehavior behavior, ParseToken.DoublyIndexedDoubleConsumer consumer)
      Process the content as a doubly-indexed double.
      Parameters:
      i - first index
      j - second index
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the doubly-indexed double
      Returns:
      always returns true
    • processAsDoubleArray

      public boolean processAsDoubleArray(Unit standard, ParsedUnitsBehavior behavior, ParseToken.DoubleArrayConsumer consumer)
      Process the content as an array of doubles.
      Parameters:
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the array
      Returns:
      always returns true
      Since:
      12.0
    • processAsIndexedDoubleArray

      public boolean processAsIndexedDoubleArray(int index, Unit standard, ParsedUnitsBehavior behavior, ParseToken.IndexedDoubleArrayConsumer consumer)
      Process the content as an indexed double array.
      Parameters:
      index - index
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the indexed double array
      Returns:
      always returns true
      Since:
      12.0
    • processAsVector

      public boolean processAsVector(Unit standard, ParsedUnitsBehavior behavior, ParseToken.VectorConsumer consumer)
      Process the content as a vector.
      Parameters:
      standard - units of parsed content as specified by CCSDS standard
      behavior - behavior to adopt for parsed unit
      consumer - consumer of the vector
      Returns:
      always returns true (or throws an exception)
    • processAsDate

      public boolean processAsDate(ParseToken.DateConsumer consumer, ContextBinding context)
      Process the content as a date.
      Parameters:
      consumer - consumer of the date
      context - context binding
      Returns:
      always returns true (or throws an exception)
    • processAsTimeSystem

      public boolean processAsTimeSystem(ParseToken.TimeSystemConsumer consumer)
      Process the content as a time system.
      Parameters:
      consumer - consumer of the time system
      Returns:
      always returns true (or throws an exception)
    • processAsFrame

      public boolean processAsFrame(ParseToken.FrameConsumer consumer, ContextBinding context, boolean allowCelestial, boolean allowOrbit, boolean allowSpacecraft)
      Process the content as a frame.
      Parameters:
      consumer - consumer of the frame
      context - context binding
      allowCelestial - if true, CelestialBodyFrame are allowed
      allowOrbit - if true, OrbitRelativeFrame are allowed
      allowSpacecraft - if true, SpacecraftBodyFrame are allowed
      Returns:
      always returns true
    • processAsCenter

      public boolean processAsCenter(ParseToken.CenterConsumer consumer, CelestialBodies celestialBodies)
      Process the content as a body center.
      Parameters:
      consumer - consumer of the body center
      celestialBodies - factory for celestial bodies
      Returns:
      always returns true
    • processAsCenterList

      public boolean processAsCenterList(ParseToken.CenterListConsumer consumer, CelestialBodies celestialBodies)
      Process the content as a body center list.
      Parameters:
      consumer - consumer of the body center list
      celestialBodies - factory for celestial bodies
      Returns:
      always returns true
    • processAsRotationOrder

      public boolean processAsRotationOrder(ParseToken.RotationOrderConsumer consumer)
      Process the content as a rotation sequence.
      Parameters:
      consumer - consumer of the rotation sequence
      Returns:
      always returns true
      Since:
      12.0
    • processAsUnitList

      public boolean processAsUnitList(ParseToken.UnitListConsumer consumer)
      Process the content as a list of units.
      Parameters:
      consumer - consumer of the time scale
      Returns:
      always returns true (or throws an exception)
    • processAsFreeTextString

      public boolean processAsFreeTextString(ParseToken.StringConsumer consumer)
      Process the content as free text string.
      Parameters:
      consumer - consumer of the string
      Returns:
      always returns true
    • processAsManeuvrableEnum

      public boolean processAsManeuvrableEnum(ParseToken.ManeuvrableConsumer consumer)
      Process the content of the Maneuvrable enum.
      Parameters:
      consumer - consumer of the enum
      Returns:
      always returns true
    • generateException

      public OrekitException generateException(Exception cause)
      Generate a parse exception for this entry.
      Parameters:
      cause - underlying cause exception (may be null)
      Returns:
      exception for this entry