1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.util; 18 19 import android.annotation.NonNull; 20 21 import org.xmlpull.v1.XmlPullParser; 22 import org.xmlpull.v1.XmlPullParserException; 23 24 import java.io.IOException; 25 import java.io.InputStream; 26 import java.io.Reader; 27 import java.util.Objects; 28 29 /** 30 * Wrapper which delegates all calls through to the given {@link XmlPullParser}. 31 */ 32 @android.ravenwood.annotation.RavenwoodKeepWholeClass 33 public class XmlPullParserWrapper implements XmlPullParser { 34 private final XmlPullParser mWrapped; 35 XmlPullParserWrapper(@onNull XmlPullParser wrapped)36 public XmlPullParserWrapper(@NonNull XmlPullParser wrapped) { 37 mWrapped = Objects.requireNonNull(wrapped); 38 } 39 setFeature(String name, boolean state)40 public void setFeature(String name, boolean state) throws XmlPullParserException { 41 mWrapped.setFeature(name, state); 42 } 43 getFeature(String name)44 public boolean getFeature(String name) { 45 return mWrapped.getFeature(name); 46 } 47 setProperty(String name, Object value)48 public void setProperty(String name, Object value) throws XmlPullParserException { 49 mWrapped.setProperty(name, value); 50 } 51 getProperty(String name)52 public Object getProperty(String name) { 53 return mWrapped.getProperty(name); 54 } 55 setInput(Reader in)56 public void setInput(Reader in) throws XmlPullParserException { 57 mWrapped.setInput(in); 58 } 59 setInput(InputStream inputStream, String inputEncoding)60 public void setInput(InputStream inputStream, String inputEncoding) 61 throws XmlPullParserException { 62 mWrapped.setInput(inputStream, inputEncoding); 63 } 64 getInputEncoding()65 public String getInputEncoding() { 66 return mWrapped.getInputEncoding(); 67 } 68 defineEntityReplacementText(String entityName, String replacementText)69 public void defineEntityReplacementText(String entityName, String replacementText) 70 throws XmlPullParserException { 71 mWrapped.defineEntityReplacementText(entityName, replacementText); 72 } 73 getNamespaceCount(int depth)74 public int getNamespaceCount(int depth) throws XmlPullParserException { 75 return mWrapped.getNamespaceCount(depth); 76 } 77 getNamespacePrefix(int pos)78 public String getNamespacePrefix(int pos) throws XmlPullParserException { 79 return mWrapped.getNamespacePrefix(pos); 80 } 81 getNamespaceUri(int pos)82 public String getNamespaceUri(int pos) throws XmlPullParserException { 83 return mWrapped.getNamespaceUri(pos); 84 } 85 getNamespace(String prefix)86 public String getNamespace(String prefix) { 87 return mWrapped.getNamespace(prefix); 88 } 89 getDepth()90 public int getDepth() { 91 return mWrapped.getDepth(); 92 } 93 getPositionDescription()94 public String getPositionDescription() { 95 return mWrapped.getPositionDescription(); 96 } 97 getLineNumber()98 public int getLineNumber() { 99 return mWrapped.getLineNumber(); 100 } 101 getColumnNumber()102 public int getColumnNumber() { 103 return mWrapped.getColumnNumber(); 104 } 105 isWhitespace()106 public boolean isWhitespace() throws XmlPullParserException { 107 return mWrapped.isWhitespace(); 108 } 109 getText()110 public String getText() { 111 return mWrapped.getText(); 112 } 113 getTextCharacters(int[] holderForStartAndLength)114 public char[] getTextCharacters(int[] holderForStartAndLength) { 115 return mWrapped.getTextCharacters(holderForStartAndLength); 116 } 117 getNamespace()118 public String getNamespace() { 119 return mWrapped.getNamespace(); 120 } 121 getName()122 public String getName() { 123 return mWrapped.getName(); 124 } 125 getPrefix()126 public String getPrefix() { 127 return mWrapped.getPrefix(); 128 } 129 isEmptyElementTag()130 public boolean isEmptyElementTag() throws XmlPullParserException { 131 return mWrapped.isEmptyElementTag(); 132 } 133 getAttributeCount()134 public int getAttributeCount() { 135 return mWrapped.getAttributeCount(); 136 } 137 getAttributeNamespace(int index)138 public String getAttributeNamespace(int index) { 139 return mWrapped.getAttributeNamespace(index); 140 } 141 getAttributeName(int index)142 public String getAttributeName(int index) { 143 return mWrapped.getAttributeName(index); 144 } 145 getAttributePrefix(int index)146 public String getAttributePrefix(int index) { 147 return mWrapped.getAttributePrefix(index); 148 } 149 getAttributeType(int index)150 public String getAttributeType(int index) { 151 return mWrapped.getAttributeType(index); 152 } 153 isAttributeDefault(int index)154 public boolean isAttributeDefault(int index) { 155 return mWrapped.isAttributeDefault(index); 156 } 157 getAttributeValue(int index)158 public String getAttributeValue(int index) { 159 return mWrapped.getAttributeValue(index); 160 } 161 getAttributeValue(String namespace, String name)162 public String getAttributeValue(String namespace, String name) { 163 return mWrapped.getAttributeValue(namespace, name); 164 } 165 getEventType()166 public int getEventType() throws XmlPullParserException { 167 return mWrapped.getEventType(); 168 } 169 next()170 public int next() throws XmlPullParserException, IOException { 171 return mWrapped.next(); 172 } 173 nextToken()174 public int nextToken() throws XmlPullParserException, IOException { 175 return mWrapped.nextToken(); 176 } 177 require(int type, String namespace, String name)178 public void require(int type, String namespace, String name) 179 throws XmlPullParserException, IOException { 180 mWrapped.require(type, namespace, name); 181 } 182 nextText()183 public String nextText() throws XmlPullParserException, IOException { 184 return mWrapped.nextText(); 185 } 186 nextTag()187 public int nextTag() throws XmlPullParserException, IOException { 188 return mWrapped.nextTag(); 189 } 190 } 191