|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.tm.LTMParser
public class LTMParser
Implements a parser for a customized version of the Linear Topic Map
Notation. This implementation is used with TM4J, and extends the
LTM 1.2 functionality. This parser is functionally identical (at
least it is intended as such) to LTMProcessor
but has no dependencies on core Ceryle application code, nor does
it implement TopicMapBuilder.
It will accept Occurrences with either a quote-delimited value or the new LTM 1.2 "[[" and "]]" delimited value for resource data. Values that are URLs are automatically created as resource references (there is currently no way to store a URL as a String).
Because of #MERGEMAP directives, this LTMParser may end up processing multiple LTM files during the course of a single build. The base and resource locators of the initial LTM document are used for the resulting TopicMap. If a #BASEURI directive is encountered, this takes precedence.
LTMProcessor| Field Summary | |
|---|---|
protected Locator |
m_baseLoc
The base Locator of the current TopicMap, as set by its source Locator or its own #BASEURI directive. |
protected Locator |
m_srcLoc
The source Locator of the current TopicMap, as provided by its source Locator. |
boolean |
strictParsing
Variable controlling whether strict XML parsing is active. |
Topic |
topicDescription
A PSI-based Topic identifying the subject of "topic description". |
| Constructor Summary | |
|---|---|
LTMParser(TopicMapProvider tmprovider,
IDGenerator idgenerator)
Constructor with a TopicMapProvider. |
|
| Method Summary | |
|---|---|
void |
build(InputStream source,
Locator srcLoc,
TopicMap topicmap)
Parses the source indicated by the TypedInputSource source, populating the provided TopicMap. |
void |
build(InputStream source,
Locator srcLoc,
TopicMap topicmap,
Topic[] addedThemes)
Parses the source indicated by the TypedInputSource source, populating the provided TopicMap. |
void |
build(InputStream source,
TopicMap topicmap)
Parses the source indicated by the TypedInputSource source, populating the provided TopicMap. |
void |
build(Reader reader,
Locator srcLoc,
TopicMap topicmap)
Parses the source indicated by the TypedInputSource source, populating the provided TopicMap. |
void |
build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
Topic[] addedThemes)
Parses the source indicated by the TypedInputSource source, populating the provided Document. |
protected boolean |
forward(Reader r)
Read one character into thisChar, then read ahead nextChar. |
String |
generateID()
Uses the existing IDGenerator to return a unique ID within the provided TopicMap topicmap. |
String |
generateID(String prefix)
Uses the existing IDGenerator to return a unique ID prefixed with the String prefix. |
TopicMap |
getTopicMap()
Returns the TopicMap generated as a result of parsing, or null if not available. |
void |
mergeMap(TypedInputSource source)
Merges the LTM file indicated by the TypedInputSource source, populating the provided Document. |
Topic |
psiDisplay(TopicMap topicmap)
Returns a Topic using the XTM 1.0 "Display" PSI as its subject indicator. |
Topic |
psiSort(TopicMap topicmap)
Returns a Topic using the XTM 1.0 "Sort" PSI as its subject indicator. |
Topic |
psiSubclass(TopicMap topicmap)
Returns a Topic using the XTM 1.0 "Subclass" PSI as its subject indicator. |
Topic |
psiSuperclass(TopicMap topicmap)
Returns a Topic using the XTM 1.0 "Superclass" PSI as its subject indicator. |
Topic |
psiSuperclassSubclass(TopicMap topicmap)
Returns a Topic using the XTM 1.0 "Superclass-Subclass" PSI as its subject indicator. |
void |
require(Reader r,
String string)
Parse a required string. |
Topic |
returnTopicByID(TopicMap topicmap,
String id)
Returns either the existing Topic whose ID is id, or a new Topic if a matching one is not already available. |
Association |
scanAssociation(Reader r)
Scans until an association end delimiter (")"), returning the Association object. |
void |
scanComment(Reader r)
Scans a C++ style comment. |
protected void |
scanDescription(Reader r,
Topic topic)
Scans forward for a topic description. |
protected void |
scanDirective(Reader r)
Scans an LTM directive. |
protected String |
scanLiteral(Reader r,
boolean normWS)
Scans forward until the closing literal delimiter, returning a String whose LT, GT, QUOT, APOS and AMP characters have been converted to entities. |
protected String |
scanName(Reader r)
Scans a Name [XML production 5]. |
Occurrence |
scanOccurrence(Reader r)
Scans until an occurrence end delimiter ("}"), returning the Occurrence object. |
protected String |
scanSpace(Reader r,
boolean required)
Scans space characters, reading forward until a non-space character is encountered. |
protected void |
scanSubjectIdentifier(Reader r,
Topic topic)
Scans forward for Published Subject Indicator (PSI). |
void |
scanSuperclass(Reader r,
Topic subclass)
Creates a superclass-subclass Association between the provided Topic and the scanned token representing a reference to the superclass Topic. |
protected String |
scanToEndOfLine(Reader r)
Scans forward until an end-of-line character, returning the string. |
Topic |
scanTopic(Reader r)
Scans until a topic end delimiter ("]"), returning the Topic object. |
protected void |
scanTopicName(Reader r,
Topic topic)
Scans forward for base name, sort name, and/or display name. |
protected Topic |
scanType(Reader r)
Scans forward for topic, occurrence or association type (roleSpec), returning a Topic that serves as the object's type, i.e., the referent in its <instanceOf> or <roleSpec> element. |
protected String |
scanURI(Reader r)
Scans a URI, rather loosely. |
protected void |
scanWhitespace(Reader r,
boolean required)
Scans white space [XML production 3], reading forward until a non-whitespace character is encountered. |
protected void |
setBaseLocator(TopicMap tm,
Locator loc,
Locator from)
Because during processing of an LTM file we might encounter #MERGEMAP directives, causing sub-modules to be parsed, and because these sub-modules may themselves include their own #MERGEMAP or #BASEURI directives, only the original LTM source is able to set the resulting base URI. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Topic topicDescription
public boolean strictParsing
protected Locator m_baseLoc
protected Locator m_srcLoc
| Constructor Detail |
|---|
public LTMParser(TopicMapProvider tmprovider,
IDGenerator idgenerator)
tmprovider - the topic map provider usedidgenerator - the ID generator to be usedConstants,
TopicMapProcessor,
TopicMap| Method Detail |
|---|
public void mergeMap(TypedInputSource source)
throws TopicMapException
LTM Extension
.
source - the TypedInputSource source to be parsed.
TopicMapException
public void build(InputStream source,
TopicMap topicmap)
throws TopicMapException
source - the TypedInputSource source to be parsedtopicmap - the TopicMap to be populated
TopicMapException - if any errors are encountered during parsing
public void build(InputStream source,
Locator srcLoc,
TopicMap topicmap)
throws TopicMapException
source - the TypedInputSource source to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populated
TopicMapException - if any errors are encountered during parsing
public void build(InputStream source,
Locator srcLoc,
TopicMap topicmap,
Topic[] addedThemes)
throws TopicMapException
source - the TypedInputSource source to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populatedaddedThemes - the themes to be added as the scope of validity for all objects in the TopicMap
TopicMapException - if any errors are encountered during parsing
public void build(Reader reader,
Locator srcLoc,
TopicMap topicmap)
throws TopicMapException
reader - the Reader to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populated
TopicMapException - if any errors are encountered during parsing
public void build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
Topic[] addedThemes)
throws TopicMapException
reader - the Reader to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populatedaddedThemes - the themes to be added as the scope of validity for all objects in the TopicMap
TopicMapException - if any errors are encountered during parsing
protected void setBaseLocator(TopicMap tm,
Locator loc,
Locator from)
tm - the TopicMap whose base URI is to be setloc - the Locator to use as a base URIfrom - the base Locator of the current TopicMappublic TopicMap getTopicMap()
public String generateID()
public String generateID(String prefix)
public Topic returnTopicByID(TopicMap topicmap,
String id)
throws TopicMapException
topicmap - a reference to the topic map to be queriedid - the ID to be searched for
DuplicateObjectIDException - if the ID specifies an identifier already assigned to a non-Topic object
TopicMapException
public Topic psiSuperclassSubclass(TopicMap topicmap)
throws TopicMapException
TopicMapException
public Topic psiSuperclass(TopicMap topicmap)
throws TopicMapException
TopicMapException
public Topic psiSubclass(TopicMap topicmap)
throws TopicMapException
TopicMapException
public Topic psiSort(TopicMap topicmap)
throws TopicMapException
TopicMapException
public Topic psiDisplay(TopicMap topicmap)
throws TopicMapException
TopicMapException
public Topic scanTopic(Reader r)
throws TopicMapException
LTM Extension: a semicolon following the topic ID (rather than a colon) indicates the superclass of this topic.
r - the Reader used to provide parsed content.
TopicMapException
public void scanSuperclass(Reader r,
Topic subclass)
throws TopicMapException
NOTE: This is an extension to LTM 1.0.
TopicMapException
protected void scanTopicName(Reader r,
Topic topic)
throws TopicMapException
[id : type = "baseName" ; "sortname" ; "dispname" / scope [NAME+]
= "baseName2" ; "sortname2" ; "dispname2" / scope2 [NAME+]
r - a Reader providing access to the document content.topic - the topic to decorate with name information.
TopicMapException
public Occurrence scanOccurrence(Reader r)
throws TopicMapException
r - the Reader used to provide parsed content.
TopicMapException
protected void scanDirective(Reader r)
throws TopicMapException
Note that the double quotes surrounding the ID value are optional.
LTM 1.0 Extension (now part of LTM 1.2)
.
r - the Reader used to provide parsed content.
TopicMapException
protected Topic scanType(Reader r)
throws TopicMapException
r - the Reader used to provide parsed content.
TopicMapException
public Association scanAssociation(Reader r)
throws TopicMapException
typingTopicId( topic1Id : roleSpec , topic2Id : roleSpec )
typingTopicId( [topic1Id] : roleSpec , [topic2Id] : roleSpec )
r - the Reader used to provide parsed content.
TopicMapException
protected void scanDescription(Reader r,
Topic topic)
throws TopicMapException
LTM Extension
.
TopicMapException
protected void scanSubjectIdentifier(Reader r,
Topic topic)
throws TopicMapException
TopicMapException
protected String scanLiteral(Reader r,
boolean normWS)
throws TopicMapException
TopicMapException
public void require(Reader r,
String string)
throws TopicMapException
TopicMapException
protected String scanToEndOfLine(Reader r)
throws TopicMapException
TopicMapExceptionXMLCharTok
public void scanComment(Reader r)
throws TopicMapException
r - the Reader used to provide parsed content.
TopicMapException
protected String scanURI(Reader r)
throws TopicMapException
r - the Reader used to provide parsed content.
TopicMapException
protected String scanName(Reader r)
throws TopicMapException
r - the Reader used to provide parsed content.
TopicMapException
protected void scanWhitespace(Reader r,
boolean required)
throws TopicMapException
required is
true, then at least one character of whitespace is required or an error will
be generated.
TopicMapException
protected String scanSpace(Reader r,
boolean required)
throws TopicMapException
required is true, then at least one space
character is required or an error will be generated.
TopicMapException
protected boolean forward(Reader r)
throws TopicMapException
thisChar is whitespace.
r - the Reader used to provide parsed content.
TopicMapException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||