|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.convert.LtmParser
public class LtmParser
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 uses Ceryle's XtmProcessor (not TM4J), and is not entirely conformant with Ontopia's LTM; instances of this are marked by the phrase "LTM Extension". In particular, it uses several new directives, several of which have been incorporated into the LTM specification. It also uses a different syntax for occurrence resource data.
Note: This class is not deprecated, but is not intended for
general consumption, being the older supported method of creating PSI
topic maps from LTM files. It is superceded by
LTMProcessor.
| Field Summary | |
|---|---|
boolean |
strictParsing
Variable controlling whether strict XML parsing is active. |
| Constructor Summary | |
|---|---|
LtmParser()
Default constructor. |
|
LtmParser(XtmProcessor xtmproc)
Constructor with a preexisting XtmProcessor xtmproc. |
|
| Method Summary | |
|---|---|
protected boolean |
forward(Reader r)
Read one character into thisChar, then read ahead nextChar. |
Reader |
getReader(String pathname)
Instantiates a BufferedReader to process the pathname as a URL or file reference, returning the Reader. |
XtmTopicMap |
getTopicMap()
Returns the XtmTopicMap generated as a result of parsing, or null if not available. |
XtmDocument |
getXtmDocument()
Return the current XtmDocument object, null if undefined. |
void |
mergeMap(TypedInputSource source,
String syntax)
Merges the LTM file indicated by the TypedInputSource source, populating the provided Document. |
void |
parse(TypedInputSource source)
Parses the source indicated by the TypedInputSource source, populating the provided Document. |
void |
require(Reader r,
String string,
String errMsg)
Parse a required string. |
XtmAssociation |
scanAssociation(Reader r)
Scans until an association end delimiter (")"), returning the XtmAssociation object. |
XtmComment |
scanComment(Reader r)
Scans a C++ style comment, returns upon finding a comment end delimiter. |
protected void |
scanDescription(Reader r,
XtmTopic topic)
Scans forward for published Subject Indicator (PSI). |
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]. |
XtmOccurrence |
scanOccurrence(Reader r)
Scans until an occurrence end delimiter ("}"), returning the XtmOccurrence object. |
XtmResourceData |
scanResourceData(Reader r)
Scans the '[[' and ']]' delimited resource data of an inline data Occurrence, returning an XtmResourceData 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,
XtmTopic topic)
Scans forward for Published Subject Indicator (PSI). |
void |
scanSuperclass(Reader r,
XtmTopic 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. |
XtmTopic |
scanTopic(Reader r)
Scans until a topic end delimiter ("]"), returning the XtmTopic object. |
protected void |
scanTopicName(Reader r,
XtmTopic topic)
Scans forward for base name, sort name, and/or display name. |
protected XtmReference |
scanType(Reader r)
Scans forward for topic, occurrence or association type (roleSpec), returning an XtmReference object that serves as the object's type, i.e., the reference in its <instanceOf> or <roleSpec> element. |
protected String |
scanURI(Reader r)
Scans a URI, rather loosely. |
protected String |
scanWhitespace(Reader r,
boolean required)
Scans white space [XML production 3], reading forward until a non-whitespace character is encountered. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public boolean strictParsing
| Constructor Detail |
|---|
public LtmParser()
public LtmParser(XtmProcessor xtmproc)
| Method Detail |
|---|
public void mergeMap(TypedInputSource source,
String syntax)
throws ProcessException
LTM Extension (now part of LTM 1.2)
.
source - the TypedInputSource source to be parsed.syntax - the syntax of the incoming document (only "ltm" is supported).
ProcessException
public void parse(TypedInputSource source)
throws ProcessException
source - the TypedInputSource source to be parsed
ProcessException - if any errors are encountered during parsingpublic XtmDocument getXtmDocument()
public XtmTopicMap getTopicMap()
public XtmTopic scanTopic(Reader r)
throws XtmException
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.
XtmException
public void scanSuperclass(Reader r,
XtmTopic subclass)
throws XtmException
XtmException
protected void scanTopicName(Reader r,
XtmTopic topic)
throws XtmException
[id : type = / scope "basename" / scope "basename"
// scope "variantName" ; "sortname" ; "dispname"]
r - a Reader providing access to the document content.topic - the topic to decorate with name information.
XtmException
public XtmOccurrence scanOccurrence(Reader r)
throws XtmException
r - the Reader used to provide parsed content.
XtmException
public XtmResourceData scanResourceData(Reader r)
throws XtmException
XtmException
protected void scanDirective(Reader r)
throws XtmException
LTM Extension
.
r - the Reader used to provide parsed content.
XtmException
protected XtmReference scanType(Reader r)
throws XtmException
Note 1: This uses a rather stupid algorithm for determining the interpretation of the scanned URI reference. If the String is an XML Name, doesn't contain a period ('.') character, and doesn't begin with either 'http://' or 'file:/', it is interpreted as a reference to an ID, and prepended with a hash ('#') character in the created reference.
Note 2: If the type is recognized as the PSI for instance, display, description, or sort, a static XtmReference for that PSI (provided by the XtmProcessor) is returned.
r - the Reader used to provide parsed content.
XtmException
public XtmAssociation scanAssociation(Reader r)
throws XtmException
typingTopicId( [topic1Id] : roleSpec , [topic2Id] : roleSpec )
r - the Reader used to provide parsed content.
XtmException
protected void scanDescription(Reader r,
XtmTopic topic)
throws XtmException
LTM Extension
.
XtmException
protected void scanSubjectIdentifier(Reader r,
XtmTopic topic)
throws XtmException
XtmException
protected String scanLiteral(Reader r,
boolean normWS)
throws XtmException
XtmException
public void require(Reader r,
String string,
String errMsg)
throws XtmException
XtmException
protected String scanToEndOfLine(Reader r)
throws XtmException
XtmExceptionXMLCharTok
public XtmComment scanComment(Reader r)
throws XtmException
r - the Reader used to provide parsed content.
XtmException
protected String scanURI(Reader r)
throws XtmException
r - the Reader used to provide parsed content.
XtmException
protected String scanName(Reader r)
throws XtmException
r - the Reader used to provide parsed content.
XtmException
protected String scanWhitespace(Reader r,
boolean required)
throws XtmException
required is
true, then at least one character of whitespace is required or an error will
be generated.
XtmException
protected String scanSpace(Reader r,
boolean required)
throws XtmException
required is true, then at least one space
character is required or an error will be generated.
XtmException
protected boolean forward(Reader r)
throws XtmException
thisChar is whitespace.
r - the Reader used to provide parsed content.
XtmException
public Reader getReader(String pathname)
throws FileNotFoundException,
IOException,
UnknownHostException
pathname - the pathname of the file intended to be read.
FileNotFoundException
IOException
UnknownHostException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||