public long getSize() throws RepositoryException { return getLength(); }
public InputStream getStream() throws RepositoryException { return AbstractQValue.this.getStream(); }
/** * @throws RepositoryException * @see QValue#getBoolean() */ public boolean getBoolean() throws RepositoryException { if (type == PropertyType.BOOLEAN) { return (Boolean) val; } else { return Boolean.valueOf(getString()); } }
/** * @see QValue#getLong() */ public long getLong() throws RepositoryException { if (type == PropertyType.LONG) { return (Long) val; } else if (type == PropertyType.DOUBLE) { return ((Double) val).longValue(); } else if (type == PropertyType.DECIMAL) { return ((BigDecimal) val).longValue(); } else if (type == PropertyType.DATE) { return getCalendar().getTimeInMillis(); } else { try { return Long.parseLong(getString()); } catch (NumberFormatException ex) { throw new ValueFormatException("not a long: " + getString(), ex); } } }
/** * @see org.apache.jackrabbit.spi.QValue#discard() */ @Override public void discard() { if (type == PropertyType.BINARY) { BLOBFileValue bfv = (BLOBFileValue) val; bfv.dispose(); } else { super.discard(); } }
/** * Returns a string representation of this <code>BinaryQValue</code> * instance. The string representation of a resource backed value is * the path of the underlying resource. If this instance is backed by an * in-memory buffer the generic object string representation of the byte * array will be used instead. * * @return A string representation of this <code>BinaryQValue</code> instance. */ @Override public String toString() { if (file != null) { // this instance is backed by a 'real' file return file.toString(); } else if (buffer != null) { // this instance is backed by an in-memory buffer return buffer.toString(); } else { return super.toString(); } }
/** * @see QValue#getDouble() */ public double getDouble() throws RepositoryException { if (type == PropertyType.DOUBLE) { return (Double) val; } else if (type == PropertyType.LONG) { return ((Long) val).doubleValue(); } else if (type == PropertyType.DATE) { return getCalendar().getTimeInMillis(); } else if (type == PropertyType.DECIMAL) { return ((BigDecimal) val).doubleValue(); } else { try { return Double.parseDouble(getString()); } catch (NumberFormatException ex) { throw new ValueFormatException("not a double: " + getString(), ex); } } }
/** * @see org.apache.jackrabbit.spi.QValue#discard() */ @Override public void discard() { if (type == PropertyType.BINARY) { BLOBFileValue bfv = (BLOBFileValue) val; bfv.dispose(); } else { super.discard(); } }
/** * Returns a string representation of this <code>BinaryQValue</code> * instance. The string representation of a resource backed value is * the path of the underlying resource. If this instance is backed by an * in-memory buffer the generic object string representation of the byte * array will be used instead. * * @return A string representation of this <code>BinaryQValue</code> instance. */ @Override public String toString() { if (file != null) { // this instance is backed by a 'real' file return file.toString(); } else if (buffer != null) { // this instance is backed by an in-memory buffer return buffer.toString(); } else { return super.toString(); } }
public long getSize() throws RepositoryException { return getLength(); }
/** * @see QValue#getLong() */ public long getLong() throws RepositoryException { if (type == PropertyType.LONG) { return (Long) val; } else if (type == PropertyType.DOUBLE) { return ((Double) val).longValue(); } else if (type == PropertyType.DECIMAL) { return ((BigDecimal) val).longValue(); } else if (type == PropertyType.DATE) { return getCalendar().getTimeInMillis(); } else { try { return Long.parseLong(getString()); } catch (NumberFormatException ex) { throw new ValueFormatException("not a long: " + getString(), ex); } } }
/** * @see QValue#getLength() */ public long getLength() throws RepositoryException { return getString().length(); }
public InputStream getStream() throws RepositoryException { return AbstractQValue.this.getStream(); }
/** * @see org.apache.jackrabbit.spi.QValue#getLength() */ @Override public long getLength() throws RepositoryException { if (PropertyType.BINARY == type) { return ((Binary) val).getSize(); } else { return super.getLength(); } }
/** * @see QValue#getDouble() */ public double getDouble() throws RepositoryException { if (type == PropertyType.DOUBLE) { return (Double) val; } else if (type == PropertyType.LONG) { return ((Long) val).doubleValue(); } else if (type == PropertyType.DATE) { return getCalendar().getTimeInMillis(); } else if (type == PropertyType.DECIMAL) { return ((BigDecimal) val).doubleValue(); } else { try { return Double.parseDouble(getString()); } catch (NumberFormatException ex) { throw new ValueFormatException("not a double: " + getString(), ex); } } }
/** * @see QValue#getLength() */ public long getLength() throws RepositoryException { return getString().length(); }
/** * @see QValue#getPath() */ public String getString() throws RepositoryException { if (type == PropertyType.BINARY) { try { InputStream stream = getStream(); try { Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); Writer writer = new StringWriter(); char[] buffer = new char[1024]; int n = reader.read(buffer); while (n != -1) { writer.write(buffer, 0, n); n = reader.read(buffer); } return writer.toString(); } finally { stream.close(); } } catch (IOException e) { throw new RepositoryException("conversion from stream to string failed", e); } } else if (type == PropertyType.DATE) { return (String) val; } else { return val.toString(); } }
/** * @see org.apache.jackrabbit.spi.QValue#getLength() */ @Override public long getLength() throws RepositoryException { if (PropertyType.BINARY == type) { return ((Binary) val).getSize(); } else { return super.getLength(); } }
/** * @throws RepositoryException * @see QValue#getBoolean() */ public boolean getBoolean() throws RepositoryException { if (type == PropertyType.BOOLEAN) { return (Boolean) val; } else { return Boolean.valueOf(getString()); } }
/** * @see QValue#getPath() */ public String getString() throws RepositoryException { if (type == PropertyType.BINARY) { try { InputStream stream = getStream(); try { Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); Writer writer = new StringWriter(); char[] buffer = new char[1024]; int n = reader.read(buffer); while (n != -1) { writer.write(buffer, 0, n); n = reader.read(buffer); } return writer.toString(); } finally { stream.close(); } } catch (IOException e) { throw new RepositoryException("conversion from stream to string failed", e); } } else if (type == PropertyType.DATE) { return (String) val; } else { return val.toString(); } }