View Javadoc

1   /*
2    * $Id: AxisStringWriter.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.soap.axis;
12  
13  import java.io.IOException;
14  import java.io.StringWriter;
15  import java.io.Writer;
16  import java.util.HashMap;
17  import java.util.Map;
18  
19  /**
20   * <code>AxisStringWriter</code> wraps a java.io.StringWriter and allows meta information to be 
21   * associated with it.
22   */
23  public class AxisStringWriter
24  {
25      private final StringWriter writer;
26      private final Map<String, Object> properties;
27  
28      public AxisStringWriter()
29      {
30          writer = new StringWriter(4096);
31          properties = new HashMap<String, Object>();
32      }
33  
34      public void write(String string)
35      {
36          writer.write(string);
37      }
38  
39      public void write(String string, int offset, int len)
40      {
41          writer.write(string, offset, len);
42      }
43  
44      public Writer getWriter()
45      {
46          return writer;
47      }
48  
49      public void flush()
50      {
51          writer.flush();
52      }
53  
54      public void close() throws IOException
55      {
56          writer.close();
57      }
58  
59      public void setProperty(String key, Object value)
60      {
61          properties.put(key, value);
62      }
63      
64      public Map<String, Object> getProperties()
65      {
66          return properties;
67      }
68  }