Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 68   Methods: 2
NCLOC: 31   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
WMLCharacterTranslatorSource.java - 50% 50% 50%
coverage coverage
 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   
 
 15   
 package org.apache.tapestry.wml;
 16   
 
 17   
 import org.apache.tapestry.util.text.AsciiCharacterMatcher;
 18   
 import org.apache.tapestry.util.text.AsciiCharacterTranslator;
 19   
 import org.apache.tapestry.util.text.ICharacterMatcher;
 20   
 import org.apache.tapestry.util.text.ICharacterTranslator;
 21   
 import org.apache.tapestry.util.text.ICharacterTranslatorSource;
 22   
 import org.apache.tapestry.util.text.MarkupCharacterTranslator;
 23   
 
 24   
 /**
 25   
  * The WML implementation of a character translator source.
 26   
  * Returns a WML translator that encodes everything that is non-safe.
 27   
  * 
 28   
  * Some code borrowed from WMLWriter (by David Solis)
 29   
  * 
 30   
  * @author mb
 31   
  * @since 4.0
 32   
  */
 33   
 public class WMLCharacterTranslatorSource implements ICharacterTranslatorSource
 34   
 {
 35   
     private static final String SAFE_CHARACTERS =
 36   
         "01234567890"
 37   
             + "abcdefghijklmnopqrstuvwxyz"
 38   
             + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 39   
             + "\t\n\r !\"#%'()*+,-./:;=?@[\\]^_`{|}~";
 40   
 
 41   
     private static final String[][] ENTITIES = {
 42   
             { "\"", """ }, 
 43   
             { "<", "&lt;" },
 44   
             { ">", "&gt;" },
 45   
             { "&", "&amp;" },
 46   
             { "$", "$$" }
 47   
         };
 48   
 
 49   
     private static final ICharacterMatcher SAFE_MATCHER = new AsciiCharacterMatcher(SAFE_CHARACTERS);
 50   
     private static final ICharacterTranslator ENTITY_TRANSLATOR = new AsciiCharacterTranslator(ENTITIES);
 51   
 
 52   
     private static final ICharacterTranslator WML_TRANSLATOR = new MarkupCharacterTranslator(true, SAFE_MATCHER, ENTITY_TRANSLATOR);
 53   
 
 54   
     /**
 55   
      * @see org.apache.tapestry.util.text.ICharacterTranslatorSource#getDefaultTranslator()
 56   
      */
 57  45
     public ICharacterTranslator getDefaultTranslator() {
 58  45
         return WML_TRANSLATOR;
 59   
     }
 60   
 
 61   
     /**
 62   
      * @see org.apache.tapestry.util.text.ICharacterTranslatorSource#getTranslator(java.lang.String)
 63   
      */
 64  0
     public ICharacterTranslator getTranslator(String encoding) {
 65  0
         return getDefaultTranslator();
 66   
     }
 67   
 }
 68