@Override public Void visit(final ASTTrue node, final Object data) throws VisitorException { nodes.put(node, valueFactory.createLiteral(true)); return null; }
@SuppressWarnings("unchecked") public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) { AbstractLiteralIV delegate = iv.getDelegate(); if (delegate==null || !(delegate instanceof PackedLongIV)) { throw new IllegalArgumentException(); } final PackedLongIV pIv = (PackedLongIV)delegate; return (V) vf.createLiteral( String.valueOf(pIv.getInlineValue()), CompressedTimestampExtension.COMPRESSED_TIMESTAMP); }
@Override public Void visit(final ASTNumericLiteral node, final Object data) throws VisitorException { nodes.put( node, valueFactory.createLiteral(node.getValue(), node.getDatatype())); return null; }
@SuppressWarnings("unchecked") public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) { final String s = Float.toString(iv.getDelegate().floatValue()); return (V) vf.createLiteral(s, datatype); }
@Override public IV<?,?> serializeLocationAndTime( final BigdataValueFactory vf, final Object latitude, final Object longitude, final Object time) { return DummyConstantNode.toDummyIV(vf.createLiteral("LocationAndTime(" + concat(latitude, longitude, time) + ")")); }
@Override public IV<?,?> serializeLocation( final BigdataValueFactory vf, final Object latitude, final Object longitude) { return DummyConstantNode.toDummyIV(vf.createLiteral("Location(" + concat(latitude, longitude) + ")")); }
final public IV get(final IBindingSet bs) { final BigdataValueFactory vf = super.getValueFactory(); final UUID uuid = UUID.randomUUID(); if (str()) { final BigdataLiteral l = vf.createLiteral(uuid.toString()); return DummyConstantNode.toDummyIV(l); } else { final BigdataURI uri = vf.createURI("urn:uuid:" + uuid.toString()); return DummyConstantNode.toDummyIV(uri); } }
/** * Attempt to convert the {@link AbstractLiteralIV#byteValue()} back into * a {@link Color}, and then use the string value of the {@link Color} to * create an RDF literal. */ public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) { final byte b = iv.getDelegate().byteValue(); final Color c = Color.valueOf(b); if (c == null) throw new RuntimeException("bad color got encoded somehow"); return (V) vf.createLiteral(c.toString(), color); }
@Override public IV get(final IBindingSet bs) throws SparqlTypeErrorException { final Literal lit = getAndCheckLiteralValue(0, bs); try { final BigdataLiteral str = getValueFactory().createLiteral(URLEncoder.encode(lit.getLabel(), "UTF-8").replace("+", "%20")); return super.asIV(str, bs); } catch (UnsupportedEncodingException uee) { throw new SparqlTypeErrorException(); } } }
@Override @SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { if (uri == null) { uri = (V) lex.getValueFactory().createLiteral(getLabel(), XSD.IPV4); uri.setIV(this); } return uri; }
/** * Returns the Literal representation of this IV. */ @SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { if (literal == null) { literal = (V) lex.getValueFactory().createLiteral(getLabel(), PACKED_LONG); literal.setIV(this); } return literal; }
@SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if (v == null) { final BigdataValueFactory f = lex.getValueFactory(); v = (V) f.createLiteral( value.toPlainString(), DTE.XSDDecimal.getDatatypeURI()); v.setIV(this); setValue(v); } return v; }
@SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if (v == null) { final BigdataValueFactory f = lex.getValueFactory(); v = (V) f.createLiteral( value.toString(), DTE.XSDInteger.getDatatypeURI()); v.setIV(this); setValue(v); } return v; }
@Override @SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if( v == null) { v = (V) lex.getValueFactory().createLiteral(value); v.setIV(this); setValue(v); } return v; }
@SuppressWarnings("unchecked") public V asValue(final LexiconRelation lex) { V v = getValueCache(); if (v == null) { final BigdataValueFactory f = lex.getValueFactory(); v = (V) f.createLiteral(value, true); v.setIV(this); setValue(v); } return v; }
@Override public IV<?,?> serializeLocationAndTime( final BigdataValueFactory vf, final Object latitude, final Object longitude, final Object time) { return DummyConstantNode.toDummyIV(vf.createLiteral("LocationAndTime(" + concat(latitude, longitude, time) + ")")); }
/** * Use the string value of the {@link LiteralExtensionIV} (which defers to the * string value of the native type) to create a literal with the epoch * datatype. */ public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) { return (V) vf.createLiteral(iv.getDelegate().stringValue(), epoch); }
/** * Attempt to convert the {@link AbstractLiteralIV#byteValue()} back into * a {@link Color}, and then use the string value of the {@link Color} to * create an RDF literal. */ public V asValue(final LiteralExtensionIV iv, final BigdataValueFactory vf) { final byte b = iv.getDelegate().byteValue(); final Color c = Color.valueOf(b); if (c == null) throw new RuntimeException("bad color got encoded somehow"); return (V) vf.createLiteral(c.toString(), color); }
/** * Unit test for {@link ValueFactory#createLiteral(String, URI)} when the * datatype URI is <code>null</code>. * * @see https://sourceforge.net/apps/trac/bigdata/ticket/226 */ public void test_create_literal_datatypeIsNull() { final BigdataLiteral l1 = vf.createLiteral("12", (URI) null); assertEquals(null, l1.getDatatype()); assertEquals(12, l1.intValue()); }
@Override public IV get(final IBindingSet bs) throws SparqlTypeErrorException { final Literal lit = getAndCheckLiteralValue(0, bs); if (lit.getDatatype() != null || lit.getLanguage() != null) { throw new SparqlTypeErrorException(); } final Literal l = getAndCheckLiteralValue(1, bs); String label = lit.getLabel(); String langLit = l.getLabel(); final BigdataLiteral str = getValueFactory().createLiteral(label, langLit); return super.asIV(str, bs); }