Coverage Report - org.seasar.cubby.converter.Converter
 
Classes in this File Line Coverage Branch Coverage Complexity
Converter
N/A
N/A
1
 
 1  
 /*
 2  
  * Copyright 2004-2009 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.cubby.converter;
 17  
 
 18  
 /**
 19  
  * 変換元クラスのインスタンスを変換先クラスのインスタンスに変換するコンバータを表します。
 20  
  * 
 21  
  * @author baba
 22  
  */
 23  
 public interface Converter {
 24  
 
 25  
         /**
 26  
          * このコンバータがサポートしているクラスを返します。
 27  
          * 
 28  
          * @return このコンバータがサポートしているクラス
 29  
          */
 30  
         Class<?> getObjectType();
 31  
 
 32  
         /**
 33  
          * このコンバータが指定された要求パラメータの型を指定された値の型に変換できるかを示します。
 34  
          * <p>
 35  
          * <code>parameterType</code> に <code>null</code> が指定された場合は
 36  
          * <code>false</code> を返します。
 37  
          * </p>
 38  
          * 
 39  
          * @param parameterType
 40  
          *            要求パラメータの型
 41  
          * @param objectType
 42  
          *            値の型
 43  
          * @return このコンバータが指定された要求パラメータの型を指定された値の型に変換できる場合は <code>true</code>
 44  
          *         、そうでない場合は <code>false</code>
 45  
          */
 46  
         boolean canConvert(Class<?> parameterType, Class<?> objectType);
 47  
 
 48  
         /**
 49  
          * <code>value</code>をこのコンバータがサポートしているクラスのインスタンスに変換します。
 50  
          * 
 51  
          * @param value
 52  
          *            変換元のオブジェクト
 53  
          * @param objectType
 54  
          *            値の型
 55  
          * @param helper
 56  
          *            変換のヘルパクラス
 57  
          * @return <code>value</code>を変換したオブジェクト
 58  
          * @throws ConversionException
 59  
          *             型変換に失敗した場合
 60  
          */
 61  
         Object convertToObject(Object value, Class<?> objectType,
 62  
                         ConversionHelper helper) throws ConversionException;
 63  
 
 64  
         /**
 65  
          * このコンバータがサポートしているクラスのインスタンスである<code>value</code>を文字列に変換します。
 66  
          * 
 67  
          * @param value
 68  
          *            変換元のオブジェクト
 69  
          * @param helper
 70  
          *            変換のヘルパクラス
 71  
          * 
 72  
          * @return <code>value</code>を変換した文字列
 73  
          */
 74  
         String convertToString(Object value, ConversionHelper helper);
 75  
 
 76  
 }