01: /*
02: * Geotools2 - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002, 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: */
17: package org.geotools.feature.iso.attribute;
18:
19: import org.geotools.feature.iso.AttributeImpl;
20: import org.opengis.feature.simple.TextAttribute;
21: import org.opengis.feature.type.AttributeDescriptor;
22:
23: public class TextualAttribute extends AttributeImpl implements
24: TextAttribute {
25:
26: public TextualAttribute(CharSequence value, AttributeDescriptor desc) {
27: super (value, desc, null);
28: }
29:
30: public Object parse(Object value) throws IllegalArgumentException {
31: if (value == null) {
32: return value;
33: }
34:
35: // string is immutable, so lets keep it
36: if (value instanceof String) {
37: return value;
38: }
39:
40: // other char sequences are not mutable, create a String from it.
41: // this also covers any other cases...
42: return value.toString();
43: }
44:
45: public String toString() {
46: StringBuffer sb = new StringBuffer("TextualAttribute[");
47: sb.append("TYPE=").append(getType().getName()).append(
48: ", content='").append(getValue()).append("']");
49: return sb.toString();
50: }
51:
52: public CharSequence getText() {
53: return (CharSequence) getValue();
54: }
55:
56: public void setText(CharSequence newValue) {
57: setValue(newValue);
58: }
59: }
|