001/**
002 * Copyright (C) 2007 - 2016, 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 */
019package org.dllearner.core.owl;
020
021import java.util.Set;
022import java.util.SortedSet;
023import java.util.TreeMap;
024
025import org.dllearner.core.AbstractReasonerComponent;
026import org.semanticweb.owlapi.model.OWLClassExpression;
027import org.slf4j.Logger;
028import org.slf4j.LoggerFactory;
029
030/**
031 * Represents a class subsumption hierarchy (ignoring equivalent concepts).
032 * 
033 * @author Jens Lehmann
034 * 
035 */
036public class LazyClassHierarchy extends ClassHierarchy {
037
038        public static Logger logger = LoggerFactory.getLogger(LazyClassHierarchy.class);
039        
040        private AbstractReasonerComponent rc;
041        
042        public LazyClassHierarchy(AbstractReasonerComponent rc) {
043                super(new TreeMap<>(), new TreeMap<>());
044                this.rc = rc;
045        }
046
047        @Override
048        public SortedSet<OWLClassExpression> getSuperClasses(OWLClassExpression concept, boolean direct) {
049                return rc.getSuperClasses(concept);
050        }
051
052        @Override
053        public SortedSet<OWLClassExpression> getSubClasses(OWLClassExpression concept, boolean direct) {
054                return rc.getSubClasses(concept);
055        }
056
057        @Override
058        public LazyClassHierarchy clone() {
059                return new LazyClassHierarchy(rc);              
060        }
061        
062        /* (non-Javadoc)
063         * @see org.dllearner.core.owl.AbstractHierarchy#cloneAndRestrict(java.util.Set)
064         */
065        @Override
066        public AbstractHierarchy<OWLClassExpression> cloneAndRestrict(Set<? extends OWLClassExpression> allowedEntities) {
067                return new LazyClassHierarchy(rc);
068        }
069        
070        /* (non-Javadoc)
071         * @see org.dllearner.core.owl.AbstractHierarchy#thinOutSubsumptionHierarchy()
072         */
073        @Override
074        public void thinOutSubsumptionHierarchy() {
075                // do nothing here because we don't have anything precomputed
076        }
077}