Coverage Report - org.apache.myfaces.shared.view.SwitchableWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
SwitchableWriter
0%
0/37
0%
0/20
2.182
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.shared.view;
 20  
 
 21  
 import java.io.IOException;
 22  
 import java.io.Writer;
 23  
 
 24  
 /**
 25  
  * Delegates the standard Writer-methods (append, close, flush, write)
 26  
  * to the given Writer, if the ResponseSwitch is enabled
 27  
  */
 28  0
 class SwitchableWriter extends Writer
 29  
 {
 30  
 
 31  0
     Writer _delegate = null;
 32  0
     ResponseSwitch _responseSwitch = null;
 33  
 
 34  
     public SwitchableWriter(Writer delegate, ResponseSwitch responseSwitch)
 35  0
     {
 36  0
         _delegate = delegate;
 37  0
         _responseSwitch = responseSwitch;
 38  0
     }
 39  
 
 40  
     public void write(String s, int start, int end) throws IOException
 41  
     {
 42  0
         if (_responseSwitch.isEnabled())
 43  
         {
 44  0
             _delegate.write(s, start, end);
 45  
         }
 46  0
     }
 47  
 
 48  
     public void write(String s) throws IOException
 49  
     {
 50  0
         if (_responseSwitch.isEnabled())
 51  
         {
 52  0
             _delegate.write(s);
 53  
         }
 54  0
     }
 55  
 
 56  
     public void write(char[] c, int start, int end) throws IOException
 57  
     {
 58  0
         if (_responseSwitch.isEnabled())
 59  
         {
 60  0
             _delegate.write(c, start, end);
 61  
         }
 62  0
     }
 63  
 
 64  
     public void write(char[] c) throws IOException
 65  
     {
 66  0
         if (_responseSwitch.isEnabled())
 67  
         {
 68  0
             _delegate.write(c);
 69  
 
 70  
         }
 71  0
     }
 72  
 
 73  
     public void write(int i) throws IOException
 74  
     {
 75  0
         if (_responseSwitch.isEnabled())
 76  
         {
 77  0
             _delegate.write(i);
 78  
         }
 79  0
     }
 80  
 
 81  
     public void flush() throws IOException
 82  
     {
 83  0
         if (_responseSwitch.isEnabled())
 84  
         {
 85  0
             _delegate.flush();
 86  
         }
 87  0
     }
 88  
 
 89  
     public void close() throws IOException
 90  
     {
 91  0
         if (_responseSwitch.isEnabled())
 92  
         {
 93  0
             _delegate.close();
 94  
         }
 95  0
     }
 96  
 
 97  
     public Writer append(char c) throws IOException
 98  
     {
 99  0
         if (_responseSwitch.isEnabled())
 100  
         {
 101  0
             return _delegate.append(c);
 102  
         }
 103  0
         return this;
 104  
     }
 105  
 
 106  
     public Writer append(CharSequence csq, int start, int end)
 107  
             throws IOException
 108  
     {
 109  0
         if (_responseSwitch.isEnabled())
 110  
         {
 111  0
             return _delegate.append(csq, start, end);
 112  
         }
 113  0
         return this;
 114  
     }
 115  
 
 116  
     public Writer append(CharSequence csq) throws IOException
 117  
     {
 118  0
         if (_responseSwitch.isEnabled())
 119  
         {
 120  0
             return _delegate.append(csq);
 121  
         }
 122  0
         return this;
 123  
     }
 124  
 }