01: package org.geotools.po.bindings;
02:
03: import org.geotools.xml.*;
04:
05: import org.geotools.po.ObjectFactory;
06:
07: import javax.xml.namespace.QName;
08:
09: /**
10: * Binding object for the type http://www.geotools.org/po:SKU.
11: *
12: * <p>
13: * <pre>
14: * <code>
15: * <xsd:simpleType name="SKU">
16: * <xsd:restriction base="xsd:string">
17: * <xsd:pattern value="\d{3}-[A-Z]{2}"/>
18: * </xsd:restriction>
19: * </xsd:simpleType>
20: *
21: * </code>
22: * </pre>
23: * </p>
24: *
25: * @generated
26: */
27: public class SKUBinding extends AbstractSimpleBinding {
28:
29: ObjectFactory factory;
30:
31: public SKUBinding(ObjectFactory factory) {
32: this .factory = factory;
33: }
34:
35: /**
36: * @generated
37: */
38: public QName getTarget() {
39: return PO.SKU;
40: }
41:
42: /**
43: * <!-- begin-user-doc -->
44: * <!-- end-user-doc -->
45: *
46: * @generated modifiable
47: */
48: public Class getType() {
49: return String.class;
50: }
51:
52: /**
53: * <!-- begin-user-doc -->
54: * <!-- end-user-doc -->
55: *
56: * @generated modifiable
57: */
58: public Object parse(InstanceComponent instance, Object value)
59: throws Exception {
60:
61: String sku = (String) value;
62:
63: if (!sku.matches("\\d{3}-[A-Z]{2}")) {
64: throw new IllegalArgumentException("Illegal sku format: "
65: + sku);
66: }
67:
68: return sku;
69: }
70:
71: }
|