KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > util > XLinkSupport


1 /*
2
3    Copyright 2000-2001 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom.util;
19
20 import org.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.Element JavaDoc;
22
23 /**
24  * This class provides support for XLink features.
25  *
26  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
27  * @version $Id: XLinkSupport.java,v 1.4 2004/08/18 07:13:37 vhardy Exp $
28  */

29 public class XLinkSupport {
30     /**
31      * The xlink namespace URI.
32      */

33     public final static String JavaDoc XLINK_NAMESPACE_URI =
34     "http://www.w3.org/1999/xlink";
35
36     /**
37      * Returns the value of the 'xlink:type' attribute of the given element.
38      */

39     public static String JavaDoc getXLinkType(Element JavaDoc elt) {
40     return elt.getAttributeNS(XLINK_NAMESPACE_URI, "type");
41     }
42
43     /**
44      * Sets the value of the 'xlink:type' attribute of the given element.
45      */

46     public static void setXLinkType(Element JavaDoc elt, String JavaDoc str) {
47     if (!"simple".equals(str) &&
48         !"extended".equals(str) &&
49         !"locator".equals(str) &&
50         !"arc".equals(str)) {
51         throw new DOMException JavaDoc(DOMException.SYNTAX_ERR,
52                                    "xlink:type='" + str + "'");
53     }
54     elt.setAttributeNS(XLINK_NAMESPACE_URI, "type", str);
55     }
56
57     /**
58      * Returns the value of the 'xlink:role' attribute of the given element.
59      */

60     public static String JavaDoc getXLinkRole(Element JavaDoc elt) {
61     return elt.getAttributeNS(XLINK_NAMESPACE_URI, "role");
62     }
63
64     /**
65      * Sets the value of the 'xlink:role' attribute of the given element.
66      */

67     public static void setXLinkRole(Element JavaDoc elt, String JavaDoc str) {
68     elt.setAttributeNS(XLINK_NAMESPACE_URI, "role", str);
69     }
70
71     /**
72      * Returns the value of the 'xlink:arcrole' attribute of the given element.
73      */

74     public static String JavaDoc getXLinkArcRole(Element JavaDoc elt) {
75     return elt.getAttributeNS(XLINK_NAMESPACE_URI, "arcrole");
76     }
77
78     /**
79      * Sets the value of the 'xlink:arcrole' attribute of the given element.
80      */

81     public static void setXLinkArcRole(Element JavaDoc elt, String JavaDoc str) {
82     elt.setAttributeNS(XLINK_NAMESPACE_URI, "arcrole", str);
83     }
84
85     /**
86      * Returns the value of the 'xlink:title' attribute of the given element.
87      */

88     public static String JavaDoc getXLinkTitle(Element JavaDoc elt) {
89     return elt.getAttributeNS(XLINK_NAMESPACE_URI, "title");
90     }
91
92     /**
93      * Sets the value of the 'xlink:title' attribute of the given element.
94      */

95     public static void setXLinkTitle(Element JavaDoc elt, String JavaDoc str) {
96     elt.setAttributeNS(XLINK_NAMESPACE_URI, "title", str);
97     }
98
99     /**
100      * Returns the value of the 'xlink:show' attribute of the given element.
101      */

102     public static String JavaDoc getXLinkShow(Element JavaDoc elt) {
103     return elt.getAttributeNS(XLINK_NAMESPACE_URI, "show");
104     }
105
106     /**
107      * Sets the value of the 'xlink:show' attribute of the given element.
108      */

109     public static void setXLinkShow(Element JavaDoc elt, String JavaDoc str) {
110     if (!"new".equals(str) &&
111         !"replace".equals(str) &&
112         !"embed".equals(str)) {
113         throw new DOMException JavaDoc(DOMException.SYNTAX_ERR,
114                                    "xlink:show='" + str + "'");
115     }
116     elt.setAttributeNS(XLINK_NAMESPACE_URI, "show", str);
117     }
118
119     /**
120      * Returns the value of the 'xlink:actuate' attribute of the given element.
121      */

122     public static String JavaDoc getXLinkActuate(Element JavaDoc elt) {
123     return elt.getAttributeNS(XLINK_NAMESPACE_URI, "actuate");
124     }
125
126     /**
127      * Sets the value of the 'xlink:actuate' attribute of the given element.
128      */

129     public static void setXLinkActuate(Element JavaDoc elt, String JavaDoc str) {
130     if (!"onReplace".equals(str) && !"onLoad".equals(str)) {
131         throw new DOMException JavaDoc(DOMException.SYNTAX_ERR,
132                                    "xlink:actuate='" + str + "'");
133     }
134     elt.setAttributeNS(XLINK_NAMESPACE_URI, "actuate", str);
135     }
136
137     /**
138      * Returns the value of the 'xlink:href' attribute of the given element.
139      */

140     public static String JavaDoc getXLinkHref(Element JavaDoc elt) {
141         return elt.getAttributeNS(XLINK_NAMESPACE_URI, "href");
142     }
143
144     /**
145      * Sets the value of the 'xlink:href' attribute of the given element.
146      */

147     public static void setXLinkHref(Element JavaDoc elt, String JavaDoc str) {
148     elt.setAttributeNS(XLINK_NAMESPACE_URI, "href", str);
149     }
150 }
151
Popular Tags