1 /*
2 * Copyright 2010 University Corporation for Advanced Internet Development, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.opensaml.xml;
18
19 import javax.xml.namespace.QName;
20
21 import org.opensaml.xml.util.XMLConstants;
22
23 /**
24 * Interface for element having a <code>@xml:space</code> attribute.
25 *
26 */
27 public interface SpaceBearing {
28
29 /** Enum representing the allowed values of the xml:space attribute. */
30 public enum XMLSpaceEnum {
31 /** xml:space value "default". */
32 DEFAULT,
33 /** xml:space value "preserve". */
34 PRESERVE;
35
36 // Unfortunately "default" is a reserved word in Java, so the enum value above has to be upper case
37 // and we have the mess below.
38
39 /** {@inheritDoc} */
40 public String toString() {
41 return super.toString().toLowerCase();
42 }
43
44 /**
45 * Parse a string value into an XMLSpaceEnum.
46 *
47 * <p>
48 * The legal values are "default" and "preserve".
49 * </p>
50 *
51 * @param value the value to parse
52 * @return the corresponding XMLSpaceEnum
53 */
54 public static XMLSpaceEnum parseValue(String value) {
55 return XMLSpaceEnum.valueOf(value.toUpperCase());
56 }
57
58 }
59
60 /** The <code>space</code> attribute local name. */
61 public static final String XML_SPACE_ATTR_LOCAL_NAME = "space";
62
63 /** The <code>xml:space</code> qualified attribute name. */
64 public static final QName XML_SPACE_ATTR_NAME =
65 new QName(XMLConstants.XML_NS, XML_SPACE_ATTR_LOCAL_NAME, XMLConstants.XML_PREFIX);
66
67 /**
68 * Returns the <code>@xml:space</code> attribute value.
69 *
70 * @return The <code>@xml:space</code> attribute value or <code>null</code>.
71 */
72 public XMLSpaceEnum getXMLSpace();
73
74 /**
75 * Sets the <code>@xml:space</code> attribute value.
76 *
77 * @param newSpace The <code>@xml:space</code> attribute value
78 */
79 public void setXMLSpace(XMLSpaceEnum newSpace);
80
81 }