KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > core > config > type > ConfigurationTypeService


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

17
18 package org.sape.carbon.core.config.type;
19
20
21 import org.sape.carbon.core.component.FunctionalInterface;
22 import org.sape.carbon.core.config.Configuration;
23
24 /**
25  * <P>Implementations of this service will provide configuration with a
26  * micro level of formatting for individual values within a configuration
27  * object. These objects could be URLs, Classes, Strings or any primitive.</P>
28  *
29  * Copyright 2002 Sapient
30  * @since carbon 1.0
31  * @author Greg Hinkle, January 2002
32  * @version $Revision: 1.10 $($Author: dvoet $ / $Date: 2003/07/29 19:50:19 $)
33  */

34 public interface ConfigurationTypeService extends FunctionalInterface {
35
36     /**
37      * Translates the supported object type into its string value
38      * @param type the Class type of configuration data
39      * @param value the object value of the configuration data to translate
40      * @return the string form of the configuration data
41      */

42     String JavaDoc toString(Class JavaDoc type, Object JavaDoc value);
43
44     /**
45      * Translates configuration data from its String value into
46      * its object form for usage by clients of the configuration
47      * service.
48      * @param type the class type of the data to translate
49      * @param value the String value to translate into objects
50      * @throws ConfigurationTypeException when the String value is not of
51      * the proper format or is an invalid value
52      * @return the Object form of the configuration information
53      */

54     Object JavaDoc toObject(Class JavaDoc type, String JavaDoc value)
55         throws ConfigurationTypeException;
56
57     /**
58      * Translates the supported object type into its Configuration value
59      * @param type the Class type that data should be stored as
60      * @param data the object to be converted to a Configuration type
61      * @return Configuration
62      * @throws ConfigurationTypeException indicates an error parsing
63      * configuration value into an object
64      */

65     Configuration toConfiguration(Class JavaDoc type, Object JavaDoc data)
66         throws ConfigurationTypeException;
67
68     /**
69      * Translates configuration data from its Configuration value into
70      * its object form for usage by clients of the configuration
71      * service.
72      *
73      * @param type the class type of the data to translate
74      * @param value the Configuration information to be converted
75      * @return Object
76      * @throws ConfigurationTypeException indicates an error parsing
77      * configuration value into an object
78      */

79     Object JavaDoc toObject(Class JavaDoc type, Configuration value)
80         throws ConfigurationTypeException;
81
82     /**
83      * Returns true if type has a complex type handler. If this is true,
84      * <code>toConfiguration(Class type, Object data)</code> and
85      * <code>toObject(Class type, Configuration value)</code> should be
86      * used to conv to and from configuration information and objects.
87      * If this is false, use
88      * <code>toString(Class type, Object value)</code> and
89      * <code>toObject(Class type, String value)</code>
90      *
91      * @param type class to check for complex type handler
92      * @return if the class has a complex type handler
93      */

94     boolean isComplexType(Class JavaDoc type);
95
96     /**
97      * Gets the required configuration interface for the given complex type.
98      * @see ComplexConfigurationTypeHandler#getRequiredConfigurationInterface()
99      * @param type must be a complex type
100      * @return Class
101      */

102     Class JavaDoc getRequiredConfigurationInterface(Class JavaDoc type);
103     
104     /**
105      * Returns true if instances of type should be cached within configuration
106      * objects
107      * @since carbon 2.1
108      * @param type
109      * @return true if type can be cached, false otherwise
110      */

111     boolean isCacheableType(Class JavaDoc type);
112 }
113
Popular Tags