org.ceryle.xml
Class SourceProcessor

java.lang.Object
  extended by org.ceryle.xml.SourceProcessor

public class SourceProcessor
extends Object

Objects of the SourceProcessor class are designed to receive a Collection containing TypedInputSource objects, that is, typed XML InputSources. The SourceProcessor will process each in turn, generating XML or XTM Documents, depending on source type.

To Do:

Planned is a syntax processor API, where rather than the SourceProcessor class "knowing" about each particular syntax processor, the driver application instantiates each processor, which then in turn registers itself with this class, keyed by processed file type. Then, the channelSource method hands off the TypedInputSource to the correct processor in turn.

Since:
JDK1.3
Version:
$Id: SourceProcessor.java,v 3.14 2007-06-20 01:28:39 altheim Exp $
Author:
Murray Altheim
See Also:
Constants

Field Summary
static String DEFAULT_PARSER_NAME
          Default parser name.
static String LEXICAL_HANDLER_PROPERTY_ID
          Lexical handler property id (http://xml.org/sax/properties/lexical-handler).
static String NAMESPACES_FEATURE_ID
          Namespaces feature id (http://xml.org/sax/features/namespaces).
 boolean normalizeWS
          When true indicates that whitespace in content should be normalized.
protected  int plinkMode
          an int indicating the current Plink mode.
 boolean prettyPrint
          When true pretty-print indents serialized XML content.
static String SCHEMA_VALIDATION_FEATURE_ID
          Schema validation feature id (http://apache.org/xml/features/validation/schema).
static String VALIDATION_FEATURE_ID
          Validation feature id (http://xml.org/sax/features/validation).
 
Constructor Summary
SourceProcessor()
          Default constructor.
 
Method Summary
 Object channelSource(TypedInputSource source)
          Processes the TypedInputSource source according to its file type, generally returning a DOM Document if the source was XML, or an TopicMap object otherwise (this all depends on file type), or even a Swing Document.
 PlinkProcessor getPlinkProcessor()
          Returns this SourceProcessor's PlinkProcessor.
 TypedInputSource getTypedInputSourceFromString(String source)
          Returns an TypedInputSource whose source is a StringReader populated with the the contents of the String source, assuming the content to be well-formed XML.
 Document importPDB(TypedInputSource source)
          This passes the message on to the currently-open DocumentView (which initiated the action).
 TopicMap parseTM(TypedInputSource source)
          Parses the XTM, LTM, or AsTMa= file source to generate a TopicMap.
 Document parseXML(TypedInputSource source)
          Parses the XML file as a TypedInputSource source to populate and return a Document.
 int processSources(Collection sources)
          Processes the available sources, a Collection containing zero or more TypedInputSource objects, using the various parser and processor classes, returning the number of files processed.
 void setMessageWriter(MessageWriter msgwriter)
          Sets the MessageWriter used for interactive I/O to the application.
 void setOutputFile(String systemId)
          Sets the output file system identifier (pathname) used for writing to the String systemId.
 void setPlinkMode(int mode)
          Sets the operational mode for plink to the String mode.
 void writeTopicMap(TopicMap topicmap, String systemId)
          Processes the TopicMap topicmap to produce a generated XML document output as systemId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACES_FEATURE_ID

public static final String NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces).

See Also:
Constant Field Values

VALIDATION_FEATURE_ID

public static final String VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).

See Also:
Constant Field Values

SCHEMA_VALIDATION_FEATURE_ID

public static final String SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).

See Also:
Constant Field Values

LEXICAL_HANDLER_PROPERTY_ID

public static final String LEXICAL_HANDLER_PROPERTY_ID
Lexical handler property id (http://xml.org/sax/properties/lexical-handler).

See Also:
Constant Field Values

DEFAULT_PARSER_NAME

public static final String DEFAULT_PARSER_NAME
Default parser name.

See Also:
Constant Field Values

prettyPrint

public boolean prettyPrint
When true pretty-print indents serialized XML content.


normalizeWS

public boolean normalizeWS
When true indicates that whitespace in content should be normalized.


plinkMode

protected int plinkMode
an int indicating the current Plink mode.

See Also:
PlinkProcessor
Constructor Detail

SourceProcessor

public SourceProcessor()
Default constructor.

Method Detail

setOutputFile

public void setOutputFile(String systemId)
Sets the output file system identifier (pathname) used for writing to the String systemId.


setPlinkMode

public void setPlinkMode(int mode)
Sets the operational mode for plink to the String mode. Modes include PlinkProcessor.MODE_NOOP, PlinkProcessor.MODE_AUGMENT, and PlinkProcessor.MODE_REMOVE.

See Also:
PlinkProcessor

setMessageWriter

public void setMessageWriter(MessageWriter msgwriter)
Sets the MessageWriter used for interactive I/O to the application.


getPlinkProcessor

public PlinkProcessor getPlinkProcessor()
Returns this SourceProcessor's PlinkProcessor.


parseXML

public Document parseXML(TypedInputSource source)
                  throws ProcessException
Parses the XML file as a TypedInputSource source to populate and return a Document. If the plink mode is active, also plinks the document.

Throws:
ProcessException

parseTM

public TopicMap parseTM(TypedInputSource source)
Parses the XTM, LTM, or AsTMa= file source to generate a TopicMap.


importPDB

public Document importPDB(TypedInputSource source)
This passes the message on to the currently-open DocumentView (which initiated the action). If no GUI is available, returns null.


writeTopicMap

public void writeTopicMap(TopicMap topicmap,
                          String systemId)
Processes the TopicMap topicmap to produce a generated XML document output as systemId. If an output file has not been specified, writes to stdout.


channelSource

public Object channelSource(TypedInputSource source)
                     throws ProcessException
Processes the TypedInputSource source according to its file type, generally returning a DOM Document if the source was XML, or an TopicMap object otherwise (this all depends on file type), or even a Swing Document.

Throws:
ProcessException

getTypedInputSourceFromString

public TypedInputSource getTypedInputSourceFromString(String source)
Returns an TypedInputSource whose source is a StringReader populated with the the contents of the String source, assuming the content to be well-formed XML.


processSources

public int processSources(Collection sources)
Processes the available sources, a Collection containing zero or more TypedInputSource objects, using the various parser and processor classes, returning the number of files processed. This resets the Topic Map processor between files.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.