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.util.Iterator;
023    import java.util.Map;
024    import java.util.Set;
025    
026    /**
027     * @author Jens Lehmann
028     *
029     */
030    public class DisjointClassesAxiom extends TerminologicalAxiom {
031    
032            /**
033             * 
034             */
035            private static final long serialVersionUID = 7788863077013583508L;
036            private Set<Description> descriptions;
037            
038            public DisjointClassesAxiom(Set<Description> descriptions) {
039                    this.descriptions = descriptions;
040            }
041    
042            /* (non-Javadoc)
043             * @see org.dllearner.core.owl.KBElement#getLength()
044             */
045            public int getLength() {
046                    int length = 1;
047                    for(Description d : descriptions)
048                            length += d.getLength();
049                    return length;
050            }
051    
052            /* (non-Javadoc)
053             * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map)
054             */
055            public String toString(String baseURI, Map<String, String> prefixes) {
056                    StringBuffer sb = new StringBuffer();
057                    sb.append("DisjointClasses(");
058                    Iterator<Description> it = descriptions.iterator();
059                    while(it.hasNext()){
060                            sb.append(it.next().toString());
061                            if(it.hasNext()){
062                                    sb.append(", ");
063                            }
064                    }
065                    sb.append(")");
066                    return sb.toString();
067            }
068            
069            public String toKBSyntaxString(String baseURI, Map<String, String> prefixes) {
070                    StringBuffer sb = new StringBuffer();
071                    sb.append("DisjointClasses(");
072                    Iterator<Description> it = descriptions.iterator();
073                    while(it.hasNext()){
074                            sb.append(it.next().toKBSyntaxString());
075                            if(it.hasNext()){
076                                    sb.append(", ");
077                            }
078                    }
079                    sb.append(")");
080                    return sb.toString();
081            }
082            
083            
084    
085            @Override
086            public void accept(AxiomVisitor visitor) {
087                    visitor.visit(this);
088            }
089    
090            public void accept(KBElementVisitor visitor) {
091                    visitor.visit(this);
092            }
093    
094            /**
095             * @return the descriptions
096             */
097            public Set<Description> getDescriptions() {
098                    return descriptions;
099            }
100    
101            /* (non-Javadoc)
102             * @see org.dllearner.core.owl.KBElement#toManchesterSyntaxString(java.lang.String, java.util.Map)
103             */
104            @Override
105            public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) {
106                    StringBuffer sb = new StringBuffer();
107                    sb.append("DisjointClasses(");
108                    Iterator<Description> it = descriptions.iterator();
109                    while(it.hasNext()){
110                            sb.append(it.next().toManchesterSyntaxString(baseURI, prefixes));
111                            if(it.hasNext()){
112                                    sb.append(", ");
113                            }
114                    }
115                    sb.append(")");
116                    return sb.toString();
117            }       
118            
119    }