01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.databinding.types;
20:
21: /**
22: * Custom class for supporting XSD data type ID The base type of Id is NCName.
23: *
24: * @see <a href="http://www.w3.org/TR/xmlschema-2/#ID">XML Schema 3.3.8</a>
25: */
26: public class Id extends NCName {
27:
28: private static final long serialVersionUID = -8442438083214211437L;
29:
30: public Id() {
31: super ();
32: }
33:
34: /**
35: * Constructor for Id.
36: *
37: * @throws IllegalArgumentException will be thrown if validation fails
38: */
39: public Id(String stValue) throws IllegalArgumentException {
40: try {
41: setValue(stValue);
42: } catch (IllegalArgumentException e) {
43: // recast normalizedString exception as token exception
44: throw new IllegalArgumentException();
45: //Messages.getMessage("badIdType00") + "data=[" +
46: //stValue + "]");
47: }
48: }
49:
50: /**
51: * Validates the data and sets the value for the object.
52: *
53: * @param stValue String value
54: * @throws IllegalArgumentException if invalid format
55: */
56: public void setValue(String stValue)
57: throws IllegalArgumentException {
58: if (!Id.isValid(stValue))
59: throw new IllegalArgumentException(
60: // Messages.getMessage("badIdType00") +
61: " data=[" + stValue + "]");
62: m_value = stValue;
63: }
64:
65: /**
66: * Validates the value against the xsd definition.
67: * <p/>
68: * Same validation as NCName for the time being
69: */
70: public static boolean isValid(String stValue) {
71: return NCName.isValid(stValue);
72: }
73: }
|