public Object call() throws RepositoryException { try { return qValueFactory.create(value); } catch (IOException e) { ex[0] = e; return null; } }}, methodName, args);
/** * {@inheritDoc} */ public Value createValue(String value) { try { QValue qvalue = qfactory.create(value, PropertyType.STRING); return new QValueValue(qvalue, resolver); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * {@inheritDoc} */ public Value createValue(boolean value) { try { QValue qvalue = qfactory.create(value); return new QValueValue(qvalue, resolver); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * {@inheritDoc} */ public Value createValue(double value) { try { QValue qvalue = qfactory.create(value); return new QValueValue(qvalue, resolver); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * {@inheritDoc} */ public Value createValue(String value) { try { QValue qvalue = qfactory.create(value, PropertyType.STRING); return new QValueValue(qvalue, resolver); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * {@inheritDoc} */ public Value createValue(long value) { try { QValue qvalue = qfactory.create(value); return new QValueValue(qvalue, resolver); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
/** * Add a {@link PropertyType#DOUBLE} value to this property. * * @param value * @return <code>this</code> * @throws RepositoryException * @throws IllegalStateException if the type of the value does not match the type of this property */ public PropertyInfoBuilder addValue(double value) throws RepositoryException { return addValue(QValueFactoryImpl.getInstance().create(value)); }
/** * Add a {@link PropertyType#NAME} value to this property. * * @param value * @return <code>this</code> * @throws RepositoryException * @throws IllegalStateException if the type of the value does not match the type of this property */ public PropertyInfoBuilder addValue(Name value) throws RepositoryException { return addValue(QValueFactoryImpl.getInstance().create(value)); }
/** * Add a {@link PropertyType#BINARY} value to this property. * * @param value * @return <code>this</code> * @throws RepositoryException * @throws IllegalStateException if the type of the value does not match the type of this property */ public PropertyInfoBuilder addValue(byte[] value) throws RepositoryException { return addValue(QValueFactoryImpl.getInstance().create(value)); }
/** * Add a {@link PropertyType#BINARY} value to this property. * * @param value * @return <code>this</code> * @throws RepositoryException * @throws IllegalStateException if the type of the value does not match the type of this property */ public PropertyInfoBuilder addValue(InputStream value) throws RepositoryException, IOException { return addValue(QValueFactoryImpl.getInstance().create(value)); }
/** * Add a {@link PropertyType#BINARY} value to this property. * * @param value * @return <code>this</code> * @throws RepositoryException * @throws IllegalStateException if the type of the value does not match the type of this property */ public PropertyInfoBuilder addValue(File value) throws RepositoryException, IOException { return addValue(QValueFactoryImpl.getInstance().create(value)); }
public void testEqualityDifferentTypes() throws RepositoryException { if (reference != null) { QValue v = factory.create(reference, PropertyType.REFERENCE); QValue v2 = factory.create(reference, PropertyType.STRING); assertFalse(v.equals(v2)); } else { log.warn("Configuration entry 'QValueFactoryTest.reference' is missing -> skip test 'testEqualityDifferentTypes'."); } }
public void testCreateInvalidDoubleValue() throws RepositoryException { try { factory.create("any", PropertyType.DOUBLE); fail("'any' cannot be converted to a valid double value."); } catch (ValueFormatException e) { // ok } }
public void testInvalidNameValue() throws RepositoryException { try { factory.create("abc", PropertyType.NAME); fail("'abc' is not a valid Name -> creating QValue should fail."); } catch (ValueFormatException e) { // ok } }
public void testReferenceValueType() throws RepositoryException { if (reference != null) { QValue v = factory.create(reference, PropertyType.REFERENCE); assertTrue("Type of a date value must be PropertyType.REFERENCE.", v.getType() == PropertyType.REFERENCE); } else { log.warn("Configuration entry 'QValueFactoryTest.reference' is missing -> skip test 'testReferenceValueType'."); } }
public void testGetDoubleOnBooleanValue() throws RepositoryException { try { QValue v = factory.create(true); v.getDouble(); fail("'true' cannot be converted to a valid double value."); } catch (ValueFormatException e) { // ok } }
public void testDateValueType() throws RepositoryException { QValue v = factory.create(calendar); assertTrue("Type of a date value must be PropertyType.DATE", v.getType() == PropertyType.DATE); } public void testDateValueEquality() throws RepositoryException {
public void testAnyValueGetName() throws RepositoryException { try { factory.create(12345).getName(); fail("12345 is not a valid Name value -> QValue.getName() should fail."); } catch (ValueFormatException e) { // ok } }
public void testAnyValueGetPath() throws RepositoryException { try { factory.create(12345).getPath(); fail("12345 is not a valid Path value -> QValue.getPath() should fail."); } catch (ValueFormatException e) { // ok } }
public void testEmptyBinaryFromInputStream() throws RepositoryException, IOException { InputStream in = new ByteArrayInputStream(new byte[0]); QValue v = factory.create(in); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(0, v.getLength()); assertEquals("", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("", new String(out.toByteArray())); }