public class DefaultXMLDialect extends java.lang.Object implements XMLDialect
CONSTRAINT_DOCTYPE, CONSTRAINT_DOCTYPE_UNBOXED, CONSTRAINT_PUBLIC_DOCTYPE, CONSTRAINT_PUBLIC_DOCTYPE_UNBOXED, CONSTRAINT_ROOT, CONSTRAINT_ROOT_UNBOXED, CONSTRAINT_SYSTEM_DOCTYPE, CONSTRAINT_SYSTEM_DOCTYPE_UNBOXED, CONSTRAINT_XMLNS, CONSTRAINT_XMLNS_UNBOXED
Constructor and Description |
---|
DefaultXMLDialect() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
constructShortcuts(java.util.List<Element> elements,
java.util.List<ProtectedPart> protectedParts)
Returns shortcut string representation of the entry source.
|
void |
defineConstraint(java.lang.Integer constraintType,
java.util.regex.Pattern template)
Defines a constraint to restrict supported subset of XML files.
|
void |
defineContentBasedTag(java.lang.String tag,
Tag.Type type) |
void |
defineIntactTag(java.lang.String tag)
Defines intact tag.
|
void |
defineIntactTags(java.lang.String[] tags)
Defines a set of intact tags from an array.
|
void |
defineOutOfTurnTag(java.lang.String tag)
Defines out of turn tag.
|
void |
defineOutOfTurnTags(java.lang.String[] tags)
Defines out of turn tags.
|
void |
defineParagraphTag(java.lang.String tag)
Defines paragraph tag.
|
void |
defineParagraphTags(java.lang.String[] tags)
Defines a set of paragraph tags from an array.
|
void |
definePreformatTag(java.lang.String tag)
Defines preformat tag.
|
void |
definePreformatTags(java.lang.String[] tags)
Defines a set of preformat tags from an array.
|
void |
defineShortcut(java.lang.String tag,
java.lang.String shortcut)
Defines a shortcut for a tag, useful for formatting tags.
|
void |
defineShortcuts(java.lang.String[] mappings)
Defines shortcuts for formatting tags.
|
void |
defineTranslatableAttribute(java.lang.String attribute)
Defines always translatable attribute (no matter what tag it belongs to).
|
void |
defineTranslatableAttributes(java.lang.String[] attributes)
Defines always translatable attributes (no matter what tag it belongs
to).
|
void |
defineTranslatableTagAttribute(java.lang.String tag,
java.lang.String attribute)
Defines translatable attribute of a tag.
|
void |
defineTranslatableTagAttributes(java.lang.String tag,
java.lang.String[] attributes)
Defines translatable attributes of a tag.
|
void |
defineTranslatableTagsAttribute(java.lang.String[] tags,
java.lang.String attribute)
Defines translatable attribute of several tags.
|
java.lang.Boolean |
getClosingTagRequired()
Gives the value of closingTag
|
java.util.Map<java.lang.Integer,java.util.regex.Pattern> |
getConstraints()
Returns defined constraints to restrict supported subset of XML files.
|
java.util.Map<java.lang.String,Tag.Type> |
getContentBasedTags()
Returns the set of content based tags.
|
java.lang.Boolean |
getForceSpacePreserving()
Gives the value of forceSpacePreserving;
|
java.util.Set<java.lang.String> |
getIntactTags()
Returns the set of tags that surround intact portions of document, that
should not be translated at all.
|
java.util.Set<java.lang.String> |
getOutOfTurnTags()
Returns the set of "out-of-turn" tags.
|
java.util.Set<java.lang.String> |
getParagraphTags()
Returns the set of defined paragraph tags.
|
java.util.Set<java.lang.String> |
getPreformatTags()
Returns the set of tags that surround preformatted text.
|
java.util.Map<java.lang.String,java.lang.String> |
getShortcuts()
Returns the map of tags to their shortcuts.
|
java.lang.Boolean |
getTagsAggregationEnabled()
Gives the value of tagsAggregationEnabled.
|
java.util.Set<java.lang.String> |
getTranslatableAttributes()
Returns the set of translatable attributes (no matter what tag they
belong to).
|
MultiMap<java.lang.String,java.lang.String> |
getTranslatableTagAttributes()
Returns the multimap of translatable attributes of each tag.
|
void |
handleXMLTag(XMLTag tag,
boolean translated)
Implement general purpose function to handle XML tag/attributes when necessary.
|
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Resolves external entites if child filter needs it.
|
void |
setClosingTagRequired(boolean onOff)
Sets closingTag to
true or false |
void |
setForceSpacePreserving(boolean onOff)
Set forceSpacePreserving.
|
void |
setTagsAggregationEnabled(boolean onOff)
Sets tagsAggregationEnabled to
true or false |
java.lang.Boolean |
validateContentBasedTag(java.lang.String tag,
Attributes atts)
For a given tag, return wether the content of this tag should be
translated, depending on the content of one attribute and the presence or
absence of other attributes.
|
java.lang.Boolean |
validateIntactTag(java.lang.String tag,
Attributes atts)
For a given tag, return whether the content of this tag should be
translated, depending on the content of one attribute and the presence or
absence of other attributes.
|
java.lang.Boolean |
validateParagraphTag(java.lang.String tag,
Attributes atts)
For a given tag, return whether the content of this tag is a paragraph
tag, depending on the content of one attribute (and/or the presence or
absence of other attributes).
|
java.lang.Boolean |
validatePreformatTag(java.lang.String tag,
Attributes atts)
For a given tag, return whether the content of this tag is a preformat
tag, depending on the content of one attribute (and/or the presence or
absence of other attributes).
|
java.lang.Boolean |
validateTranslatableTag(java.lang.String tag,
Attributes atts)
For a given tag, return whether the content of this tag should be
translated, depending on the content of one attribute and the presence or
absence of other attributes.
|
java.lang.Boolean |
validateTranslatableTagAttribute(java.lang.String tag,
java.lang.String attribute,
Attributes atts)
Returns for a given attribute of a given tag if the attribute should be
translated with the given other attributes present.
|
public void defineParagraphTag(java.lang.String tag)
public void defineParagraphTags(java.lang.String[] tags)
public void defineContentBasedTag(java.lang.String tag, Tag.Type type)
public void definePreformatTag(java.lang.String tag)
public void definePreformatTags(java.lang.String[] tags)
public void defineIntactTag(java.lang.String tag)
public void defineIntactTags(java.lang.String[] tags)
public void defineTranslatableTagAttribute(java.lang.String tag, java.lang.String attribute)
public void defineTranslatableTagAttributes(java.lang.String tag, java.lang.String[] attributes)
public void defineTranslatableTagsAttribute(java.lang.String[] tags, java.lang.String attribute)
public void defineTranslatableAttribute(java.lang.String attribute)
public void defineTranslatableAttributes(java.lang.String[] attributes)
public void defineOutOfTurnTag(java.lang.String tag)
public void defineOutOfTurnTags(java.lang.String[] tags)
public void defineConstraint(java.lang.Integer constraintType, java.util.regex.Pattern template)
constraintType
- Type of constraint, see CONSTRAINT_... constants.template
- Regular expression for a specified constrained string.public void defineShortcut(java.lang.String tag, java.lang.String shortcut)
tag
- Tag name.shortcut
- The shortcut for a tag.public void defineShortcuts(java.lang.String[] mappings)
defineShortcut(String,String)
multiple times.mappings
- Array of strings, where even elements (0th, 2nd, etc) are
tags, and odd elements are their corresponding shortcuts.public java.util.Set<java.lang.String> getParagraphTags()
Each entry in a set should be a String class.
getParagraphTags
in interface XMLDialect
public java.util.Map<java.lang.String,Tag.Type> getContentBasedTags()
getContentBasedTags
in interface XMLDialect
public java.util.Set<java.lang.String> getPreformatTags()
Each entry in a set should be a String class.
getPreformatTags
in interface XMLDialect
public java.util.Set<java.lang.String> getIntactTags()
Each entry in a set should be a String class.
getIntactTags
in interface XMLDialect
public MultiMap<java.lang.String,java.lang.String> getTranslatableTagAttributes()
Each entry should map from a String to a set of Strings.
getTranslatableTagAttributes
in interface XMLDialect
public java.lang.Boolean validateTranslatableTagAttribute(java.lang.String tag, java.lang.String attribute, Attributes atts)
validateTranslatableTagAttribute
in interface XMLDialect
public java.lang.Boolean validateIntactTag(java.lang.String tag, Attributes atts)
validateIntactTag
in interface XMLDialect
tag
- The tag that could be translatedatts
- The list of the tag attributestrue
or false
public java.lang.Boolean validateContentBasedTag(java.lang.String tag, Attributes atts)
XMLDialect
validateContentBasedTag
in interface XMLDialect
tag
- The tag that could be translatedatts
- The list of the tag attributestrue
or false
public java.lang.Boolean validateTranslatableTag(java.lang.String tag, Attributes atts)
validateTranslatableTag
in interface XMLDialect
tag
- The tag that could be translatedatts
- The list of the tag attributestrue
or false
public java.lang.Boolean validateParagraphTag(java.lang.String tag, Attributes atts)
validateParagraphTag
in interface XMLDialect
tag
- The tag that could be a paragraph tagatts
- The list of the tag attributestrue
or false
public java.lang.Boolean validatePreformatTag(java.lang.String tag, Attributes atts)
validatePreformatTag
in interface XMLDialect
tag
- The tag that could be a preformat tagatts
- The list of the tag attributestrue
or false
public java.util.Set<java.lang.String> getTranslatableAttributes()
Each entry in a set should be a String class.
getTranslatableAttributes
in interface XMLDialect
public java.util.Set<java.lang.String> getOutOfTurnTags()
Each entry in a set should be a String class.
getOutOfTurnTags
in interface XMLDialect
public java.util.Map<java.lang.Integer,java.util.regex.Pattern> getConstraints()
Each entry should map an Integer
to a Pattern
-- regular
expression for a specified constrained string.
getConstraints
in interface XMLDialect
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
null
.resolveEntity
in interface XMLDialect
public java.util.Map<java.lang.String,java.lang.String> getShortcuts()
Each entry should map a String
to a String
-- a tag to
its shortcut.
getShortcuts
in interface XMLDialect
public void setClosingTagRequired(boolean onOff)
true
or false
setClosingTagRequired
in interface XMLDialect
onOff
- The parameter setting whether closing tags should be used or
not for empty tags.public java.lang.Boolean getClosingTagRequired()
getClosingTagRequired
in interface XMLDialect
public void setTagsAggregationEnabled(boolean onOff)
true
or false
setTagsAggregationEnabled
in interface XMLDialect
onOff
- The parameter setting whether tags aggregation can be enabled
in order to reduce the number of tags shown to the user.public java.lang.Boolean getTagsAggregationEnabled()
getTagsAggregationEnabled
in interface XMLDialect
public java.lang.Boolean getForceSpacePreserving()
getForceSpacePreserving
in interface XMLDialect
public void setForceSpacePreserving(boolean onOff)
setForceSpacePreserving
in interface XMLDialect
public void handleXMLTag(XMLTag tag, boolean translated)
handleXMLTag
in interface XMLDialect
public java.lang.String constructShortcuts(java.util.List<Element> elements, java.util.List<ProtectedPart> protectedParts)
Here's <b>bold text</b>
should return
Here's <b0>bold text</b0>
.constructShortcuts
in interface XMLDialect