/** * Returns the length of the value of this property. * <p> * The default implementation measures the length of the {@link Value} * instance returned by the generic {@link Property#getValue()} method. * * @return length of the property value * @throws RepositoryException if an error occurs */ public long getLength() throws RepositoryException { return getLength(getValue()); }
/** * Removes this property. * <p> * The default implementation calls {@link Node#setProperty(String, Value)} * with a <code>null</code> value on the parent node. * * @throws RepositoryException if an error occurs */ public void remove() throws RepositoryException { getParent().setProperty(getName(), (Value) null); }
/** * Returns the lengths of the values of this property. * <p> * The default implementation measures the lengths of the {@link Value} * instances returned by the generic {@link Property#getValues()} method. * * @return lengths of the property values * @throws RepositoryException if an error occurs */ public long[] getLengths() throws RepositoryException { Value[] values = getValues(); long[] lengths = new long[values.length]; for (int i = 0; i < values.length; i++) { lengths[i] = getLength(values[i]); } return lengths; }
String value = getString(); switch (getType()) { case PropertyType.PATH: try { return (value.startsWith("/")) ? getSession().getProperty(value) : getParent().getProperty(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); return getParent().getProperty(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); String path = getSession().getValueFactory().createValue(value, PropertyType.PATH).getString(); return (path.startsWith("/")) ? getSession().getProperty(path) : getParent().getProperty(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value);
/** * Returns the string value of this property. * <p> * The default implementation forwards the method call to the * {@link Value} instance returned by the generic * {@link Property#getValue()} method. * * @return string value * @throws RepositoryException if an error occurs */ public String getString() throws RepositoryException { return getValue().getString(); }
/** * Returns the node referenced by this property. * <p> * The default implementation checks that this property is a reference * property (or tries to convert the property value to a reference) and * uses {@link Session#getNodeByUUID(String)} to retrieve the * referenced node. * * @return node referenced by this property * @throws RepositoryException if an error occurs */ public Node getNode() throws RepositoryException { Session session = getSession(); Value value = getValue(); if (value.getType() != PropertyType.REFERENCE) { value = session.getValueFactory().createValue( value.getString(), PropertyType.REFERENCE); } return session.getNodeByUUID(value.getString()); }
@Override public String toString() { String valueString; if (isMultiple()) { valueString = StringUtils.join(values, ", "); } else { valueString = values.length == 0 ? "" : values[0].toString(); } return super.toString() + ": " + valueString; } }
String value = getString(); switch (getType()) { case PropertyType.PATH: try { return (value.startsWith("/")) ? getSession().getProperty(value) : getParent().getProperty(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); return getParent().getProperty(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); String path = getSession().getValueFactory().createValue(value, PropertyType.PATH).getString(); return (path.startsWith("/")) ? getSession().getProperty(path) : getParent().getProperty(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value);
/** * Returns the string value of this property. * <p> * The default implementation forwards the method call to the * {@link Value} instance returned by the generic * {@link Property#getValue()} method. * * @return string value * @throws RepositoryException if an error occurs */ public String getString() throws RepositoryException { return getValue().getString(); }
/** * Sets the value of this property. * <p> * The default implementation forwards the call to the * {@link Node#setProperty(String, Value)} method of the parent node * using the name of this property. * * @param value passed through * @throws RepositoryException if an error occurs */ public void setValue(Value value) throws RepositoryException { getParent().setProperty(getName(), value); }
String value = getString(); switch (getType()) { case PropertyType.PATH: try { return (value.startsWith("/")) ? getSession().getProperty(value) : getParent().getProperty(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); return getParent().getProperty(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); String path = getSession().getValueFactory().createValue(value, PropertyType.PATH).getString(); return (path.startsWith("/")) ? getSession().getProperty(path) : getParent().getProperty(path); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value);
/** * Returns the string value of this property. * <p> * The default implementation forwards the method call to the * {@link Value} instance returned by the generic * {@link Property#getValue()} method. * * @return string value * @throws RepositoryException if an error occurs */ public String getString() throws RepositoryException { return getValue().getString(); }
/** * Returns the length of the value of this property. * <p> * The default implementation measures the length of the {@link Value} * instance returned by the generic {@link Property#getValue()} method. * * @return length of the property value * @throws RepositoryException if an error occurs */ public long getLength() throws RepositoryException { return getLength(getValue()); }
/** * Returns the lengths of the values of this property. * <p> * The default implementation measures the lengths of the {@link Value} * instances returned by the generic {@link Property#getValues()} method. * * @return lengths of the property values * @throws RepositoryException if an error occurs */ public long[] getLengths() throws RepositoryException { Value[] values = getValues(); long[] lengths = new long[values.length]; for (int i = 0; i < values.length; i++) { lengths[i] = getLength(values[i]); } return lengths; }
/** * Sets the values of this property. * <p> * The default implementation forwards the call to the * {@link Node#setProperty(String, Value[])} method of the parent node * using the name of this property. * * @param values passed through * @throws RepositoryException if an error occurs */ public void setValue(Value[] values) throws RepositoryException { getParent().setProperty(getName(), values); }
String value = getString(); switch (getType()) { case PropertyType.REFERENCE: case PropertyType.WEAKREFERENCE: return getSession().getNodeByIdentifier(value); return (value.startsWith("/")) ? getSession().getNode(value) : getParent().getNode(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); return getParent().getNode(value); } catch (PathNotFoundException e) { throw new ItemNotFoundException(value); try { Value refValue = getSession().getValueFactory().createValue(value, PropertyType.REFERENCE); return getSession().getNodeByIdentifier(refValue.getString()); } catch (ItemNotFoundException e) { throw e; } catch (RepositoryException e) { Value pathValue = getSession().getValueFactory().createValue(value, PropertyType.PATH); try { return (value.startsWith("/")) ? getSession().getNode(pathValue.getString()) : getParent().getNode(pathValue.getString()); } catch (PathNotFoundException e1) { throw new ItemNotFoundException(pathValue.getString());
/** * Returns the string value of this property. * <p> * The default implementation forwards the method call to the * {@link Value} instance returned by the generic * {@link Property#getValue()} method. * * @return string value * @throws RepositoryException if an error occurs */ public String getString() throws RepositoryException { return getValue().getString(); }
/** * Returns the length of the value of this property. * <p> * The default implementation measures the length of the {@link Value} * instance returned by the generic {@link Property#getValue()} method. * * @return length of the property value * @throws RepositoryException if an error occurs */ public long getLength() throws RepositoryException { return getLength(getValue()); }
/** * Returns the lengths of the values of this property. * <p> * The default implementation measures the lengths of the {@link Value} * instances returned by the generic {@link Property#getValues()} method. * * @return lengths of the property values * @throws RepositoryException if an error occurs */ public long[] getLengths() throws RepositoryException { Value[] values = getValues(); long[] lengths = new long[values.length]; for (int i = 0; i < values.length; i++) { lengths[i] = getLength(values[i]); } return lengths; }
/** * Removes this property. * <p> * The default implementation calls {@link Node#setProperty(String, Value)} * with a <code>null</code> value on the parent node. * * @throws RepositoryException if an error occurs */ public void remove() throws RepositoryException { getParent().setProperty(getName(), (Value) null); }