|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.tm.LTMProcessor
public class LTMProcessor
Implements a parser for the Linear Topic Map Notation as described in the Ontopia paper of the same name, by Lars Marius Garshol. This implementation is used with TM4J, and extends the LTM 1.2 functionality; instances of this are marked by the phrase "LTM Extension".
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 LTMProcessor 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.
| Field Summary | |
|---|---|
boolean |
displayNameIsLabel
Variable controlling whether display names should call TopicMapProcessor.setLabel(Topic,String). |
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". |
| Fields inherited from interface org.tm4j.topicmap.utils.TopicMapBuilder |
|---|
OPTION_ADDED_THEMES |
| Constructor Summary | |
|---|---|
LTMProcessor(TopicMapProcessor tmprocessor)
Constructor using a TopicMapProcessor tmprocessor. |
|
| 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,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider)
Parses the source indicated by the TypedInputSource source, populating the provided TopicMap. |
void |
build(InputStream source,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider,
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 Document. |
void |
build(InputStream source,
TopicMap topicmap,
TopicMapProvider provider)
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 TopicMap. |
void |
build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider)
Parses the source indicated by the TypedInputSource source, populating the provided TopicMap. |
void |
build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider,
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. |
TopicMap |
getTopicMap()
Returns the TopicMap generated as a result of parsing, or null if not available. |
boolean |
isSupportedProperty(String propertyName)
Determines whether or not a specific property is supported by the TopicMapBuilder implementation. |
void |
mergeMap(TypedInputSource source)
Merges the LTM file indicated by the TypedInputSource source, populating the provided Document. |
void |
require(Reader r,
String string,
String errMsg)
Parse a required string. |
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. |
void |
setProperty(String propertyName,
Object value)
Set a configuration property for the builder which will be applied to the processing of subsequent invocations of the build()
method. |
| 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
public boolean displayNameIsLabel
TopicMapProcessor.setLabel(Topic,String).
Default value is true.
protected Locator m_baseLoc
protected Locator m_srcLoc
| Constructor Detail |
|---|
public LTMProcessor(TopicMapProcessor tmprocessor)
tmprocessor - the topic map processor usedMessageHandler,
Constants,
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 IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
build(InputStream,Locator,TopicMap,TopicMapProvider).
source - the TypedInputSource source to be parsedtopicmap - the TopicMap to be populated
TopicMapException - if any errors are encountered during parsing
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(InputStream source,
TopicMap topicmap,
TopicMapProvider provider)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
build(InputStream,Locator,TopicMap,TopicMapProvider).
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
source - the TypedInputSource source to be parsedtopicmap - the TopicMap to be populatedprovider - the TopicMapProvider to be used to retrieve merged TopicMaps
TopicMapException - if any errors are encountered during parsing
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(InputStream source,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuildersource - the TypedInputSource source to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populatedprovider - the TopicMapProvider to be used to retrieve merged TopicMaps
TopicMapException - if any errors are encountered during parsing
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(InputStream source,
Locator srcLoc,
TopicMap topicmap)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuildersource - 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
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(InputStream source,
Locator srcLoc,
TopicMap topicmap,
Topic[] addedThemes)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuildersource - 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
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(InputStream source,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider,
Topic[] addedThemes)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuildersource - the TypedInputSource source to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populatedprovider - the TopicMapProvider to be used to retrieve merged TopicMapsaddedThemes - the themes to be added as the scope of validity for all objects in the TopicMap
TopicMapException - if any errors are encountered during parsing
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuilderreader - the Reader to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populatedprovider - the TopicMapProvider to be used to retrieve merged TopicMaps
TopicMapException - if any errors are encountered during parsing
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(Reader reader,
Locator srcLoc,
TopicMap topicmap)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuilderreader - 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
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
Topic[] addedThemes)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuilderreader - 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
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
public void build(Reader reader,
Locator srcLoc,
TopicMap topicmap,
TopicMapProvider provider,
Topic[] addedThemes)
throws IOException,
LocatorFactoryException,
TopicMapProcessingException,
PropertyVetoException,
TopicMapProviderException
An implementation method for org.tm4j.topicmap.TopicMapBuilder.
build in interface TopicMapBuilderreader - the Reader to be parsedsrcLoc - the base address of the source being parsedtopicmap - the TopicMap to be populatedprovider - the TopicMapProvider to be used to retrieve merged TopicMapsaddedThemes - the themes to be added as the scope of validity for all objects in the TopicMap
TopicMapException - if any errors are encountered during parsing
IOException
LocatorFactoryException
TopicMapProcessingException
PropertyVetoException
TopicMapProviderException
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 TopicMap
public void setProperty(String propertyName,
Object value)
throws BuilderPropertyNotRecognizedException,
BuilderPropertyInvalidException
build()
method. A typical use of this method will be to set parser options prior
to parsing the input stream.
This method currently throws a BuilderPropertyNotRecognizedException, as this class does not support any of the TM4J properties.
setProperty in interface TopicMapBuilderpropertyName - the name of the property to be set. See inidividual
implementation classes for details of which properties
are recognized by each implementation.value - the value to be applied to the property.
BuilderPropertyNotRecognizedException - if propertyName
specifies a property which is not supported by the
TopicMapBuilder implementation.
BuilderPropertyInvalidException - if value falls outside
the supported range of values for the specified property.public boolean isSupportedProperty(String propertyName)
This method currently always returns false, as this class does not support any of the TM4J properties.
isSupportedProperty in interface TopicMapBuilderpropertyName - the name of the property to check for support.
true if the property is supported and false otherwise.public TopicMap getTopicMap()
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,
ParseException
r - the Reader used to provide parsed content.
TopicMapException
ParseException
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,
ParseException
TopicMapException
ParseException
protected String scanLiteral(Reader r,
boolean normWS)
throws ParseException
ParseException
public void require(Reader r,
String string,
String errMsg)
throws ParseException
ParseException
protected String scanToEndOfLine(Reader r)
throws ParseException
ParseExceptionXMLCharTok
public void scanComment(Reader r)
throws ParseException
r - the Reader used to provide parsed content.
ParseException
protected String scanURI(Reader r)
throws ParseException
r - the Reader used to provide parsed content.
ParseException
protected String scanName(Reader r)
throws ParseException
r - the Reader used to provide parsed content.
ParseException
protected void scanWhitespace(Reader r,
boolean required)
throws ParseException
required is
true, then at least one character of whitespace is required or an error will
be generated.
ParseException
protected String scanSpace(Reader r,
boolean required)
throws ParseException
required is true, then at least one space
character is required or an error will be generated.
ParseException
protected boolean forward(Reader r)
throws ParseException
thisChar is whitespace.
r - the Reader used to provide parsed content.
ParseException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||