KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > xml > XLink


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
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
18 /* $Id: XLink.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.xml;
21
22 import org.w3c.dom.Attr JavaDoc;
23 import org.w3c.dom.Document JavaDoc;
24 import org.w3c.dom.Element JavaDoc;
25
26 public class XLink {
27
28     public String JavaDoc type = null;
29     public String JavaDoc href = null;
30     public String JavaDoc show = null;
31     public String JavaDoc name = null;
32     public Element JavaDoc element = null;
33
34     public static final String JavaDoc XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
35     public static final String JavaDoc ATTRIBUTE_HREF = "href";
36     public static final String JavaDoc ATTRIBUTE_SHOW = "show";
37     public static final String JavaDoc ATTRIBUTE_TYPE = "type";
38
39     /**
40      *
41      */

42     public XLink() {
43         type = "simple";
44         show = "undefined";
45     }
46
47     /**
48      *
49      */

50     public XLink(Element JavaDoc element) {
51         this();
52         this.element = element;
53
54         name = element.getNodeName();
55
56         Attr JavaDoc hrefAttribute = element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_HREF);
57         if (hrefAttribute != null) {
58             href = hrefAttribute.getNodeValue();
59         }
60         Attr JavaDoc typeAttribute = element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_TYPE);
61         if (typeAttribute != null) {
62             type = typeAttribute.getNodeValue();
63         }
64         Attr JavaDoc showAttribute = element.getAttributeNodeNS(XLINK_NAMESPACE, ATTRIBUTE_SHOW);
65         if (showAttribute != null) {
66             show = showAttribute.getNodeValue();
67         }
68
69     }
70
71     /**
72      *
73      */

74     public Element JavaDoc getXLink(Document JavaDoc document, DOMParserFactory dpf) {
75         return (Element JavaDoc) dpf.cloneNode(document, element, true);
76     }
77
78     /**
79      *
80      */

81     public String JavaDoc toString() {
82         return "XLink: type=\""
83             + type
84             + "\", HREF=\""
85             + href
86             + "\", show=\""
87             + show
88             + "\", name=\""
89             + name
90             + "\"";
91     }
92 }
93
Popular Tags