FileDocCategorySizeDatePackage
SAX2EventRecorder.javaAPI DocApache Axis 1.411192Sat Apr 22 18:57:28 BST 2006org.apache.axis.message

SAX2EventRecorder

public class SAX2EventRecorder extends Object
This class records SAX2 Events and allows the events to be replayed by start and stop index

Fields Summary
private static final Integer
Z
private static final Integer
STATE_SET_DOCUMENT_LOCATOR
private static final Integer
STATE_START_DOCUMENT
private static final Integer
STATE_END_DOCUMENT
private static final Integer
STATE_START_PREFIX_MAPPING
private static final Integer
STATE_END_PREFIX_MAPPING
private static final Integer
STATE_START_ELEMENT
private static final Integer
STATE_END_ELEMENT
private static final Integer
STATE_CHARACTERS
private static final Integer
STATE_IGNORABLE_WHITESPACE
private static final Integer
STATE_PROCESSING_INSTRUCTION
private static final Integer
STATE_SKIPPED_ENTITY
private static final Integer
STATE_NEWELEMENT
private static final Integer
STATE_START_DTD
private static final Integer
STATE_END_DTD
private static final Integer
STATE_START_ENTITY
private static final Integer
STATE_END_ENTITY
private static final Integer
STATE_START_CDATA
private static final Integer
STATE_END_CDATA
private static final Integer
STATE_COMMENT
Locator
locator
objArrayVector
events
Constructors Summary
Methods Summary
public intcharacters(char[] p1, int p2, int p3)

        return events.add(STATE_CHARACTERS, 
                          (Object)clone(p1, p2, p3), 
                          Z, Z, Z);
    
public voidclear()

    
       
        locator = null;
        events = new objArrayVector();
    
private static char[]clone(char[] in, int off, int len)

        char[] out = new char[len];
        System.arraycopy(in, off, out, 0, len);
        return out;
    
public voidcomment(char[] ch, int start, int length)

        events.add(STATE_COMMENT, 
                   (Object)clone(ch, start, length), 
                   Z, Z, Z);
    
public voidendCDATA()

        events.add(STATE_END_CDATA, Z, Z, Z, Z);
    
public voidendDTD()

        events.add(STATE_END_DTD, Z, Z, Z, Z);
    
public intendDocument()

        return events.add(STATE_END_DOCUMENT, Z,Z,Z,Z);
    
public intendElement(java.lang.String p1, java.lang.String p2, java.lang.String p3)

        return events.add(STATE_END_ELEMENT, p1, p2, p3, Z);
    
public voidendEntity(java.lang.String name)

        events.add(STATE_END_ENTITY, name, Z, Z, Z);
    
public intendPrefixMapping(java.lang.String p1)

        return events.add(STATE_END_PREFIX_MAPPING, p1,Z,Z,Z);
    
public intgetLength()

        return events.getLength();
    
public intignorableWhitespace(char[] p1, int p2, int p3)

        return events.add(STATE_IGNORABLE_WHITESPACE,
                          (Object)clone(p1, p2, p3),
                          Z, Z, Z);
    
public intnewElement(MessageElement elem)

        return events.add(STATE_NEWELEMENT, elem, Z,Z,Z);
    
public intprocessingInstruction(java.lang.String p1, java.lang.String p2)

        return events.add(STATE_PROCESSING_INSTRUCTION, p1, p2, Z,Z);
    
public voidreplay(org.xml.sax.ContentHandler handler)

        if (events.getLength() > 0) {
            replay(0, events.getLength() - 1, handler);
        }
    
public voidreplay(int start, int stop, org.xml.sax.ContentHandler handler)

        // Special case : play the whole thing for [0, -1]
        if ((start == 0) && (stop == -1)) {
            replay(handler);
            return;
        }
        
        if (stop + 1 > events.getLength() ||
            stop < start) {
            return; // should throw an error here
        }        
        
        LexicalHandler lexicalHandler = null;
        if (handler instanceof LexicalHandler) {
            lexicalHandler = (LexicalHandler) handler;
        }
        
        for (int n = start; n <= stop; n++) {
            Object event = events.get(n,0);
            if (event == STATE_START_ELEMENT) {
                handler.startElement((String)events.get(n,1), 
                                     (String)events.get(n,2),
                                     (String)events.get(n,3),
                                     (org.xml.sax.Attributes)events.get(n,4));
                
            } else if (event == STATE_END_ELEMENT) {
                handler.endElement((String)events.get(n,1), 
                                   (String)events.get(n,2),
                                   (String)events.get(n,3));
                
            } else if (event == STATE_CHARACTERS) {
                char[] data = (char[])events.get(n,1);
                handler.characters(data, 0, data.length);
                
            } else if (event == STATE_IGNORABLE_WHITESPACE) {
                char[] data = (char[])events.get(n,1);
                handler.ignorableWhitespace(data, 0, data.length);
                
            } else if (event == STATE_PROCESSING_INSTRUCTION) {
                handler.processingInstruction((String)events.get(n,1),
                                              (String)events.get(n,2));
                
            } else if (event == STATE_SKIPPED_ENTITY) {
                handler.skippedEntity((String)events.get(n,1));
                
            } else if (event == STATE_SET_DOCUMENT_LOCATOR) {
                handler.setDocumentLocator(locator);
                
            } else if (event == STATE_START_DOCUMENT) {
                handler.startDocument();
                
            } else if (event == STATE_END_DOCUMENT) {
                handler.endDocument();
                
            } else if (event == STATE_START_PREFIX_MAPPING) {
                handler.startPrefixMapping((String)events.get(n, 1),
                                           (String)events.get(n, 2));
                
            } else if (event == STATE_END_PREFIX_MAPPING) {
                handler.endPrefixMapping((String)events.get(n, 1));
                
            } else if (event == STATE_START_DTD && lexicalHandler != null) {
                lexicalHandler.startDTD((String)events.get(n,1), 
                                   (String)events.get(n,2),
                                   (String)events.get(n,3));
            } else if (event == STATE_END_DTD && lexicalHandler != null) {
                lexicalHandler.endDTD();
            
            } else if (event == STATE_START_ENTITY && lexicalHandler != null) {
                lexicalHandler.startEntity((String)events.get(n,1));
            
            } else if (event == STATE_END_ENTITY && lexicalHandler != null) {
                lexicalHandler.endEntity((String)events.get(n,1));
            
            } else if (event == STATE_START_CDATA && lexicalHandler != null) {
                lexicalHandler.startCDATA();
            
            } else if (event == STATE_END_CDATA && lexicalHandler != null) {
                lexicalHandler.endCDATA();
            
            } else if (event == STATE_COMMENT && lexicalHandler != null) {
                char[] data = (char[])events.get(n,1);
                lexicalHandler.comment(data, 0, data.length);
            
            } else if (event == STATE_NEWELEMENT) {
                if (handler instanceof DeserializationContext) {
                    DeserializationContext context =
                              (DeserializationContext)handler;
                    context.setCurElement(
                              (MessageElement)(events.get(n,1)));
                }
            }
        }
    
public intsetDocumentLocator(org.xml.sax.Locator p1)

        locator = p1;
        return events.add(STATE_SET_DOCUMENT_LOCATOR, Z,Z,Z,Z);
    
public intskippedEntity(java.lang.String p1)

        return events.add(STATE_SKIPPED_ENTITY, p1, Z,Z,Z);
    
public voidstartCDATA()

        events.add(STATE_START_CDATA, Z, Z, Z, Z);
    
public voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)

        events.add(STATE_START_DTD, name, publicId, systemId, Z);
    
public intstartDocument()

        return events.add(STATE_START_DOCUMENT, Z,Z,Z,Z);
    
public intstartElement(java.lang.String p1, java.lang.String p2, java.lang.String p3, org.xml.sax.Attributes p4)

        return events.add(STATE_START_ELEMENT, p1, p2, p3, p4);
    
public voidstartEntity(java.lang.String name)

        events.add(STATE_START_ENTITY, name, Z, Z, Z);
    
public intstartPrefixMapping(java.lang.String p1, java.lang.String p2)

        return events.add(STATE_START_PREFIX_MAPPING, p1, p2, Z,Z);