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.XmlSerializer; 22 23 import java.io.IOException; 24 import java.io.OutputStream; 25 import java.io.Writer; 26 import java.util.Objects; 27 28 /** 29 * Wrapper which delegates all calls through to the given {@link XmlSerializer}. 30 */ 31 @android.ravenwood.annotation.RavenwoodKeepWholeClass 32 public class XmlSerializerWrapper implements XmlSerializer { 33 private final XmlSerializer mWrapped; 34 XmlSerializerWrapper(@onNull XmlSerializer wrapped)35 public XmlSerializerWrapper(@NonNull XmlSerializer wrapped) { 36 mWrapped = Objects.requireNonNull(wrapped); 37 } 38 setFeature(String name, boolean state)39 public void setFeature(String name, boolean state) { 40 mWrapped.setFeature(name, state); 41 } 42 getFeature(String name)43 public boolean getFeature(String name) { 44 return mWrapped.getFeature(name); 45 } 46 setProperty(String name, Object value)47 public void setProperty(String name, Object value) { 48 mWrapped.setProperty(name, value); 49 } 50 getProperty(String name)51 public Object getProperty(String name) { 52 return mWrapped.getProperty(name); 53 } 54 setOutput(OutputStream os, String encoding)55 public void setOutput(OutputStream os, String encoding) throws IOException { 56 mWrapped.setOutput(os, encoding); 57 } 58 setOutput(Writer writer)59 public void setOutput(Writer writer) 60 throws IOException, IllegalArgumentException, IllegalStateException { 61 mWrapped.setOutput(writer); 62 } 63 startDocument(String encoding, Boolean standalone)64 public void startDocument(String encoding, Boolean standalone) throws IOException { 65 mWrapped.startDocument(encoding, standalone); 66 } 67 endDocument()68 public void endDocument() throws IOException { 69 mWrapped.endDocument(); 70 } 71 setPrefix(String prefix, String namespace)72 public void setPrefix(String prefix, String namespace) throws IOException { 73 mWrapped.setPrefix(prefix, namespace); 74 } 75 getPrefix(String namespace, boolean generatePrefix)76 public String getPrefix(String namespace, boolean generatePrefix) { 77 return mWrapped.getPrefix(namespace, generatePrefix); 78 } 79 getDepth()80 public int getDepth() { 81 return mWrapped.getDepth(); 82 } 83 getNamespace()84 public String getNamespace() { 85 return mWrapped.getNamespace(); 86 } 87 getName()88 public String getName() { 89 return mWrapped.getName(); 90 } 91 startTag(String namespace, String name)92 public XmlSerializer startTag(String namespace, String name) throws IOException { 93 return mWrapped.startTag(namespace, name); 94 } 95 attribute(String namespace, String name, String value)96 public XmlSerializer attribute(String namespace, String name, String value) 97 throws IOException { 98 return mWrapped.attribute(namespace, name, value); 99 } 100 endTag(String namespace, String name)101 public XmlSerializer endTag(String namespace, String name) throws IOException { 102 return mWrapped.endTag(namespace, name); 103 } 104 text(String text)105 public XmlSerializer text(String text) throws IOException{ 106 return mWrapped.text(text); 107 } 108 text(char[] buf, int start, int len)109 public XmlSerializer text(char[] buf, int start, int len) throws IOException { 110 return mWrapped.text(buf, start, len); 111 } 112 cdsect(String text)113 public void cdsect(String text) 114 throws IOException, IllegalArgumentException, IllegalStateException { 115 mWrapped.cdsect(text); 116 } 117 entityRef(String text)118 public void entityRef(String text) throws IOException { 119 mWrapped.entityRef(text); 120 } 121 processingInstruction(String text)122 public void processingInstruction(String text) throws IOException { 123 mWrapped.processingInstruction(text); 124 } 125 comment(String text)126 public void comment(String text) throws IOException { 127 mWrapped.comment(text); 128 } 129 docdecl(String text)130 public void docdecl(String text) throws IOException { 131 mWrapped.docdecl(text); 132 } 133 ignorableWhitespace(String text)134 public void ignorableWhitespace(String text) throws IOException { 135 mWrapped.ignorableWhitespace(text); 136 } 137 flush()138 public void flush() throws IOException { 139 mWrapped.flush(); 140 } 141 } 142