com.simonstl.gorille
Class Ripper

java.lang.Object
  |
  +--com.simonstl.gorille.Ripper

public class Ripper
extends java.lang.Object

A context-aware processor for manipulating markup labels and content. Note that this processor does no DOCTYPE processing. This code is based on the parser from the Tiny API for Markup (TAM), but reports a text version of the document with context rather than abstracting it so heavily to nodes. For more detail on the events that Ripper produces, see the DocProcI class. This class is not particularly elegant, using methods to isolate code for editorial convenience but relying on variables which are global to the class for most communications inside of the parser. This will improve with time, hopefully. The easiest way to use this class is to create a Ripper object and assign a handler (and possibly a context, if you want to use one other than the default), then call the parse() method with an appropriate InputStream. This parser does not presently understand character encodings, and in fact regards the XML declaration as a processing instruction. This will also improve with time.

Author:
simonstl@simonstl.com

Field Summary
protected  java.util.ArrayList attributes
           
 
Constructor Summary
Ripper()
          Creates a new instance of Ripper
 
Method Summary
protected  void error(java.lang.String s)
          errors are reported and processing halts
protected  void fatalError(java.lang.String s)
          fatal errors are reported and processing halts
 ContextI getContext()
           
 int getDiagLimit()
           
 boolean getFeature(java.lang.String name)
           
 DocProcI getHandler()
           
protected  int internalProcessAmpersand(int state)
           
protected  int internalProcessEntities(char currentChar, int state)
           
protected  void lineEndNorm(char currentChar, int state)
           
 void parse(java.io.Reader r)
           
protected  int processAmpersand(int state)
           
protected  int processCDATA(char currentChar, int state)
           
protected  int processComments(char currentChar, int state)
           
protected  int processDOCTYPE(char currentChar, int state)
           
protected  int processEndTag(char currentChar, int state)
           
protected  int processEntities(char currentChar, int state)
           
protected  int processPIs(char currentChar, int state)
           
protected  int processStartTagCollecting(char currentChar, int state)
           
protected  void processStartTagForContext(char currentChar)
           
protected  void processStartTagForReporting(char currentChar)
           
protected  int processXMLDecl(char currentChar, int state)
           
 void setContext(ContextI context)
           
 void setDiagLimit(int limit)
           
 void setFeature(java.lang.String name, boolean value)
           
 void setHandler(DocProcI _handler)
           
 void setMaxBuf(int _size)
           
protected  void startTagDone()
           
protected  void warning(java.lang.String s)
          warnings are reported and processing continues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

protected java.util.ArrayList attributes
Constructor Detail

Ripper

public Ripper()
Creates a new instance of Ripper

Method Detail

setMaxBuf

public void setMaxBuf(int _size)

getHandler

public DocProcI getHandler()

setHandler

public void setHandler(DocProcI _handler)

parse

public void parse(java.io.Reader r)
           throws GorilleException
GorilleException

processAmpersand

protected int processAmpersand(int state)
                        throws GorilleException
GorilleException

internalProcessAmpersand

protected int internalProcessAmpersand(int state)
                                throws GorilleException
GorilleException

processDOCTYPE

protected int processDOCTYPE(char currentChar,
                             int state)
                      throws GorilleException
GorilleException

processComments

protected int processComments(char currentChar,
                              int state)
                       throws GorilleException
GorilleException

processCDATA

protected int processCDATA(char currentChar,
                           int state)
                    throws GorilleException
GorilleException

processXMLDecl

protected int processXMLDecl(char currentChar,
                             int state)
                      throws GorilleException
GorilleException

processPIs

protected int processPIs(char currentChar,
                         int state)
                  throws GorilleException
GorilleException

processEndTag

protected int processEndTag(char currentChar,
                            int state)
                     throws GorilleException
GorilleException

processStartTagCollecting

protected int processStartTagCollecting(char currentChar,
                                        int state)
                                 throws GorilleException
GorilleException

processStartTagForContext

protected void processStartTagForContext(char currentChar)
                                  throws GorilleException
GorilleException

startTagDone

protected void startTagDone()

processStartTagForReporting

protected void processStartTagForReporting(char currentChar)
                                    throws GorilleException
GorilleException

processEntities

protected int processEntities(char currentChar,
                              int state)
                       throws GorilleException
GorilleException

internalProcessEntities

protected int internalProcessEntities(char currentChar,
                                      int state)
                               throws GorilleException
GorilleException

lineEndNorm

protected void lineEndNorm(char currentChar,
                           int state)

fatalError

protected void fatalError(java.lang.String s)
                   throws GorilleException
fatal errors are reported and processing halts

GorilleException

error

protected void error(java.lang.String s)
              throws GorilleException
errors are reported and processing halts

GorilleException

warning

protected void warning(java.lang.String s)
                throws GorilleException
warnings are reported and processing continues

GorilleException

setFeature

public void setFeature(java.lang.String name,
                       boolean value)

getFeature

public boolean getFeature(java.lang.String name)

setContext

public void setContext(ContextI context)

getContext

public ContextI getContext()

setDiagLimit

public void setDiagLimit(int limit)

getDiagLimit

public int getDiagLimit()