Refine search
private boolean mustSendBinary(final Value val) throws RepositoryException { if (val.getType() != BINARY) { final String ser = val.getString(); for (int i = 0; i < ser.length(); i++) { char c = ser.charAt(i); if (c >= 0 && c < 32 && c != '\r' && c != '\n' && c != '\t') { return true; } } } return false; }
private boolean checkPropertyExists(final Authorizable authorizable) throws RepositoryException { Value[] values = authorizable.getProperty(propertyName); for (Value val : values) { if ((val.getType() == PropertyType.STRING) && StringUtils .equals(val.getString(), propertyValue)) { return true; } } return false; }
private boolean checkPropertyExists(final Authorizable authorizable) throws RepositoryException { Value[] values = authorizable.getProperty(propertyName); for (Value val : values) { if ((val.getType() == PropertyType.STRING) && StringUtils .equals(val.getString(), propertyValue)) { return true; } } return false; }
private static String format(Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: case PropertyType.BOOLEAN: return '\'' + value.getString() + '\''; case PropertyType.LONG: case PropertyType.DOUBLE: return value.getString(); case PropertyType.DATE: return "xs:dateTime('" + value.getString() + "')"; default: throw new RepositoryException("Property of type " + PropertyType.nameFromValue(value.getType()) + " not supported"); } }
private static String format(Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: case PropertyType.BOOLEAN: return '\'' + value.getString() + '\''; case PropertyType.LONG: case PropertyType.DOUBLE: return value.getString(); case PropertyType.DATE: return "xs:dateTime('" + value.getString() + "')"; default: throw new RepositoryException("Property of type " + PropertyType.nameFromValue(value.getType()) + " not supported"); } }
/** * Get the node that a property value refers to. * @param session Session to use to load the node. * @param v Value that refers to a node. * @return the JCR node * @throws RepositoryException When there is an error accessing the node. * @throws RepositoryRuntimeException When the value type is not PATH, REFERENCE or WEAKREFERENCE. **/ public static javax.jcr.Node nodeForValue(final Session session, final Value v) throws RepositoryException { if (v.getType() == PATH) { return session.getNode(v.getString()); } else if (v.getType() == REFERENCE || v.getType() == WEAKREFERENCE) { return session.getNodeByIdentifier(v.getString()); } else { throw new RepositoryRuntimeException("Cannot convert value of type " + PropertyType.nameFromValue(v.getType()) + " to a node reference"); } }
@Nonnull public static String format(@Nonnull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: case PropertyType.BOOLEAN: return '\'' + QueryUtil.escapeForQuery(value.getString()) + '\''; case PropertyType.LONG: case PropertyType.DOUBLE: return value.getString(); case PropertyType.DATE: return "xs:dateTime('" + value.getString() + "')"; default: throw new RepositoryException("Property of type " + PropertyType.nameFromValue(value.getType()) + " not supported"); } }
@NotNull public static String format(@NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: case PropertyType.BOOLEAN: return '\'' + QueryUtil.escapeForQuery(value.getString()) + '\''; case PropertyType.LONG: case PropertyType.DOUBLE: return value.getString(); case PropertyType.DATE: return "xs:dateTime('" + value.getString() + "')"; default: throw new RepositoryException("Property of type " + PropertyType.nameFromValue(value.getType()) + " not supported"); } }
@NotNull public static String format(@NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: case PropertyType.BOOLEAN: return '\'' + QueryUtil.escapeForQuery(value.getString()) + '\''; case PropertyType.LONG: case PropertyType.DOUBLE: return value.getString(); case PropertyType.DATE: return "xs:dateTime('" + value.getString() + "')"; default: throw new RepositoryException("Property of type " + PropertyType.nameFromValue(value.getType()) + " not supported"); } }
private Map<String, Value> adjustRestrictions(Map<String, Value> restrictions) throws RepositoryException { // make sure the nodePath restriction is of type PATH Value v = restrictions.get(jcrNodePathName); if (v == null) { v = restrictions.get(P_NODE_PATH.toString()); } if (v != null && v.getType() != PropertyType.PATH) { v = valueFactory.createValue(v.getString(), PropertyType.PATH); restrictions.put(jcrNodePathName, v); } // ... and glob is of type STRING. v = restrictions.get(jcrGlobName); if (v == null) { v = restrictions.get(P_GLOB.toString()); } if (v != null && v.getType() != PropertyType.STRING) { v = valueFactory.createValue(v.getString(), PropertyType.STRING); restrictions.put(jcrGlobName, v); } return restrictions; }
/** * Return the length of the specified JCR value object. * * @param value The value. * @return The length of the given value. * @throws RepositoryException If an error occurs. */ private static long getLength(Value value) throws RepositoryException { if (value.getType() == PropertyType.BINARY) { return value.getBinary().getSize(); } else { return value.getString().length(); } }
/** * Return the length of the specified JCR value object. * * @param value The value. * @return The length of the given value. * @throws RepositoryException If an error occurs. */ private static long getLength(Value value) throws RepositoryException { if (value.getType() == PropertyType.BINARY) { return value.getBinary().getSize(); } else { return value.getString().length(); } }
/** * Return the length of the specified JCR value object. * * @param value The value. * @return The length of the given value. * @throws RepositoryException If an error occurs. */ private static long getLength(Value value) throws RepositoryException { if (value.getType() == PropertyType.BINARY) { return value.getBinary().getSize(); } else { return value.getString().length(); } }
private Object getValue(Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.BOOLEAN: return Boolean.valueOf(value.getBoolean()); case PropertyType.LONG: return Long.valueOf(value.getLong()); case PropertyType.DOUBLE: return Double.valueOf(value.getDouble()); case PropertyType.STRING: default: return value.getString(); } }
private Object getValue(Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.BOOLEAN: return Boolean.valueOf(value.getBoolean()); case PropertyType.LONG: return Long.valueOf(value.getLong()); case PropertyType.DOUBLE: return Double.valueOf(value.getDouble()); case PropertyType.STRING: default: return value.getString(); } }
/** * Compares values as defined in the JCR specification. * * @param object value for comparison * @return <code>true</code> if the values are equal, * <code>false</code> otherwise * @see <a href="https://issues.apache.org/jira/browse/JCRRMI-16">JCRRMI-16</a> */ public boolean equals(Object object) { try { return (object instanceof Value) && getType() == ((Value) object).getType() && getString().equals(((Value) object).getString()); } catch (RepositoryException e) { return false; } }
/** Wrap JCR Values in a simple way */ private Scriptable wrap(Value value) throws ValueFormatException, IllegalStateException, RepositoryException { Object javaObject; if (value.getType() == PropertyType.REFERENCE) { String nodeUuid = value.getString(); javaObject = node.getSession().getNodeByUUID(nodeUuid); } else { javaObject = toJavaObject(value); } return ScriptRuntime.toObject(this, javaObject); }
public int getHashCode(Value value) { try { switch (value.getType()) { case PropertyType.BOOLEAN: return Boolean.valueOf(value.getBoolean()).hashCode(); case PropertyType.LONG: return Long.valueOf(value.getLong()).hashCode(); case PropertyType.BINARY: return getStreamComparer().getHashCode(value.getStream()); } return value.getString().hashCode(); } catch (RepositoryException e) { log.error("Could not calculate hash code", e); return 0; } }