@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; }
@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; }
@Override public URI getDatatype() { return getValue().getDatatype(); }
@Override public URI getDatatype() { return getValue().getDatatype(); }
@Override public boolean isNumeric() { V value = getValue(); if (value==null) throw new NotMaterializedException(); if (!(value instanceof BigdataLiteral)) return false; return NumericIV.numericalDatatypes.contains(((BigdataLiteral)value).getDatatype()); }
@Override public boolean isNumeric() { V value = getValue(); if (value==null) throw new NotMaterializedException(); if (!(value instanceof BigdataLiteral)) return false; return NumericIV.numericalDatatypes.contains(((BigdataLiteral)value).getDatatype()); }
/** * 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); } }
/** * 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); } }
/** * Unit test for {@link ValueFactory#createLiteral(XMLGregorianCalendar)}. * * @see https://sourceforge.net/apps/trac/bigdata/ticket/117 */ public void test_gregorian() throws DatatypeConfigurationException { final XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendarDate( 2010,// year 1, // month, 13, // day, 0// timezone ); assertEquals(// "http://www.w3.org/2001/XMLSchema#date",// vf.createLiteral(cal).getDatatype().stringValue()// ); }
/** * Unit test for {@link ValueFactory#createLiteral(XMLGregorianCalendar)}. * * @see https://sourceforge.net/apps/trac/bigdata/ticket/117 */ public void test_gregorian() throws DatatypeConfigurationException { final XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendarDate( 2010,// year 1, // month, 13, // day, 0// timezone ); assertEquals(// "http://www.w3.org/2001/XMLSchema#date",// vf.createLiteral(cal).getDatatype().stringValue()// ); }
public void test_create_literal_xsdInt() { final BigdataLiteral l1 = vf.createLiteral("12", XSD.INT); assertEquals(XSD.INT, l1.getDatatype()); assertEquals(12, l1.intValue()); }
/** * 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()); }
/** * 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()); }
public void test_create_literal_xsdInt() { final BigdataLiteral l1 = vf.createLiteral("12", XSD.INT); assertEquals(XSD.INT, l1.getDatatype()); assertEquals(12, l1.intValue()); }
/** * 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); } }
/** * Unit test for {@link ValueFactory#createLiteral(XMLGregorianCalendar)}. * * @see https://sourceforge.net/apps/trac/bigdata/ticket/117 */ public void test_gregorian() throws DatatypeConfigurationException { final XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendarDate( 2010,// year 1, // month, 13, // day, 0// timezone ); assertEquals(// "http://www.w3.org/2001/XMLSchema#date",// vf.createLiteral(cal).getDatatype().stringValue()// ); }
public void test_create_literal_xsdInt() { final BigdataLiteral l1 = vf.createLiteral("12", XSD.INT); assertEquals(XSD.INT, l1.getDatatype()); assertEquals(12, l1.intValue()); }
/** * 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()); }
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; } }
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; } }