Package org.robolectric.android
Class XmlResourceParserImpl
java.lang.Object
org.robolectric.android.XmlResourceParserImpl
- All Implemented Interfaces:
XmlResourceParser,AttributeSet,AutoCloseable,XmlPullParser
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]All the parser features currently supported by Android.static final String[]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
ConstructorsConstructorDescriptionXmlResourceParserImpl(Document document, String fileName, String packageName, String applicationPackageName, ResourceTable resourceTable) Deprecated.XmlResourceParserImpl(Document document, Path fileName, String packageName, String applicationPackageName, ResourceTable resourceTable) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voiddefineEntityReplacementText(String entityName, String replacementText) protected voidfinalize()getAttribute(String namespace, String name) booleangetAttributeBooleanValue(int idx, boolean defaultValue) booleangetAttributeBooleanValue(String namespace, String attribute, boolean defaultValue) intfloatgetAttributeFloatValue(int idx, float defaultValue) floatgetAttributeFloatValue(String namespace, String attribute, float defaultValue) intgetAttributeIntValue(int idx, int defaultValue) intgetAttributeIntValue(String namespace, String attribute, int defaultValue) intgetAttributeListValue(int idx, String[] options, int defaultValue) intgetAttributeListValue(String namespace, String attribute, String[] options, int defaultValue) getAttributeName(int index) intgetAttributeNameResource(int index) getAttributeNamespace(int index) getAttributePrefix(int index) intgetAttributeResourceValue(int idx, int defaultValue) intgetAttributeResourceValue(String namespace, String attribute, int defaultValue) getAttributeType(int index) intgetAttributeUnsignedIntValue(int idx, int defaultValue) intgetAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue) getAttributeValue(int index) getAttributeValue(String namespace, String name) intintgetDepth()intbooleangetFeature(String name) intgetIdAttributeResourceValue(int defaultValue) intgetName()getNamespace(String prefix) intgetNamespaceCount(int depth) getNamespacePrefix(int pos) getNamespaceUri(int pos) getProperty(String name) intgetText()char[]getTextCharacters(int[] holderForStartAndLength) booleanisAttributeDefault(int index) booleanbooleanbooleanisWhitespace(String text) intnext()intnextTag()nextText()intvoidvoidsetFeature(String name, boolean state) voidsetInput(InputStream inputStream, String inputEncoding) voidvoidsetProperty(String name, Object value)
-
Field Details
-
AVAILABLE_FEATURES
All the parser features currently supported by Android. -
UNAVAILABLE_FEATURES
All the parser features currently NOT supported by Android.
-
-
Constructor Details
-
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 Details
-
setFeature
- Specified by:
setFeaturein interfaceXmlPullParser- Throws:
XmlPullParserException
-
getFeature
- Specified by:
getFeaturein interfaceXmlPullParser
-
setProperty
- Specified by:
setPropertyin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getProperty
- Specified by:
getPropertyin interfaceXmlPullParser
-
setInput
- Specified by:
setInputin interfaceXmlPullParser- Throws:
XmlPullParserException
-
setInput
- Specified by:
setInputin interfaceXmlPullParser- Throws:
XmlPullParserException
-
defineEntityReplacementText
public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException - Specified by:
defineEntityReplacementTextin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getInputEncoding
- Specified by:
getInputEncodingin interfaceXmlPullParser
-
getNamespace
- Specified by:
getNamespacein interfaceXmlPullParser
-
getNamespaceCount
- Specified by:
getNamespaceCountin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getPositionDescription
- Specified by:
getPositionDescriptionin interfaceAttributeSet- Specified by:
getPositionDescriptionin interfaceXmlPullParser
-
getNamespaceUri
- Specified by:
getNamespaceUriin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumberin interfaceXmlPullParser
-
getDepth
public int getDepth()- Specified by:
getDepthin interfaceXmlPullParser
-
getText
- Specified by:
getTextin interfaceXmlPullParser
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceXmlPullParser
-
getEventType
- Specified by:
getEventTypein interfaceXmlPullParser- Throws:
XmlPullParserException
-
isWhitespace
- Throws:
XmlPullParserException
-
isWhitespace
- Specified by:
isWhitespacein interfaceXmlPullParser- Throws:
XmlPullParserException
-
getPrefix
- Specified by:
getPrefixin interfaceXmlPullParser
-
getTextCharacters
public char[] getTextCharacters(int[] holderForStartAndLength) - Specified by:
getTextCharactersin interfaceXmlPullParser
-
getNamespace
- Specified by:
getNamespacein interfaceXmlPullParser
-
getName
- Specified by:
getNamein interfaceXmlPullParser
-
getAttribute
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceAttributeSet- Specified by:
getAttributeNamespacein interfaceXmlPullParser- Specified by:
getAttributeNamespacein interfaceXmlResourceParser
-
getAttributeName
- Specified by:
getAttributeNamein interfaceAttributeSet- Specified by:
getAttributeNamein interfaceXmlPullParser
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceXmlPullParser
-
isEmptyElementTag
- Specified by:
isEmptyElementTagin interfaceXmlPullParser- Throws:
XmlPullParserException
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCountin interfaceAttributeSet- Specified by:
getAttributeCountin interfaceXmlPullParser
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceAttributeSet- Specified by:
getAttributeValuein interfaceXmlPullParser
-
qualify
-
getAttributeType
- Specified by:
getAttributeTypein interfaceXmlPullParser
-
isAttributeDefault
public boolean isAttributeDefault(int index) - Specified by:
isAttributeDefaultin interfaceXmlPullParser
-
nextToken
- Specified by:
nextTokenin interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceAttributeSet- Specified by:
getAttributeValuein interfaceXmlPullParser
-
next
- 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
- Specified by:
nextTextin interfaceXmlPullParser- Throws:
XmlPullParserExceptionIOException
-
nextTag
- 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
- Specified by:
getAttributeBooleanValuein interfaceAttributeSet
-
getAttributeResourceValue
- Specified by:
getAttributeResourceValuein interfaceAttributeSet
-
getAttributeIntValue
- Specified by:
getAttributeIntValuein interfaceAttributeSet
-
getAttributeUnsignedIntValue
- Specified by:
getAttributeUnsignedIntValuein interfaceAttributeSet
-
getAttributeFloatValue
- Specified by:
getAttributeFloatValuein interfaceAttributeSet
-
getAttributeListValue
- 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
- Specified by:
getIdAttributein interfaceAttributeSet
-
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
-
finalize
-
XmlResourceParserImpl(Document, Path, String, String, ResourceTable)instead.