View Javadoc

    1   /*
    2    * $Id: StrutsMockBodyContent.java 471756 2006-11-06 15:01:43Z husted $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21  package org.apache.struts2.views.jsp;
    22
    23  import java.io.IOException;
    24  import java.io.Reader;
    25  import java.io.Writer;
    26
    27  import javax.servlet.jsp.JspWriter;
    28  import javax.servlet.jsp.tagext.BodyContent;
    29
    30
    31  /***
    32   * StrutsMockBodyContent
    33   *
    34   */
    35  public class StrutsMockBodyContent extends BodyContent {
    36
    37      private JspWriter jspWriter;
    38      private String body = null;
    39
    40
    41      public StrutsMockBodyContent(JspWriter jspWriter) {
    42          super(jspWriter);
    43          this.jspWriter = jspWriter;
    44      }
    45
    46
    47      public Reader getReader() {
    48          return null;
    49      }
    50
    51      public int getRemaining() {
    52          return jspWriter.getRemaining();
    53      }
    54
    55      public void setString(String body) {
    56          this.body = body;
    57      }
    58
    59      public String getString() {
    60          return body;
    61      }
    62
    63      public void clear() throws IOException {
    64          jspWriter.clear();
    65      }
    66
    67      public void clearBuffer() throws IOException {
    68          jspWriter.clearBuffer();
    69      }
    70
    71      public void close() throws IOException {
    72          jspWriter.close();
    73      }
    74
    75      public void newLine() throws IOException {
    76          jspWriter.newLine();
    77      }
    78
    79      public void print(double v) throws IOException {
    80          jspWriter.print(v);
    81      }
    82
    83      public void print(int i) throws IOException {
    84          jspWriter.print(i);
    85      }
    86
    87      public void print(long l) throws IOException {
    88          jspWriter.print(l);
    89      }
    90
    91      public void print(float v) throws IOException {
    92          jspWriter.print(v);
    93      }
    94
    95      public void print(boolean b) throws IOException {
    96          jspWriter.print(b);
    97      }
    98
    99      public void print(String s) throws IOException {
    100         jspWriter.print(s);
    101     }
    102
    103     public void print(char c) throws IOException {
    104         jspWriter.print(c);
    105     }
    106
    107     public void print(Object o) throws IOException {
    108         jspWriter.print(o);
    109     }
    110
    111     public void print(char[] chars) throws IOException {
    112         jspWriter.print(chars);
    113     }
    114
    115     public void println() throws IOException {
    116         jspWriter.println();
    117     }
    118
    119     public void println(char c) throws IOException {
    120         jspWriter.println(c);
    121     }
    122
    123     public void println(String s) throws IOException {
    124         jspWriter.println(s);
    125     }
    126
    127     public void println(char[] chars) throws IOException {
    128         jspWriter.println(chars);
    129     }
    130
    131     public void println(boolean b) throws IOException {
    132         jspWriter.println(b);
    133     }
    134
    135     public void println(long l) throws IOException {
    136         jspWriter.println(l);
    137     }
    138
    139     public void println(int i) throws IOException {
    140         jspWriter.println(i);
    141     }
    142
    143     public void println(float v) throws IOException {
    144         jspWriter.println(v);
    145     }
    146
    147     public void println(double v) throws IOException {
    148         jspWriter.println(v);
    149     }
    150
    151     public void println(Object o) throws IOException {
    152         jspWriter.println(o);
    153     }
    154
    155     public void write(char[] chars, int i, int i1) throws IOException {
    156         jspWriter.write(chars, i, i1);
    157     }
    158
    159     public void writeOut(Writer writer) throws IOException {
    160         writer.write(body);
    161     }
    162 }