@Override public boolean test( T x ) { Node n = (x instanceof Triple) ? ((Triple) x).getSubject() : ((x instanceof EnhNode) ? ((EnhNode) x).asNode() : (Node) x); try { getNodeAs( n, m_asKey ); } catch (Exception ignore) { return false; } return true; } }
@Override public boolean test( T x ) { Node n = (x instanceof Triple) ? ((Triple) x).getSubject() : ((x instanceof EnhNode) ? ((EnhNode) x).asNode() : (Node) x); try { getNodeAs( n, m_asKey ); } catch (Exception ignore) { return false; } return true; } }
/** 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 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 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 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() ); }
public void testXMLLiteral() { Literal ll; ll = m.createLiteral("<bad",true); assertTrue("Error checking must be off.",((EnhNode)ll).asNode().getLiteralIsXML()); ll = m.createTypedLiteral("<bad/>",XMLLiteralType.theXMLLiteralType); assertFalse("Error checking must be on.",((EnhNode)ll).asNode().getLiteralIsXML()); ll = m.createTypedLiteral("<good></good>",XMLLiteralType.theXMLLiteralType); assertTrue("Well-formed XMLLiteral.",((EnhNode)ll).asNode().getLiteralIsXML()); }
public void testXMLLiteral() { Literal ll; ll = m.createLiteral("<bad",true); assertTrue("Error checking must be off.",((EnhNode)ll).asNode().getLiteralIsXML()); ll = m.createTypedLiteral("<bad/>",XMLLiteralType.theXMLLiteralType); assertFalse("Error checking must be on.",((EnhNode)ll).asNode().getLiteralIsXML()); ll = m.createTypedLiteral("<good></good>",XMLLiteralType.theXMLLiteralType); assertTrue("Well-formed XMLLiteral.",((EnhNode)ll).asNode().getLiteralIsXML()); }