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_FEATURESAll the parser features currently supported by Android.static String[]UNAVAILABLE_FEATURESAll 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:
setFeaturein interfaceXmlPullParser- Throws:
XmlPullParserException
-
getFeature
public boolean getFeature(String name)
- Specified by:
getFeaturein interfaceXmlPullParser
-
setProperty
public void setProperty(String name, Object value) throws XmlPullParserException
- Specified by:
setPropertyin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getProperty
public Object getProperty(String name)
- Specified by:
getPropertyin interfaceXmlPullParser
-
setInput
public void setInput(Reader in) throws XmlPullParserException
- Specified by:
setInputin interfaceXmlPullParser- Throws:
XmlPullParserException
-
setInput
public void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException
- Specified by:
setInputin interfaceXmlPullParser- Throws:
XmlPullParserException
-
defineEntityReplacementText
public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException
- Specified by:
defineEntityReplacementTextin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getNamespacePrefix
public String getNamespacePrefix(int pos) throws XmlPullParserException
- Specified by:
getNamespacePrefixin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getInputEncoding
public String getInputEncoding()
- Specified by:
getInputEncodingin interfaceXmlPullParser
-
getNamespace
public String getNamespace(String prefix)
- Specified by:
getNamespacein interfaceXmlPullParser
-
getNamespaceCount
public int getNamespaceCount(int depth) throws XmlPullParserException- Specified by:
getNamespaceCountin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getPositionDescription
public String getPositionDescription()
- Specified by:
getPositionDescriptionin interfaceAttributeSet- Specified by:
getPositionDescriptionin interfaceXmlPullParser
-
getNamespaceUri
public String getNamespaceUri(int pos) throws XmlPullParserException
- Specified by:
getNamespaceUriin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumberin interfaceXmlPullParser
-
getDepth
public int getDepth()
- Specified by:
getDepthin interfaceXmlPullParser
-
getText
public String getText()
- Specified by:
getTextin interfaceXmlPullParser
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumberin interfaceXmlPullParser
-
getEventType
public int getEventType() throws XmlPullParserException- Specified by:
getEventTypein interfaceXmlPullParser- Throws:
XmlPullParserException
-
isWhitespace
public boolean isWhitespace(String text) throws XmlPullParserException
- Throws:
XmlPullParserException
-
isWhitespace
public boolean isWhitespace() throws XmlPullParserException- Specified by:
isWhitespacein interfaceXmlPullParser- Throws:
XmlPullParserException
-
getPrefix
public String getPrefix()
- Specified by:
getPrefixin interfaceXmlPullParser
-
getTextCharacters
public char[] getTextCharacters(int[] holderForStartAndLength)
- Specified by:
getTextCharactersin interfaceXmlPullParser
-
getNamespace
public String getNamespace()
- Specified by:
getNamespacein interfaceXmlPullParser
-
getName
public String getName()
- Specified by:
getNamein interfaceXmlPullParser
-
getAttributeNamespace
public String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespacein interfaceAttributeSet- Specified by:
getAttributeNamespacein interfaceXmlPullParser- Specified by:
getAttributeNamespacein interfaceXmlResourceParser
-
getAttributeName
public String getAttributeName(int index)
- Specified by:
getAttributeNamein interfaceAttributeSet- Specified by:
getAttributeNamein interfaceXmlPullParser
-
getAttributePrefix
public String getAttributePrefix(int index)
- Specified by:
getAttributePrefixin interfaceXmlPullParser
-
isEmptyElementTag
public boolean isEmptyElementTag() throws XmlPullParserException- Specified by:
isEmptyElementTagin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCountin interfaceAttributeSet- Specified by:
getAttributeCountin interfaceXmlPullParser
-
getAttributeValue
public String getAttributeValue(int index)
- Specified by:
getAttributeValuein interfaceAttributeSet- Specified by:
getAttributeValuein interfaceXmlPullParser
-
getAttributeType
public String getAttributeType(int index)
- Specified by:
getAttributeTypein interfaceXmlPullParser
-
isAttributeDefault
public boolean isAttributeDefault(int index)
- Specified by:
isAttributeDefaultin interfaceXmlPullParser
-
nextToken
public int nextToken() throws XmlPullParserException, IOException- Specified by:
nextTokenin interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
getAttributeValue
public String getAttributeValue(String namespace, String name)
- Specified by:
getAttributeValuein interfaceAttributeSet- Specified by:
getAttributeValuein interfaceXmlPullParser
-
next
public int next() throws XmlPullParserException, IOException- Specified by:
nextin interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
require
public void require(int type, String namespace, String name) throws XmlPullParserException, IOException- Specified by:
requirein interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
nextText
public String nextText() throws XmlPullParserException, IOException
- Specified by:
nextTextin interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
nextTag
public int nextTag() throws XmlPullParserException, IOException- Specified by:
nextTagin interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
getAttributeNameResource
public int getAttributeNameResource(int index)
- Specified by:
getAttributeNameResourcein interfaceAttributeSet
-
getAttributeListValue
public int getAttributeListValue(String namespace, String attribute, String[] options, int defaultValue)
- Specified by:
getAttributeListValuein interfaceAttributeSet
-
getAttributeBooleanValue
public boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue)
- Specified by:
getAttributeBooleanValuein interfaceAttributeSet
-
getAttributeResourceValue
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue)
- Specified by:
getAttributeResourceValuein interfaceAttributeSet
-
getAttributeIntValue
public int getAttributeIntValue(String namespace, String attribute, int defaultValue)
- Specified by:
getAttributeIntValuein interfaceAttributeSet
-
getAttributeUnsignedIntValue
public int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue)
- Specified by:
getAttributeUnsignedIntValuein interfaceAttributeSet
-
getAttributeFloatValue
public float getAttributeFloatValue(String namespace, String attribute, float defaultValue)
- Specified by:
getAttributeFloatValuein interfaceAttributeSet
-
getAttributeListValue
public int getAttributeListValue(int idx, String[] options, int defaultValue)- Specified by:
getAttributeListValuein interfaceAttributeSet
-
getAttributeBooleanValue
public boolean getAttributeBooleanValue(int idx, boolean defaultValue)- Specified by:
getAttributeBooleanValuein interfaceAttributeSet
-
getAttributeResourceValue
public int getAttributeResourceValue(int idx, int defaultValue)- Specified by:
getAttributeResourceValuein interfaceAttributeSet
-
getAttributeIntValue
public int getAttributeIntValue(int idx, int defaultValue)- Specified by:
getAttributeIntValuein interfaceAttributeSet
-
getAttributeUnsignedIntValue
public int getAttributeUnsignedIntValue(int idx, int defaultValue)- Specified by:
getAttributeUnsignedIntValuein interfaceAttributeSet
-
getAttributeFloatValue
public float getAttributeFloatValue(int idx, float defaultValue)- Specified by:
getAttributeFloatValuein interfaceAttributeSet
-
getIdAttribute
public String getIdAttribute()
- Specified by:
getIdAttributein interfaceAttributeSet
-
getClassAttribute
public String getClassAttribute()
- Specified by:
getClassAttributein interfaceAttributeSet
-
getIdAttributeResourceValue
public int getIdAttributeResourceValue(int defaultValue)
- Specified by:
getIdAttributeResourceValuein interfaceAttributeSet
-
getStyleAttribute
public int getStyleAttribute()
- Specified by:
getStyleAttributein interfaceAttributeSet
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceXmlResourceParser
-
-