001    /**
002     * Copyright (c) 2000-2013 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    import com.liferay.portal.kernel.xml.Visitor;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class AttributeImpl extends NodeImpl implements Attribute {
026    
027            public AttributeImpl(org.dom4j.Attribute attribute) {
028                    super(attribute);
029    
030                    _attribute = attribute;
031            }
032    
033            @Override
034            public <T, V extends Visitor<T>> T accept(V visitor) {
035                    return visitor.visitAttribute(this);
036            }
037    
038            @Override
039            public boolean equals(Object obj) {
040                    if (this == obj) {
041                            return true;
042                    }
043    
044                    if (!(obj instanceof AttributeImpl)) {
045                            return false;
046                    }
047    
048                    org.dom4j.Attribute attribute =
049                            ((AttributeImpl)obj).getWrappedAttribute();
050    
051                    return _attribute.equals(attribute);
052            }
053    
054            @Override
055            public Object getData() {
056                    return _attribute.getData();
057            }
058    
059            @Override
060            public Namespace getNamespace() {
061                    org.dom4j.Namespace namespace = _attribute.getNamespace();
062    
063                    if (namespace == null) {
064                            return null;
065                    }
066                    else {
067                            return new NamespaceImpl(namespace);
068                    }
069            }
070    
071            @Override
072            public String getNamespacePrefix() {
073                    return _attribute.getNamespacePrefix();
074            }
075    
076            @Override
077            public String getNamespaceURI() {
078                    return _attribute.getNamespaceURI();
079            }
080    
081            @Override
082            public QName getQName() {
083                    org.dom4j.QName qName = _attribute.getQName();
084    
085                    if (qName == null) {
086                            return null;
087                    }
088                    else {
089                            return new QNameImpl(qName);
090                    }
091            }
092    
093            @Override
094            public String getQualifiedName() {
095                    return _attribute.getQualifiedName();
096            }
097    
098            @Override
099            public String getValue() {
100                    return _attribute.getValue();
101            }
102    
103            public org.dom4j.Attribute getWrappedAttribute() {
104                    return _attribute;
105            }
106    
107            @Override
108            public int hashCode() {
109                    return _attribute.hashCode();
110            }
111    
112            @Override
113            public void setData(Object data) {
114                    _attribute.setData(data);
115            }
116    
117            @Override
118            public void setNamespace(Namespace namespace) {
119                    NamespaceImpl namespaceImpl = (NamespaceImpl)namespace;
120    
121                    _attribute.setNamespace(namespaceImpl.getWrappedNamespace());
122            }
123    
124            @Override
125            public void setValue(String value) {
126                    _attribute.setValue(value);
127            }
128    
129            @Override
130            public String toString() {
131                    return _attribute.toString();
132            }
133    
134            private org.dom4j.Attribute _attribute;
135    
136    }