1 6 7 package com.hp.hpl.jena.enhanced.test; 8 9 import com.hp.hpl.jena.enhanced.*; 10 import com.hp.hpl.jena.graph.*; 11 15 public class TestSubjectImpl extends TestCommonImpl implements TestSubject { 16 17 public static final Implementation factory = new Implementation() { 18 public boolean canWrap( Node n, EnhGraph eg ) 19 { return true; } 20 public EnhNode wrap(Node n,EnhGraph eg) { 21 return new TestSubjectImpl(n,eg); 22 } 23 }; 24 25 26 private TestSubjectImpl(Node n,EnhGraph eg) { 27 super( n, eg ); 28 } 29 30 public boolean supports( Class t) 31 { return t.isInstance( this ) && isSubject(); } 32 33 public boolean isSubject() { 34 return findSubject() != null; 35 } 36 37 public TestProperty aProperty() { 38 if (!isSubject()) 39 throw new IllegalStateException ("Node is not the subject of a triple."); 40 return (TestProperty)enhGraph.getNodeAs(findSubject().getPredicate(),TestProperty.class); 41 } 42 } 43 44 73 | Popular Tags |