Package net.ontopia.topicmaps.xml
Class XTMContentHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- net.ontopia.topicmaps.xml.AbstractTopicMapContentHandler
-
- net.ontopia.topicmaps.xml.XTMContentHandler
-
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,DeclHandler
,LexicalHandler
public class XTMContentHandler extends AbstractTopicMapContentHandler implements LexicalHandler, DeclHandler
INTERNAL: SAX2 content handler used for importing XTM 1.0 topic map documents. The content handler builds a topic map object based on a SAX event stream conforming to the XTM topic map interchange syntax. See http://www.topicmaps.org/xtm/1.0/
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>
entities
Keeps track of the declared entities, in order that the base URI can be set correctly in external entities.protected boolean
isSubDocument
Used to tell if we are reading the top-level XTM document (false) or if we are reading a merged-in XTM document (true).static String
NS_NS
static String
NS_XLINK
static String
NS_XTM
static LocatorIF
nullPSI
protected ExternalReferenceHandlerIF
ref_handler
static String
SAX_DECL_HANDLER
static String
SAX_LEXICAL_HANDLER
protected TopicMapStoreFactoryIF
stores
-
Fields inherited from class net.ontopia.topicmaps.xml.AbstractTopicMapContentHandler
doc_address, ehandler, info, locator, parents, processed_documents_accumulated, processed_documents_current, processed_documents_from_parent, propagated_themes
-
-
Constructor Summary
Constructors Constructor Description XTMContentHandler(TopicMapStoreFactoryIF stores, LocatorIF base_address)
XTMContentHandler(TopicMapStoreFactoryIF stores, LocatorIF base_address, Collection<LocatorIF> processed_documents)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addItemIdentifier(TMObjectIF tmobject, LocatorIF sourceLocator)
protected TopicIF
addSubjectIdentifier(TopicIF topic, LocatorIF subjectIndicator)
void
attributeDecl(String eName, String aName, String type, String mode, String value)
void
characters(char[] ch, int start, int length)
void
comment(char[] ch, int start, int length)
protected LocatorIF
createLocator(String address)
protected TopicIF
createTopicFromLazyTopic()
protected LocatorIF
createURILocator(String address)
void
elementDecl(String name, String model)
void
endCDATA()
void
endDocument()
void
endDTD()
void
endElement(String uri, String name, String qName)
void
endEntity(String name)
void
endPrefixMapping(String prefix)
void
externalEntityDecl(String name, String publicId, String systemId)
protected LocatorIF
getBaseAddress()
static TopicIF
getDefaultOccurrenceTopic(TopicMapIF topicmap)
ExternalReferenceHandlerIF
getExternalReferenceHandler()
INTERNAL: Gets the external reference handler.static TopicIF
getNullTopic(TopicMapIF topicmap)
protected TopicIF
getParentTopic()
protected TopicIF
getReferencedExternalTopic(LocatorIF orig_locator)
Collection<TopicMapIF>
getTopicMaps()
INTERNAL: Gets the topic maps found after having parsed the input source.void
internalEntityDecl(String name, String value)
protected void
processMember(TopicIF player)
protected void
processTheme(TopicIF theme)
protected void
processTopicReference(TopicIF referenced_topic)
void
register(XMLReader parser)
INTERNAL: Registers the handler with the parser and configures the parser.protected void
registerSourceLocator(TMObjectIF tmobject, String id)
protected TopicIF
registerSourceLocator(TopicIF topic, LocatorIF locator)
protected TopicIF
registerSubjectIndicator(TopicIF topic, LocatorIF locator)
protected TopicIF
registerSubjectLocator(TopicIF topic, LocatorIF locator)
static void
removeDefaultOccurrenceTopic(TopicMapIF topicmap)
static void
removeNullTopic(TopicMapIF topicmap)
protected TopicIF
resolveResourceRef(LocatorIF locator)
protected TopicIF
resolveSourceLocatorOrSubjectIndicator(LocatorIF locator)
protected TopicIF
resolveTopicRef(String address)
void
setExternalReferenceHandler(ExternalReferenceHandlerIF ref_handler)
INTERNAL: Sets the external reference handler.void
setSubDocument(boolean isSubDocument)
INTERNAL: Tell the handler whether this is a top-level document or not.void
startCDATA()
void
startDocument()
void
startDTD(String name, String publicId, String systemId)
void
startElement(String uri, String name, String qName, Attributes atts)
void
startEntity(String name)
void
startPrefixMapping(String prefix, String uri)
-
Methods inherited from class net.ontopia.topicmaps.xml.AbstractTopicMapContentHandler
getDefaultErrorHandler, getLocationInfo, getPropagatedThemes, propagateThemes, setDocumentLocator, setPropagatedThemes
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
NS_XTM
public static final String NS_XTM
- See Also:
- Constant Field Values
-
NS_XLINK
public static final String NS_XLINK
- See Also:
- Constant Field Values
-
NS_NS
public static final String NS_NS
- See Also:
- Constant Field Values
-
nullPSI
public static final LocatorIF nullPSI
-
SAX_LEXICAL_HANDLER
public static final String SAX_LEXICAL_HANDLER
- See Also:
- Constant Field Values
-
SAX_DECL_HANDLER
public static final String SAX_DECL_HANDLER
- See Also:
- Constant Field Values
-
stores
protected TopicMapStoreFactoryIF stores
-
entities
protected Map<String,String> entities
Keeps track of the declared entities, in order that the base URI can be set correctly in external entities.
-
isSubDocument
protected boolean isSubDocument
Used to tell if we are reading the top-level XTM document (false) or if we are reading a merged-in XTM document (true).
-
ref_handler
protected ExternalReferenceHandlerIF ref_handler
-
-
Constructor Detail
-
XTMContentHandler
public XTMContentHandler(TopicMapStoreFactoryIF stores, LocatorIF base_address)
-
XTMContentHandler
public XTMContentHandler(TopicMapStoreFactoryIF stores, LocatorIF base_address, Collection<LocatorIF> processed_documents)
-
-
Method Detail
-
getTopicMaps
public Collection<TopicMapIF> getTopicMaps()
INTERNAL: Gets the topic maps found after having parsed the input source.
-
getExternalReferenceHandler
public ExternalReferenceHandlerIF getExternalReferenceHandler()
INTERNAL: Gets the external reference handler. The reference handler will receive notifications on references to external topics and topic maps.
-
setExternalReferenceHandler
public void setExternalReferenceHandler(ExternalReferenceHandlerIF ref_handler)
INTERNAL: Sets the external reference handler.
-
setSubDocument
public void setSubDocument(boolean isSubDocument)
INTERNAL: Tell the handler whether this is a top-level document or not.
-
register
public void register(XMLReader parser)
INTERNAL: Registers the handler with the parser and configures the parser.- Overrides:
register
in classAbstractTopicMapContentHandler
-
startDocument
public void startDocument()
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
-
endDocument
public void endDocument()
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
-
startElement
public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length)
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
-
endElement
public void endElement(String uri, String name, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri)
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
-
endPrefixMapping
public void endPrefixMapping(String prefix)
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
-
getBaseAddress
protected LocatorIF getBaseAddress()
-
resolveTopicRef
protected TopicIF resolveTopicRef(String address) throws SAXException
- Throws:
SAXException
-
registerSourceLocator
protected void registerSourceLocator(TMObjectIF tmobject, String id)
-
registerSubjectIndicator
protected TopicIF registerSubjectIndicator(TopicIF topic, LocatorIF locator)
-
resolveSourceLocatorOrSubjectIndicator
protected TopicIF resolveSourceLocatorOrSubjectIndicator(LocatorIF locator)
-
getReferencedExternalTopic
protected TopicIF getReferencedExternalTopic(LocatorIF orig_locator) throws SAXException
- Throws:
SAXException
-
processTheme
protected void processTheme(TopicIF theme)
-
processTopicReference
protected void processTopicReference(TopicIF referenced_topic)
-
processMember
protected void processMember(TopicIF player)
-
addItemIdentifier
protected void addItemIdentifier(TMObjectIF tmobject, LocatorIF sourceLocator)
-
addSubjectIdentifier
protected TopicIF addSubjectIdentifier(TopicIF topic, LocatorIF subjectIndicator)
-
getParentTopic
protected TopicIF getParentTopic()
-
createTopicFromLazyTopic
protected TopicIF createTopicFromLazyTopic()
-
startEntity
public void startEntity(String name)
- Specified by:
startEntity
in interfaceLexicalHandler
-
endEntity
public void endEntity(String name)
- Specified by:
endEntity
in interfaceLexicalHandler
-
comment
public void comment(char[] ch, int start, int length)
- Specified by:
comment
in interfaceLexicalHandler
-
startCDATA
public void startCDATA()
- Specified by:
startCDATA
in interfaceLexicalHandler
-
endCDATA
public void endCDATA()
- Specified by:
endCDATA
in interfaceLexicalHandler
-
startDTD
public void startDTD(String name, String publicId, String systemId)
- Specified by:
startDTD
in interfaceLexicalHandler
-
endDTD
public void endDTD()
- Specified by:
endDTD
in interfaceLexicalHandler
-
externalEntityDecl
public void externalEntityDecl(String name, String publicId, String systemId)
- Specified by:
externalEntityDecl
in interfaceDeclHandler
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String mode, String value)
- Specified by:
attributeDecl
in interfaceDeclHandler
-
elementDecl
public void elementDecl(String name, String model)
- Specified by:
elementDecl
in interfaceDeclHandler
-
internalEntityDecl
public void internalEntityDecl(String name, String value)
- Specified by:
internalEntityDecl
in interfaceDeclHandler
-
getNullTopic
public static TopicIF getNullTopic(TopicMapIF topicmap)
-
getDefaultOccurrenceTopic
public static TopicIF getDefaultOccurrenceTopic(TopicMapIF topicmap)
-
removeNullTopic
public static void removeNullTopic(TopicMapIF topicmap)
-
removeDefaultOccurrenceTopic
public static void removeDefaultOccurrenceTopic(TopicMapIF topicmap)
-
-