001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.net.http;
020
021import java.io.IOException;
022import java.io.OutputStream;
023
024import javax.servlet.ServletOutputStream;
025
026import lucee.runtime.op.Caster;
027
028public final class ServletOutputStreamDummy extends ServletOutputStream {
029
030        private OutputStream os;
031
032        //private HttpServletResponseDummy rsp;
033        //private ByteArrayOutputStream baos;
034
035        public ServletOutputStreamDummy(OutputStream os) {
036                this.os=os;
037        }
038        
039        @Override
040        public void print(boolean b) throws IOException {
041                write(b?"true".getBytes():"false".getBytes());
042        }
043
044        @Override
045        public void print(char c) throws IOException {
046                print(new String(new char[]{c}));
047        }
048
049        @Override
050        public void print(double d) throws IOException {
051                write(Caster.toString(d).getBytes());
052        }
053
054        @Override
055        public void print(float f) throws IOException {
056                write(Caster.toString(f).getBytes());
057        }
058
059        @Override
060        public void print(int i) throws IOException {
061                write(Caster.toString(i).getBytes());
062        }
063
064        @Override
065        public void print(long l) throws IOException {
066                write(Caster.toString(l).getBytes());
067        }
068
069        @Override
070        public void print(String str) throws IOException {
071                write(str.getBytes());
072        }
073
074        @Override
075        public void println() throws IOException {
076                write("\\".getBytes());
077        }
078
079        @Override
080        public void println(boolean b) throws IOException {
081                print(b);
082                println();
083        }
084
085        @Override
086        public void println(char c) throws IOException {
087                print(c);
088                println();
089        }
090
091        @Override
092        public void println(double d) throws IOException {
093                print(d);
094                println();
095        }
096
097        @Override
098        public void println(float f) throws IOException {
099                print(f);
100                println();
101        }
102
103        @Override
104        public void println(int i) throws IOException {
105                print(i);
106                println();
107        }
108
109        @Override
110        public void println(long l) throws IOException {
111                print(l);
112                println();
113        }
114
115        @Override
116        public void println(String str) throws IOException {
117                print(str);
118                println();
119        }
120
121        @Override
122        public void write(byte[] b) throws IOException {
123                write(b,0,b.length);
124        }
125
126        @Override
127        public void write(byte[] b, int off, int len) throws IOException {
128                os.write(b, off, len);
129        }
130
131        @Override
132        public void write(int b) throws IOException {
133                os.write(b);
134        }
135
136        @Override
137        public void close() throws IOException {
138                os.close();
139        }
140
141        @Override
142        public void flush() throws IOException {
143                os.flush();
144        }
145
146}