1 19 20 package com.hp.hpl.jena.ontology.impl; 23 24 25 26 import com.hp.hpl.jena.enhanced.*; 29 import com.hp.hpl.jena.graph.*; 30 import com.hp.hpl.jena.ontology.*; 31 import com.hp.hpl.jena.rdf.model.Resource; 32 33 34 43 public class SomeValuesFromRestrictionImpl 44 extends RestrictionImpl 45 implements SomeValuesFromRestriction 46 { 47 50 53 58 public static Implementation factory = new Implementation() { 59 public EnhNode wrap( Node n, EnhGraph eg ) { 60 if (canWrap( n, eg )) { 61 return new SomeValuesFromRestrictionImpl( n, eg ); 62 } 63 else { 64 throw new ConversionException( "Cannot convert node " + n + " to SomeValuesFromRestriction"); 65 } 66 } 67 68 public boolean canWrap( Node node, EnhGraph eg ) { 69 Profile profile = (eg instanceof OntModel) ? ((OntModel) eg).getProfile() : null; 72 return (profile != null) && profile.isSupported( node, eg, SomeValuesFromRestriction.class ); 73 } 74 }; 75 76 77 80 83 91 public SomeValuesFromRestrictionImpl( Node n, EnhGraph g ) { 92 super( n, g ); 93 } 94 95 96 99 101 108 public void setSomeValuesFrom( Resource cls ) { 109 setPropertyValue( getProfile().SOME_VALUES_FROM(), "SOME_VALUES_FROM", cls ); 110 } 111 112 119 public Resource getSomeValuesFrom() { 120 checkProfile( getProfile().SOME_VALUES_FROM(), "SOME_VALUES_FROM" ); 121 Resource r = (Resource) getRequiredProperty( getProfile().SOME_VALUES_FROM() ).getObject(); 122 123 boolean currentStrict = ((OntModel) getModel()).strictMode(); 124 ((OntModel) getModel()).setStrictMode( true ); 125 126 try { 127 if (r.canAs( OntClass.class )) { 128 return (Resource) r.as( OntClass.class ); 130 } 131 else if (r.canAs( DataRange.class )) { 132 return (Resource) r.as( DataRange.class ); 134 } 135 else { 136 return r; 138 } 139 } 140 finally { 141 ((OntModel) getModel()).setStrictMode( currentStrict ); 142 } 143 } 144 145 152 public boolean hasSomeValuesFrom( Resource cls ) { 153 return hasPropertyValue( getProfile().SOME_VALUES_FROM(), "SOME_VALUES_FROM", cls ); 154 } 155 156 162 public void removeSomeValuesFrom( Resource cls ) { 163 removePropertyValue( getProfile().SOME_VALUES_FROM(), "SOME_VALUES_FROM", cls ); 164 } 165 166 167 170 174 } 175 176 177 206 207 | Popular Tags |