001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: /* $Id: XLink.java 473861 2006-11-12 03:51:14Z gregor $ */
020:
021: package org.apache.lenya.xml;
022:
023: import org.w3c.dom.Attr;
024: import org.w3c.dom.Element;
025:
026: /**
027: * Helper class for XLinks
028: */
029: public class XLink {
030:
031: /**
032: * <code>type</code> The Xlink type
033: */
034: public String type = null;
035: /**
036: * <code>href</code> The XLink href
037: */
038: public String href = null;
039: /**
040: * <code>show</code> The value of the show attribute
041: */
042: public String show = null;
043: /**
044: * <code>name</code> The Xlink name
045: */
046: public String name = null;
047: /**
048: * <code>element</code> The Xlink element
049: */
050: public Element element = null;
051: /**
052: * <code>XLINK_NAMESPACE</code> The XLink namespace
053: */
054: public static final String XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
055: /**
056: * <code>ATTRIBUTE_HREF</code> The href attribte
057: */
058: public static final String ATTRIBUTE_HREF = "href";
059: /**
060: * <code>ATTRIBUTE_SHOW</code> The show attribute
061: */
062: public static final String ATTRIBUTE_SHOW = "show";
063: /**
064: * <code>ATTRIBUTE_TYPE</code> The type attribute
065: */
066: public static final String ATTRIBUTE_TYPE = "type";
067:
068: /**
069: * Constructor
070: */
071: public XLink() {
072: this .type = "simple";
073: this .show = "undefined";
074: }
075:
076: /**
077: * Constructor
078: * @param _element The element
079: */
080: public XLink(Element _element) {
081: this ();
082: this .element = _element;
083:
084: this .name = _element.getNodeName();
085:
086: Attr hrefAttribute = _element.getAttributeNodeNS(
087: XLINK_NAMESPACE, ATTRIBUTE_HREF);
088: if (hrefAttribute != null) {
089: this .href = hrefAttribute.getNodeValue();
090: }
091: Attr typeAttribute = _element.getAttributeNodeNS(
092: XLINK_NAMESPACE, ATTRIBUTE_TYPE);
093: if (typeAttribute != null) {
094: this .type = typeAttribute.getNodeValue();
095: }
096: Attr showAttribute = _element.getAttributeNodeNS(
097: XLINK_NAMESPACE, ATTRIBUTE_SHOW);
098: if (showAttribute != null) {
099: this .show = showAttribute.getNodeValue();
100: }
101:
102: }
103:
104: /**
105: * Returns a printout of the XLink values
106: * @return The printout
107: */
108: public String toString() {
109: return "XLink: type=\"" + this .type + "\", href=\"" + this .href
110: + "\", show=\"" + this .show + "\", name=\"" + this .name
111: + "\"";
112: }
113: }
|