Package org.w3c.its

Class ITSEngine

    • Constructor Detail

      • ITSEngine

        public ITSEngine​(Document doc,
                         URI docURI)
      • ITSEngine

        public ITSEngine​(Document doc,
                         URI docURI,
                         String docEncoding,
                         boolean isHTML5,
                         Map<String,​String> map)
        Creates a new ITSEngine object.
        Parameters:
        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).
    • Method Detail

      • getTranslatableAttributeRuleTriggered

        public boolean getTranslatableAttributeRuleTriggered()
        Indicates if the processed document has triggered a rule for a translatable attribute. This must be called only after applyRules(long).
        Returns:
        true if the document has triggered a rule for a translatable attribute.
      • getTargetPointerRuleTriggered

        public boolean getTargetPointerRuleTriggered()
        Indicates if the processed document has triggered a target pointer rule. This must be called only after applyRules(long).
        Returns:
        true if the processed document has triggered a target pointer rule.
      • getXPath

        public XPath getXPath()
        Gets internal XPath object used in this ITS engine.
        Returns:
        the internal XPath object used in this ITS engine.
      • addExternalRules

        public void addExternalRules​(Document rulesDoc,
                                     URI docURI)
        Description copied from interface: IProcessor
        Adds a set of global rules to the document to process.

        The 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).

        Specified by:
        addExternalRules in interface IProcessor
        Parameters:
        rulesDoc - Document where the global rules are declared.
        docURI - URI of the document. This is needed because xlink:href need a initial location.
      • applyRules

        public void applyRules​(long dataCategories)
        Description copied from interface: IProcessor
        Applies the current ITS rules to the document. This method decorates the document tree with special flags that are used for getting the different ITS information later.
        Specified by:
        applyRules in interface IProcessor
        Parameters:
        dataCategories - 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.

      • disapplyRules

        public void disapplyRules()
        Description copied from interface: IProcessor
        Removes all the special flags added when applying the ITS rules. Once you have called this method you should call IProcessor.applyRules(long) again to be able to use ITS-aware methods again.
        Specified by:
        disapplyRules in interface IProcessor
      • backTracking

        public boolean backTracking()
        Description copied from interface: ITraversal
        Indicates whether the current node is found while backtracking. For example, for an element node, this indicate the equivalent of a closing tag.
        Specified by:
        backTracking in interface ITraversal
        Returns:
        true if the current node is found while backtracking, false otherwise.
      • nextNode

        public Node nextNode()
        Description copied from interface: ITraversal
        Moves to the next node in the traversal of the document.
        Specified by:
        nextNode in interface ITraversal
        Returns:
        the current node of the traversal. Null if the document is traversed.
      • getTextContent

        public static String getTextContent​(Node node)
        Gets the text content of the first TEXT child of an element node. This is to use instead of node.getTextContent() which does not work with some Macintosh Java VMs. Note this work-around get only the first TEXT node.
        Parameters:
        node - the container element.
        Returns:
        the text of the first TEXT child node.
      • getTranslate

        public boolean getTranslate​(Attr attribute)
        Description copied from interface: ITraversal
        Indicates if the current element or one of its attributes is translatable.
        Specified by:
        getTranslate in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the element.
        Returns:
        true if the queried element or attribute is translatable, false otherwise.
      • getTargetPointer

        public String getTargetPointer​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the target pointer for the current element of the traversal or one of its attributes.
        Specified by:
        getTargetPointer in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the element.
        Returns:
        the XPath relative to the current element or attribute to the node where the translation should be placed.
      • getIdValue

        public String getIdValue​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the id value for the current element of the traversal or one of its attributes.
        Specified by:
        getIdValue in interface ITraversal
        Parameters:
        attribute - 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.
        Returns:
        the value of the identifier for the queried part.
      • getWithinText

        public int getWithinText()
        Description copied from interface: ITraversal
        Gets the element-withinText-related information for the current element. This data category applies only to elements.
        Specified by:
        getWithinText in interface ITraversal
        Returns:
        One of the WINTINTEXT_* values.
      • getTerm

        public boolean getTerm​(Attr attribute)
        Description copied from interface: ITraversal
        Indicates if a given attribute of the current element of the traversal or one of its attributes is a term.
        Specified by:
        getTerm in interface ITraversal
        Parameters:
        attribute - The attribute to query or null for the element.
        Returns:
        True if the queried part is a term, false otherwise.
      • getTermInfo

        public String getTermInfo​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the information associated with a given term node or one of its attributes.
        Specified by:
        getTermInfo in interface ITraversal
        Parameters:
        attribute - The attribute to query or null for the element.
        Returns:
        the information associated with the queried part.
      • getTermConfidence

        public Double getTermConfidence​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the confidence associated with a given term node or one of its attributes.
        Specified by:
        getTermConfidence in interface ITraversal
        Parameters:
        attribute - The attribute to query or null for the element.
        Returns:
        the confidence associated with the queried part.
      • getTerminologyAnnotation

        public GenericAnnotations getTerminologyAnnotation​(Attr attribute)
        Gets the terminology annotation set for the current element or one of its attributes. Note that the returned object is not the same at each each call.
        Parameters:
        attribute - the attribute to look up, or null for the element.
        Returns:
        the annotation set for the queried node (can be null).
      • getLocNote

        public String getLocNote​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the localization note of the current element of the traversal or one of its attributes.
        Specified by:
        getLocNote in interface ITraversal
        Parameters:
        attribute - the attribute to query or null for the element.
        Returns:
        The localization note of the queried part.
      • getDomains

        public String getDomains​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the domain or domains for the current element or one of its attributes.
        Specified by:
        getDomains in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the current element.
        Returns:
        a comma-separated string representing the list of domains for the queried part. See http://www.w3.org/TR/its20/#domain-implementation for details on the format of the string.
      • preserveWS

        public boolean preserveWS​(Attr attribute)
        Description copied from interface: ITraversal
        Indicates if the white spaces of the current element of the traversal or the given attribute must be preserved.
        Specified by:
        preserveWS in interface ITraversal
        Returns:
        True if the white spaces of the current element or the given attribute must be preserve, false if they may or may not be preserved.
      • getLanguage

        public String getLanguage()
        Description copied from interface: ITraversal
        Gets the language for the current element of the traversal and its attributes.
        Specified by:
        getLanguage in interface ITraversal
        Returns:
        The language code for the current element and its attributes.
      • getExternalResourceRef

        public String getExternalResourceRef​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the external resource reference for the current element of the traversal or one of its attributes.
        Specified by:
        getExternalResourceRef in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the element.
        Returns:
        the external resource reference for the queried part, or null.
      • getLocaleFilter

        public String getLocaleFilter()
        Description copied from interface: ITraversal
        Gets the locale filter information.
        Specified by:
        getLocaleFilter in interface ITraversal
        Returns:
        A a comma-separated list of extended language ranges as defined in BCP-47 (and possibly empty). If the first character is '!' the type is 'exclude' otherwise the type is 'include'.
      • getLocQualityIssuesRef

        public String getLocQualityIssuesRef​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the standoff location of the Localization Quality Issue records for the current element or one of its attributes.
        Specified by:
        getLocQualityIssuesRef in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        Returns:
        the standoff location of the records for the queried parts (can be null).
      • getLocQualityIssueCount

        public int getLocQualityIssueCount​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the number of Localization Quality Issue annotations for the current element or one of its attributes.
        Specified by:
        getLocQualityIssueCount in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        Returns:
        the number of issues for the queried part.
      • getLocQualityIssueAnnotations

        public GenericAnnotations getLocQualityIssueAnnotations​(Attr attribute)
        Gets the localization quality issue annotations for the current element or one of its attributes. Note that the returned objects are not the same at each each call.
        Parameters:
        attribute - the attribute to look up, or null for the element.
        Returns:
        the annotation set for the queried node (can be null).
      • getLocQualityIssueType

        public String getLocQualityIssueType​(Attr attribute,
                                             int index)
        Description copied from interface: ITraversal
        Gets the type of the Localization Quality Issue instance for the current element or one of its attribute, for the given index.
        Specified by:
        getLocQualityIssueType in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        index - the index of the issue in the list (zero-based).
        Returns:
        the type for the issue at the given index for the queried part (can be null).
        See Also:
        ITraversal.getLocQualityIssueCount(Attr)
      • getLocQualityIssueComment

        public String getLocQualityIssueComment​(Attr attribute,
                                                int index)
        Description copied from interface: ITraversal
        Gets the comment of the Localization Quality Issue instance for the current element or one of its attribute, for the given index.
        Specified by:
        getLocQualityIssueComment in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        index - the index of the issue in the list (zero-based).
        Returns:
        the comment for the issue at the given index for the queried part (can be null).
        See Also:
        ITraversal.getLocQualityIssueCount(Attr)
      • getLocQualityIssueSeverity

        public Double getLocQualityIssueSeverity​(Attr attribute,
                                                 int index)
        Description copied from interface: ITraversal
        Gets the severity of the Localization Quality Issue instance for the current element or one of its attribute, for the given index.
        Specified by:
        getLocQualityIssueSeverity in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        index - the index of the issue in the list (zero-based).
        Returns:
        the severity for the issue at the given index for the queried part (can be null).
        See Also:
        ITraversal.getLocQualityIssueCount(Attr)
      • getLocQualityIssueProfileRef

        public String getLocQualityIssueProfileRef​(Attr attribute,
                                                   int index)
        Description copied from interface: ITraversal
        Gets the comment of the Localization Quality Issue instance for the current element or one of its attribute, for the given index.
        Specified by:
        getLocQualityIssueProfileRef in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        index - the index of the issue in the list (zero-based).
        Returns:
        the comment for the issue at the given index for the queried part (can be null).
        See Also:
        ITraversal.getLocQualityIssueCount(Attr)
      • getLocQualityIssueEnabled

        public Boolean getLocQualityIssueEnabled​(Attr attribute,
                                                 int index)
        Description copied from interface: ITraversal
        Gets the enabled/disabled flag of the Localization Quality Issue instance for the current element or one of its attribute, for the given index.
        Specified by:
        getLocQualityIssueEnabled in interface ITraversal
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        index - the index of the issue in the list (zero-based).
        Returns:
        the enabled/disabled flag for the issue at the given index for the queried part (can be null).
        See Also:
        ITraversal.getLocQualityIssueCount(Attr)
      • getTextAnalysisAnnotation

        public GenericAnnotations getTextAnalysisAnnotation​(Attr attribute)
        Gets the text analysis annotations for the current element or one of its attributes. Note that the returned objects are not the same instances at each each call.
        Parameters:
        attribute - the attribute to look up, or null for the element.
        Returns:
        the annotations for the queried node (can be null).
      • getLocQualityRatingAnnotation

        public GenericAnnotations getLocQualityRatingAnnotation()
        Gets the localization quality rating annotation set for the current element.
        Returns:
        the annotation set for the queried node (can be null).
      • getStorageSize

        public Integer getStorageSize​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the storage size for the current element or one of its attributes.
        Specified by:
        getStorageSize in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the current element.
        Returns:
        the storage size for the queried part.
      • getStorageEncoding

        public String getStorageEncoding​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the storage encoding for the current element or one of its attributes.
        Specified by:
        getStorageEncoding in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the current element.
        Returns:
        the storage encoding for the queried part.
      • getLineBreakType

        public String getLineBreakType​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the storage line-break type for the current element or one of its attributes.
        Specified by:
        getLineBreakType in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the current element.
        Returns:
        the storage line-break type for the queried part.
      • getAllowedCharacters

        public String getAllowedCharacters​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the pattern of allowed characters for the current element or one of its attributes.
        Specified by:
        getAllowedCharacters in interface ITraversal
        Parameters:
        attribute - the attribute to query or null to query the current element.
        Returns:
        the pattern of allowed characters for the queried part.
      • getSubFilter

        public String getSubFilter​(Attr attribute)
      • getAnnotatorsRef

        public String getAnnotatorsRef()
        Description copied from interface: ITraversal
        Gets the tools references associated with the current element of the traversal and its attributes.

        The returned value is sorted by data category and hold all data categories within scope (not just the ones set on the given node).

        Specified by:
        getAnnotatorsRef in interface ITraversal
        Returns:
        the tools references associated with the current element of the traversal and its attributes.
      • getAnnotatorRef

        public String getAnnotatorRef​(String dc)
        Description copied from interface: ITraversal
        Gets the annotator reference for a given data category.
        Specified by:
        getAnnotatorRef in interface ITraversal
        Parameters:
        dc - the name of the data category to look up.
        Returns:
        the reference for the given data category, or null.
      • getMtConfidence

        public Double getMtConfidence​(Attr attribute)
        Description copied from interface: ITraversal
        Gets the MT Confidence value for the current element of the traversal or one of its attributes.
        Specified by:
        getMtConfidence in interface ITraversal
        Parameters:
        attribute - the attribute to query or null for the element.
        Returns:
        the MT Confidence value or null if none is set.
      • getProvenanceAnnotations

        public GenericAnnotations getProvenanceAnnotations​(Attr attribute)
        Gets the annotations for the Provenance data category for the current element or for one of its attributes.
        Parameters:
        attribute - the attribute to query, or null to query the current element.
        Returns:
        the annotations for the queried part, or null if there is none.