Package org.xtce.toolkit
Class XTCEDatabaseCompressor
- java.lang.Object
-
- org.xtce.toolkit.XTCEDatabaseParser
-
- org.xtce.toolkit.XTCEDatabaseCompressor
-
public class XTCEDatabaseCompressor extends XTCEDatabaseParser
Class to implement the capability to compress the XML in an XTCE document considering the schema features to reduce document size. This compression is still under construction. Options that may be used in this class are provided in the constructor using the Properties argument. All keys are expected to have a boolean value. Any missing keys are assumed to be false/unselected. The list of keys is: BASIC_DEFAULTS IDENTITY_CALIBRATORS UNNEEDED_LISTS ENUM_2_BOOL RAW_VALID_RANGES ADVANCED_DEFAULTS DUPLICATE_TYPES START_BITS XTCE_PREFIX- Author:
- dovereem
-
-
Constructor Summary
Constructors Constructor Description XTCEDatabaseCompressor(File file, Properties options)Constructor Create and initialize an instance of the XTCE Database Compressor for XML document compression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcompress()Perform all of the compression steps except saving the result.longcompressAdditionalAttributes()Compress additional attributes that have default values.longcompressCalibrationTestAttributes()Compress calibration test attributes used in several elements.longcompressContainerStartBits()Compress location elements in containers where the start bit provided is the same as it would have been using the default of 0 past end of previous item.longcompressDuplicateTypes()Compress Type elements for Parameter and Argument that can be considered duplicate when refactoring is possible.longcompressEmptyUnitSets()Compress the empty UnitSet elements by removing them to reduce size.longcompressEncodingAttributes()Compress Raw Data Encoding attributes.longcompressIdentityCalibrators()Remove identity calibrators that have no effect on the calibrated value.longcompressListsAndSets()Remove List and Set element variants that are unnecessary because there is only 1 child element and that element is valid outside the grouping.longcompressParameterPropertiesAttributes()Compress ParameterProperties attributes and remove the element if there is no additional content.longcompressSimpleEnumerations()Compress simple enumeration types to boolean types.longcompressValidRangeTruisms()Compress ValidRange specifications that are nothing more than truisms when taking into account the size of the encoding.List<String>getMessages()Retrieve the messages that were generated, if any, during the file compression activity.booleansave()Conclude the compression by saving the XML content to an automatically generated filename.booleansave(File xmlFile)Conclude the compression by saving the XML content to a provided file.-
Methods inherited from class org.xtce.toolkit.XTCEDatabaseParser
evaluateXPathQuery, getChanged, getDocument, getDocumentElement, getDocumentWarnings, getErrorCount, getFilename, getNamespaceFromDocument, getSchemaFromDocument, isReadOnly, loadDatabase, loadDatabase, loadDatabase, newDatabase, normalizeDocument, removeDefaultAttribute, renameElement, saveDatabase, setChanged, setFilename, updateHistorySet, validateDocument
-
-
-
-
Constructor Detail
-
XTCEDatabaseCompressor
public XTCEDatabaseCompressor(File file, Properties options) throws XTCEDatabaseException
Constructor Create and initialize an instance of the XTCE Database Compressor for XML document compression. The provided file is loaded and if successful, the user can begin the conversion with the compress() method, or select specific step methods.- Parameters:
file- File containing the XTCE database XML file to load and use for the conversion operation.options- Properties containing the compression options.- Throws:
XTCEDatabaseException- thrown in the event that the file cannot be suitably loaded for conversion.
-
-
Method Detail
-
getMessages
public List<String> getMessages()
Retrieve the messages that were generated, if any, during the file compression activity.- Returns:
- List of String objects containing the messages. This return will never be null, but it can be an empty list.
-
compress
public long compress()
Perform all of the compression steps except saving the result.- Returns:
- long containing the number of elements/attributes that were modified during the compression operation. This is not particularly useful to know, but might be of interest to user display messages.
-
compressEncodingAttributes
public long compressEncodingAttributes()
Compress Raw Data Encoding attributes. bitOrder="mostSignificantBitFirst" abstract="false"- Returns:
- long containing the number of encoding attributes that were changed on DataEncoding elements.
-
compressParameterPropertiesAttributes
public long compressParameterPropertiesAttributes()
Compress ParameterProperties attributes and remove the element if there is no additional content. dataSource="telemetered" readOnly="false"- Returns:
- long containing the number of ParameterProperties elements that were modified or removed entirely.
-
compressCalibrationTestAttributes
public long compressCalibrationTestAttributes()
Compress calibration test attributes used in several elements. useCalibratedValue="true" comparisonOperator="==" instance="0"- Returns:
- long containing the number of removed attributes.
-
compressListsAndSets
public long compressListsAndSets()
Remove List and Set element variants that are unnecessary because there is only 1 child element and that element is valid outside the grouping.- Returns:
- long containing the number of List or Set elements removed.
-
compressIdentityCalibrators
public long compressIdentityCalibrators()
Remove identity calibrators that have no effect on the calibrated value. This does not remove identity calibrators that are in the context matching feature because those may be used to undo another context.- Returns:
- long containing the number of calibrator elements removed.
-
compressSimpleEnumerations
public long compressSimpleEnumerations()
Compress simple enumeration types to boolean types.- Returns:
- long containing the number of calibrator elements removed.
-
compressValidRangeTruisms
public long compressValidRangeTruisms()
Compress ValidRange specifications that are nothing more than truisms when taking into account the size of the encoding.- Returns:
- long containing the number ValidRange elements modified or removed.
-
compressDuplicateTypes
public long compressDuplicateTypes()
Compress Type elements for Parameter and Argument that can be considered duplicate when refactoring is possible.- Returns:
- long containing the number Types elements removed.
-
compressContainerStartBits
public long compressContainerStartBits()
Compress location elements in containers where the start bit provided is the same as it would have been using the default of 0 past end of previous item.- Returns:
- long containing the number location elements removed.
-
compressAdditionalAttributes
public long compressAdditionalAttributes()
Compress additional attributes that have default values. IntegerDataEncoding/@sizeInBits="8" IntegerDataEncoding/@encoding="unsigned" FloatDataEncoding/@sizeInBits="32" FloatDataEncoding/@encoding="IEEE754_1985" StringDataEncoding/@encoding="UTF-8" IntegerParameterType/@signed="true" IntegerParameterType/@sizeInBits="32" FloatParameterType/@sizeInBits="32" BooleanParameterType/@zeroStringValue="False" BooleanParameterType/@oneStringValue="True"- Returns:
- long containing the number of removed attributes.
-
compressEmptyUnitSets
public long compressEmptyUnitSets()
Compress the empty UnitSet elements by removing them to reduce size. This method would only be applicable after migration to XTCE 1.2, so for now it is not active here, but instead on the conversion class.- Returns:
- long containing the number of UnitSet elements that were removed.
-
save
public boolean save()
Conclude the compression by saving the XML content to an automatically generated filename. The file will be overwritten if it already exists. The old file name will be used to create the new file name. First it will try to replace the ".xml" extension with "-NEW.xml". If that does not succeed, then the file name will receive "-NEW.xml" at the end to make the new file name.- Returns:
- boolean indicating if the save operation was successful.
-
save
public boolean save(File xmlFile)
Conclude the compression by saving the XML content to a provided file. The file will be overwritten if it already exists.- Parameters:
xmlFile- File containing the path and name to the target filename to save.- Returns:
- boolean indicating if the save operation was successful.
-
-