|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.io.OutputOptions
Object that specifies how an HTML, XHTML, or XML file will be formatted.
Use of certain options may be required when using certain document types in order to provide compatibility for buggy or less capable browsers. Make sure to read the option descriptions and do your own testing to make sure these options are really necessary for use in your application...
oo.setEnableXHTMLCompatibility(true)
oo.setUseAposEntity(false)
oo.setOmitXMLHeader(true)
(if serving as content-type "text/html", inconsequential when formatting HTML as XHTML)oo.setUseAposEntity(false)
oo.setOmitAttributeCharEntityRefs(true)
(discouraged, unless truly found to be required)oo.setFormat(org.enhydra.xml.io.OutputOptions.FORMAT_XHTML)
Also, when using pretty printing, the following options are recommended to make it truly pretty...
oo.setPrettyPrinting(true)
oo.setPreserveSpace(false)
(provides for cleaner output even when pretty printing not enabled)oo.setIndentSize(2)
(optional, default is 4)Freeform options are not currently utilized internally by XMLC. The capability is provided as a convenience to the user.
Inner Class Summary | |
static class |
OutputOptions.Format
Desired output format enumerated type. |
Field Summary | |
static OutputOptions.Format |
FORMAT_AUTO
Constant indicating format should be determined automatically from examining the document object. |
static OutputOptions.Format |
FORMAT_HTML
Constant indicating HTML format. |
static OutputOptions.Format |
FORMAT_XHTML
Constant indicating XHTML format. |
static OutputOptions.Format |
FORMAT_XML
Constant indicating XML format. |
Constructor Summary | |
OutputOptions()
Construct with default values. |
|
OutputOptions(OutputOptions src)
Copy constructor. |
Method Summary | |
void |
addFreeformOption(Object key,
Object value)
Associates the specified value with the specified key. |
void |
addFreeformOptions(Map opts)
Copies all of the mappings from the specified map. |
void |
createCodeGenerator(String varName,
boolean makeReadOnly,
JavaCode code)
Generate code to create an object with the same attributes as this object. |
boolean |
getDropHtmlSpanIds()
Get the drop HTML SPAN element ids flag. |
boolean |
getEnableXHTMLCompatibility()
Get enable-xhtml-compatibility flag. |
String |
getEncoding()
Get the encoding. |
OutputOptions.Format |
getFormat()
Get the output format for the file. |
Object |
getFreeformOption(Object key)
Returns the value mapped to the specified key. |
protected Map |
getFreeformOptions()
Returns a copy of the options map. |
int |
getIndentSize()
Get indentation size. |
String |
getJavaEncoding()
Deprecated. Use getEncoding() or getMIMEEncoding(). |
String |
getMIMEEncoding()
Get the MIME encoding. |
String |
getMIMEType()
Get the MIME for an output routine to use. |
boolean |
getOmitAttributeCharEntityRefs()
Get value of flag that enables or disables the use of character entity references in attribute values. |
boolean |
getOmitDocType()
Get flag indicating if the DOCTYPE should be omitted. |
boolean |
getOmitEncoding()
Get flag indicating if encoding should be omitted from the XML header. |
boolean |
getOmitXMLHeader()
Get flag indicating if the XML header should be omitted. |
boolean |
getPreserveSpace()
Get the default space-preservation flag. |
boolean |
getPrettyPrinting()
Get pretty-printing flag. |
String |
getPublicId()
Get the public id to be used in the DOCUMENT. |
String |
getSystemId()
Get the system id to be used in the DOCUMENT. |
Set |
getURLRewriteAttributes()
Get a copy of the URL attribute names to apply session rewriting. |
URLRewriter |
getURLRewriter()
Get the URLRewriter. |
boolean |
getUseAposEntity()
Get use-apos-entity flag |
boolean |
getUseHTML4Entities()
Get the flag telling whether to use named entities from HTML 4.0 or not. |
String |
getXmlEncoding()
Deprecated. Use getMIMEEncoding(). |
void |
markReadOnly()
Mark the object as read-only. |
void |
setDropHtmlSpanIds(boolean drop)
Set the drop HTML <span> element id's flag. |
void |
setEnableXHTMLCompatibility(boolean enable)
Enable or disable XMLC XHTML compatibility workarounds |
void |
setEncoding(String encoding)
Set the encoding. |
void |
setFormat(OutputOptions.Format format)
Set the output format for the file. |
void |
setFreeformOptions(Map opts)
Copies all of the mappings from the specified map. |
void |
setIndentSize(int size)
Set indentation size. |
void |
setJavaEncoding(String newJavaEncoding)
Deprecated. Use setEncoding(). |
void |
setMIMEType(String mimeType)
Set the MIME for an output routine to use. |
void |
setOmitAttributeCharEntityRefs(boolean omit)
Set value of flag that enables or disables the use of character entity references in attribute values. |
void |
setOmitDocType(boolean omit)
Set flag indicating if the DOCTYPE should be omitted. |
void |
setOmitEncoding(boolean omit)
Set flag indicating if encoding should be omitted from the XML header. |
void |
setOmitXMLHeader(boolean omit)
Set flag indicating if the XML header should be omitted. |
void |
setPreserveSpace(boolean preserve)
Set the default space-preservation flag. |
void |
setPrettyPrinting(boolean enable)
Enable or disable pretty-printing. |
void |
setPublicId(String publicId)
Set the public id to use in the DOCUMENT. |
void |
setSystemId(String systemId)
Set the system id to use in the DOCUMENT. |
void |
setURLRewriteAttributes(Set attributes)
Set the attribute names to apply URLRewriting to (assuming URLRewriting is being used instead of session cookies). |
void |
setURLRewriteAttributes(String[] attributes)
|
void |
setURLRewriter(URLRewriter urlRewriter)
Set the URLRewriter that all URL attributes will be passed through. |
void |
setUseAposEntity(boolean enable)
Enable or disable the use of ' for escaping single quotes. |
void |
setUseHTML4Entities(boolean useHTML4Entities)
Set the flag telling whether to use named entities from HTML 4.0 or not. |
void |
setXmlEncoding(String newXmlEncoding)
Deprecated. Use setEncoding(). |
String |
toString()
Convert to a string for debugging. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final OutputOptions.Format FORMAT_AUTO
public static final OutputOptions.Format FORMAT_HTML
public static final OutputOptions.Format FORMAT_XHTML
public static final OutputOptions.Format FORMAT_XML
Constructor Detail |
public OutputOptions()
public OutputOptions(OutputOptions src)
Method Detail |
public void markReadOnly()
OutputOptions(OutputOptions)
public void setFormat(OutputOptions.Format format)
format
- one of FORMAT_AUTO, FORMAT_HTML, FORMAT_XHTML, FORMAT_XMLpublic OutputOptions.Format getFormat()
public String getEncoding()
public void setEncoding(String encoding)
encoding
- The new encoding, or null to clear.public String getMIMEEncoding()
public boolean getUseAposEntity()
public void setUseAposEntity(boolean enable)
' was added in to the XML spec and doesn't exist in the HTML spec. As such, some browsers (some versions of IE) handle this poorly in attributes (think JavaScript). It is recommended that you disable the use of ' entity if you run into problems. This option will, eventually, be unnecessary once more browsers provide support for the ' entity.
enable
- true to enable, false to disable.public boolean getEnableXHTMLCompatibility()
public void setEnableXHTMLCompatibility(boolean enable)
Many browsers still in heavy use don't fully support XHTML. In order to make the transition to XHTML, XMLC must allow for reasonable workarounds to known compatibility issues in these less capable browsers. Setting this flag to 'true' tells XMLC and, specifically, the XMLFormater to do anything it needs to maintain compatibility with older browsers. Currently, the following XHTML compatibility issues are accounted for:
Note that this method name is intentionally generic to allow for the application of other arbitrary workarounds without requiring new methods to be added to OutputOptions.
enable
- true to enable, false to disablepublic boolean getPrettyPrinting()
public void setPrettyPrinting(boolean enable)
enable
- true to enable, false to disablepublic int getIndentSize()
public void setIndentSize(int size)
size
- Number of characters to indent at each level.public boolean getPreserveSpace()
public void setPreserveSpace(boolean preserve)
perserve
- true if preserving space where not otherwise specified
by the documentpublic boolean getOmitXMLHeader()
public void setOmitXMLHeader(boolean omit)
omit
- true to omit, false to admitpublic boolean getOmitDocType()
public void setOmitDocType(boolean omit)
omit
- true to omit, false to admitpublic boolean getOmitEncoding()
public void setOmitEncoding(boolean omit)
omit
- true to omit, false to admitpublic boolean getDropHtmlSpanIds()
public void setDropHtmlSpanIds(boolean drop)
MS Internet Explorer 4.0 gets very confused about keep-alive connections if HTML <span> tags have "id" attributes. Until we find another workaround, this removes "id"'s from <span> tags.
Unless you have to support IE4 users and require keep-alive connections to your application, this option is not recommended
drop
- true to drop, false to keeppublic boolean getOmitAttributeCharEntityRefs()
public void setOmitAttributeCharEntityRefs(boolean omit)
By default, all standard character entity references are used in attribute values. While this is legal in HTML and XML, some HTML clients may not handle this well (for instance, one of the major browsers didn't correctly expand the entity references in PARAM values passed to applets). If this flag is set, then standard character entity references (such as &) will not be substituted. Numeric character entity references will still be substituted for quotes and for characters that can't be represented in the encoding.
This option is not recommended for XML and should be avoided in any case unless this issue becomes a problem in your application.
omit
- true to omit, false to admitgetOmitAttributeCharEntityRefs()
public void setURLRewriter(URLRewriter urlRewriter)
urlRewriter
- The URLRewriter object, or null to disassociate
any URL rewriter.DocumentInfo
public URLRewriter getURLRewriter()
DocumentInfo
public Set getURLRewriteAttributes()
public void setURLRewriteAttributes(Set attributes)
attributes
- a set of attribute name strings to rewrite, null to use
defaults defined in each respective XMLCDomFactory
implementation.public void setURLRewriteAttributes(String[] attributes)
setURLRewriteAttributes(Set)
public String getPublicId()
public void setPublicId(String publicId)
public String getSystemId()
public void setSystemId(String systemId)
public String getMIMEType()
public void setMIMEType(String mimeType)
mimeType
- the mime-type to usepublic void createCodeGenerator(String varName, boolean makeReadOnly, JavaCode code)
The following attributes are not generated in the new code:
varName
- Variable or field name of variable to store
the object in. It must already be declared.makeReadOnly
- Should the created object be made read-only?code
- Add generated code to this object.public String toString()
toString
in class Object
public String getJavaEncoding()
getEncoding()
,
getMIMEEncoding()
public void setJavaEncoding(String newJavaEncoding)
setEncoding(java.lang.String)
public String getXmlEncoding()
getMIMEEncoding()
public void setXmlEncoding(String newXmlEncoding)
public boolean getUseHTML4Entities()
public void setUseHTML4Entities(boolean useHTML4Entities)
useHTML4Entities
- true to enable, false to disablepublic void addFreeformOption(Object key, Object value)
key
- option keyvalue
- option valuepublic void addFreeformOptions(Map opts)
opts
- options mappublic void setFreeformOptions(Map opts)
addFreeformOptions(Map)
, all pre-existing entries are discarded
and replaced by the entries in opts. Setting null is equivalent to
setting an empty opts; it simply clears all pre-existing options rather
than literally storing the null value.opts
- options mappublic Object getFreeformOption(Object key)
key
- option key.protected Map getFreeformOptions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |