public class ParserBuilder extends AbstractBuilder<ParserBuilder>
CCSDS 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.
| Constructor and Description |
|---|
ParserBuilder()
Simple constructor.
|
ParserBuilder(DataContext dataContext)
Simple constructor.
|
| Modifier and Type | Method and Description |
|---|---|
AcmParser |
buildAcmParser()
Build a parser for
Attitude Comprehensive Messages. |
AemParser |
buildAemParser()
Build a parser for
Attitude Ephemeris Messages. |
ApmParser |
buildApmParser()
Build a parser for
Attitude Parameters Messages. |
CdmParser |
buildCdmParser()
Build a parser for
Conjunction Data Messages. |
NdmParser |
buildNdmParser()
Build a parser for
Navigation Data Messages. |
OcmParser |
buildOcmParser()
Build a parser for
Orbit Comprehensive Messages. |
OemParser |
buildOemParser()
Build a parser for
Orbit Ephemeris Messages. |
OmmParser |
buildOmmParser()
Build a parser for
Orbit Mean elements Messages. |
OpmParser |
buildOpmParser()
Build a parser for
Orbit Parameters Messages. |
TdmParser |
buildTdmParser()
Build a parser for
Tracking 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.
|
getConventions, getDataContext, getEquatorialRadius, getFlattening, getMissionReferenceDate, getRangeUnitsConverter, withConventions, withDataContext, withEquatorialRadius, withFlattening, withMissionReferenceDate, withRangeUnitsConverter@DefaultDataContext public ParserBuilder()
This constructor creates a builder with
IERS conventions set to IERSConventions.IERS_2010simple EOP set to truedata context set to default contextmission reference date set to nullgravitational coefficient set to Double.NaNcentral body equatorial radius set to Double.NaNcentral body flattening set to Double.NaNdefault mass set to Double.NaNdefault interpolation degree set to 1parsed unit behavior set to ParsedUnitsBehavior.CONVERT_COMPATIBLEconverter for range units set to IdentityConverterpublic ParserBuilder(DataContext dataContext)
This constructor creates a builder with
IERS conventions set to IERSConventions.IERS_2010simple EOP set to truemission reference date set to nullgravitational coefficient set to Double.NaNcentral body equatorial radius set to Double.NaNcentral body flattening set to Double.NaNdefault mass set to Double.NaNdefault interpolation degree set to 1parsed unit behavior set to ParsedUnitsBehavior.CONVERT_COMPATIBLEconverter for range units set to IdentityConverterdataContext - data context used to retrieve frames, time scales, etc.protected ParserBuilder create(IERSConventions newConventions, double newEquatorialRadius, double newFlattening, DataContext newDataContext, AbsoluteDate newMissionReferenceDate, RangeUnitsConverter newRangeUnitsConverter)
create in class AbstractBuilder<ParserBuilder>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 for Range Unitspublic ParserBuilder withSimpleEOP(boolean newSimpleEOP)
newSimpleEOP - true if tidal effects are ignored when interpolating EOPpublic boolean isSimpleEOP()
public ParserBuilder withMu(double newMu)
newMu - gravitational coefficientpublic double getMu()
public ParserBuilder withDefaultMass(double newDefaultMass)
The default mass is used only by OpmParser.
newDefaultMass - default masspublic double getDefaultMass()
public ParserBuilder withDefaultInterpolationDegree(int newDefaultInterpolationDegree)
The default interpolation degree is used only by AemParser
and OemParser.
newDefaultInterpolationDegree - default interpolation degreepublic int getDefaultInterpolationDegree()
public ParserBuilder withParsedUnitsBehavior(ParsedUnitsBehavior newParsedUnitsBehavior)
newParsedUnitsBehavior - behavior to adopt for handling parsed unitspublic ParsedUnitsBehavior getParsedUnitsBehavior()
public ParserBuilder withFilter(Function<ParseToken,List<ParseToken>> filter)
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);
filter - token filter to addpublic Function<ParseToken,List<ParseToken>>[] getFilters()
public NdmParser buildNdmParser()
Navigation Data Messages.public OpmParser buildOpmParser()
Orbit Parameters Messages.public OmmParser buildOmmParser()
Orbit Mean elements Messages.public OemParser buildOemParser()
Orbit Ephemeris Messages.public OcmParser buildOcmParser()
Orbit Comprehensive Messages.public ApmParser buildApmParser()
Attitude Parameters Messages.public AemParser buildAemParser()
Attitude Ephemeris Messages.public AcmParser buildAcmParser()
Attitude Comprehensive Messages.public TdmParser buildTdmParser()
Tracking Data Messages.public CdmParser buildCdmParser()
Conjunction Data Messages.Copyright © 2002-2023 CS GROUP. All rights reserved.