001: /***
002: * Retrotranslator: a Java bytecode transformer that translates Java classes
003: * compiled with JDK 5.0 into classes that can be run on JVM 1.4.
004: *
005: * Copyright (c) 2005 - 2008 Taras Puchko
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: * 3. Neither the name of the copyright holders nor the names of its
017: * contributors may be used to endorse or promote products derived from
018: * this software without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
021: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
022: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
023: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
024: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
025: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
026: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
027: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
028: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
029: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
030: * THE POSSIBILITY OF SUCH DAMAGE.
031: */package net.sf.retrotranslator.runtime.java.io;
032:
033: import java.io.*;
034: import java.util.*;
035:
036: /**
037: * @author Taras Puchko
038: */
039: public class _PrintStream {
040:
041: public static class PrintStreamBuilder {
042:
043: private OutputStream out;
044: private String encoding;
045:
046: protected PrintStreamBuilder(OutputStream out, String encoding) {
047: this .out = out;
048: this .encoding = encoding;
049: }
050:
051: public OutputStream argument1() {
052: return out;
053: }
054:
055: public boolean argument2() {
056: return false;
057: }
058:
059: public String argument3() {
060: return encoding;
061: }
062: }
063:
064: public static OutputStream convertConstructorArguments(File file)
065: throws FileNotFoundException {
066: return new FileOutputStream(file);
067: }
068:
069: public static OutputStream convertConstructorArguments(
070: String fileName) throws FileNotFoundException {
071: return new FileOutputStream(fileName);
072: }
073:
074: public static PrintStreamBuilder createInstanceBuilder(File file,
075: String csn) throws FileNotFoundException {
076: return new PrintStreamBuilder(new FileOutputStream(file), csn);
077: }
078:
079: public static PrintStreamBuilder createInstanceBuilder(
080: String fileName, String csn) throws FileNotFoundException {
081: return new PrintStreamBuilder(new FileOutputStream(fileName),
082: csn);
083: }
084:
085: public static PrintStream append(PrintStream printStream,
086: CharSequence csq) {
087: printStream.print(csq);
088: return printStream;
089: }
090:
091: public static PrintStream append(PrintStream printStream,
092: CharSequence csq, int start, int end) {
093: printStream.print(String.valueOf(csq).substring(start, end));
094: return printStream;
095: }
096:
097: public static PrintStream append(PrintStream printStream, char c) {
098: printStream.print(c);
099: return printStream;
100: }
101:
102: public static PrintStream format(PrintStream printStream,
103: Locale locale, String format, Object... args) {
104: new Formatter(printStream, locale).format(format, args);
105: return printStream;
106: }
107:
108: public static PrintStream format(PrintStream printStream,
109: String format, Object... args) {
110: new Formatter(printStream).format(format, args);
111: return printStream;
112: }
113:
114: public static PrintStream printf(PrintStream printStream,
115: Locale locale, String format, Object... args) {
116: return format(printStream, locale, format, args);
117: }
118:
119: public static PrintStream printf(PrintStream printStream,
120: String format, Object... args) {
121: return format(printStream, format, args);
122: }
123:
124: }
|