1 /* 2 * Copyright (C) 2011 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 vogar.target; 18 19 import java.io.PrintStream; 20 21 public abstract class PrintStreamDecorator extends PrintStream { 22 public PrintStreamDecorator(PrintStream delegate) { 23 super(delegate); 24 } 25 26 @Override public final void print(long l) { 27 print(String.valueOf(l)); 28 } 29 30 @Override public final void print(int i) { 31 print(String.valueOf(i)); 32 } 33 34 @Override public final void print(float f) { 35 print(String.valueOf(f)); 36 } 37 38 @Override public final void print(double d) { 39 print(String.valueOf(d)); 40 } 41 42 @Override public final void print(char[] s) { 43 print(String.valueOf(s)); 44 } 45 46 @Override public final void print(char c) { 47 print(String.valueOf(c)); 48 } 49 50 @Override public final void print(Object obj) { 51 print(obj != null ? obj.toString() : "null"); 52 } 53 54 @Override public abstract void print(String str); 55 56 @Override public final void println() { 57 print("\n"); 58 } 59 60 /** 61 * Although println() is documented to be equivalent to print() 62 * followed by println(), this isn't the behavior on HotSpot 63 * and we must manually override println(String) to ensure that 64 * newlines aren't dropped. 65 */ 66 @Override public final void println(String s) { 67 print(s + "\n"); 68 } 69 70 @Override public final void println(long l) { 71 println(String.valueOf(l)); 72 } 73 74 @Override public final void println(int i) { 75 println(String.valueOf(i)); 76 } 77 78 @Override public final void println(float f) { 79 println(String.valueOf(f)); 80 } 81 82 @Override public final void println(double d) { 83 println(String.valueOf(d)); 84 } 85 86 @Override public final void println(char[] s) { 87 println(String.valueOf(s)); 88 } 89 90 @Override public final void println(char c) { 91 println(String.valueOf(c)); 92 } 93 94 @Override public final void println(Object obj) { 95 println(obj != null ? obj.toString() : "null"); 96 } 97 } 98