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.util.iterator.ExtendedIterator; 34 35 36 46 public class DataRangeImpl 47 extends OntResourceImpl 48 implements DataRange 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 DataRangeImpl( n, eg ); 65 } 66 else { 67 throw new ConversionException( "Cannot convert node " + n + " to DataRange"); 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, DataRange.class ); 75 } 76 }; 77 78 79 82 85 93 public DataRangeImpl( Node n, EnhGraph g ) { 94 super( n, g ); 95 } 96 97 98 101 104 106 112 public void setOneOf( RDFList en ) { 113 setPropertyValue( getProfile().ONE_OF(), "ONE_OF", en ); 114 } 115 116 121 public void addOneOf( Literal lit ) { 122 addListPropertyValue( getProfile().ONE_OF(), "ONE_OF", lit ); 123 } 124 125 131 public void addOneOf( Iterator literals ) { 132 while( literals.hasNext() ) { 133 addOneOf( (Literal) literals.next() ); 134 } 135 } 136 137 142 public RDFList getOneOf() { 143 return (RDFList) objectAs( getProfile().ONE_OF(), "ONE_OF", RDFList.class ); 144 } 145 146 152 public ExtendedIterator listOneOf() { 153 return getOneOf().iterator().mapWith( new AsMapper( Literal.class ) ); 154 } 155 156 163 public boolean hasOneOf( Literal lit ) { 164 return getOneOf().contains( lit ); 165 } 166 167 173 public void removeOneOf( Literal lit ) { 174 setOneOf( getOneOf().remove( lit ) ); 175 } 176 177 178 181 185 } 186 187 188 217 218 | Popular Tags |