01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.feature.type;
17:
18: import org.geotools.feature.DefaultAttributeType;
19: import org.geotools.feature.PrimativeAttributeType;
20: import org.opengis.filter.Filter;
21:
22: /**
23: *
24: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/feature/type/TextualAttributeType.java $
25: */
26: public class TextualAttributeType extends DefaultAttributeType
27: implements PrimativeAttributeType {
28: public TextualAttributeType(String name, boolean nillable, int min,
29: int max, Object defaultValue, Filter filter) {
30: super (name, String.class, nillable, min, max, defaultValue);
31: this .filter = filter;
32: }
33:
34: private Filter filter;
35:
36: public Object parse(Object value) throws IllegalArgumentException {
37: if (value == null) {
38: return value;
39: }
40:
41: // string is immutable, so lets keep it
42: if (value instanceof String) {
43: return value;
44: }
45:
46: // other char sequences are not mutable, create a String from it.
47: // this also covers any other cases...
48: return value.toString();
49: }
50:
51: /**
52: * Duplicate as a String
53: *
54: * @param o DOCUMENT ME!
55: *
56: * @return a String obtained by calling toString or null.
57: */
58: public Object duplicate(Object o) {
59: if (o == null) {
60: return null;
61: }
62:
63: return o.toString();
64: }
65:
66: /* (non-Javadoc)
67: * @see org.geotools.feature.PrimativeAttributeType#getRestriction()
68: */
69: public Filter getRestriction() {
70: return filter;
71: }
72: }
|