/*
* @(#)ExiOption.java
*
* Copyright (C) 2011 The MITRE Corporation
*
* This program and its interfaces are free software;
* you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* The ExiOption enum defines various options provided
* by the W3C EXI specification, plus some options needed
* by the ExiProcessor class. Note: not all of the options
* listed in the W3C EXI specification are listed here,
* nor are all of the options supported by EXIficient
* listed here.
*
* For more information, see the specification itself at:
* http://www.w3.org/TR/exi/#options
*
* @author Craig Garrett, MITRE, garrett@mitre.org
*/
public enum ExiOption {
XML_IN (
"xml_in", // commandLineArg
"[XML source file]", // valuePlacemark
"XML source file", // name
"Read text XML data from this file", // description
"", // url
"-xml_in sampleInput.xml" // example
),
EXI_OUT (
"exi_out", // commandLineArg
"[EXI destination file]", // valuePlacemark
"EXI destination file", // name
"Writes EXI encoded data to this file", // description
"", // url
"-exi_out sampleOutput.exi" // example
),
EXI_IN (
"exi_in", // commandLineArg
"[EXI source file]", // valuePlacemark
"EXI source file", // name
"Read text EXI data from this file", // description
"", // url
"-exi_in sampleInput.exi" // example
),
XML_OUT (
"xml_out", // commandLineArg
"[XML destination file]", // valuePlacemark
"XML destination file", // name
"Writes text XML data to this file", // description
"", // url
"-xml_out sampleOutput.xml" // example
),
COOKIE (
"cookie", // commandLineArg
"", // valuePlacemark
"EXI Cookie in Header", // name
"Includes the EXI Cookie in the Header (the string '$EXI' will be the first 4 bytes of the file); default is off. This option is not needed during decoding.", // description
"http://www.w3.org/TR/exi/#header", // url
"-cookie" // example
),
HEADER_OPTIONS (
"header_options", // commandLineArg
"", // valuePlacemark
"EXI Option flags in Header", // name
"Includes flags in the Header indicating which EXI Options were used during encoding; default is off. This option is not needed during decoding.", // description
"http://www.w3.org/TR/exi/#header", // url
"-header_options" // example
),
SCHEMA (
"schema", // commandLineArg
"[XML Schema file]", // valuePlacemark
"Schema-informed encoding and decoding", // name
"Uses the specified XML Schema (XML Schema 1.0 only) for encoding and decoding to increase compression; default is schema-less encoding and decoding. During decoding, this option will override any 'schemaId' value in the EXI Header, but if this option does not resolve to a valid path/filename, then the program will attempt to load a schema using the 'schemaId' header value as a path/filename.", // description
"http://www.w3.org/TR/exi/#informedGrammars", // url
"-schema mySchema.xsd" // example
),
STRICT (
"strict", // commandLineArg
"", // valuePlacemark
"Strict Interpretation of Schemas", // name
"Increase compactness by allowing only grammars defined by the XML Schema (use only in schema-informed mode); default is off. Not compatible with preserve_prefixes, preserve_dtd, preserve_comments, and preserve_pi.", // description
"http://www.w3.org/TR/exi/#key-strictOption", // url
"-strict" // example
),
XSD_TYPES_ONLY (
"xsd_types_only", // commandLineArg
"", // valuePlacemark
"XSD Types Only", // name
"Only use XML Schema Datatypes (types defined by the W3C XML Schema specification) when instance docs make use of xsi:type; default is off. Should not be used with -strict.", // description
"http://www.w3.org/TR/exi/#builtinElemGrammars", // url
"-xsd_types_only" // example
),
COMPRESSION (
"compression", // commandLineArg
"", // valuePlacemark
"EXI Compression", // name
"Increases compactness using additional computational resources; default is off. Overrides all 'alignment' option values. Provides best results when message sizes large and repetitive.", // description
"http://www.w3.org/TR/exi/#compression", // url
"-compression" // example
),
ALIGNMENT (
"alignment", // commandLineArg
"[bit_packed, byte_packed, pre_compression]", // valuePlacemark
"Alignment", // name
"Controls the alignment of event codes and content items. Incompatible with the compression option. Default is bit_packed.", // description
"http://www.w3.org/TR/exi/#key-alignmentOption", // url
"-alignment pre_compression" // example
),
PRESERVE_NAMESPACE_PREFIXES (
"preserve_prefixes", // commandLineArg
"", // valuePlacemark
"Preserve Namespace Prefixes", // name
"Enables preservation of XML namespace prefixes when encoding to EXI; default is off. Enabling this option will disable -strict.", // description
"http://www.w3.org/TR/exi/#fidelityOptions", // url
"-preserve_prefixes" // example
),
PRESERVE_DTD (
"preserve_dtd", // commandLineArg
"", // valuePlacemark
"Preserve DTD", // name
"Enables preservation of embedded DTD in XML documents when encoding to EXI; default is off. Enabling this option will disable -strict.", // description
"http://www.w3.org/TR/exi/#fidelityOptions", // url
"-preserve_dtd" // example
),
PRESERVE_LEXICAL_VALUES (
"preserve_lexicalValues", // commandLineArg
"", // valuePlacemark
"Preserve Lexical Values", // name
"Enables preservation of the Lexical form of element and attribute values when encoding to EXI; default is off.", // description
"http://www.w3.org/TR/exi/#fidelityOptions", // url
"-preserve_lexicalValues" // example
),
PRESERVE_COMMENTS (
"preserve_comments", // commandLineArg
"", // valuePlacemark
"Preserve Comments", // name
"Enables preservation of XML Comments when encoding to EXI; default is off. Enabling this option will disable -strict.", // description
"http://www.w3.org/TR/exi/#fidelityOptions", // url
"-preserve_comments" // example
),
PRESERVE_PI (
"preserve_pi", // commandLineArg
"", // valuePlacemark
"Preserve Processing Instructions", // name
"Enables preservation of Processing Instructions when encoding to EXI; default is off. Enabling this option will disable -strict.", // description
"http://www.w3.org/TR/exi/#fidelityOptions", // url
"-preserve_pi" // example
),
XSI_SCHEMALOCATION (
"xsi_schemaLocation", // commandLineArg
"", // valuePlacemark
"Include xsi:schemaLocation", // name
"Includes/preserves xsi:schemaLocation/noNamespaceSchemaLocation attribute; default is off. This option is not needed during decoding.", // description
"http://www.w3.org/TR/exi/#addingProductionsStrict", // url
"-xsi_schemaLocation" // example
),
SCHEMAID (
"schemaID", // commandLineArg
"[XML Schema ID]", // valuePlacemark
"Include schemaId in Header", // name
"Includes the schemaId in the Header; default is off. The schemaId may be any string value according to the EXI specification, but during EXI decoding, this program will interpret the schemaId as a schema path/filename. Enabling this option will also enable -header_options. This option is only available if schema-informed coding is used (i.e. if -schema [XML Schema file] is provided). Because the schemaId value comes from the EXI file's header, this command-line option is not used during decoding (if present, it is ignored); instead, the schemaId value contained in the EXI Header will be used. Also see the -schema option for more information.", // description
"http://www.w3.org/TR/exi/#key-schemaIdOption", // url
"-schemaID mySchemaId" // example
),
SELF_CONTAINED (
"self_contained", // commandLineArg
"", // valuePlacemark
"Self-Contained Elements", // name
"Enables the use of self-contained elements in the EXI stream; default is off.", // description
"http://www.w3.org/TR/exi/#key-selfContained", // url
"-self_contained" // example
),
FRAGMENT (
"fragment", // commandLineArg
"", // valuePlacemark
"XML Fragment", // name
"Indicates whether the EXI body is an EXI document or an EXI fragment; default is false.", // description
"http://www.w3.org/TR/exi/#key-fragmentOption", // url
"-fragment" // example
),
BLOCK_SIZE (
"blockSize", // commandLineArg
"[bytes]", // valuePlacemark
"Block Size", // name
"Specifies the block size (in bytes) used for EXI compression; default is 1,000,000 bytes.", // description
"http://www.w3.org/TR/exi/#key-blockSizeOption", // url
"-blockSize 65536" // example
),
VALUE_MAX_LENGTH (
"valueMaxLength", // commandLineArg
"[bytes]", // valuePlacemark
"Value Max Length", // name
"Specifies the maximum length of value content items to be considered for addition to the string table; default is 'unbounded'.", // description
"http://www.w3.org/TR/exi/#key-valueMaxLengthOption", // url
"-valueMaxLength 1024" // example
),
VALUE_PARTITION_CAPACITY (
"valuePartitionCapacity", // commandLineArg
"[bytes]", // valuePlacemark
"Value Partition Capacity", // name
"Specifies the maximum number of value content items in the string table at any given time; default is 'unbounded' when the 'valuePartitionCapacity' option is absent.", // description
"http://www.w3.org/TR/exi/#key-valuePartitionCapacityOption", // url
"-valuePartitionCapacity 1024" // example
);
private final String commandLineArg;
private final String valuePlacemark; // a syntactical place-holder for an option's value
private final String name;
private final String description;
private final String url;
private final String example;
private ExiOption(
String commandLineArg,
String valuePlacemark,
String name,
String description,
String url,
String example
) {
this.commandLineArg = commandLineArg;
this.valuePlacemark = valuePlacemark;
this.name = name;
this.description = description;
this.url = url;
this.example = example;
}
public String getCommandLineArg() { return commandLineArg; }
public String getValuePlacemark() { return valuePlacemark; }
public String getName() { return name; }
public String getDescription() { return description; }
public String getUrl() { return url; }
public String getExample() { return example; }
/**
* Converts a String value to an ExiOption enum, using
* the commandLineArg property of the enum. This method is
* not case-sensitive.
*
* @param commandLineArg a String containing the commandLineArg property of the ExiOption enum
* @return the corresponding ExiOption, or null if no matching ExiOption is found
*/
public static ExiOption valueOfCommandLineArg(String commandLineArg) {
ExiOption returnValue = null; // default
for (ExiOption exiOption : ExiOption.values())
if (commandLineArg.equalsIgnoreCase(exiOption.getCommandLineArg()))
return exiOption;
return returnValue; // just in case
}
}