Interface Generator
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractGenerator
,KvnGenerator
,XmlGenerator
public interface Generator extends AutoCloseable
Generation interface for CCSDS messages.- Since:
- 11.0
- Author:
- Luc Maisonobe
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
close()
Close the generator.String
dateToCalendarString(TimeConverter converter, AbsoluteDate date)
Convert a date to calendar string value with high precision.String
dateToString(int year, int month, int day, int hour, int minute, double seconds)
Convert a date to string value with high precision.String
dateToString(TimeConverter converter, AbsoluteDate date)
Convert a date to string value with high precision.String
doubleToString(double value)
Convert a double to string value with high precision.void
endMessage(String root)
End CCSDS message.void
enterSection(String name)
Enter into a new section.String
exitSection()
Exit last section.FileFormat
getFormat()
Get the generated file format.String
getOutputName()
Get the name of the output (for error messages).void
newLine()
Finish current line.String
siToCcsdsName(String siName)
Convert a SI unit name to a CCSDS name.void
startMessage(String root, String messageTypeKey, double version)
Start CCSDS message.String
unitsListToString(List<Unit> units)
Convert a list of units to a bracketed string.void
writeComments(List<String> comments)
Write comment lines.void
writeEntry(String key, char value, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, double value, Unit unit, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, int value, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, Double value, Unit unit, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, Enum<?> value, boolean mandatory)
Write a single key/value entry.default void
writeEntry(String key, Integer value, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, String value, Unit unit, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, List<String> value, boolean mandatory)
Write a single key/value entry.void
writeEntry(String key, TimeConverter converter, AbsoluteDate date, boolean forceCalendar, boolean mandatory)
Write a single key/value entry.void
writeRawData(char data)
Write raw data.void
writeRawData(CharSequence data)
Write raw data.
-
-
-
Method Detail
-
getOutputName
String getOutputName()
Get the name of the output (for error messages).- Returns:
- name of the output
-
getFormat
FileFormat getFormat()
Get the generated file format.- Returns:
- generated file format
-
startMessage
void startMessage(String root, String messageTypeKey, double version) throws IOException
Start CCSDS message.- Parameters:
messageTypeKey
- key for message typeroot
- root element for XML filesversion
- format version- Throws:
IOException
- if an I/O error occurs.
-
endMessage
void endMessage(String root) throws IOException
End CCSDS message.- Parameters:
root
- root element for XML files- Throws:
IOException
- if an I/O error occurs.
-
writeComments
void writeComments(List<String> comments) throws IOException
Write comment lines.- Parameters:
comments
- comments to write- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, String value, Unit unit, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to writeunit
- output unit (may be null)mandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, List<String> value, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to writemandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, Enum<?> value, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to writemandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, TimeConverter converter, AbsoluteDate date, boolean forceCalendar, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writeconverter
- converter to use for datesdate
- the date to writeforceCalendar
- if true, the date is forced to calendar formatmandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, char value, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to writemandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, int value, boolean mandatory) throws IOException
Write a single key/value entry.Note that the
mandatory
flag has no effect and a value is always written because the whole domain ofvalue
is treated as valid. UsewriteEntry(String, Integer, boolean)
for integer values that may not be present.- Parameters:
key
- the keyword to writevalue
- the value to writemandatory
- if true, null values triggers exception, otherwise they are silently ignored.- Throws:
IOException
- if an I/O error occurs.- See Also:
writeEntry(String, Integer, boolean)
-
writeEntry
default void writeEntry(String key, Integer value, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to writemandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, double value, Unit unit, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to write (in SI units)unit
- output unitmandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
writeEntry
void writeEntry(String key, Double value, Unit unit, boolean mandatory) throws IOException
Write a single key/value entry.- Parameters:
key
- the keyword to writevalue
- the value to write (in SI units)unit
- output unitmandatory
- if true, null values triggers exception, otherwise they are silently ignored- Throws:
IOException
- if an I/O error occurs.
-
newLine
void newLine() throws IOException
Finish current line.- Throws:
IOException
- if an I/O error occurs.
-
writeRawData
void writeRawData(char data) throws IOException
Write raw data.- Parameters:
data
- raw data to write- Throws:
IOException
- if an I/O error occurs.
-
writeRawData
void writeRawData(CharSequence data) throws IOException
Write raw data.- Parameters:
data
- raw data to write- Throws:
IOException
- if an I/O error occurs.
-
enterSection
void enterSection(String name) throws IOException
Enter into a new section.- Parameters:
name
- section name- Throws:
IOException
- if an I/O error occurs.
-
exitSection
String exitSection() throws IOException
Exit last section.- Returns:
- section name
- Throws:
IOException
- if an I/O error occurs.
-
close
void close() throws IOException
Close the generator.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- if an I/O error occurs.
-
dateToString
String dateToString(TimeConverter converter, AbsoluteDate date)
Convert a date to string value with high precision.- Parameters:
converter
- converter for datesdate
- date to write- Returns:
- date as a string (may be either a relative date or a calendar date)
-
dateToCalendarString
String dateToCalendarString(TimeConverter converter, AbsoluteDate date)
Convert a date to calendar string value with high precision.- Parameters:
converter
- converter for datesdate
- date to write- Returns:
- date as a calendar string
- Since:
- 12.0
-
dateToString
String dateToString(int year, int month, int day, int hour, int minute, double seconds)
Convert a date to string value with high precision.- Parameters:
year
- yearmonth
- monthday
- dayhour
- hourminute
- minuteseconds
- seconds- Returns:
- date as a string
-
doubleToString
String doubleToString(double value)
Convert a double to string value with high precision.We don't want to loose internal accuracy when writing doubles but we also don't want to have ugly representations like STEP = 1.25000000000000000 so we try a few simple formats first and fall back to scientific notation if it doesn't work.
- Parameters:
value
- value to format- Returns:
- formatted value, with all original value accuracy preserved, or null
if value is null or
Double.NaN
-
unitsListToString
String unitsListToString(List<Unit> units)
Convert a list of units to a bracketed string.- Parameters:
units
- lists to output (may be null or empty)- Returns:
- bracketed string (null if units list is null or empty)
-
-