Package ro.sync.ecss.extensions.tei.id
Class TEIP5IDTypeRecognizer
- java.lang.Object
-
- ro.sync.ecss.extensions.api.link.IDTypeRecognizer
-
- ro.sync.ecss.extensions.tei.id.TEIP5IDTypeRecognizer
-
@API(type=INTERNAL, src=PUBLIC) public class TEIP5IDTypeRecognizer extends IDTypeRecognizer
Implementation of ID declarations and references recognizer for TEI P5 framework. In this framework the IDs are declared in attributes with name 'id'. The references are recognized in attributes ptr/@target or ref/@target, see http://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-ptr.html.
-
-
Field Summary
-
Fields inherited from class ro.sync.ecss.extensions.api.link.IDTypeRecognizer
MODE_LOCATE_DECLARATIONS, MODE_LOCATE_REFERENCES
-
-
Constructor Summary
Constructors Constructor Description TEIP5IDTypeRecognizer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.boolean
isDefaultIDTypeRecognitionAvailable()
Iffalse
then disable the default recognition of the IDs based on the current associated schema.boolean
isIDTypeRecognitionAvailable()
If true then ID type recognition is available.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.
-
-
-
Method Detail
-
detectIDType
public 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
Description copied from class:IDTypeRecognizer
Detect the ID declaration or reference for the provided attribute context and offset. The offset is relative to the attribute value.- Specified by:
detectIDType
in classIDTypeRecognizer
- 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.- See Also:
IDTypeRecognizer.detectIDType(java.lang.String, ro.sync.contentcompletion.xml.Context, java.lang.String, java.lang.String, java.lang.String, int)
-
locateIDType
public int[] locateIDType(java.lang.String systemID, Context context, java.lang.String attrName, java.lang.String attrNs, java.lang.String attributeValue, IDTypeIdentifier idIdentifier, short mode)
Description copied from class:IDTypeRecognizer
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.
- Specified by:
locateIDType
in classIDTypeRecognizer
- 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 areIDTypeRecognizer.MODE_LOCATE_REFERENCES
andIDTypeRecognizer.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.
- See Also:
IDTypeRecognizer.locateIDType(java.lang.String, ro.sync.contentcompletion.xml.Context, java.lang.String, java.lang.String, java.lang.String, ro.sync.ecss.extensions.api.link.IDTypeIdentifier, short)
-
isDefaultIDTypeRecognitionAvailable
public boolean isDefaultIDTypeRecognitionAvailable()
Description copied from class:IDTypeRecognizer
Iffalse
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.- Specified by:
isDefaultIDTypeRecognitionAvailable
in classIDTypeRecognizer
- Returns:
- True to disable the recognition of the IDs based on the current associated schema.
- See Also:
IDTypeRecognizer.isDefaultIDTypeRecognitionAvailable()
-
isIDTypeRecognitionAvailable
public boolean isIDTypeRecognitionAvailable()
Description copied from class:IDTypeRecognizer
If true then ID type recognition is available. If this method return false also the default ID type recognition will be disabled.- Specified by:
isIDTypeRecognitionAvailable
in classIDTypeRecognizer
- Returns:
- False to disable the recognition of the IDs.
- See Also:
IDTypeRecognizer.isIDTypeRecognitionAvailable()
-
-