1 19 20 package com.hp.hpl.jena.ontology.impl; 23 24 25 import java.util.Iterator ; 28 29 import com.hp.hpl.jena.enhanced.*; 30 import com.hp.hpl.jena.graph.Node; 31 import com.hp.hpl.jena.ontology.*; 32 import com.hp.hpl.jena.rdf.model.*; 33 import com.hp.hpl.jena.util.iterator.ExtendedIterator; 34 35 36 45 public class ComplementClassImpl 46 extends OntClassImpl 47 implements ComplementClass 48 { 49 52 55 60 public static Implementation factory = new Implementation() { 61 public EnhNode wrap( Node n, EnhGraph eg ) { 62 if (canWrap( n, eg )) { 63 return new ComplementClassImpl( n, eg ); 64 } 65 else { 66 throw new ConversionException( "Cannot convert node " + n + " to ComplementClass"); 67 } 68 } 69 70 public boolean canWrap( Node node, EnhGraph eg ) { 71 Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null; 73 Property comp = (profile == null) ? null : profile.COMPLEMENT_OF(); 74 75 return (profile != null) && 76 profile.isSupported( node, eg, OntClass.class ) && 77 comp != null && 78 eg.asGraph().contains( node, comp.asNode(), Node.ANY ); 79 } 80 }; 81 82 83 86 89 97 public ComplementClassImpl( Node n, EnhGraph g ) { 98 super( n, g ); 99 } 100 101 102 105 107 115 public void setOperands( RDFList operands ) { 116 throw new UnsupportedOperationException ( "ComplementClass takes a single operand, not a list."); 117 } 118 119 120 126 public void setOperand( Resource cls ) { 127 setPropertyValue( getProfile().COMPLEMENT_OF(), "COMPLEMENT_OF", cls ); 128 } 129 130 136 public void addOperand( Resource cls ) { 137 throw new UnsupportedOperationException ( "ComplementClass is only defined for a single operand."); 138 } 139 140 146 public void addOperands( Iterator classes ) { 147 throw new UnsupportedOperationException ( "ComplementClass is only defined for a single operand."); 148 } 149 150 155 public RDFList getOperands() { 156 throw new UnsupportedOperationException ( "ComplementClass takes a single operand, not a list."); 157 } 158 159 165 public ExtendedIterator listOperands() { 166 return listAs( getProfile().COMPLEMENT_OF(), "COMPLEMENT_OF", OntClass.class ); 167 } 168 169 175 public boolean hasOperand( Resource cls ) { 176 return hasPropertyValue( getProfile().COMPLEMENT_OF(), "COMPLEMENT_OF", cls ); 177 } 178 179 184 public OntClass getOperand() { 185 return (OntClass) objectAs( getProfile().COMPLEMENT_OF(), "COMPLEMENT_OF", OntClass.class ); 186 } 187 188 192 public void removeOperand( Resource res ) { 193 removePropertyValue( getProfile().COMPLEMENT_OF(), "COMPLEMENT_OF", res ); 194 } 195 196 197 202 public Property operator() { 203 return getProfile().COMPLEMENT_OF(); 204 } 205 206 207 208 211 215 } 216 217 218 247 248 249 | Popular Tags |