FileDocCategorySizeDatePackage
BridgeXmlBlockParser.javaAPI DocAndroid 1.5 API11893Wed May 06 22:42:02 BST 2009com.android.layoutlib.bridge

BridgeXmlBlockParser

public class BridgeXmlBlockParser extends Object implements android.content.res.XmlResourceParser
{@link BridgeXmlBlockParser} reimplements most of android.xml.XmlBlock.Parser. It delegates to both an instance of {@link XmlPullParser} and an instance of {@link XmlPullAttributes} (for the {@link AttributeSet} part).

Fields Summary
private XmlPullParser
mParser
private android.util.XmlPullAttributes
mAttrib
private boolean
mStarted
private boolean
mDecNextDepth
private int
mDepth
private int
mEventType
private final boolean
mPlatformFile
Constructors Summary
public BridgeXmlBlockParser(XmlPullParser parser, BridgeContext context, boolean platformFile)
Builds a {@link BridgeXmlBlockParser}.

param
parser The XmlPullParser to get the content from.
param
context the Context.
param
platformFile Indicates whether the the file is a platform file or not.


                                       
           
        mParser = parser;
        mPlatformFile = platformFile;
        mAttrib = new BridgeXmlPullAttributes(parser, context, mPlatformFile);
    
Methods Summary
public voidclose()

        // pass
    
public voiddefineEntityReplacementText(java.lang.String entityName, java.lang.String replacementText)

        throw new XmlPullParserException(
                "defineEntityReplacementText() not supported");
    
public booleangetAttributeBooleanValue(int index, boolean defaultValue)

        return mAttrib.getAttributeBooleanValue(index, defaultValue);
    
public booleangetAttributeBooleanValue(java.lang.String namespace, java.lang.String attribute, boolean defaultValue)

        return mAttrib.getAttributeBooleanValue(namespace, attribute, defaultValue);
    
public intgetAttributeCount()

        return mParser.getAttributeCount();
    
public floatgetAttributeFloatValue(int index, float defaultValue)

        return mAttrib.getAttributeFloatValue(index, defaultValue);
    
public floatgetAttributeFloatValue(java.lang.String namespace, java.lang.String attribute, float defaultValue)

        return mAttrib.getAttributeFloatValue(namespace, attribute, defaultValue);
    
public intgetAttributeIntValue(int index, int defaultValue)

        return mAttrib.getAttributeIntValue(index, defaultValue);
    
public intgetAttributeIntValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)

        return mAttrib.getAttributeIntValue(namespace, attribute, defaultValue);
    
public intgetAttributeListValue(int index, java.lang.String[] options, int defaultValue)

        return mAttrib.getAttributeListValue(index, options, defaultValue);
    
public intgetAttributeListValue(java.lang.String namespace, java.lang.String attribute, java.lang.String[] options, int defaultValue)

        return mAttrib.getAttributeListValue(namespace, attribute, options, defaultValue);
    
public java.lang.StringgetAttributeName(int index)

        return mParser.getAttributeName(index);
    
public intgetAttributeNameResource(int index)

        return mAttrib.getAttributeNameResource(index);
    
public java.lang.StringgetAttributeNamespace(int index)

        return mParser.getAttributeNamespace(index);
    
public java.lang.StringgetAttributePrefix(int index)

        throw new RuntimeException("getAttributePrefix not supported");
    
public intgetAttributeResourceValue(int index, int defaultValue)

        return mAttrib.getAttributeResourceValue(index, defaultValue);
    
public intgetAttributeResourceValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)

        return mAttrib.getAttributeResourceValue(namespace, attribute, defaultValue);
    
public java.lang.StringgetAttributeType(int index)

        return "CDATA";
    
public intgetAttributeUnsignedIntValue(int index, int defaultValue)

        return mAttrib.getAttributeUnsignedIntValue(index, defaultValue);
    
public intgetAttributeUnsignedIntValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)

        return mAttrib.getAttributeUnsignedIntValue(namespace, attribute, defaultValue);
    
public java.lang.StringgetAttributeValue(int index)

        return mParser.getAttributeValue(index);
    
public java.lang.StringgetAttributeValue(java.lang.String namespace, java.lang.String name)

        return mParser.getAttributeValue(namespace, name);
    
public java.lang.StringgetClassAttribute()

        return mAttrib.getClassAttribute();
    
public intgetColumnNumber()

        return -1;
    
public intgetDepth()

        return mDepth;
    
public intgetEventType()

        return mEventType;
    
public booleangetFeature(java.lang.String name)

        if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
            return true;
        }
        if (FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) {
            return true;
        }
        return false;
    
public java.lang.StringgetIdAttribute()

        return mAttrib.getIdAttribute();
    
public intgetIdAttributeResourceValue(int defaultValue)

        return mAttrib.getIdAttributeResourceValue(defaultValue);
    
public java.lang.StringgetInputEncoding()

        return null;
    
public intgetLineNumber()

        return mParser.getLineNumber();
    
public java.lang.StringgetName()

        return mParser.getName();
    
public java.lang.StringgetNamespace(java.lang.String prefix)

        throw new RuntimeException("getNamespace() not supported");
    
public java.lang.StringgetNamespace()

        return mParser.getNamespace();
    
public intgetNamespaceCount(int depth)

        throw new XmlPullParserException("getNamespaceCount() not supported");
    
public java.lang.StringgetNamespacePrefix(int pos)

        throw new XmlPullParserException("getNamespacePrefix() not supported");
    
public java.lang.StringgetNamespaceUri(int pos)

        throw new XmlPullParserException("getNamespaceUri() not supported");
    
public java.lang.StringgetPositionDescription()

        return "Binary XML file line #" + getLineNumber();
    
public java.lang.StringgetPrefix()

        throw new RuntimeException("getPrefix not supported");
    
public java.lang.ObjectgetProperty(java.lang.String name)

        return null;
    
public intgetStyleAttribute()

        return mAttrib.getStyleAttribute();
    
public java.lang.StringgetText()

        return mParser.getText();
    
public char[]getTextCharacters(int[] holderForStartAndLength)

        String txt = getText();
        char[] chars = null;
        if (txt != null) {
            holderForStartAndLength[0] = 0;
            holderForStartAndLength[1] = txt.length();
            chars = new char[txt.length()];
            txt.getChars(0, txt.length(), chars, 0);
        }
        return chars;
    
public java.lang.ObjectgetViewKey()

        if (mParser instanceof IXmlPullParser) {
            return ((IXmlPullParser)mParser).getViewKey();
        }

        return null;
    
public booleanisAttributeDefault(int index)

        return false;
    
public booleanisEmptyElementTag()

        // XXX Need to detect this.
        return false;
    
public booleanisPlatformFile()

        return mPlatformFile;
    
public booleanisWhitespace()

        // Original comment: whitespace was stripped by aapt.
        return mParser.isWhitespace();
    
public intnext()

        if (!mStarted) {
            mStarted = true;
            return START_DOCUMENT;
        }
        int ev = mParser.next();
        if (mDecNextDepth) {
            mDepth--;
            mDecNextDepth = false;
        }
        switch (ev) {
        case START_TAG:
            mDepth++;
            break;
        case END_TAG:
            mDecNextDepth = true;
            break;
        }
        mEventType = ev;
        return ev;
    
public intnextTag()

        int eventType = next();
        if (eventType == TEXT && isWhitespace()) { // skip whitespace
            eventType = next();
        }
        if (eventType != START_TAG && eventType != END_TAG) {
            throw new XmlPullParserException(getPositionDescription()
                    + ": expected start or end tag", this, null);
        }
        return eventType;
    
public java.lang.StringnextText()

        if (getEventType() != START_TAG) {
            throw new XmlPullParserException(getPositionDescription()
                    + ": parser must be on START_TAG to read next text", this,
                    null);
        }
        int eventType = next();
        if (eventType == TEXT) {
            String result = getText();
            eventType = next();
            if (eventType != END_TAG) {
                throw new XmlPullParserException(
                        getPositionDescription()
                                + ": event TEXT it must be immediately followed by END_TAG",
                        this, null);
            }
            return result;
        } else if (eventType == END_TAG) {
            return "";
        } else {
            throw new XmlPullParserException(getPositionDescription()
                    + ": parser must be on START_TAG or TEXT to read text",
                    this, null);
        }
    
public intnextToken()

        return next();
    
public voidrequire(int type, java.lang.String namespace, java.lang.String name)

        if (type != getEventType()
                || (namespace != null && !namespace.equals(getNamespace()))
                || (name != null && !name.equals(getName())))
            throw new XmlPullParserException("expected " + TYPES[type]
                    + getPositionDescription());
    
public voidsetFeature(java.lang.String name, boolean state)

        if (FEATURE_PROCESS_NAMESPACES.equals(name) && state) {
            return;
        }
        if (FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name) && state) {
            return;
        }
        throw new XmlPullParserException("Unsupported feature: " + name);
    
public voidsetInput(java.io.Reader in)

        mParser.setInput(in);
    
public voidsetInput(java.io.InputStream inputStream, java.lang.String inputEncoding)

        mParser.setInput(inputStream, inputEncoding);
    
public voidsetProperty(java.lang.String name, java.lang.Object value)

        throw new XmlPullParserException("setProperty() not supported");