1 6 7 package com.hp.hpl.jena.enhanced; 8 9 import com.hp.hpl.jena.graph.*; 10 import com.hp.hpl.jena.rdf.model.*; 11 12 22 public class EnhNode extends Polymorphic implements FrontsNode 23 { 24 25 26 final protected Node node; 27 28 29 final protected EnhGraph enhGraph; 30 31 public EnhNode( Node n, EnhGraph g ) { 32 super(); 33 node=n; 34 enhGraph = g; 35 } 36 37 39 43 public Node asNode() { 44 return node; 45 } 46 47 51 public EnhGraph getGraph() { 52 return enhGraph; 53 } 54 55 63 public EnhNode viewAs( Class t ) { 64 return (EnhNode) asInternal( t ); 65 } 66 67 68 public RDFNode as( Class t ) 69 { return (RDFNode) viewAs( t ); } 70 71 74 public boolean canAs( Class t ) 75 { return canSupport( t ); } 76 77 81 final public int hashCode() { 82 return node.hashCode(); 83 } 84 85 96 final public boolean equals( Object o ) 97 { return o instanceof FrontsNode && node.equals(((FrontsNode) o).asNode()); } 98 99 public boolean isValid() 100 { return true; } 101 102 108 protected Polymorphic convertTo( Class t ) 109 { 110 EnhGraph eg = getGraph(); 111 Implementation imp = getPersonality().getImplementation( t ); 112 if (imp == null) throw new UnsupportedPolymorphismException( eg, t ); 113 Polymorphic result = imp.wrap( asNode(), eg ); 114 this.addView( result ); 115 return result; 116 } 117 118 124 protected boolean canSupport( Class t ) 125 { 126 return getPersonality().getImplementation( t ).canWrap( asNode(), getGraph() ); 127 } 128 129 135 protected Personality getPersonality() { 136 return ((GraphPersonality) getGraph().getPersonality()).nodePersonality(); 137 } 138 139 } 140 141 170 | Popular Tags |