/** make a new instance of a type _interf_ based on the node _n_ and the polymorphic _that_; use the implementation wrapper for _interf_ in _types_. */ public <X extends T> X newInstance( Class<X> interf, Node n, EnhGraph that ) { Implementation impl = types.get( interf ); if (impl == null) throw new PersonalityConfigException( interf + " not in Personality." ); EnhNode result = impl.wrap( n, that ); if (!interf.isInstance(result)) throw new PersonalityConfigException( interf + " misconfigured." ); return interf.cast( result ); }
/** answer true iff this enhanced node can support the class <code>t</code>, ie it is already a value <code>t</code> or it can be reimplemented as a <code>t</code> via the graph's personality's implementation. If this node has no graph, answer false. */ @Override protected <X extends RDFNode> boolean canSupport( Class<X> t ) { if (alreadyHasView( t )) return true; if (getGraph() == null) return false; Implementation imp = getPersonality().getImplementation( t ); return imp == null ? false : imp.canWrap( asNode(), getGraph() ); }
/** answer true iff this enhanced node can support the class <code>t</code>, ie it is already a value <code>t</code> or it can be reimplemented as a <code>t</code> via the graph's personality's implementation. If this node has no graph, answer false. */ @Override protected <X extends RDFNode> boolean canSupport( Class<X> t ) { if (alreadyHasView( t )) return true; if (getGraph() == null) return false; Implementation imp = getPersonality().getImplementation( t ); return imp == null ? false : imp.canWrap( asNode(), getGraph() ); }
/** make a new instance of a type _interf_ based on the node _n_ and the polymorphic _that_; use the implementation wrapper for _interf_ in _types_. */ public <X extends T> X newInstance( Class<X> interf, Node n, EnhGraph that ) { Implementation impl = types.get( interf ); if (impl == null) throw new PersonalityConfigException( interf + " not in Personality." ); EnhNode result = impl.wrap( n, that ); if (!interf.isInstance(result)) throw new PersonalityConfigException( interf + " misconfigured." ); return interf.cast( result ); }
/** Answer an new enhanced node object that presents <i>this</i> in a way which satisfies type <code>t</code>. The new object is linked into this object's sibling ring. If the node cannot be converted, throw an UnsupportedPolymorphismException. */ @Override protected <X extends RDFNode> X convertTo( Class<X> t ) { EnhGraph eg = getGraph(); if (eg == null) throw new UnsupportedPolymorphismException( this, false, t ); Implementation imp = getPersonality().getImplementation( t ); if (imp == null) throw new UnsupportedPolymorphismException( this, true, t ); EnhNode result = imp.wrap( asNode(), eg ); this.addView( result ); return t.cast( result ); }
/** Answer an new enhanced node object that presents <i>this</i> in a way which satisfies type <code>t</code>. The new object is linked into this object's sibling ring. If the node cannot be converted, throw an UnsupportedPolymorphismException. */ @Override protected <X extends RDFNode> X convertTo( Class<X> t ) { EnhGraph eg = getGraph(); if (eg == null) throw new UnsupportedPolymorphismException( this, false, t ); Implementation imp = getPersonality().getImplementation( t ); if (imp == null) throw new UnsupportedPolymorphismException( this, true, t ); EnhNode result = imp.wrap( asNode(), eg ); this.addView( result ); return t.cast( result ); }