2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.clay.convert.TimeZoneConverter
 
Classes in this File Line Coverage Branch Coverage Complexity
TimeZoneConverter
0% 
0% 
2
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 /*
 19  
  * $Id: TimeZoneConverter.java 464373 2006-10-16 04:21:54Z rahul $
 20  
  */
 21  
 package org.apache.shale.clay.convert;
 22  
 
 23  
 import java.util.TimeZone;
 24  
 
 25  
 import javax.faces.component.UIComponent;
 26  
 import javax.faces.context.FacesContext;
 27  
 import javax.faces.convert.Converter;
 28  
 
 29  
 /**
 30  
  * <p>Converts a time zone id literal string into the
 31  
  * <code>TimeZone</code> and back to a string.</p>
 32  
  */
 33  0
 public class TimeZoneConverter implements Converter {
 34  
 
 35  
     /**
 36  
      * <p>Converts the string zone ID into a TimeZone object.</p>
 37  
      *
 38  
      * @param facesContext jsf faces context
 39  
      * @param component converter assigned
 40  
      * @param value to be converterd
 41  
      * @return strong typed value
 42  
      */
 43  
     public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
 44  
 
 45  0
         TimeZone zone = TimeZone.getTimeZone(value);
 46  0
         return zone;
 47  
     }
 48  
 
 49  
     /**
 50  
      * <p>Converts a TimeZone object into the string zone id.</p>
 51  
      *
 52  
      * @param facesContext jsf faces context
 53  
      * @param component converter assigned
 54  
      * @param value to be converterd
 55  
      * @return string represention of the value
 56  
      */
 57  
     public String getAsString(FacesContext facesContext, UIComponent component, Object value) {
 58  
 
 59  0
         TimeZone zone = (TimeZone) value;
 60  0
         if (value != null) {
 61  0
            return zone.getID();
 62  
         }
 63  
 
 64  0
         return null;
 65  
     }
 66  
 
 67  
 }