@Test public void shouldAllowValidLongValues() throws Exception { NodeType constrainedType = validateTypeDefinition(); JcrPropertyDefinition prop = propertyDefinitionFor(constrainedType, TestLexicon.CONSTRAINED_LONG); Value[] values = new Value[] {valueFor(0.1, PropertyType.LONG), valueFor(10, PropertyType.LONG), valueFor(50, PropertyType.LONG)}; assertThat(satisfiesConstraints(prop, new Value[] {}), is(true)); assertThat(satisfiesConstraints(prop, new Value[] {valueFor(4.99, PropertyType.LONG)}), is(true)); assertThat(satisfiesConstraints(prop, values), is(true)); }
boolean satisfiesConstraints( Value value, JcrSession session ) { if (value == null) return false; if (valueConstraints == null || valueConstraints.length == 0) { return true; } int type = requiredType == PropertyType.UNDEFINED ? value.getType() : requiredType; ConstraintChecker checker = this.checker; if (checker == null || checker.getType() != type) { checker = createChecker(context, type, valueConstraints); this.checker = checker; } try { return checker.matches(value, session); } catch (ValueFormatException vfe) { return false; } }
JcrPropertyDefinition extends JcrItemDefinition implements PropertyDefinition { boolean satisfiesConstraints( Value value, JcrSession session ) { if (value == null) return false; if (valueConstraints == null || valueConstraints.length == 0) { return true; } int type = requiredType == PropertyType.UNDEFINED ? value.getType() : requiredType; ConstraintChecker checker = this.checker; if (checker == null || checker.getType() != type) { checker = createChecker(context, type, valueConstraints); this.checker = checker; } try { return checker.matches(value, session); } catch (ValueFormatException vfe) { return false; } } }
JcrPropertyDefinition extends JcrItemDefinition implements PropertyDefinition { boolean satisfiesConstraints( Value value, JcrSession session ) { if (value == null) return false; if (valueConstraints == null || valueConstraints.length == 0) { return true; } int type = requiredType == PropertyType.UNDEFINED ? value.getType() : requiredType; ConstraintChecker checker = this.checker; if (checker == null || checker.getType() != type) { checker = createChecker(context, type, valueConstraints); this.checker = checker; } try { return checker.matches(value, session); } catch (ValueFormatException vfe) { return false; } } JcrPropertyDefinition( ExecutionContext context,
                           JcrNodeType declaringNodeType,
                           NodeKey prototypeKey,
                           Name name,
                           int onParentVersion,
                           boolean autoCreated,
                           boolean mandatory,
                           boolean protectedItem,
                           JcrValue[] defaultValues,
                           int requiredType,
                           String[] valueConstraints,
                           boolean multiple,
                           boolean fullTextSearchable,
                           boolean queryOrderable,
                           String[] queryOperators ); }
JcrPropertyDefinition extends JcrItemDefinition implements PropertyDefinition { boolean satisfiesConstraints( Value value, JcrSession session ) { if (value == null) return false; if (valueConstraints == null || valueConstraints.length == 0) { return true; } int type = requiredType == PropertyType.UNDEFINED ? value.getType() : requiredType; ConstraintChecker checker = this.checker; if (checker == null || checker.getType() != type) { checker = createChecker(context, type, valueConstraints); this.checker = checker; } try { return checker.matches(value, session); } catch (ValueFormatException vfe) { return false; } } JcrPropertyDefinition( ExecutionContext context,
                           JcrNodeType declaringNodeType,
                           NodeKey prototypeKey,
                           Name name,
                           int onParentVersion,
                           boolean autoCreated,
                           boolean mandatory,
                           boolean protectedItem,
                           JcrValue[] defaultValues,
                           int requiredType,
                           String[] valueConstraints,
                           boolean multiple,
                           boolean fullTextSearchable,
                           boolean queryOrderable,
                           String[] queryOperators ); PropertyDefinitionId getId(); @Override JcrValue[] getDefaultValues(); boolean hasDefaultValues(); @Override int getRequiredType(); @Override String[] getValueConstraints(); @Override boolean isMultiple(); @Override boolean isFullTextSearchable(); @Override boolean isQueryOrderable(); @Override String[] getAvailableQueryOperators(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); }
JcrPropertyDefinition extends JcrItemDefinition implements PropertyDefinition { boolean satisfiesConstraints( Value value, JcrSession session ) { if (value == null) return false; if (valueConstraints == null || valueConstraints.length == 0) { return true; } int type = requiredType == PropertyType.UNDEFINED ? value.getType() : requiredType; ConstraintChecker checker = this.checker; if (checker == null || checker.getType() != type) { checker = createChecker(context, type, valueConstraints); this.checker = checker; } try { return checker.matches(value, session); } catch (ValueFormatException vfe) { return false; } } JcrPropertyDefinition( ExecutionContext context,
                           JcrNodeType declaringNodeType,
                           NodeKey prototypeKey,
                           Name name,
                           int onParentVersion,
                           boolean autoCreated,
                           boolean mandatory,
                           boolean protectedItem,
                           JcrValue[] defaultValues,
                           int requiredType,
                           String[] valueConstraints,
                           boolean multiple,
                           boolean fullTextSearchable,
                           boolean queryOrderable,
                           String[] queryOperators ); PropertyDefinitionId getId(); @Override JcrValue[] getDefaultValues(); boolean hasDefaultValues(); @Override int getRequiredType(); @Override String[] getValueConstraints(); @Override boolean isMultiple(); @Override boolean isFullTextSearchable(); @Override boolean isQueryOrderable(); @Override String[] getAvailableQueryOperators(); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj );  }