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>entitiesKeeps track of the declared entities, in order that the base URI can be set correctly in external entities.protected booleanisSubDocumentUsed to tell if we are reading the top-level XTM document (false) or if we are reading a merged-in XTM document (true).static StringNS_NSstatic StringNS_XLINKstatic StringNS_XTMstatic LocatorIFnullPSIprotected ExternalReferenceHandlerIFref_handlerstatic StringSAX_DECL_HANDLERstatic StringSAX_LEXICAL_HANDLERprotected TopicMapStoreFactoryIFstores-
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 voidaddItemIdentifier(TMObjectIF tmobject, LocatorIF sourceLocator)protected TopicIFaddSubjectIdentifier(TopicIF topic, LocatorIF subjectIndicator)voidattributeDecl(String eName, String aName, String type, String mode, String value)voidcharacters(char[] ch, int start, int length)voidcomment(char[] ch, int start, int length)protected LocatorIFcreateLocator(String address)protected TopicIFcreateTopicFromLazyTopic()protected LocatorIFcreateURILocator(String address)voidelementDecl(String name, String model)voidendCDATA()voidendDocument()voidendDTD()voidendElement(String uri, String name, String qName)voidendEntity(String name)voidendPrefixMapping(String prefix)voidexternalEntityDecl(String name, String publicId, String systemId)protected LocatorIFgetBaseAddress()static TopicIFgetDefaultOccurrenceTopic(TopicMapIF topicmap)ExternalReferenceHandlerIFgetExternalReferenceHandler()INTERNAL: Gets the external reference handler.static TopicIFgetNullTopic(TopicMapIF topicmap)protected TopicIFgetParentTopic()protected TopicIFgetReferencedExternalTopic(LocatorIF orig_locator)Collection<TopicMapIF>getTopicMaps()INTERNAL: Gets the topic maps found after having parsed the input source.voidinternalEntityDecl(String name, String value)protected voidprocessMember(TopicIF player)protected voidprocessTheme(TopicIF theme)protected voidprocessTopicReference(TopicIF referenced_topic)voidregister(XMLReader parser)INTERNAL: Registers the handler with the parser and configures the parser.protected voidregisterSourceLocator(TMObjectIF tmobject, String id)protected TopicIFregisterSourceLocator(TopicIF topic, LocatorIF locator)protected TopicIFregisterSubjectIndicator(TopicIF topic, LocatorIF locator)protected TopicIFregisterSubjectLocator(TopicIF topic, LocatorIF locator)static voidremoveDefaultOccurrenceTopic(TopicMapIF topicmap)static voidremoveNullTopic(TopicMapIF topicmap)protected TopicIFresolveResourceRef(LocatorIF locator)protected TopicIFresolveSourceLocatorOrSubjectIndicator(LocatorIF locator)protected TopicIFresolveTopicRef(String address)voidsetExternalReferenceHandler(ExternalReferenceHandlerIF ref_handler)INTERNAL: Sets the external reference handler.voidsetSubDocument(boolean isSubDocument)INTERNAL: Tell the handler whether this is a top-level document or not.voidstartCDATA()voidstartDocument()voidstartDTD(String name, String publicId, String systemId)voidstartElement(String uri, String name, String qName, Attributes atts)voidstartEntity(String name)voidstartPrefixMapping(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:
registerin classAbstractTopicMapContentHandler
-
startDocument
public void startDocument()
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler
-
endDocument
public void endDocument()
- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler
-
startElement
public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length)- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
endElement
public void endElement(String uri, String name, String qName) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri)
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler
-
endPrefixMapping
public void endPrefixMapping(String prefix)
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin 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:
startEntityin interfaceLexicalHandler
-
endEntity
public void endEntity(String name)
- Specified by:
endEntityin interfaceLexicalHandler
-
comment
public void comment(char[] ch, int start, int length)- Specified by:
commentin interfaceLexicalHandler
-
startCDATA
public void startCDATA()
- Specified by:
startCDATAin interfaceLexicalHandler
-
endCDATA
public void endCDATA()
- Specified by:
endCDATAin interfaceLexicalHandler
-
startDTD
public void startDTD(String name, String publicId, String systemId)
- Specified by:
startDTDin interfaceLexicalHandler
-
endDTD
public void endDTD()
- Specified by:
endDTDin interfaceLexicalHandler
-
externalEntityDecl
public void externalEntityDecl(String name, String publicId, String systemId)
- Specified by:
externalEntityDeclin interfaceDeclHandler
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String mode, String value)
- Specified by:
attributeDeclin interfaceDeclHandler
-
elementDecl
public void elementDecl(String name, String model)
- Specified by:
elementDeclin interfaceDeclHandler
-
internalEntityDecl
public void internalEntityDecl(String name, String value)
- Specified by:
internalEntityDeclin 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)
-
-