001    /**
002     * Copyright (c) 2000-2012 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                    org.dom4j.Attribute attribute =
041                            ((AttributeImpl)obj).getWrappedAttribute();
042    
043                    return _attribute.equals(attribute);
044            }
045    
046            public Object getData() {
047                    return _attribute.getData();
048            }
049    
050            public Namespace getNamespace() {
051                    org.dom4j.Namespace namespace = _attribute.getNamespace();
052    
053                    if (namespace == null) {
054                            return null;
055                    }
056                    else {
057                            return new NamespaceImpl(namespace);
058                    }
059            }
060    
061            public String getNamespacePrefix() {
062                    return _attribute.getNamespacePrefix();
063            }
064    
065            public String getNamespaceURI() {
066                    return _attribute.getNamespaceURI();
067            }
068    
069            public QName getQName() {
070                    org.dom4j.QName qName = _attribute.getQName();
071    
072                    if (qName == null) {
073                            return null;
074                    }
075                    else {
076                            return new QNameImpl(qName);
077                    }
078            }
079    
080            public String getQualifiedName() {
081                    return _attribute.getQualifiedName();
082            }
083    
084            public String getValue() {
085                    return _attribute.getValue();
086            }
087    
088            public org.dom4j.Attribute getWrappedAttribute() {
089                    return _attribute;
090            }
091    
092            @Override
093            public int hashCode() {
094                    return _attribute.hashCode();
095            }
096    
097            public void setData(Object data) {
098                    _attribute.setData(data);
099            }
100    
101            public void setNamespace(Namespace namespace) {
102                    NamespaceImpl namespaceImpl = (NamespaceImpl)namespace;
103    
104                    _attribute.setNamespace(namespaceImpl.getWrappedNamespace());
105            }
106    
107            public void setValue(String value) {
108                    _attribute.setValue(value);
109            }
110    
111            @Override
112            public String toString() {
113                    return _attribute.toString();
114            }
115    
116            private org.dom4j.Attribute _attribute;
117    
118    }