public class XmlResourceParserImpl
extends java.lang.Object
implements android.content.res.XmlResourceParser
Concrete implementation of the XmlResourceParser
.
Clients expects a pull parser while the resource loader initialise this object with a Document
. This implementation navigates the dom and emulates a pull parser by raising all the opportune events.
Note that the original android implementation is based on a set of native methods calls. Here those methods are re-implemented in java when possible.
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
AVAILABLE_FEATURES
All the parser features currently supported by Android.
|
static java.lang.String[] |
UNAVAILABLE_FEATURES
All the parser features currently NOT supported by Android.
|
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, FEATURE_PROCESS_DOCDECL, FEATURE_PROCESS_NAMESPACES, FEATURE_REPORT_NAMESPACE_ATTRIBUTES, FEATURE_VALIDATION, IGNORABLE_WHITESPACE, NO_NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT, TYPES
Constructor and Description |
---|
XmlResourceParserImpl(org.w3c.dom.Document document,
java.lang.String fileName,
java.lang.String packageName,
java.lang.String applicationPackageName,
ResourceTable resourceTable) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
defineEntityReplacementText(java.lang.String entityName,
java.lang.String replacementText) |
protected void |
finalize() |
java.lang.String |
getAttribute(java.lang.String namespace,
java.lang.String name) |
boolean |
getAttributeBooleanValue(int idx,
boolean defaultValue) |
boolean |
getAttributeBooleanValue(java.lang.String namespace,
java.lang.String attribute,
boolean defaultValue) |
int |
getAttributeCount() |
float |
getAttributeFloatValue(int idx,
float defaultValue) |
float |
getAttributeFloatValue(java.lang.String namespace,
java.lang.String attribute,
float defaultValue) |
int |
getAttributeIntValue(int idx,
int defaultValue) |
int |
getAttributeIntValue(java.lang.String namespace,
java.lang.String attribute,
int defaultValue) |
int |
getAttributeListValue(int idx,
java.lang.String[] options,
int defaultValue) |
int |
getAttributeListValue(java.lang.String namespace,
java.lang.String attribute,
java.lang.String[] options,
int defaultValue) |
java.lang.String |
getAttributeName(int index) |
int |
getAttributeNameResource(int index) |
java.lang.String |
getAttributeNamespace(int index) |
java.lang.String |
getAttributePrefix(int index) |
int |
getAttributeResourceValue(int idx,
int defaultValue) |
int |
getAttributeResourceValue(java.lang.String namespace,
java.lang.String attribute,
int defaultValue) |
java.lang.String |
getAttributeType(int index) |
int |
getAttributeUnsignedIntValue(int idx,
int defaultValue) |
int |
getAttributeUnsignedIntValue(java.lang.String namespace,
java.lang.String attribute,
int defaultValue) |
java.lang.String |
getAttributeValue(int index) |
java.lang.String |
getAttributeValue(java.lang.String namespace,
java.lang.String name) |
java.lang.String |
getClassAttribute() |
int |
getColumnNumber() |
int |
getDepth() |
int |
getEventType() |
boolean |
getFeature(java.lang.String name) |
java.lang.String |
getIdAttribute() |
int |
getIdAttributeResourceValue(int defaultValue) |
java.lang.String |
getInputEncoding() |
int |
getLineNumber() |
java.lang.String |
getName() |
java.lang.String |
getNamespace() |
java.lang.String |
getNamespace(java.lang.String prefix) |
int |
getNamespaceCount(int depth) |
java.lang.String |
getNamespacePrefix(int pos) |
java.lang.String |
getNamespaceUri(int pos) |
java.lang.String |
getPositionDescription() |
java.lang.String |
getPrefix() |
java.lang.Object |
getProperty(java.lang.String name) |
int |
getStyleAttribute() |
java.lang.String |
getText() |
char[] |
getTextCharacters(int[] holderForStartAndLength) |
boolean |
isAttributeDefault(int index) |
boolean |
isEmptyElementTag() |
boolean |
isWhitespace() |
boolean |
isWhitespace(java.lang.String text) |
int |
next() |
int |
nextTag() |
java.lang.String |
nextText() |
int |
nextToken() |
java.lang.String |
qualify(java.lang.String value) |
void |
require(int type,
java.lang.String namespace,
java.lang.String name) |
void |
setFeature(java.lang.String name,
boolean state) |
void |
setInput(java.io.InputStream inputStream,
java.lang.String inputEncoding) |
void |
setInput(java.io.Reader in) |
void |
setProperty(java.lang.String name,
java.lang.Object value) |
public static final java.lang.String[] AVAILABLE_FEATURES
All the parser features currently supported by Android.
public static final java.lang.String[] UNAVAILABLE_FEATURES
All the parser features currently NOT supported by Android.
public XmlResourceParserImpl(org.w3c.dom.Document document, java.lang.String fileName, java.lang.String packageName, java.lang.String applicationPackageName, ResourceTable resourceTable)
public void setFeature(java.lang.String name, boolean state) throws org.xmlpull.v1.XmlPullParserException
setFeature
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public boolean getFeature(java.lang.String name)
getFeature
in interface org.xmlpull.v1.XmlPullParser
public void setProperty(java.lang.String name, java.lang.Object value) throws org.xmlpull.v1.XmlPullParserException
setProperty
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface org.xmlpull.v1.XmlPullParser
public void setInput(java.io.Reader in) throws org.xmlpull.v1.XmlPullParserException
setInput
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public void setInput(java.io.InputStream inputStream, java.lang.String inputEncoding) throws org.xmlpull.v1.XmlPullParserException
setInput
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public void defineEntityReplacementText(java.lang.String entityName, java.lang.String replacementText) throws org.xmlpull.v1.XmlPullParserException
defineEntityReplacementText
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public java.lang.String getNamespacePrefix(int pos) throws org.xmlpull.v1.XmlPullParserException
getNamespacePrefix
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public java.lang.String getInputEncoding()
getInputEncoding
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getNamespace(java.lang.String prefix)
getNamespace
in interface org.xmlpull.v1.XmlPullParser
public int getNamespaceCount(int depth) throws org.xmlpull.v1.XmlPullParserException
getNamespaceCount
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public java.lang.String getPositionDescription()
getPositionDescription
in interface android.util.AttributeSet
getPositionDescription
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getNamespaceUri(int pos) throws org.xmlpull.v1.XmlPullParserException
getNamespaceUri
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public int getColumnNumber()
getColumnNumber
in interface org.xmlpull.v1.XmlPullParser
public int getDepth()
getDepth
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getText()
getText
in interface org.xmlpull.v1.XmlPullParser
public int getLineNumber()
getLineNumber
in interface org.xmlpull.v1.XmlPullParser
public int getEventType() throws org.xmlpull.v1.XmlPullParserException
getEventType
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public boolean isWhitespace(java.lang.String text) throws org.xmlpull.v1.XmlPullParserException
org.xmlpull.v1.XmlPullParserException
public boolean isWhitespace() throws org.xmlpull.v1.XmlPullParserException
isWhitespace
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public java.lang.String getPrefix()
getPrefix
in interface org.xmlpull.v1.XmlPullParser
public char[] getTextCharacters(int[] holderForStartAndLength)
getTextCharacters
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getNamespace()
getNamespace
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getName()
getName
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getAttribute(java.lang.String namespace, java.lang.String name)
public java.lang.String getAttributeNamespace(int index)
getAttributeNamespace
in interface android.content.res.XmlResourceParser
getAttributeNamespace
in interface android.util.AttributeSet
getAttributeNamespace
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getAttributeName(int index)
getAttributeName
in interface android.util.AttributeSet
getAttributeName
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getAttributePrefix(int index)
getAttributePrefix
in interface org.xmlpull.v1.XmlPullParser
public boolean isEmptyElementTag() throws org.xmlpull.v1.XmlPullParserException
isEmptyElementTag
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
public int getAttributeCount()
getAttributeCount
in interface android.util.AttributeSet
getAttributeCount
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String getAttributeValue(int index)
getAttributeValue
in interface android.util.AttributeSet
getAttributeValue
in interface org.xmlpull.v1.XmlPullParser
public java.lang.String qualify(java.lang.String value)
public java.lang.String getAttributeType(int index)
getAttributeType
in interface org.xmlpull.v1.XmlPullParser
public boolean isAttributeDefault(int index)
isAttributeDefault
in interface org.xmlpull.v1.XmlPullParser
public int nextToken() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
nextToken
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
java.io.IOException
public java.lang.String getAttributeValue(java.lang.String namespace, java.lang.String name)
getAttributeValue
in interface android.util.AttributeSet
getAttributeValue
in interface org.xmlpull.v1.XmlPullParser
public int next() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
next
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
java.io.IOException
public void require(int type, java.lang.String namespace, java.lang.String name) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
require
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
java.io.IOException
public java.lang.String nextText() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
nextText
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
java.io.IOException
public int nextTag() throws org.xmlpull.v1.XmlPullParserException, java.io.IOException
nextTag
in interface org.xmlpull.v1.XmlPullParser
org.xmlpull.v1.XmlPullParserException
java.io.IOException
public int getAttributeNameResource(int index)
getAttributeNameResource
in interface android.util.AttributeSet
public int getAttributeListValue(java.lang.String namespace, java.lang.String attribute, java.lang.String[] options, int defaultValue)
getAttributeListValue
in interface android.util.AttributeSet
public boolean getAttributeBooleanValue(java.lang.String namespace, java.lang.String attribute, boolean defaultValue)
getAttributeBooleanValue
in interface android.util.AttributeSet
public int getAttributeResourceValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)
getAttributeResourceValue
in interface android.util.AttributeSet
public int getAttributeIntValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)
getAttributeIntValue
in interface android.util.AttributeSet
public int getAttributeUnsignedIntValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)
getAttributeUnsignedIntValue
in interface android.util.AttributeSet
public float getAttributeFloatValue(java.lang.String namespace, java.lang.String attribute, float defaultValue)
getAttributeFloatValue
in interface android.util.AttributeSet
public int getAttributeListValue(int idx, java.lang.String[] options, int defaultValue)
getAttributeListValue
in interface android.util.AttributeSet
public boolean getAttributeBooleanValue(int idx, boolean defaultValue)
getAttributeBooleanValue
in interface android.util.AttributeSet
public int getAttributeResourceValue(int idx, int defaultValue)
getAttributeResourceValue
in interface android.util.AttributeSet
public int getAttributeIntValue(int idx, int defaultValue)
getAttributeIntValue
in interface android.util.AttributeSet
public int getAttributeUnsignedIntValue(int idx, int defaultValue)
getAttributeUnsignedIntValue
in interface android.util.AttributeSet
public float getAttributeFloatValue(int idx, float defaultValue)
getAttributeFloatValue
in interface android.util.AttributeSet
public java.lang.String getIdAttribute()
getIdAttribute
in interface android.util.AttributeSet
public java.lang.String getClassAttribute()
getClassAttribute
in interface android.util.AttributeSet
public int getIdAttributeResourceValue(int defaultValue)
getIdAttributeResourceValue
in interface android.util.AttributeSet
public int getStyleAttribute()
getStyleAttribute
in interface android.util.AttributeSet
public void close()
close
in interface android.content.res.XmlResourceParser
close
in interface java.lang.AutoCloseable
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable