Class ParserBuilder
- java.lang.Object
-
- org.orekit.files.ccsds.ndm.AbstractBuilder<ParserBuilder>
-
- org.orekit.files.ccsds.ndm.ParserBuilder
-
public class ParserBuilder extends AbstractBuilder<ParserBuilder>
Builder for allCCSDS Message
files parsers.This builder can be used for building all CCSDS Messages parsers types. It is particularly useful in multi-threaded context as parsers cannot be shared between threads and thus several independent parsers must be built in this case.
- Since:
- 11.0
- Author:
- Luc Maisonobe
-
-
Constructor Summary
Constructors Constructor Description ParserBuilder()
Simple constructor.ParserBuilder(DataContext dataContext)
Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AcmParser
buildAcmParser()
Build a parser forAttitude Comprehensive Messages
.AemParser
buildAemParser()
Build a parser forAttitude Ephemeris Messages
.ApmParser
buildApmParser()
Build a parser forAttitude Parameters Messages
.CdmParser
buildCdmParser()
Build a parser forConjunction Data Messages
.NdmParser
buildNdmParser()
Build a parser forNavigation Data Messages
.OcmParser
buildOcmParser()
Build a parser forOrbit Comprehensive Messages
.OemParser
buildOemParser()
Build a parser forOrbit Ephemeris Messages
.OmmParser
buildOmmParser()
Build a parser forOrbit Mean elements Messages
.OpmParser
buildOpmParser()
Build a parser forOrbit Parameters Messages
.TdmParser
buildTdmParser()
Build a parser forTracking Data Messages
.protected ParserBuilder
create(IERSConventions newConventions, double newEquatorialRadius, double newFlattening, DataContext newDataContext, AbsoluteDate newMissionReferenceDate, RangeUnitsConverter newRangeUnitsConverter)
Build an instance.int
getDefaultInterpolationDegree()
Get the default interpolation degree.double
getDefaultMass()
Get the default mass.Function<ParseToken,List<ParseToken>>[]
getFilters()
Get the filters to apply to parse tokens.double
getMu()
Get the gravitational coefficient.ParsedUnitsBehavior
getParsedUnitsBehavior()
Get the behavior to adopt for handling parsed units.boolean
isSimpleEOP()
Check if tidal effects are ignored when interpolating EOP.ParserBuilder
withDefaultInterpolationDegree(int newDefaultInterpolationDegree)
Set up the default interpolation degree.ParserBuilder
withDefaultMass(double newDefaultMass)
Set up the default mass.ParserBuilder
withFilter(Function<ParseToken,List<ParseToken>> filter)
Add a filter for parsed tokens.ParserBuilder
withMu(double newMu)
Set up the gravitational coefficient.ParserBuilder
withParsedUnitsBehavior(ParsedUnitsBehavior newParsedUnitsBehavior)
Set up the behavior to adopt for handling parsed units.ParserBuilder
withSimpleEOP(boolean newSimpleEOP)
Set up flag for ignoring tidal effects when interpolating EOP.-
Methods inherited from class org.orekit.files.ccsds.ndm.AbstractBuilder
getConventions, getDataContext, getEquatorialRadius, getFlattening, getMissionReferenceDate, getRangeUnitsConverter, withConventions, withDataContext, withEquatorialRadius, withFlattening, withMissionReferenceDate, withRangeUnitsConverter
-
-
-
-
Constructor Detail
-
ParserBuilder
@DefaultDataContext public ParserBuilder()
Simple constructor.This constructor creates a builder with
IERS conventions
set toIERSConventions.IERS_2010
simple EOP
set totrue
data context
set todefault context
mission reference date
set tonull
gravitational coefficient
set toDouble.NaN
central body equatorial radius
set toDouble.NaN
central body flattening
set toDouble.NaN
default mass
set toDouble.NaN
default interpolation degree
set to1
parsed unit behavior
set toParsedUnitsBehavior.CONVERT_COMPATIBLE
converter for range units
set toIdentityConverter
-
ParserBuilder
public ParserBuilder(DataContext dataContext)
Simple constructor.This constructor creates a builder with
IERS conventions
set toIERSConventions.IERS_2010
simple EOP
set totrue
mission reference date
set tonull
gravitational coefficient
set toDouble.NaN
central body equatorial radius
set toDouble.NaN
central body flattening
set toDouble.NaN
default mass
set toDouble.NaN
default interpolation degree
set to1
parsed unit behavior
set toParsedUnitsBehavior.CONVERT_COMPATIBLE
converter for range units
set toIdentityConverter
- Parameters:
dataContext
- data context used to retrieve frames, time scales, etc.
-
-
Method Detail
-
create
protected ParserBuilder create(IERSConventions newConventions, double newEquatorialRadius, double newFlattening, DataContext newDataContext, AbsoluteDate newMissionReferenceDate, RangeUnitsConverter newRangeUnitsConverter)
Build an instance.- Specified by:
create
in classAbstractBuilder<ParserBuilder>
- Parameters:
newConventions
- IERS ConventionsnewEquatorialRadius
- central body equatorial radiusnewFlattening
- central body flatteningnewDataContext
- used to retrieve frames, time scales, etc.newMissionReferenceDate
- reference date for Mission Elapsed Time or Mission Relative Time time systemsnewRangeUnitsConverter
- converter forRange Units
- Returns:
- new instance
-
withSimpleEOP
public ParserBuilder withSimpleEOP(boolean newSimpleEOP)
Set up flag for ignoring tidal effects when interpolating EOP.- Parameters:
newSimpleEOP
- true if tidal effects are ignored when interpolating EOP- Returns:
- a new builder with updated configuration (the instance is not changed)
-
isSimpleEOP
public boolean isSimpleEOP()
Check if tidal effects are ignored when interpolating EOP.- Returns:
- true if tidal effects are ignored when interpolating EOP
-
withMu
public ParserBuilder withMu(double newMu)
Set up the gravitational coefficient.- Parameters:
newMu
- gravitational coefficient- Returns:
- a new builder with updated configuration (the instance is not changed)
-
getMu
public double getMu()
Get the gravitational coefficient.- Returns:
- gravitational coefficient
-
withDefaultMass
public ParserBuilder withDefaultMass(double newDefaultMass)
Set up the default mass.The default mass is used only by
OpmParser
.- Parameters:
newDefaultMass
- default mass- Returns:
- a new builder with updated configuration (the instance is not changed)
-
getDefaultMass
public double getDefaultMass()
Get the default mass.- Returns:
- default mass
-
withDefaultInterpolationDegree
public ParserBuilder withDefaultInterpolationDegree(int newDefaultInterpolationDegree)
Set up the default interpolation degree.The default interpolation degree is used only by
AemParser
andOemParser
.- Parameters:
newDefaultInterpolationDegree
- default interpolation degree- Returns:
- a new builder with updated configuration (the instance is not changed)
-
getDefaultInterpolationDegree
public int getDefaultInterpolationDegree()
Get the default interpolation degree.- Returns:
- default interpolation degree
-
withParsedUnitsBehavior
public ParserBuilder withParsedUnitsBehavior(ParsedUnitsBehavior newParsedUnitsBehavior)
Set up the behavior to adopt for handling parsed units.- Parameters:
newParsedUnitsBehavior
- behavior to adopt for handling parsed units- Returns:
- a new builder with updated configuration (the instance is not changed)
-
getParsedUnitsBehavior
public ParsedUnitsBehavior getParsedUnitsBehavior()
Get the behavior to adopt for handling parsed units.- Returns:
- behavior to adopt for handling parsed units
-
withFilter
public ParserBuilder withFilter(Function<ParseToken,List<ParseToken>> filter)
Add a filter for parsed tokens.This filter allows to change parsed tokens. This method can be called several times, once for each filter to set up. The filters are always applied in the order they were set. There are several use cases for this feature.
The first use case is to allow parsing malformed CCSDS messages with some known discrepancies that can be fixed. One real life example (the one that motivated the development of this feature) is OMM files in XML format that add an empty OBJECT_ID. This could be fixed by setting a filter as follows:
Omm omm = new ParserBuilder(). withFilter(token -> { if ("OBJECT_ID".equals(token.getName()) && (token.getRawContent() == null || token.getRawContent().isEmpty())) { // replace null/empty entries with "unknown" return Collections.singletonList(new ParseToken(token.getType(), token.getName(), "unknown", token.getUnits(), token.getLineNumber(), token.getFileName())); } else { return Collections.singletonList(token); } }). buildOmmParser(). parseMessage(message);
A second use case is to remove unwanted data. For example in order to remove all user-defined data one could use:
Omm omm = new ParserBuilder(). withFilter(token -> { if (token.getName().startsWith("USER_DEFINED")) { return Collections.emptyList(); } else { return Collections.singletonList(token); } }). buildOmmmParser(). parseMessage(message);
A third use case is to add data not originally present in the file. For example in order to add a generated ODM V3 message id to an ODM V2 message that lacks it, one could do:
final String myMessageId = ...; // this could be computed from a counter, or a SHA256 digest, or some metadata Omm omm = new ParserBuilder() withFilter(token -> { if ("CCSDS_OMM_VERS".equals(token.getName())) { // enforce ODM V3 return Collections.singletonList(new ParseToken(token.getType(), token.getName(), "3.0", token.getUnits(), token.getLineNumber(), token.getFileName())); } else { return Collections.singletonList(token); } }). withFilter(token -> { if ("ORIGINATOR".equals(token.getName())) { // add generated message ID after ORIGINATOR entry return Arrays.asList(token, new ParseToken(TokenType.ENTRY, "MESSAGE_ID", myMessageId, null, -1, token.getFileName())); } else { return Collections.singletonList(token); } }). buildOmmmParser(). parseMessage(message);
- Parameters:
filter
- token filter to add- Returns:
- a new builder with updated configuration (the instance is not changed)
- Since:
- 12.0
-
getFilters
public Function<ParseToken,List<ParseToken>>[] getFilters()
Get the filters to apply to parse tokens.- Returns:
- filters to apply to parse tokens
- Since:
- 12.0
-
buildNdmParser
public NdmParser buildNdmParser()
Build a parser forNavigation Data Messages
.- Returns:
- a new parser
-
buildOpmParser
public OpmParser buildOpmParser()
Build a parser forOrbit Parameters Messages
.- Returns:
- a new parser
-
buildOmmParser
public OmmParser buildOmmParser()
Build a parser forOrbit Mean elements Messages
.- Returns:
- a new parser
-
buildOemParser
public OemParser buildOemParser()
Build a parser forOrbit Ephemeris Messages
.- Returns:
- a new parser
-
buildOcmParser
public OcmParser buildOcmParser()
Build a parser forOrbit Comprehensive Messages
.- Returns:
- a new parser
-
buildApmParser
public ApmParser buildApmParser()
Build a parser forAttitude Parameters Messages
.- Returns:
- a new parser
-
buildAemParser
public AemParser buildAemParser()
Build a parser forAttitude Ephemeris Messages
.- Returns:
- a new parser
-
buildAcmParser
public AcmParser buildAcmParser()
Build a parser forAttitude Comprehensive Messages
.- Returns:
- a new parser
- Since:
- 12.0
-
buildTdmParser
public TdmParser buildTdmParser()
Build a parser forTracking Data Messages
.- Returns:
- a new parser
-
buildCdmParser
public CdmParser buildCdmParser()
Build a parser forConjunction Data Messages
.- Returns:
- a new parser
-
-