001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.xml;
016    
017    import com.liferay.portal.kernel.xml.Attribute;
018    import com.liferay.portal.kernel.xml.Namespace;
019    import com.liferay.portal.kernel.xml.QName;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class AttributeImpl extends NodeImpl implements Attribute {
025    
026            public AttributeImpl(org.dom4j.Attribute attribute) {
027                    super(attribute);
028    
029                    _attribute = attribute;
030            }
031    
032            public Object getData() {
033                    return _attribute.getData();
034            }
035    
036            public boolean equals(Object obj) {
037                    org.dom4j.Attribute attribute =
038                            ((AttributeImpl)obj).getWrappedAttribute();
039    
040                    return _attribute.equals(attribute);
041            }
042    
043            public Namespace getNamespace() {
044                    org.dom4j.Namespace namespace = _attribute.getNamespace();
045    
046                    if (namespace == null) {
047                            return null;
048                    }
049                    else {
050                            return new NamespaceImpl(namespace);
051                    }
052            }
053    
054            public String getNamespacePrefix() {
055                    return _attribute.getNamespacePrefix();
056            }
057    
058            public String getNamespaceURI() {
059                    return _attribute.getNamespaceURI();
060            }
061    
062            public QName getQName() {
063                    org.dom4j.QName qName = _attribute.getQName();
064    
065                    if (qName == null) {
066                            return null;
067                    }
068                    else {
069                            return new QNameImpl(qName);
070                    }
071            }
072    
073            public String getQualifiedName() {
074                    return _attribute.getQualifiedName();
075            }
076    
077            public String getValue() {
078                    return _attribute.getValue();
079            }
080    
081            public org.dom4j.Attribute getWrappedAttribute() {
082                    return _attribute;
083            }
084    
085            public int hashCode() {
086                    return _attribute.hashCode();
087            }
088    
089            public void setData(Object data) {
090                    _attribute.setData(data);
091            }
092    
093            public void setNamespace(Namespace namespace) {
094                    NamespaceImpl namespaceImpl = (NamespaceImpl)namespace;
095    
096                    _attribute.setNamespace(namespaceImpl.getWrappedNamespace());
097            }
098    
099            public void setValue(String value) {
100                    _attribute.setValue(value);
101            }
102    
103            public String toString() {
104                    return _attribute.toString();
105            }
106    
107            private org.dom4j.Attribute _attribute;
108    
109    }