001    /**
002     * Copyright (C) 2007-2011, Jens Lehmann
003     *
004     * This file is part of DL-Learner.
005     *
006     * DL-Learner is free software; you can redistribute it and/or modify
007     * it under the terms of the GNU General Public License as published by
008     * the Free Software Foundation; either version 3 of the License, or
009     * (at your option) any later version.
010     *
011     * DL-Learner is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014     * GNU General Public License for more details.
015     *
016     * You should have received a copy of the GNU General Public License
017     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
018     */
019    
020    package org.dllearner.core.owl;
021    
022    import java.net.URI;
023    import java.util.Map;
024    
025    /**
026     * @author Jens Lehmann
027     *
028     */
029    public class Datatype implements DataRange {
030            
031        private URI uri;
032    
033        public Datatype(String uriString) {
034            uri = URI.create(uriString);
035        }
036    
037            public URI getURI() {
038                    return uri;
039            }
040    
041            @Override
042            public String toString() {
043                    return uri.toString();
044            }
045    
046            public int getLength() {
047                    return 1;
048            }
049    
050            public void accept(KBElementVisitor visitor) {
051                    visitor.visit(this);
052            }       
053            
054            public String toString(String baseURI, Map<String, String> prefixes) {
055                    return uri.toString();
056            }
057            
058            public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) {
059                    return uri.toString();
060            }
061            
062            /* (non-Javadoc)
063             * @see org.dllearner.core.owl.KBElement#toManchesterSyntaxString(java.lang.String, java.util.Map)
064             */
065            @Override
066            public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
067                    return uri.toString();
068            }
069    
070            @Override
071            public int hashCode() {
072                    final int prime = 31;
073                    int result = 1;
074                    result = prime * result + ((uri == null) ? 0 : uri.hashCode());
075                    return result;
076            }
077    
078            @Override
079            public boolean equals(Object obj) {
080                    if (this == obj)
081                            return true;
082                    if (obj == null)
083                            return false;
084                    if (getClass() != obj.getClass())
085                            return false;
086                    Datatype other = (Datatype) obj;
087                    if (uri == null) {
088                            if (other.uri != null)
089                                    return false;
090                    } else if (!uri.equals(other.uri))
091                            return false;
092                    return true;
093            }       
094    }