Package org.robolectric.android
Class XmlResourceParserImpl
- java.lang.Object
-
- org.robolectric.android.XmlResourceParserImpl
-
- All Implemented Interfaces:
XmlResourceParser
,AttributeSet
,AutoCloseable
,XmlPullParser
public class XmlResourceParserImpl extends Object implements XmlResourceParser
Concrete implementation of theXmlResourceParser
. Clients expects a pull parser while the resource loader initialise this object with aDocument
. 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.
-
-
Field Summary
Fields Modifier and Type Field Description static String[]
AVAILABLE_FEATURES
All the parser features currently supported by Android.static String[]
UNAVAILABLE_FEATURES
All the parser features currently NOT supported by Android.-
Fields inherited from interface org.xmlpull.v1.XmlPullParser
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 Summary
Constructors Constructor Description XmlResourceParserImpl(Document document, String fileName, String packageName, String applicationPackageName, ResourceTable resourceTable)
Deprecated.XmlResourceParserImpl(Document document, Path fileName, String packageName, String applicationPackageName, ResourceTable resourceTable)
-
Method Summary
-
-
-
Constructor Detail
-
XmlResourceParserImpl
@Deprecated public XmlResourceParserImpl(Document document, String fileName, String packageName, String applicationPackageName, ResourceTable resourceTable)
Deprecated.
-
XmlResourceParserImpl
public XmlResourceParserImpl(Document document, Path fileName, String packageName, String applicationPackageName, ResourceTable resourceTable)
-
-
Method Detail
-
setFeature
public void setFeature(String name, boolean state) throws XmlPullParserException
- Specified by:
setFeature
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getFeature
public boolean getFeature(String name)
- Specified by:
getFeature
in interfaceXmlPullParser
-
setProperty
public void setProperty(String name, Object value) throws XmlPullParserException
- Specified by:
setProperty
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getProperty
public Object getProperty(String name)
- Specified by:
getProperty
in interfaceXmlPullParser
-
setInput
public void setInput(Reader in) throws XmlPullParserException
- Specified by:
setInput
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
setInput
public void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException
- Specified by:
setInput
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
defineEntityReplacementText
public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException
- Specified by:
defineEntityReplacementText
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getNamespacePrefix
public String getNamespacePrefix(int pos) throws XmlPullParserException
- Specified by:
getNamespacePrefix
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getInputEncoding
public String getInputEncoding()
- Specified by:
getInputEncoding
in interfaceXmlPullParser
-
getNamespace
public String getNamespace(String prefix)
- Specified by:
getNamespace
in interfaceXmlPullParser
-
getNamespaceCount
public int getNamespaceCount(int depth) throws XmlPullParserException
- Specified by:
getNamespaceCount
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getPositionDescription
public String getPositionDescription()
- Specified by:
getPositionDescription
in interfaceAttributeSet
- Specified by:
getPositionDescription
in interfaceXmlPullParser
-
getNamespaceUri
public String getNamespaceUri(int pos) throws XmlPullParserException
- Specified by:
getNamespaceUri
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumber
in interfaceXmlPullParser
-
getDepth
public int getDepth()
- Specified by:
getDepth
in interfaceXmlPullParser
-
getText
public String getText()
- Specified by:
getText
in interfaceXmlPullParser
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumber
in interfaceXmlPullParser
-
getEventType
public int getEventType() throws XmlPullParserException
- Specified by:
getEventType
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
isWhitespace
public boolean isWhitespace(String text) throws XmlPullParserException
- Throws:
XmlPullParserException
-
isWhitespace
public boolean isWhitespace() throws XmlPullParserException
- Specified by:
isWhitespace
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getPrefix
public String getPrefix()
- Specified by:
getPrefix
in interfaceXmlPullParser
-
getTextCharacters
public char[] getTextCharacters(int[] holderForStartAndLength)
- Specified by:
getTextCharacters
in interfaceXmlPullParser
-
getNamespace
public String getNamespace()
- Specified by:
getNamespace
in interfaceXmlPullParser
-
getName
public String getName()
- Specified by:
getName
in interfaceXmlPullParser
-
getAttributeNamespace
public String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespace
in interfaceAttributeSet
- Specified by:
getAttributeNamespace
in interfaceXmlPullParser
- Specified by:
getAttributeNamespace
in interfaceXmlResourceParser
-
getAttributeName
public String getAttributeName(int index)
- Specified by:
getAttributeName
in interfaceAttributeSet
- Specified by:
getAttributeName
in interfaceXmlPullParser
-
getAttributePrefix
public String getAttributePrefix(int index)
- Specified by:
getAttributePrefix
in interfaceXmlPullParser
-
isEmptyElementTag
public boolean isEmptyElementTag() throws XmlPullParserException
- Specified by:
isEmptyElementTag
in interfaceXmlPullParser
- Throws:
XmlPullParserException
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCount
in interfaceAttributeSet
- Specified by:
getAttributeCount
in interfaceXmlPullParser
-
getAttributeValue
public String getAttributeValue(int index)
- Specified by:
getAttributeValue
in interfaceAttributeSet
- Specified by:
getAttributeValue
in interfaceXmlPullParser
-
getAttributeType
public String getAttributeType(int index)
- Specified by:
getAttributeType
in interfaceXmlPullParser
-
isAttributeDefault
public boolean isAttributeDefault(int index)
- Specified by:
isAttributeDefault
in interfaceXmlPullParser
-
nextToken
public int nextToken() throws XmlPullParserException, IOException
- Specified by:
nextToken
in interfaceXmlPullParser
- Throws:
XmlPullParserException
IOException
-
getAttributeValue
public String getAttributeValue(String namespace, String name)
- Specified by:
getAttributeValue
in interfaceAttributeSet
- Specified by:
getAttributeValue
in interfaceXmlPullParser
-
next
public int next() throws XmlPullParserException, IOException
- Specified by:
next
in interfaceXmlPullParser
- Throws:
XmlPullParserException
IOException
-
require
public void require(int type, String namespace, String name) throws XmlPullParserException, IOException
- Specified by:
require
in interfaceXmlPullParser
- Throws:
XmlPullParserException
IOException
-
nextText
public String nextText() throws XmlPullParserException, IOException
- Specified by:
nextText
in interfaceXmlPullParser
- Throws:
XmlPullParserException
IOException
-
nextTag
public int nextTag() throws XmlPullParserException, IOException
- Specified by:
nextTag
in interfaceXmlPullParser
- Throws:
XmlPullParserException
IOException
-
getAttributeNameResource
public int getAttributeNameResource(int index)
- Specified by:
getAttributeNameResource
in interfaceAttributeSet
-
getAttributeListValue
public int getAttributeListValue(String namespace, String attribute, String[] options, int defaultValue)
- Specified by:
getAttributeListValue
in interfaceAttributeSet
-
getAttributeBooleanValue
public boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue)
- Specified by:
getAttributeBooleanValue
in interfaceAttributeSet
-
getAttributeResourceValue
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue)
- Specified by:
getAttributeResourceValue
in interfaceAttributeSet
-
getAttributeIntValue
public int getAttributeIntValue(String namespace, String attribute, int defaultValue)
- Specified by:
getAttributeIntValue
in interfaceAttributeSet
-
getAttributeUnsignedIntValue
public int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue)
- Specified by:
getAttributeUnsignedIntValue
in interfaceAttributeSet
-
getAttributeFloatValue
public float getAttributeFloatValue(String namespace, String attribute, float defaultValue)
- Specified by:
getAttributeFloatValue
in interfaceAttributeSet
-
getAttributeListValue
public int getAttributeListValue(int idx, String[] options, int defaultValue)
- Specified by:
getAttributeListValue
in interfaceAttributeSet
-
getAttributeBooleanValue
public boolean getAttributeBooleanValue(int idx, boolean defaultValue)
- Specified by:
getAttributeBooleanValue
in interfaceAttributeSet
-
getAttributeResourceValue
public int getAttributeResourceValue(int idx, int defaultValue)
- Specified by:
getAttributeResourceValue
in interfaceAttributeSet
-
getAttributeIntValue
public int getAttributeIntValue(int idx, int defaultValue)
- Specified by:
getAttributeIntValue
in interfaceAttributeSet
-
getAttributeUnsignedIntValue
public int getAttributeUnsignedIntValue(int idx, int defaultValue)
- Specified by:
getAttributeUnsignedIntValue
in interfaceAttributeSet
-
getAttributeFloatValue
public float getAttributeFloatValue(int idx, float defaultValue)
- Specified by:
getAttributeFloatValue
in interfaceAttributeSet
-
getIdAttribute
public String getIdAttribute()
- Specified by:
getIdAttribute
in interfaceAttributeSet
-
getClassAttribute
public String getClassAttribute()
- Specified by:
getClassAttribute
in interfaceAttributeSet
-
getIdAttributeResourceValue
public int getIdAttributeResourceValue(int defaultValue)
- Specified by:
getIdAttributeResourceValue
in interfaceAttributeSet
-
getStyleAttribute
public int getStyleAttribute()
- Specified by:
getStyleAttribute
in interfaceAttributeSet
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceXmlResourceParser
-
-