Class IDTypeRecognizer

  • Direct Known Subclasses:
    DITAIDTypeRecognizer, TEIP5IDTypeRecognizer

    @API(type=EXTENDABLE,
         src=PUBLIC)
    public abstract class IDTypeRecognizer
    extends java.lang.Object
    Recognizer for ID declaration and references in attribute values. The recognizer may be used when search references and declaration for a particular ID.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract java.util.List<IDTypeIdentifier> detectIDType​(java.lang.String systemID, Context context, java.lang.String attrName, java.lang.String attrNs, java.lang.String attributeValue, int offset)
      Detect the ID declaration or reference for the provided attribute context and offset.
      abstract boolean isDefaultIDTypeRecognitionAvailable()
      If false then disable the default recognition of the IDs based on the current associated schema.
      abstract boolean isIDTypeRecognitionAvailable()
      If true then ID type recognition is available.
      abstract int[] locateIDType​(java.lang.String systemID, Context context, java.lang.String attrName, java.lang.String attrNs, java.lang.String attributeValue, IDTypeIdentifier idIdentifier, short mode)
      Detect if the given ID is located in the specified attribute.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODE_LOCATE_DECLARATIONS

        public static final short MODE_LOCATE_DECLARATIONS
        Mode used when locate an ID. It is used to locate declaration.
        See Also:
        Constant Field Values
      • MODE_LOCATE_REFERENCES

        public static final short MODE_LOCATE_REFERENCES
        Mode used when locate an ID. It is used to locate references.
        See Also:
        Constant Field Values
    • Constructor Detail

      • IDTypeRecognizer

        public IDTypeRecognizer()
    • Method Detail

      • detectIDType

        public abstract java.util.List<IDTypeIdentifier> detectIDType​(java.lang.String systemID,
                                                                      Context context,
                                                                      java.lang.String attrName,
                                                                      java.lang.String attrNs,
                                                                      java.lang.String attributeValue,
                                                                      int offset)
                                                               throws CannotRecognizeIDException
        Detect the ID declaration or reference for the provided attribute context and offset. The offset is relative to the attribute value.
        Parameters:
        systemID - The systemID of the resource that specifies the attribute.
        context - The element content to detect the ID. The top element from the context element stack represents the parent element.
        attrName - The attribute name.
        attrNs - The attribute namespace.
        attributeValue - The attribute value.
        offset - The offset that is relative to the attribute value. It is zero based. If it is -1 and the attribute type is IDREFS then all the IDs should be returned.
        Returns:
        The ID identifier for the given attribute and offset. If the offset is -1 and the attribute type is IDREFS then all the IDs should be returned. Can be null if no ID was detected.
        Throws:
        CannotRecognizeIDException - Exception that can be thrown when an ID cannot be identified in the given context.
      • locateIDType

        public abstract int[] locateIDType​(java.lang.String systemID,
                                           Context context,
                                           java.lang.String attrName,
                                           java.lang.String attrNs,
                                           java.lang.String attributeValue,
                                           IDTypeIdentifier idIdentifier,
                                           short mode)
        Detect if the given ID is located in the specified attribute. If an attribute declaration or reference was identified then compute it's location relative to the attribute value. Usually the method is used for attributes with IDREFS type to detect the internal ID references.




        Parameters:
        systemID - The systemID of the resource that specifies the attribute.
        context - The element content to detect the ID. The top element from the context element stack represents the parent element.
        attrName - The attribute name.
        attrNs - The attribute namespace.
        attributeValue - The attribute value.
        idIdentifier - The ID identifier.
        mode - The detection mode that is represented as a bitwise mask. Supported modes are MODE_LOCATE_REFERENCES and MODE_LOCATE_DECLARATIONS.
        Returns:
        The location of the ID [startOffset, endOffset) in the given attribute value, by example if the attribute value is 'idRef1 idRef2' and we are looking for 'idRef1' the method should return [0, 6). The endOffset is exclusive. Null value can be returned if the ID was not located.
      • isDefaultIDTypeRecognitionAvailable

        public abstract boolean isDefaultIDTypeRecognitionAvailable()
        If false then disable the default recognition of the IDs based on the current associated schema. Otherwise the IDs declaration and references will be detected for document with DTD, XML Schema or RelaxNG schemas.
        Returns:
        True to disable the recognition of the IDs based on the current associated schema.
      • isIDTypeRecognitionAvailable

        public abstract boolean isIDTypeRecognitionAvailable()
        If true then ID type recognition is available. If this method return false also the default ID type recognition will be disabled.
        Returns:
        False to disable the recognition of the IDs.