LayoutParserWrapper.java revision f129fdf7257bd8f90f1ec1766f0a5b3573509704
197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta/* 297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * Copyright (C) 2015 The Android Open Source Project 397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * 497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * Licensed under the Apache License, Version 2.0 (the "License"); 597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * you may not use this file except in compliance with the License. 697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * You may obtain a copy of the License at 797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * 897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * http://www.apache.org/licenses/LICENSE-2.0 997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * 1097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * Unless required by applicable law or agreed to in writing, software 1197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * distributed under the License is distributed on an "AS IS" BASIS, 1297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * See the License for the specific language governing permissions and 1497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * limitations under the License. 1597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta */ 1697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 1797ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptapackage com.android.layoutlib.bridge.impl; 1897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 1997ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport org.xmlpull.v1.XmlPullParser; 2097ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport org.xmlpull.v1.XmlPullParserException; 2197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 2297ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport android.annotation.Nullable; 2397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 2497ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport java.io.IOException; 2597ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport java.io.InputStream; 2697ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport java.io.Reader; 2797ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport java.util.ArrayList; 2897ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport java.util.Collections; 2997ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptaimport java.util.List; 3097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 3197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta/** 3297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * A wrapper around XmlPullParser that can peek forward to inspect if the file is a data-binding 3397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta * layout and some parts need to be stripped. 3497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta */ 3597ec082dda2f1ca25d38437716583c8254740866Deepanshu Guptapublic class LayoutParserWrapper implements XmlPullParser { 3697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 3797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // Data binding constants. 3897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private static final String TAG_LAYOUT = "layout"; 3997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private static final String TAG_DATA = "data"; 4097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private static final String DEFAULT = "default="; 4197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 4297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private final XmlPullParser mDelegate; 4397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 4497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // Storage for peeked values. 4597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private boolean mPeeked; 4697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private int mEventType; 4797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private int mDepth; 4897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private int mNext; 4997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private List<Attribute> mAttributes; 5097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private String mText; 5197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private String mName; 5297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 5397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // Used to end the document before the actual parser ends. 5497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private int mFinalDepth = -1; 5597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private boolean mEndNow; 5697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 5797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public LayoutParserWrapper(XmlPullParser delegate) { 5897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDelegate = delegate; 5997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 6097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 6197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public LayoutParserWrapper peekTillLayoutStart() throws IOException, XmlPullParserException { 6297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta final int STATE_LAYOUT_NOT_STARTED = 0; // <layout> tag not encountered yet. 6397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta final int STATE_ROOT_NOT_STARTED = 1; // the main view root not found yet. 6497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta final int STATE_INSIDE_DATA = 2; // START_TAG for <data> found, but not END_TAG. 6597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 6697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int state = STATE_LAYOUT_NOT_STARTED; 6797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int dataDepth = -1; // depth of the <data> tag. Should be two. 6897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta while (true) { 6997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int peekNext = peekNext(); 7097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta switch (peekNext) { 7197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta case START_TAG: 7297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (state == STATE_LAYOUT_NOT_STARTED) { 7397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mName.equals(TAG_LAYOUT)) { 7497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta state = STATE_ROOT_NOT_STARTED; 7597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else { 7697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return this; // no layout tag in the file. 7797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 7897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else if (state == STATE_ROOT_NOT_STARTED) { 7997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mName.equals(TAG_DATA)) { 8097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta state = STATE_INSIDE_DATA; 8197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta dataDepth = mDepth; 8297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else { 8397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mFinalDepth = mDepth; 8497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return this; 8597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 8697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 8797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta break; 8897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta case END_TAG: 8997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (state == STATE_INSIDE_DATA) { 9097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mDepth <= dataDepth) { 9197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta state = STATE_ROOT_NOT_STARTED; 9297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 9397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 9497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta break; 9597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta case END_DOCUMENT: 9697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // No layout start found. 9797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return this; 9897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 9997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // consume the peeked tag. 10097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta next(); 10197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 10297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 10397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 10497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private int peekNext() throws IOException, XmlPullParserException { 10597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mPeeked) { 10697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mNext; 10797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 10897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mEventType = mDelegate.getEventType(); 10997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mNext = mDelegate.next(); 11097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mEventType == START_TAG) { 11197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int count = mDelegate.getAttributeCount(); 11297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mAttributes = count > 0 ? new ArrayList<Attribute>(count) : 11397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta Collections.<Attribute>emptyList(); 11497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta for (int i = 0; i < count; i++) { 11597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mAttributes.add(new Attribute(mDelegate.getAttributeNamespace(i), 11697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDelegate.getAttributeName(i), mDelegate.getAttributeValue(i))); 11797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 11897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 11997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDepth = mDelegate.getDepth(); 12097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mText = mDelegate.getText(); 12197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mName = mDelegate.getName(); 12297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mPeeked = true; 12397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mNext; 12497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 12597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 12697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private void reset() { 12797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mAttributes = null; 12897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mText = null; 12997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mName = null; 13097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mPeeked = false; 13197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 13297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 13397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 13497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int next() throws XmlPullParserException, IOException { 13597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int returnValue; 13697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int depth; 13797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mPeeked) { 13897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta returnValue = mNext; 13997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta depth = mDepth; 14097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta reset(); 14197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else if (mEndNow) { 14297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return END_DOCUMENT; 14397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else { 14497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta returnValue = mDelegate.next(); 14597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta depth = getDepth(); 14697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 14797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (returnValue == END_TAG && depth <= mFinalDepth) { 14897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mEndNow = true; 14997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 15097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return returnValue; 15197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 15297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 15397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 15497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int getEventType() throws XmlPullParserException { 15597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mPeeked ? mEventType : mDelegate.getEventType(); 15697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 15797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 15897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 15997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int getDepth() { 16097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mPeeked ? mDepth : mDelegate.getDepth(); 16197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 16297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 16397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 16497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getName() { 16597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mPeeked ? mName : mDelegate.getName(); 16697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 16797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 16897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 16997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getText() { 17097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mPeeked ? mText : mDelegate.getText(); 17197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 17297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 17397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 17497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getAttributeValue(@Nullable String namespace, String name) { 17597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta String returnValue = null; 17697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mPeeked) { 17797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mAttributes == null) { 17897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (mEventType != START_TAG) { 179f129fdf7257bd8f90f1ec1766f0a5b3573509704Deepanshu Gupta throw new IndexOutOfBoundsException("getAttributeValue() called when not at START_TAG."); 18097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else { 18197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return null; 18297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 18397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else { 18497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta for (Attribute attribute : mAttributes) { 18597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta //noinspection StringEquality for nullness check. 18697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (attribute.name.equals(name) && (attribute.namespace == namespace || 18797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta attribute.namespace != null && attribute.namespace.equals(namespace))) { 18897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta returnValue = attribute.value; 18997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta break; 19097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 19197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 19297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 19397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } else { 19497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta returnValue = mDelegate.getAttributeValue(namespace, name); 19597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 19697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // Check if the value is bound via data-binding, if yes get the default value. 19797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta if (returnValue != null && mFinalDepth >= 0 && returnValue.startsWith("@{")) { 19897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // TODO: Improve the detection of default keyword. 19997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta int i = returnValue.lastIndexOf(DEFAULT); 20097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return i > 0 ? returnValue.substring(i + DEFAULT.length(), returnValue.length() - 1) 20197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta : null; 20297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 20397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return returnValue; 20497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 20597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 20697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta private static class Attribute { 20797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Nullable 20897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public final String namespace; 20997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public final String name; 21097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public final String value; 21197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 21297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public Attribute(@Nullable String namespace, String name, String value) { 21397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta this.namespace = namespace; 21497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta this.name = name; 21597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta this.value = value; 21697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 21797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 21897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 21997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // Not affected by peeking. 22097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 22197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 22297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public void setFeature(String s, boolean b) throws XmlPullParserException { 22397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDelegate.setFeature(s, b); 22497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 22597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 22697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 22797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public void setProperty(String s, Object o) throws XmlPullParserException { 22897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDelegate.setProperty(s, o); 22997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 23097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 23197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 23297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public void setInput(InputStream inputStream, String s) throws XmlPullParserException { 23397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDelegate.setInput(inputStream, s); 23497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 23597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 23697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 23797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public void setInput(Reader reader) throws XmlPullParserException { 23897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta mDelegate.setInput(reader); 23997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 24097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 24197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 24297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getInputEncoding() { 24397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mDelegate.getInputEncoding(); 24497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 24597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 24697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 24797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getNamespace(String s) { 24897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mDelegate.getNamespace(s); 24997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 25097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 25197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 25297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getPositionDescription() { 25397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mDelegate.getPositionDescription(); 25497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 25597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 25697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 25797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int getLineNumber() { 25897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mDelegate.getLineNumber(); 25997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 26097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 26197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 26297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getNamespace() { 26397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mDelegate.getNamespace(); 26497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 26597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 26697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 26797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int getColumnNumber() { 26897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta return mDelegate.getColumnNumber(); 26997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 27097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 27197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta // -- We don't care much about the methods that follow. 27297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 27397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 27497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public void require(int i, String s, String s1) throws XmlPullParserException, IOException { 27597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 27697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 27797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 27897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 27997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public boolean getFeature(String s) { 28097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 28197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 28297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 28397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 28497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public void defineEntityReplacementText(String s, String s1) throws XmlPullParserException { 28597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 28697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 28797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 28897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 28997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public Object getProperty(String s) { 29097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 29197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 29297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 29397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 29497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int nextToken() throws XmlPullParserException, IOException { 29597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 29697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 29797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 29897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 29997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int getNamespaceCount(int i) throws XmlPullParserException { 30097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 30197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 30297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 30397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 30497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getNamespacePrefix(int i) throws XmlPullParserException { 30597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 30697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 30797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 30897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 30997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getNamespaceUri(int i) throws XmlPullParserException { 31097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 31197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 31297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 31397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 31497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public boolean isWhitespace() throws XmlPullParserException { 31597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 31697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 31797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 31897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 31997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public char[] getTextCharacters(int[] ints) { 32097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 32197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 32297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 32397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 32497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getPrefix() { 32597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 32697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 32797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 32897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 32997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public boolean isEmptyElementTag() throws XmlPullParserException { 33097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 33197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 33297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 33397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 33497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int getAttributeCount() { 33597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 33697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 33797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 33897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 33997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getAttributeNamespace(int i) { 34097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 34197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 34297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 34397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 34497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getAttributeName(int i) { 34597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 34697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 34797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 34897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 34997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getAttributePrefix(int i) { 35097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 35197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 35297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 35397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 35497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getAttributeType(int i) { 35597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 35697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 35797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 35897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 35997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public boolean isAttributeDefault(int i) { 36097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 36197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 36297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 36397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 36497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String getAttributeValue(int i) { 36597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 36697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 36797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 36897ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 36997ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public String nextText() throws XmlPullParserException, IOException { 37097ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 37197ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 37297ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta 37397ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta @Override 37497ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta public int nextTag() throws XmlPullParserException, IOException { 37597ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta throw new UnsupportedOperationException("Only few parser methods are supported."); 37697ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta } 37797ec082dda2f1ca25d38437716583c8254740866Deepanshu Gupta} 378