001    /**
002     * Copyright (c) 2000-present 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.util.StringPool;
018    import com.liferay.portal.kernel.xml.DocumentType;
019    
020    import java.util.Objects;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class DocumentTypeImpl implements DocumentType {
026    
027            public DocumentTypeImpl(org.dom4j.DocumentType documentType) {
028                    _documentType = documentType;
029            }
030    
031            @Override
032            public boolean equals(Object obj) {
033                    if (this == obj) {
034                            return true;
035                    }
036    
037                    if (!(obj instanceof DocumentTypeImpl)) {
038                            return false;
039                    }
040    
041                    DocumentTypeImpl documentTypeImpl = (DocumentTypeImpl)obj;
042    
043                    if (Objects.equals(_documentType, documentTypeImpl._documentType)) {
044                            return true;
045                    }
046    
047                    return false;
048            }
049    
050            @Override
051            public String getName() {
052                    return _documentType.getName();
053            }
054    
055            @Override
056            public String getPublicId() {
057                    if (_documentType == null) {
058                            return null;
059                    }
060    
061                    return _documentType.getPublicID();
062            }
063    
064            @Override
065            public String getSystemId() {
066                    if (_documentType == null) {
067                            return null;
068                    }
069    
070                    return _documentType.getSystemID();
071            }
072    
073            public org.dom4j.DocumentType getWrappedDocumentType() {
074                    return _documentType;
075            }
076    
077            @Override
078            public int hashCode() {
079                    if (_documentType == null) {
080                            return super.hashCode();
081                    }
082    
083                    return _documentType.hashCode();
084            }
085    
086            @Override
087            public String toString() {
088                    if (_documentType == null) {
089                            return StringPool.BLANK;
090                    }
091    
092                    return _documentType.toString();
093            }
094    
095            private org.dom4j.DocumentType _documentType;
096    
097    }