View Javadoc

1   /*
2   MadCaching is a Tile Caching solution
3   Copyright (C) 2005  Mac Vu
4   
5   This program is free software; you can redistribute it and/or
6   modify it under the terms of the GNU General Public License
7   as published by the Free Software Foundation; either version 2
8   of the License, or (at your option) any later version.
9   
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  GNU General Public License for more details.
14  
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18   */
19  package com.macvu.tiles.capture;
20  
21  import java.io.ByteArrayOutputStream;
22  import java.io.OutputStream;
23  import java.io.PrintWriter;
24  import java.io.Serializable;
25  
26  public class CacheContent implements Serializable {
27      ByteArrayOutputStream cache;
28  
29      PrintWriter writer;
30  
31      public CacheContent() {
32          cache = new ByteArrayOutputStream(32768);
33      }
34  
35      public OutputStream getOutputStream() {
36          return cache;
37      }
38  
39      public PrintWriter getWriter() {
40          if (writer == null) {
41              writer = new PrintWriter(cache);
42          }
43  
44          return writer;
45      }
46  
47      public String getCache() {
48          return cache.toString();
49      }
50  }