public class ITSEngine extends Object implements IProcessor, ITraversal
IProcessor and ITraversal interfaces.
This class allows you to apply ITS (the Internationalization Tag Set) to a given document and retrieve the corresponding metadata on each node.
See http://www.w3.org/TR/its20/ for more details on ITS.
| Modifier and Type | Field and Description |
|---|---|
static String |
ITS_MIMETYPE |
static String |
ITS_VERSION1 |
static String |
ITS_VERSION2 |
DC_ALL, DC_ALLOWEDCHARS, DC_DIRECTIONALITY, DC_DOMAIN, DC_EXTERNALRES, DC_IDVALUE, DC_LANGINFO, DC_LOCFILTER, DC_LOCNOTE, DC_LOCQUALITYISSUE, DC_LOCQUALITYRATING, DC_MTCONFIDENCE, DC_PRESERVESPACE, DC_PROVENANCE, DC_STORAGESIZE, DC_SUBFILTER, DC_TARGETPOINTER, DC_TERMINOLOGY, DC_TEXTANALYSIS, DC_TRANSLATE, DC_WITHINTEXTDIR_LRO, DIR_LTR, DIR_RLO, DIR_RTL, WITHINTEXT_NESTED, WITHINTEXT_NO, WITHINTEXT_YES| Constructor and Description |
|---|
ITSEngine(Document doc,
URI docURI) |
ITSEngine(Document doc,
URI docURI,
boolean isHTML5,
Map<String,String> map) |
ITSEngine(Document doc,
URI docURI,
String docEncoding,
boolean isHTML5,
Map<String,String> map)
Creates a new ITSEngine object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExternalRules(Document rulesDoc,
URI docURI)
Adds a set of global rules to the document to process.
|
void |
addExternalRules(URI docURI)
Adds a set of global rules to the document to process.
|
void |
applyRules(long dataCategories)
Applies the current ITS rules to the document.
|
boolean |
backTracking()
Indicates whether the current node is found while backtracking.
|
void |
disapplyRules()
Removes all the special flags added when applying the ITS rules.
|
String |
getAllowedCharacters(Attr attribute)
Gets the pattern of allowed characters for the current element or one of its attributes.
|
String |
getAnnotatorRef(String dc)
Gets the annotator reference for a given data category.
|
String |
getAnnotatorsRef()
Gets the tools references associated with the current element of the traversal and its attributes.
|
int |
getDirectionality(Attr attribute)
Gets the directionality for the text of a given attribute of the current
node of the traversal.
|
String |
getDomains(Attr attribute)
Gets the domain or domains for the current element
or one of its attributes.
|
String |
getExternalResourceRef(Attr attribute)
Gets the external resource reference for the current element of the traversal
or one of its attributes.
|
String |
getIdValue(Attr attribute)
Gets the id value for the current element of the traversal or one of its attributes.
|
String |
getLanguage()
Gets the language for the current element of the traversal and its attributes.
|
String |
getLineBreakType(Attr attribute)
Gets the storage line-break type for the current element or one of its attributes.
|
String |
getLocaleFilter()
Gets the locale filter information.
|
String |
getLocNote(Attr attribute)
Gets the localization note of the current element of the traversal or
one of its attributes.
|
String |
getLocNoteType(Attr attribute) |
GenericAnnotations |
getLocQualityIssueAnnotations(Attr attribute)
Gets the localization quality issue annotations for the current element
or one of its attributes.
|
String |
getLocQualityIssueComment(Attr attribute,
int index)
Gets the comment of the Localization Quality Issue instance for the current element
or one of its attribute, for the given index.
|
int |
getLocQualityIssueCount(Attr attribute)
Gets the number of Localization Quality Issue annotations for the current element
or one of its attributes.
|
Boolean |
getLocQualityIssueEnabled(Attr attribute,
int index)
Gets the enabled/disabled flag of the Localization Quality Issue instance for the current element
or one of its attribute, for the given index.
|
String |
getLocQualityIssueProfileRef(Attr attribute,
int index)
Gets the comment of the Localization Quality Issue instance for the current element
or one of its attribute, for the given index.
|
Double |
getLocQualityIssueSeverity(Attr attribute,
int index)
Gets the severity of the Localization Quality Issue instance for the current element
or one of its attribute, for the given index.
|
String |
getLocQualityIssuesRef(Attr attribute)
Gets the standoff location of the Localization Quality Issue records for the current element
or one of its attributes.
|
String |
getLocQualityIssueType(Attr attribute,
int index)
Gets the type of the Localization Quality Issue instance for the current element
or one of its attribute, for the given index.
|
GenericAnnotations |
getLocQualityRatingAnnotation()
Gets the localization quality rating annotation set for the current element.
|
String |
getLocQualityRatingProfileRef(Attr attribute) |
Double |
getLocQualityRatingScore(Attr attribute) |
Double |
getLocQualityRatingScoreThreshold(Attr attribute) |
Integer |
getLocQualityRatingVote(Attr attribute) |
Integer |
getLocQualityRatingVoteThreshold(Attr attribute) |
Double |
getMtConfidence(Attr attribute)
Gets the MT Confidence value for the current element of the traversal or one
of its attributes.
|
GenericAnnotations |
getProvenanceAnnotations(Attr attribute)
Gets the annotations for the Provenance data category for the current element
or for one of its attributes.
|
String |
getProvOrg(Attr attribute,
int index) |
String |
getProvPerson(Attr attribute,
int index) |
int |
getProvRecordCount(Attr attribute) |
String |
getProvRecordsRef(Attr attribute) |
String |
getProvRef(Attr attribute,
int index) |
String |
getProvRevOrg(Attr attribute,
int index) |
String |
getProvRevPerson(Attr attribute,
int index) |
String |
getProvRevTool(Attr attribute,
int index) |
String |
getProvTool(Attr attribute,
int index) |
String |
getStorageEncoding(Attr attribute)
Gets the storage encoding for the current element or one of its attributes.
|
Integer |
getStorageSize(Attr attribute)
Gets the storage size for the current element or one of its attributes.
|
GenericAnnotations |
getStorageSizeAnnotation(Attr attribute) |
String |
getSubFilter(Attr attribute) |
String |
getTargetPointer(Attr attribute)
Gets the target pointer for the current element of the traversal or one of its attributes.
|
boolean |
getTargetPointerRuleTriggered()
Indicates if the processed document has triggered a target pointer rule.
|
boolean |
getTerm(Attr attribute)
Indicates if a given attribute of the current element of the traversal or
one of its attributes is a term.
|
Double |
getTermConfidence(Attr attribute)
Gets the confidence associated with a given term node or one of its
attributes.
|
String |
getTermInfo(Attr attribute)
Gets the information associated with a given term node or one of its
attributes.
|
GenericAnnotations |
getTerminologyAnnotation(Attr attribute)
Gets the terminology annotation set for the current element
or one of its attributes.
|
GenericAnnotations |
getTextAnalysisAnnotation(Attr attribute)
Gets the text analysis annotations for the current element
or one of its attributes.
|
String |
getTextAnalysisClass(Attr attribute) |
Double |
getTextAnalysisConfidence(Attr attribute) |
String |
getTextAnalysisIdent(Attr attribute) |
String |
getTextAnalysisSource(Attr attribute) |
static String |
getTextContent(Node node)
Gets the text content of the first TEXT child of an element node.
|
boolean |
getTranslatableAttributeRuleTriggered()
Indicates if the processed document has triggered a rule for a translatable attribute.
|
boolean |
getTranslate(Attr attribute)
Indicates if the current element or one of its attributes is
translatable.
|
int |
getWithinText()
Gets the element-withinText-related information for the current element.
|
XPath |
getXPath()
Gets internal XPath object used in this ITS engine.
|
Node |
nextNode()
Moves to the next node in the traversal of the document.
|
boolean |
preserveWS(Attr attribute)
Indicates if the white spaces of the current element of the traversal
or the given attribute must be preserved.
|
void |
setVariables(Map<String,String> map) |
void |
startTraversal()
Starts the traversal of the document.
|
public static final String ITS_VERSION1
public static final String ITS_VERSION2
public static final String ITS_MIMETYPE
public ITSEngine(Document doc, URI docURI, String docEncoding, boolean isHTML5, Map<String,String> map)
doc - the document to process.docURI - the URI of the document to process.docEncoding - the default encoding for the document.isHTML5 - true if the document is an HTML5 document.map - map of the parameters key-value pairs (can be null).public boolean getTranslatableAttributeRuleTriggered()
applyRules(long).public boolean getTargetPointerRuleTriggered()
applyRules(long).public XPath getXPath()
public void addExternalRules(URI docURI)
IProcessorIProcessor.addExternalRules(Document, URI) for more details.addExternalRules in interface IProcessordocURI - URI of the document that contains the rules to add.public void addExternalRules(Document rulesDoc, URI docURI)
IProcessorThe rules are added to the internal storage of the document, not to the document tree.
Use this method to add one rule set or more before calling IProcessor.applyRules(long).
addExternalRules in interface IProcessorrulesDoc - Document where the global rules are declared.docURI - URI of the document. This is needed because xlink:href need a initial location.public void applyRules(long dataCategories)
IProcessorapplyRules in interface IProcessordataCategories - Flag indicating what data categories to apply.
The value must be one of the DC_* values or several combined with
a OR operator. For example: applyRules(DC_TRANSLATE | DC_LOCNOTE);
Use DC_ALL to apply all data categories.
public void disapplyRules()
IProcessorIProcessor.applyRules(long) again to be able
to use ITS-aware methods again.disapplyRules in interface IProcessorpublic boolean backTracking()
ITraversalbackTracking in interface ITraversalpublic Node nextNode()
ITraversalnextNode in interface ITraversalpublic void startTraversal()
ITraversalITraversal.nextNode().startTraversal in interface ITraversalpublic static String getTextContent(Node node)
node - the container element.public boolean getTranslate(Attr attribute)
ITraversalgetTranslate in interface ITraversalattribute - the attribute to query or null to query the element.public String getTargetPointer(Attr attribute)
ITraversalgetTargetPointer in interface ITraversalattribute - the attribute to query or null to query the element.public String getIdValue(Attr attribute)
ITraversalgetIdValue in interface ITraversalattribute - the attribute to query or null to query the element.
This method is used for both the ITS 2.0 feature and the deprecated extension to ITS 1.0.public int getDirectionality(Attr attribute)
ITraversalgetDirectionality in interface ITraversalattribute - the attribute to query or null to query the element.ITraversal.DIR_LTR, ITraversal.DIR_RTL, ITraversal.DIR_LRO or ITraversal.DIR_RLO)
for the queried part.public int getWithinText()
ITraversalgetWithinText in interface ITraversalpublic boolean getTerm(Attr attribute)
ITraversalgetTerm in interface ITraversalattribute - The attribute to query or null for the element.public String getTermInfo(Attr attribute)
ITraversalgetTermInfo in interface ITraversalattribute - The attribute to query or null for the element.public Double getTermConfidence(Attr attribute)
ITraversalgetTermConfidence in interface ITraversalattribute - The attribute to query or null for the element.public GenericAnnotations getTerminologyAnnotation(Attr attribute)
attribute - the attribute to look up, or null for the element.public String getLocNote(Attr attribute)
ITraversalgetLocNote in interface ITraversalattribute - the attribute to query or null for the element.public String getLocNoteType(Attr attribute)
getLocNoteType in interface ITraversalpublic String getDomains(Attr attribute)
ITraversalgetDomains in interface ITraversalattribute - the attribute to query or null to query the current element.public boolean preserveWS(Attr attribute)
ITraversalpreserveWS in interface ITraversalpublic String getLanguage()
ITraversalgetLanguage in interface ITraversalpublic String getExternalResourceRef(Attr attribute)
ITraversalgetExternalResourceRef in interface ITraversalattribute - the attribute to query or null to query the element.public String getLocaleFilter()
ITraversalgetLocaleFilter in interface ITraversalpublic String getLocQualityIssuesRef(Attr attribute)
ITraversalgetLocQualityIssuesRef in interface ITraversalattribute - the attribute to query, or null to query the current element.public int getLocQualityIssueCount(Attr attribute)
ITraversalgetLocQualityIssueCount in interface ITraversalattribute - the attribute to query, or null to query the current element.public GenericAnnotations getLocQualityIssueAnnotations(Attr attribute)
attribute - the attribute to look up, or null for the element.public String getLocQualityIssueType(Attr attribute, int index)
ITraversalgetLocQualityIssueType in interface ITraversalattribute - the attribute to query, or null to query the current element.index - the index of the issue in the list (zero-based).ITraversal.getLocQualityIssueCount(Attr)public String getLocQualityIssueComment(Attr attribute, int index)
ITraversalgetLocQualityIssueComment in interface ITraversalattribute - the attribute to query, or null to query the current element.index - the index of the issue in the list (zero-based).ITraversal.getLocQualityIssueCount(Attr)public Double getLocQualityIssueSeverity(Attr attribute, int index)
ITraversalgetLocQualityIssueSeverity in interface ITraversalattribute - the attribute to query, or null to query the current element.index - the index of the issue in the list (zero-based).ITraversal.getLocQualityIssueCount(Attr)public String getLocQualityIssueProfileRef(Attr attribute, int index)
ITraversalgetLocQualityIssueProfileRef in interface ITraversalattribute - the attribute to query, or null to query the current element.index - the index of the issue in the list (zero-based).ITraversal.getLocQualityIssueCount(Attr)public Boolean getLocQualityIssueEnabled(Attr attribute, int index)
ITraversalgetLocQualityIssueEnabled in interface ITraversalattribute - the attribute to query, or null to query the current element.index - the index of the issue in the list (zero-based).ITraversal.getLocQualityIssueCount(Attr)public GenericAnnotations getTextAnalysisAnnotation(Attr attribute)
attribute - the attribute to look up, or null for the element.public String getTextAnalysisClass(Attr attribute)
getTextAnalysisClass in interface ITraversalpublic String getTextAnalysisSource(Attr attribute)
getTextAnalysisSource in interface ITraversalpublic String getTextAnalysisIdent(Attr attribute)
getTextAnalysisIdent in interface ITraversalpublic Double getTextAnalysisConfidence(Attr attribute)
getTextAnalysisConfidence in interface ITraversalpublic GenericAnnotations getLocQualityRatingAnnotation()
public Double getLocQualityRatingScore(Attr attribute)
getLocQualityRatingScore in interface ITraversalpublic Integer getLocQualityRatingVote(Attr attribute)
getLocQualityRatingVote in interface ITraversalpublic Double getLocQualityRatingScoreThreshold(Attr attribute)
getLocQualityRatingScoreThreshold in interface ITraversalpublic Integer getLocQualityRatingVoteThreshold(Attr attribute)
getLocQualityRatingVoteThreshold in interface ITraversalpublic String getLocQualityRatingProfileRef(Attr attribute)
getLocQualityRatingProfileRef in interface ITraversalpublic GenericAnnotations getStorageSizeAnnotation(Attr attribute)
public Integer getStorageSize(Attr attribute)
ITraversalgetStorageSize in interface ITraversalattribute - the attribute to query or null to query the current element.public String getStorageEncoding(Attr attribute)
ITraversalgetStorageEncoding in interface ITraversalattribute - the attribute to query or null to query the current element.public String getLineBreakType(Attr attribute)
ITraversalgetLineBreakType in interface ITraversalattribute - the attribute to query or null to query the current element.public String getAllowedCharacters(Attr attribute)
ITraversalgetAllowedCharacters in interface ITraversalattribute - the attribute to query or null to query the current element.public String getAnnotatorsRef()
ITraversalThe returned value is sorted by data category and hold all data categories within scope (not just the ones set on the given node).
getAnnotatorsRef in interface ITraversalpublic String getAnnotatorRef(String dc)
ITraversalgetAnnotatorRef in interface ITraversaldc - the name of the data category to look up.public Double getMtConfidence(Attr attribute)
ITraversalgetMtConfidence in interface ITraversalattribute - the attribute to query or null for the element.public GenericAnnotations getProvenanceAnnotations(Attr attribute)
attribute - the attribute to query, or null to query the current element.public String getProvRecordsRef(Attr attribute)
getProvRecordsRef in interface ITraversalpublic int getProvRecordCount(Attr attribute)
getProvRecordCount in interface ITraversalpublic String getProvPerson(Attr attribute, int index)
getProvPerson in interface ITraversalpublic String getProvOrg(Attr attribute, int index)
getProvOrg in interface ITraversalpublic String getProvTool(Attr attribute, int index)
getProvTool in interface ITraversalpublic String getProvRevPerson(Attr attribute, int index)
getProvRevPerson in interface ITraversalpublic String getProvRevOrg(Attr attribute, int index)
getProvRevOrg in interface ITraversalpublic String getProvRevTool(Attr attribute, int index)
getProvRevTool in interface ITraversalpublic String getProvRef(Attr attribute, int index)
getProvRef in interface ITraversalCopyright © 2021. All rights reserved.