/** * {@inheritDoc} */ public int getType() { return qvalue.getType(); }
/** * @see javax.jcr.Value#getType() */ public int getType() { return qvalue.getType(); }
public int getType() { if (propertyType == PropertyType.UNDEFINED) { // in case of empty-value-array of a multivalued property the type // must always be set. propertyType = getValues()[0].getType(); } return propertyType; }
@Override public void addProperty(NodeId parentId, Name propertyName, QValue value) throws RepositoryException { checkConsumed(); String uri = getItemUri(parentId, propertyName, sessionInfo); HttpPut request = new HttpPut(uri); request.setHeader(HEADER_CONTENT_TYPE, JcrValueType.contentTypeFromType(value.getType())); request.setEntity(getEntity(value)); requests.add(request); }
@Override public void addProperty(NodeId parentId, Name propertyName, QValue value) throws RepositoryException { checkConsumed(); String uri = getItemUri(parentId, propertyName, sessionInfo); HttpPut request = new HttpPut(uri); request.setHeader(HEADER_CONTENT_TYPE, JcrValueType.contentTypeFromType(value.getType())); request.setEntity(getEntity(value)); requests.add(request); }
@Override public Value createValue(QValue qvalue) { if (qvalue instanceof InternalValue && PropertyType.BINARY == qvalue.getType()) { try { return new BinaryValueImpl(((InternalValue) qvalue).getBLOBFileValue().copy()); } catch (RepositoryException e) { // should not get here log.error(e.getMessage(), e); } } return super.createValue(qvalue); }
@Override public Value createValue(QValue qvalue) { if (qvalue instanceof InternalValue && PropertyType.BINARY == qvalue.getType()) { try { return new BinaryValueImpl(((InternalValue) qvalue).getBLOBFileValue().copy()); } catch (RepositoryException e) { // should not get here log.error(e.getMessage(), e); } } return super.createValue(qvalue); }
/** * {@inheritDoc} */ public boolean getBoolean() throws RepositoryException { setValueConsumed(); if (getType() == PropertyType.STRING || getType() == PropertyType.BINARY || getType() == PropertyType.BOOLEAN) { return Boolean.valueOf(qvalue.getString()).booleanValue(); } else { throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType())); } }
/** * @see javax.jcr.Value#getBoolean() */ public boolean getBoolean() throws RepositoryException { if (getType() == PropertyType.STRING || getType() == PropertyType.BINARY || getType() == PropertyType.BOOLEAN) { return Boolean.valueOf(qvalue.getString()); } else { throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType())); } }
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 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 testEmptyBinaryFromFile() throws RepositoryException, IOException { File f = File.createTempFile("QValueFactoryImplTest", ".txt"); f.deleteOnExit(); QValue v = factory.create(f); assertEquals(PropertyType.BINARY, v.getType()); assertValueLength(v, 0); assertEquals("", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("", new String(out.toByteArray())); }
public void testBinaryFromInputStream() throws RepositoryException, IOException { InputStream in = new ByteArrayInputStream(new byte[] {'a', 'b', 'c'}); QValue v = factory.create(in); assertEquals(PropertyType.BINARY, v.getType()); assertValueLength(v, 3); assertEquals("abc", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("abc", new String(out.toByteArray())); }
public void testEmptyBinaryFromFile() throws RepositoryException, IOException { File f = File.createTempFile("QValueFactoryImplTest", ".txt"); f.deleteOnExit(); QValue v = factory.create(f); 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())); }
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())); }
public void testEmptyBinaryFromByteArray() throws RepositoryException, IOException { QValue v = factory.create(new byte[0]); assertEquals(PropertyType.BINARY, v.getType()); assertValueLength(v, 0); assertEquals("", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("", new String(out.toByteArray())); }
public void testBinaryFromByteArray() throws RepositoryException, IOException { QValue v = factory.create(new byte[] {'a', 'b', 'c'}); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(3, v.getLength()); assertEquals("abc", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("abc", new String(out.toByteArray())); }
public void testEmptyBinaryFromByteArray() throws RepositoryException, IOException { QValue v = factory.create(new byte[0]); 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())); }