/** * Creates a string {@link RyaType} object. * @param value the {@link String} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#STRING} and the data set to the specified {@code value}. */ public static RyaType stringRyaType(final String value) { return new RyaType(XMLSchema.STRING, value); }
/** * Creates a string {@link RyaType} object. * @param value the {@link String} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#STRING} and the data set to the specified {@code value}. */ public static RyaType stringRyaType(final String value) { return new RyaType(XMLSchema.STRING, value); }
@Override public RyaType newInstance() { return new RyaType(); }
/** * Creates a byte {@link RyaType} object. * @param value the {@link Byte} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#BYTE} and the data set to the specified {@code value}. */ public static RyaType byteRyaType(final Byte value) { return new RyaType(XMLSchema.BYTE, Byte.toString(value)); }
/** * Creates a double {@link RyaType} object. * @param value the {@link Double} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#DOUBLE} and the data set to the specified {@code value}. */ public static RyaType doubleRyaType(final Double value) { return new RyaType(XMLSchema.DOUBLE, Double.toString(value)); }
/** * Creates a short {@link RyaType} object. * @param value the {@link Short} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#SHORT} and the data set to the specified {@code value}. */ public static RyaType shortRyaType(final Short value) { return new RyaType(XMLSchema.SHORT, Short.toString(value)); }
/** * Creates a boolean {@link RyaType} object. * @param value the {@link Boolean} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#BOOLEAN} and the data set to the specified * {@code value}. */ public static RyaType booleanRyaType(final Boolean value) { return new RyaType(XMLSchema.BOOLEAN, Boolean.toString(value)); }
/** * Creates a float {@link RyaType} object. * @param value the {@link Float} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#FLOAT} and the data set to the specified {@code value}. */ public static RyaType floatRyaType(final Float value) { return new RyaType(XMLSchema.FLOAT, Float.toString(value)); }
/** * Creates a byte {@link RyaType} object. * @param value the {@link Byte} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#BYTE} and the data set to the specified {@code value}. */ public static RyaType byteRyaType(final Byte value) { return new RyaType(XMLSchema.BYTE, Byte.toString(value)); }
/** * Creates an integer {@link RyaType} object. * @param value the {@link Integer} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#INTEGER} and the data set to the specified * {@code value}. */ public static RyaType intRyaType(final Integer value) { return new RyaType(XMLSchema.INTEGER, Integer.toString(value)); }
/** * Creates a long {@link RyaType} object. * @param value the {@link Long} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#LONG} and the data set to the specified {@code value}. */ public static RyaType longRyaType(final Long value) { return new RyaType(XMLSchema.LONG, Long.toString(value)); }
/** * Creates a short {@link RyaType} object. * @param value the {@link Short} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#SHORT} and the data set to the specified {@code value}. */ public static RyaType shortRyaType(final Short value) { return new RyaType(XMLSchema.SHORT, Short.toString(value)); }
/** * * Creates a URI {@link RyaType} object. * @param value the {@link URI} object. * @return the {@link RyaType} with the data type set to * {@link XMLSchema#ANYURI} and the data set to the specified {@code value}. */ public static RyaType uriRyaType(final URI value) { return new RyaType(XMLSchema.ANYURI, value.stringValue()); }
/** * Creates a copy tool split time {@link RyaStatement} from the specified {@link Date}. * @param date the copy tool split time {@link Date}. * @return the {@link RyaStatement} for the copy tool split time. */ public static RyaStatement createCopyToolSplitTimeRyaStatement(final Date date) { final Literal literal = VALUE_FACTORY.createLiteral(date != null ? date : DEFAULT_DATE); final RyaType timeObject = new RyaType(literal.getDatatype(), literal.stringValue()); return new RyaStatement(RTS_SUBJECT_RYA, RTS_COPY_TOOL_SPLIT_TIME_PREDICATE_RYA, timeObject); }
@Test public void testSerialization() throws Exception { Long i = randomLong(); byte[] serialize = new LongRyaTypeResolver().serialize(new RyaType(XMLSchema.LONG, i.toString())); assertEquals(i, new Long(new LongRyaTypeResolver().deserialize(serialize).getData())); }
public void testHashedTripleRowSerialization() throws Exception { final RyaIRI subj = new RyaIRI("urn:test#subj"); final RyaIRI pred = new RyaIRI("urn:test#pred"); final RyaType obj = new RyaType("mydata"); final RyaStatement statement = new RyaStatement(subj, pred, obj); final MockRdfConfiguration config = new MockRdfConfiguration(); config.set(MockRdfConfiguration.CONF_PREFIX_ROW_WITH_HASH, Boolean.TRUE.toString()); final RyaTripleContext instance = RyaTripleContext.getInstance(config); final Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement); final TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO); assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow)); }
public void testTripleRowSerialization() throws Exception { final RyaIRI subj = new RyaIRI("urn:test#subj"); final RyaIRI pred = new RyaIRI("urn:test#pred"); final RyaType obj = new RyaType("mydata"); final RyaStatement statement = new RyaStatement(subj, pred, obj); final RyaTripleContext instance = RyaTripleContext.getInstance(new MockRdfConfiguration()); final Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement); final TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO); assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow)); }
public void testCustomDataTypeSerialization() throws Exception { RyaType ryaType = new RyaType(SimpleValueFactory.getInstance().createIRI("urn:test#datatype"), "testdata"); byte[] serialize = new CustomDatatypeResolver().serialize(ryaType); RyaType deserialize = new CustomDatatypeResolver().deserialize(serialize); assertEquals(ryaType, deserialize); } }
@Test public void testEqualsNullFields() throws Exception { Assert.assertFalse("equals(null) should return false.", a.equals(null)); Assert.assertFalse("Same data, one null datatype should be unequal.", a.equals(nullType)); Assert.assertFalse("Same datatype, one null data should be unequal.", a.equals(nullData)); Assert.assertFalse("Same datatype, data, one null lang should be unequal.", aLang.equals(nullLang)); final RyaType sameNull = new RyaType(null, null); Assert.assertTrue("Matching null fields should be equal.", sameNull.equals(nullBoth)); }