/** * @inheritDoc */ public long[] getLengths() throws ValueFormatException, RepositoryException { return property.getLengths(); }
public long[] jsGet_lengths() { try { return property.getLengths(); } catch (RepositoryException re) { return new long[0]; } }
@Override public long[] getLengths() throws RepositoryException { return delegate.getLengths(); }
public long[] getLengths() throws RepositoryException { return this.item.getLengths();}
/** {@inheritDoc} */ public long[] getLengths() throws RepositoryException, RemoteException { try { return property.getLengths(); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Override public long[] getLengths() throws ValueFormatException, RepositoryException { return getWrappedProperty().getLengths(); }
public long[] execute() throws Exception { return getDelegate().getLengths(); } });
/** * {@inheritDoc} */ public long getContentLength() { if (contentLength == null) { if (tmpFile == null) { contentLength = -1L; try { if (valueIndex < 0) { contentLength = property.getLength(); } else { long[] lengths = property.getLengths(); if (valueIndex < lengths.length) { contentLength = lengths[valueIndex]; } } } catch (RepositoryException e) { // ignore } } else { contentLength = tmpFile.length(); } } return contentLength; }
/** * Tests the Property.getLengths() method. The returned values are either -1 * or the lengths of the according strings. */ public void testGetLengths() throws RepositoryException { if (multiple) { Value[] values = prop.getValues(); long[] lengths = prop.getLengths(); for (int i = 0; i < lengths.length; i++) { if (lengths[i] > -1) { assertEquals("Property.getLengths() returns " + "wrong array of the lengths of a multivalue property.", values[i].getString().length(), lengths[i]); } } } else { try { prop.getLengths(); fail("Property.getLengths() called on a sinlge value property " + "should throw a ValueFormatException."); } catch (ValueFormatException vfe) { // ok } } }
/** * Tests the Property.getLengths() method. The returned values are either -1 * or the lengths of the according conversions to strings. */ public void testGetLengths() throws RepositoryException { if (multiple) { Value[] values = prop.getValues(); long[] lengths = prop.getLengths(); for (int i = 0; i < lengths.length; i++) { if (lengths[i] > -1) { assertEquals("Property.getLengths() returns " + "wrong array of the lengths of a multivalue property.", values[i].getString().length(), lengths[i]); } } } else { try { prop.getLengths(); fail("Property.getLengths() called on a sinlge value property " + "should throw a ValueFormatException."); } catch (ValueFormatException vfe) { // ok } } } }
/** * Tests the Property.getLengths() method. The returned values are either -1 * or the lengths of the according conversions to strings. */ public void testGetLengths() throws RepositoryException { if (multiple) { Value[] values = prop.getValues(); long[] lengths = prop.getLengths(); for (int i = 0; i < lengths.length; i++) { if (lengths[i] > -1) { assertEquals("Property.getLengths() returns " + "wrong array of the lengths of a multivalue property.", values[i].getString().length(), lengths[i]); } } } else { try { prop.getLengths(); fail("Property.getLengths() called on a sinlge value property " + "should throw a ValueFormatException."); } catch (ValueFormatException vfe) { // ok } } } }
/** * Tests the Property.getLengths() method. The test is successful, if either * -1 is returned */ public void testGetLengths() throws RepositoryException { if (multiple) { Value[] values = prop.getValues(); long[] lengths = prop.getLengths(); for (int i = 0; i < lengths.length; i++) { long length = PropertyUtil.countBytes(values[i]); assertEquals("Property.getLengths() returns " + "wrong array of the lengths of a multivalue property.", length, lengths[i]); } } else { try { prop.getLengths(); fail("Property.getLengths() called on a sinlge value property " + "should throw a ValueFormatException."); } catch (ValueFormatException vfe) { // ok } } }
public long[] getLengths(Property property) throws RepositoryException { if (getPrevious() != null) { return getPrevious().getLengths(property); } else { return property.getLengths(); } }
@Override public DavProperty<?> getProperty(DavPropertyName name) { DavProperty prop = super.getProperty(name); if (prop == null && exists()) { try { Property p = (Property) item; if (isMultiple()) { if (JCR_LENGTHS.equals(name)) { prop = new LengthsProperty(p.getLengths()); } } else { if (JCR_LENGTH.equals(name)) { long length = p.getLength(); prop = new DefaultDavProperty<String>(JCR_LENGTH, String.valueOf(length), true); } else if (JCR_GET_STRING.equals(name) && p.getType() != PropertyType.BINARY) { // getstring property is only created for single value // non-binary jcr properties prop = new DefaultDavProperty<String>(JCR_GET_STRING, p.getString(), true); } } } catch (RepositoryException e) { log.error("Failed to retrieve resource properties: "+e.getMessage()); } } return prop; }
/** * Tests if Property.getLengths() fails for single value property. */ public void testGetLengthsFromSingleValued() throws RepositoryException, NotExecutableException { Property singleProp = PropertyUtil.searchSingleValuedProperty(testRootNode); if (singleProp == null) { throw new NotExecutableException("No single valued property found."); } try { singleProp.getLengths(); fail("Property.getLengths() called on a single value property must fail (ValueFormatException)."); } catch (ValueFormatException vfe) { // ok } } }
/** * Returns the values of the given value length operand at the given row. * * @see #getProperty(PropertyValue, Row) * @param operand value length operand * @param row row * @return values of the operand at the given row * @throws RepositoryException if the operand can't be evaluated */ private Value[] getLengthValues(Length operand, Row row) throws RepositoryException { Property property = getProperty(operand.getPropertyValue(), row); if (property == null) { return new Value[0]; } else if (property.isMultiple()) { long[] lengths = property.getLengths(); Value[] values = new Value[lengths.length]; for (int i = 0; i < lengths.length; i++) { values[i] = factory.createValue(lengths[i]); } return values; } else { long length = property.getLength(); return new Value[] { factory.createValue(length) }; } }
/** * Returns the values of the given value length operand for the given node. * * @see #getProperty(PropertyValue, Node) * @param operand value length operand * @param node node * @return values of the operand for the given node * @throws RepositoryException if the operand can't be evaluated */ private Value[] getLengthValues(Length operand, Node n) throws RepositoryException { Property property = getProperty(operand.getPropertyValue(), n); if (property == null) { return new Value[0]; } if (property.isMultiple()) { long[] lengths = property.getLengths(); Value[] values = new Value[lengths.length]; for (int i = 0; i < lengths.length; i++) { values[i] = factory.createValue(lengths[i]); } return values; } long length = property.getLength(); return new Value[] { factory.createValue(length) }; }
/** * Returns the values of the given value length operand for the given node. * * @see #getProperty(PropertyValue, Node) * @param operand value length operand * @param node node * @return values of the operand for the given node * @throws RepositoryException if the operand can't be evaluated */ private Value[] getLengthValues(Length operand, Node n) throws RepositoryException { Property property = getProperty(operand.getPropertyValue(), n); if (property == null) { return new Value[0]; } if (property.isMultiple()) { long[] lengths = property.getLengths(); Value[] values = new Value[lengths.length]; for (int i = 0; i < lengths.length; i++) { values[i] = factory.createValue(lengths[i]); } return values; } long length = property.getLength(); return new Value[] { factory.createValue(length) }; }
private static void checkLength(Property p) throws RepositoryException { if (p.isMultiple()) { Value[] vals = p.getValues(); long[] lengths = p.getLengths(); for (int i = 0; i < lengths.length; i++) { assertTrue("Wrong property length", lengths[i] == getValueLength(vals[i])); } } else { assertTrue("Wrong property length", p.getLength() == getValueLength(p.getValue())); } }
public void checkValue( Property prop ) throws Exception { // Should provide a value and not multiple values ... Value val = prop.getValue(); assertThat(val, notNullValue()); assertThat(prop.getDefinition(), notNullValue()); // Should not allow multiple-value methods ... try { prop.getValues(); fail("Should not be able to call 'getValues()' on a single-value property"); } catch (ValueFormatException e) { // expected } try { prop.getLengths(); fail("Should not be able to call 'getValues()' on a single-value property"); } catch (ValueFormatException e) { // expected } }