FileDocCategorySizeDatePackage
WbxmlParser.javaAPI DocAndroid 1.5 API6184Wed May 06 22:42:46 BST 2009com.android.im.imps

WbxmlParser

public final class WbxmlParser extends Object

Fields Summary
private static final int
BUFFER_SIZE
private ContentHandler
mContentHandler
private int
mNativeParser
private AttributesImpl
atts
Constructors Summary
public WbxmlParser()


      
        atts = new AttributesImpl();
        mNativeParser = nativeCreate("UTF-8");
        if (mNativeParser == 0) {
            throw new OutOfMemoryError();
        }
    
Methods Summary
voidcharacters(char[] ch, int length)

        if(mContentHandler != null) {
            mContentHandler.characters(ch, 0, length);
        }
    
voidendElement(java.lang.String name)

        if(mContentHandler != null) {
            mContentHandler.endElement("", name, name);
        }
    
protected voidfinalize()

        if (mNativeParser != 0) {
            nativeRelease(mNativeParser);
        }
    
native intnativeCreate(java.lang.String encoding)

native voidnativeParse(int nativeParser, byte[] ch, int length, boolean isEnd)

native voidnativeRelease(int nativeParser)

native voidnativeReset(int nativeParser)

static native voidnativeStaticInitialize()

public voidparse(org.xml.sax.InputSource in)

        InputStream byteStream = in.getByteStream();
        byte[] buffer = new byte[BUFFER_SIZE];
        int length;
        // FIXME: nativeParse should throw ParserException but the dalvik
        // seems to have problem throwing non-system exceptions from JNI
        // code. Use IAE for now and file a bug report for this.
        try {
            while ((length = byteStream.read(buffer)) != -1) {
                nativeParse(mNativeParser, buffer, length, false);
            }
            nativeParse(mNativeParser, new byte[1], 0, true);
        } catch (IllegalArgumentException e) {
            throw new ParserException(e);
        }
    
public voidreset()

        if (mNativeParser != 0) {
            nativeReset(mNativeParser);
        }
        atts.names = null;
        atts.values = null;
        mContentHandler = null;
    
public voidsetContentHandler(org.xml.sax.ContentHandler contentHandler)

        mContentHandler = contentHandler;
    
voidstartElement(java.lang.String name, java.lang.String[] attrNames, java.lang.String[] attrValues)

        atts.names = attrNames;
        atts.values = attrValues;
        if(mContentHandler != null) {
            mContentHandler.startElement("", name, name, atts);
        }