01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.compass.core.converter;
18:
19: import org.compass.core.mapping.ResourcePropertyMapping;
20:
21: /**
22: * A specialized converter that can convert to and from strings as well. Handles {@link ResourcePropertyMapping}.
23: *
24: * @author kimchy
25: */
26: public interface ResourcePropertyConverter extends Converter {
27:
28: /**
29: * Converts from a String and into it's Object representation.
30: *
31: * @param str The string to convert from
32: * @param resourcePropertyMapping The resource property mapping
33: * @return Theh object converterd from the String
34: * @throws ConversionException
35: */
36: Object fromString(String str,
37: ResourcePropertyMapping resourcePropertyMapping)
38: throws ConversionException;
39:
40: /**
41: * Converts the Object into a String.
42: *
43: * <p>Note that toString must be able to handle a <code>null</code> resourcePropertyMapping.
44: *
45: * @param o The Object to convert from
46: * @param resourcePropertyMapping The resource proeprty mapping
47: * @return The String converted from the Object
48: * @throws ConversionException
49: */
50: String toString(Object o,
51: ResourcePropertyMapping resourcePropertyMapping)
52: throws ConversionException;
53:
54: /**
55: * Returns <code>true</code> if this converter should be used to convert query parser related
56: * values. Conversion is done by calling {@link #fromString(String, org.compass.core.mapping.ResourcePropertyMapping)}
57: * and then {@link #toString(Object, org.compass.core.mapping.ResourcePropertyMapping)}.
58: */
59: boolean canNormalize();
60: }
|