public void test_create_literal_xsdInt() { final BigdataLiteral l1 = vf.createLiteral("12", XSD.INT); assertEquals(XSD.INT, l1.getDatatype()); assertEquals(12, l1.intValue()); }
@Override public String getLabel() { return getValue().getLabel(); }
@Override public BigInteger integerValue() { return getValue().integerValue(); }
/** * Asserts that the two {@link BigdataValue}s that are passed in are * {@link BigdataLiteral} of the same type and that the actual values * value, interpreted as numerical value, are identical. * * @param val * @param bigdataLiteral * * @throw {@link AssertionError} in case they are not */ protected void assertSemanticallyIdentical(final BigdataValue x1, final BigdataLiteral x2) { assertTrue(x1 instanceof BigdataLiteral); // assert they're both of the same datatype final BigdataLiteral x1AsLiteral = (BigdataLiteral) x1; assertEquals(x1AsLiteral.getDatatype(), x2.getDatatype()); // compare the component values String[] x1Components = x1.stringValue().split("#"); String[] x2Components = x2.stringValue().split("#"); assertEquals(x1Components.length, x2Components.length); for (int i = 0; i < x1Components.length; i++) { BigDecimal d1i = new BigDecimal(x1Components[i]); BigDecimal d2i = new BigDecimal(x2Components[i]); assertEquals(d1i, d2i); } }
new Constant(new XSDNumericIV(hit.getCosine())), // cosine new Constant(new XSDNumericIV(hit.getRank())), // rank new Constant(((BigdataLiteral) query).getIV()) }; log.trace(bs); log.trace(query.getClass()); log.trace(((BigdataLiteral) query).getIV()); log.trace(((BigdataLiteral) query).getIV().getClass());
@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; }
@Override public boolean isValid(final Object obj) { if (!(obj instanceof BigdataLiteral)) { // Only index Literals. return false; } final BigdataLiteral lit = (BigdataLiteral) obj; if (!indexDatatypeLiterals && lit.getDatatype() != null) { // Ignore datatype literals. return false; } return true; }
.createURI(XSD.UNSIGNED_BYTE.toString())).intValue() == 198); .createURI(XSD.UNSIGNED_BYTE.toString())).intValue() == 0); .createURI(XSD.UNSIGNED_BYTE.toString())).intValue() == 50); .createURI(XSD.UNSIGNED_SHORT.toString())).intValue() == (Short.MAX_VALUE + 10)); .createURI(XSD.UNSIGNED_SHORT.toString())).intValue() == 0); .createURI(XSD.UNSIGNED_INT.toString())).longValue() == (10L + Integer.MAX_VALUE)); .createURI(XSD.UNSIGNED_INT.toString())).longValue() == 0L); .createURI(XSD.UNSIGNED_LONG.toString())).integerValue().equals(bi)); .createURI(XSD.UNSIGNED_LONG.toString())).integerValue().equals(biz)); BigInteger bi100 = BigInteger.valueOf(100); assertTrue(f.createLiteral("100", f .createURI(XSD.UNSIGNED_LONG.toString())).integerValue().equals(bi100));
private int checkNode(BOp bop) { int cnt = 0; for (BOp arg: bop.args()) { cnt += checkNode(arg); } if (bop instanceof ValueExpressionNode) { for (BOp arg: ((ValueExpressionNode)bop).getValueExpression().args()) { cnt+=checkNode(arg); } } if (bop instanceof ConstantNode) { // constant node in AST BigdataValue value = ((ConstantNode)bop).getValue(); if (value instanceof BigdataLiteral && XMLSchema.DATE.equals(((BigdataLiteral)value).getDatatype())) { assertFalse(((BigdataLiteral)value).getIV().isNullIV()); assertTrue(value.getIV() instanceof LiteralExtensionIV); cnt++; } } if (bop instanceof Constant) { // constant in valueExpr IV value = (IV) ((Constant)bop).get(); assertFalse(value.isNullIV()); assertTrue(value instanceof LiteralExtensionIV || value instanceof XSDBooleanIV); cnt++; } return cnt; } }
assertTrue(l1.getIV().isInline()); assertTrue(l2.getIV().isInline()); assertTrue(l3.getIV().isInline()); assertFalse(l4.getIV().isInline()); assertFalse(l5.getIV().isInline()); final LiteralExtensionIV iv1 = (LiteralExtensionIV) l1.getIV(); final LiteralExtensionIV iv2 = (LiteralExtensionIV) l2.getIV(); final LiteralExtensionIV iv3 = (LiteralExtensionIV) l3.getIV(); if(log.isInfoEnabled()) log.info(l1.getLabel() + ": " + iv1.getDelegate().byteValue()); if(log.isInfoEnabled()) log.info(l2.getLabel() + ": " + iv2.getDelegate().byteValue()); if(log.isInfoEnabled()) log.info(l3.getLabel() + ": " + iv3.getDelegate().byteValue());
if (XSD.DATETIME.equals(bl.getDatatype())||XSD.DATE.equals(bl.getDatatype())||XSD.TIME.equals(bl.getDatatype())) { XMLGregorianCalendar cal=bl.calendarValue(); switch (op()) { case DAY:
@Override public String stringValue() { return getValue().stringValue(); }
@Override public int intValue() { return getValue().intValue(); }
@Override public long longValue() { return getValue().longValue(); }
/** * 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; }
@Override public boolean isValid(final Object obj) { if (!(obj instanceof BigdataLiteral)) { // Only index Literals. return false; } final BigdataLiteral lit = (BigdataLiteral) obj; if (!indexDatatypeLiterals && lit.getDatatype() != null) { // Ignore datatype literals. return false; } return true; }
.createURI(XSD.UNSIGNED_BYTE.toString())).intValue() == 198); .createURI(XSD.UNSIGNED_BYTE.toString())).intValue() == 0); .createURI(XSD.UNSIGNED_BYTE.toString())).intValue() == 50); .createURI(XSD.UNSIGNED_SHORT.toString())).intValue() == (Short.MAX_VALUE + 10)); .createURI(XSD.UNSIGNED_SHORT.toString())).intValue() == 0); .createURI(XSD.UNSIGNED_INT.toString())).longValue() == (10L + Integer.MAX_VALUE)); .createURI(XSD.UNSIGNED_INT.toString())).longValue() == 0L); .createURI(XSD.UNSIGNED_LONG.toString())).integerValue().equals(bi)); .createURI(XSD.UNSIGNED_LONG.toString())).integerValue().equals(biz)); BigInteger bi100 = BigInteger.valueOf(100); assertTrue(f.createLiteral("100", f .createURI(XSD.UNSIGNED_LONG.toString())).integerValue().equals(bi100));
private int checkNode(BOp bop) { int cnt = 0; for (BOp arg: bop.args()) { cnt += checkNode(arg); } if (bop instanceof ValueExpressionNode) { for (BOp arg: ((ValueExpressionNode)bop).getValueExpression().args()) { cnt+=checkNode(arg); } } if (bop instanceof ConstantNode) { // constant node in AST BigdataValue value = ((ConstantNode)bop).getValue(); if (value instanceof BigdataLiteral && XMLSchema.DATE.equals(((BigdataLiteral)value).getDatatype())) { assertFalse(((BigdataLiteral)value).getIV().isNullIV()); assertTrue(value.getIV() instanceof LiteralExtensionIV); cnt++; } } if (bop instanceof Constant) { // constant in valueExpr IV value = (IV) ((Constant)bop).get(); assertFalse(value.isNullIV()); assertTrue(value instanceof LiteralExtensionIV || value instanceof XSDBooleanIV); cnt++; } return cnt; } }
/** * Asserts that the two {@link BigdataValue}s that are passed in are * {@link BigdataLiteral} of the same type and that the actual values * value, interpreted as numerical value, are identical. * * @param val * @param bigdataLiteral * * @throw {@link AssertionError} in case they are not */ protected void assertSemanticallyIdentical(final BigdataValue x1, final BigdataLiteral x2) { assertTrue(x1 instanceof BigdataLiteral); // assert they're both of the same datatype final BigdataLiteral x1AsLiteral = (BigdataLiteral) x1; assertEquals(x1AsLiteral.getDatatype(), x2.getDatatype()); // compare the component values String[] x1Components = x1.stringValue().split("#"); String[] x2Components = x2.stringValue().split("#"); assertEquals(x1Components.length, x2Components.length); for (int i = 0; i < x1Components.length; i++) { BigDecimal d1i = new BigDecimal(x1Components[i]); BigDecimal d2i = new BigDecimal(x2Components[i]); assertEquals(d1i, d2i); } }