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.*; 31 import com.hp.hpl.jena.ontology.*; 32 import com.hp.hpl.jena.rdf.model.*; 33 import com.hp.hpl.jena.rdf.model.Resource; 34 import com.hp.hpl.jena.util.iterator.ExtendedIterator; 35 36 37 46 public class AllDifferentImpl 47 extends OntResourceImpl 48 implements AllDifferent 49 { 50 53 56 61 public static Implementation factory = new Implementation() { 62 public EnhNode wrap( Node n, EnhGraph eg ) { 63 if (canWrap( n, eg )) { 64 return new AllDifferentImpl( n, eg ); 65 } 66 else { 67 throw new ConversionException( "Cannot convert node " + n + " to AllDifferent"); 68 } 69 } 70 71 public boolean canWrap( Node node, EnhGraph eg ) { 72 Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null; 74 return (profile != null) && profile.isSupported( node, eg, AllDifferent.class ); 75 } 76 }; 77 78 79 82 85 93 public AllDifferentImpl( Node n, EnhGraph g ) { 94 super( n, g ); 95 } 96 97 98 99 102 109 public void setDistinctMembers( RDFList members ) { 110 setPropertyValue( getProfile().DISTINCT_MEMBERS(), "DISTINCT_MEMBERS", members ); 111 } 112 113 118 public void addDistinctMember( Resource res ) { 119 addListPropertyValue( getProfile().DISTINCT_MEMBERS(), "DISTINCT_MEMBERS", res ); 120 } 121 122 127 public void addDistinctMembers( Iterator individuals ) { 128 while (individuals.hasNext()) { 129 addDistinctMember( (Resource) individuals.next() ); 130 } 131 } 132 133 138 public RDFList getDistinctMembers() { 139 return (RDFList) objectAs( getProfile().DISTINCT_MEMBERS(), "DISTINCT_MEMBERS", RDFList.class ); 140 } 141 142 148 public ExtendedIterator listDistinctMembers() { 149 return getDistinctMembers().iterator(); 150 } 151 152 158 public boolean hasDistinctMember( Resource res ) { 159 return getDistinctMembers().contains( res ); 160 } 161 162 167 public void removeDistinctMember( Resource res ) { 168 setDistinctMembers( getDistinctMembers().remove( res ) ); 169 } 170 171 172 173 176 180 } 181 182 183 212 213 | Popular Tags |