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