Coverage Report - org.apache.tapestry.markup.DefaultAttribute
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultAttribute
0%
0/23
0%
0/8
1.714
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 package org.apache.tapestry.markup;
 15  
 
 16  
 import java.io.PrintWriter;
 17  
 
 18  
 
 19  
 /**
 20  
  * Used to hold markup attribute data for writing in a specific format.
 21  
  * 
 22  
  * @author jkuhnert
 23  
  */
 24  
 public class DefaultAttribute implements Attribute
 25  
 {
 26  
     protected String _value;
 27  
     protected boolean _raw;
 28  
     
 29  
     public DefaultAttribute(String value, boolean raw)
 30  0
     {
 31  0
         _value = value;
 32  0
         _raw = raw;
 33  0
     }
 34  
     
 35  
     public Object getValue()
 36  
     {
 37  0
         return _value;
 38  
     }
 39  
     
 40  
     void append(Object value)
 41  
     {
 42  0
         if (value == null)
 43  0
             return;
 44  
         
 45  0
         _value += " " + value;
 46  0
     }
 47  
     
 48  
     void setRaw(boolean raw)
 49  
     {
 50  0
         _raw = raw;
 51  0
     }
 52  
     
 53  
     public boolean isRaw()
 54  
     {
 55  0
         return _raw;
 56  
     }
 57  
     
 58  
     void print(String name, PrintWriter writer, MarkupFilter filter)
 59  
     {
 60  0
         writer.print(' ');
 61  0
         writer.print(name);
 62  0
         writer.print("=\"");
 63  
 
 64  0
         if (_raw && _value != null) {
 65  
             
 66  0
             writer.write(_value);
 67  
             
 68  0
         } else if (_value != null) {
 69  
             
 70  0
             char[] data = _value.toCharArray();
 71  0
             filter.print(writer, data, 0, data.length, true);
 72  
         }
 73  
         
 74  0
         writer.print('"');
 75  0
     }
 76  
     
 77  
     public String toString()
 78  
     {
 79  0
         return _value;
 80  
     }
 81  
 }