private String extractArg(String prefix, List<Node> objArgs) { String value = null; for (Node node : objArgs) { if (node.isLiteral()) { String arg = node.getLiteral().toString(); if (arg.startsWith(prefix + ":")) { value = arg.substring(prefix.length()+1); break; } } } return value; }
public void testGetLiteralValuePlainString() { Node s = NodeCreateUtils.create( "'aString'" ); assertSame( s.getLiteral().getValue(), s.getLiteralValue() ); }
public void testHashCodesForHexBinary_1() { LiteralLabel A = node("'0123'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; LiteralLabel B = node("'0123'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testGetLiteralValuePlainString() { Node s = NodeCreateUtils.create( "'aString'" ); assertSame( s.getLiteral().getValue(), s.getLiteralValue() ); }
public void testHashCodesForHexBinary_2() { LiteralLabel A = node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; LiteralLabel B = node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testHashCodesForBase64Binary_1() { LiteralLabel A = node("'0123'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral() ; LiteralLabel B = node("'0123'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testHashCodesForHexBinary_1() { LiteralLabel A = node("'0123'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; LiteralLabel B = node("'0123'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testHashCodesForHexBinary_2() { LiteralLabel A = node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; LiteralLabel B = node("'illegal'http://www.w3.org/2001/XMLSchema#hexBinary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testHashCodesForBase64Binary_2() { LiteralLabel A = node("'illgeal'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral() ; LiteralLabel B = node("'illgeal'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testHashCodesForBase64Binary_2() { LiteralLabel A = node("'illgeal'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral() ; LiteralLabel B = node("'illgeal'http://www.w3.org/2001/XMLSchema#base64Binary").getLiteral() ; assertEquals(A.hashCode(), B.hashCode()) ; }
public void testIsValidLiteral1() { Literal lit = m.createTypedLiteral("100", XSDDatatype.XSD+"#anyType") ; assertFalse(XSDDatatype.XSDinteger.isValidLiteral(lit.asNode().getLiteral())); } public void testIsValidLiteral2()
public void testIsValidLiteral2() { Literal lit = m.createTypedLiteral("100", XSDDatatype.XSD+"#anySimpleType") ; assertFalse(XSDDatatype.XSDinteger.isValidLiteral(lit.asNode().getLiteral())); }
public void testIsValidLiteral1() { Literal lit = m.createTypedLiteral("100", XSDDatatype.XSD+"#anyType") ; assertFalse(XSDDatatype.XSDinteger.isValidLiteral(lit.asNode().getLiteral())); } public void testIsValidLiteral2()
public static String str(Node node) { if ( node.isLiteral() ) return node.getLiteral().getLexicalForm() ; if ( node.isURI() ) return node.getURI() ; // if ( node.isBlank() ) return node.getBlankNodeId().getLabelString() ; // if ( node.isBlank() ) return "" ; if ( node.isBlank() ) NodeValue.raise(new ExprTypeException("Blank node: " + node)) ; NodeValue.raise(new ExprEvalException("Not a string: " + node)) ; return "[undef]" ; }
public void testBinary2() { // Check round tripping from value LiteralLabel l2 = m.createTypedLiteral("DCpj", XSDDatatype.XSDbase64Binary).asNode().getLiteral(); Object data2 = l2.getValue(); assertTrue("binary test 3", data2 instanceof byte[]); byte[] data2b = (byte[])data2; assertEquals("binary test 4", data2b[0], data[0]); assertEquals("binary test 5", data2b[1], data[1]); assertEquals("binary test 6", data2b[2], data[2]); }
public void testBinary2() { // Check round tripping from value LiteralLabel l2 = m.createTypedLiteral("DCpj", XSDDatatype.XSDbase64Binary).asNode().getLiteral(); Object data2 = l2.getValue(); assertTrue("binary test 3", data2 instanceof byte[]); byte[] data2b = (byte[])data2; assertEquals("binary test 4", data2b[0], data[0]); assertEquals("binary test 5", data2b[1], data[1]); assertEquals("binary test 6", data2b[2], data[2]); }
@Test public void testMakeNode() { NodeValueSortKey nv = new NodeValueSortKey("Casa", "pt-BR"); Node n = nv.makeNode(); assertTrue(n.isLiteral()); assertEquals("Casa", n.getLiteral().toString()); }
/** test that the label of a Node can be retrieved from that Node in a way appropriate to that Node. */ public void testLabels() { BlankNodeId id = BlankNodeId.create(); assertEquals( "get URI value", U, NodeFactory.createURI( U ).getURI() ); assertEquals( "get blank value", id, NodeFactory.createBlankNode( id ).getBlankNodeId() ); assertEquals( "get literal value", L, NodeFactory.createLiteral( L ).getLiteral() ); assertEquals( "get variable name", N, NodeFactory.createVariable( N ).getName() ); }
public void testLiterals() { assertFalse( "literal nodes aren't blank", NodeFactory.createLiteral( L ).isBlank() ); assertTrue( "literal nodes are literal", NodeFactory.createLiteral( L ).isLiteral() ); assertFalse( "literal nodes aren't variables", NodeFactory.createLiteral( L ).isVariable() ); assertFalse( "literal nodes aren't URIs", NodeFactory.createLiteral( L ).isURI() ); assertEquals( "literal nodes preserve value", NodeFactory.createLiteral( L ).getLiteral(), L ); }
public void testLiterals() { assertFalse( "literal nodes aren't blank", NodeFactory.createLiteral( L ).isBlank() ); assertTrue( "literal nodes are literal", NodeFactory.createLiteral( L ).isLiteral() ); assertFalse( "literal nodes aren't variables", NodeFactory.createLiteral( L ).isVariable() ); assertFalse( "literal nodes aren't URIs", NodeFactory.createLiteral( L ).isURI() ); assertEquals( "literal nodes preserve value", NodeFactory.createLiteral( L ).getLiteral(), L ); }