org.fosstrak.llrp.commander.util
Class LLRPRangeConstraint

java.lang.Object
  extended by org.fosstrak.llrp.commander.util.LLRPRangeConstraint

public class LLRPRangeConstraint
extends java.lang.Object

This class represents an LLRP range constraint. It specifies that a certain numeric field value must lie within some ranges.

Author:
Ulrich Etter, ETHZ

Constructor Summary
LLRPRangeConstraint(java.lang.String messageOrParameterName, java.lang.String fieldName, Range[] ranges, java.lang.String preconditionedEnumerationName, java.lang.String preconditionedEnumerationValue)
          Creates a new range constraint.
 
Method Summary
 int getDefaultValue()
           
 java.lang.String getErrorMessage()
           
 java.lang.String getFieldName()
           
 java.lang.String getMessageOrParameterName()
           
 java.lang.String getPreconditionedEnumerationName()
           
 java.lang.String getPreconditionedEnumerationValue()
           
 boolean isSatisfied(int fieldValue)
          Checks whether this constraint is satisfied by the given field value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LLRPRangeConstraint

public LLRPRangeConstraint(java.lang.String messageOrParameterName,
                           java.lang.String fieldName,
                           Range[] ranges,
                           java.lang.String preconditionedEnumerationName,
                           java.lang.String preconditionedEnumerationValue)
Creates a new range constraint.

Example:
To create a constraint that specifies that the field DurationPeriod of the parameter RFSurveySpecStopTrigger must be greater than 0 if the enumeration StopTriggerType has value Duration, use the following code:
new LLRPRangeConstraint( "RFSurveySpecStopTrigger", "DurationPeriod", new Range[] { new Range(1, Integer.MAX_VALUE) }, "StopTriggerType", "Duration");

Parameters:
messageOrParameterName - the name of the message/parameter this constraint is defined for
fieldName - the name of the field this constraint is defined for
ranges - an array of ranges; for a value to satisfy a constraint it must lie in one of this ranges
preconditionedEnumerationName - the name of the enumeration on which this constraint is dependent; use null if this constraint does not depend on any enumeration
preconditionedEnumerationValue - the value of the enumeration on which this constraint is dependent; use null if this constraint does not depend on any enumeration
Method Detail

isSatisfied

public boolean isSatisfied(int fieldValue)
Checks whether this constraint is satisfied by the given field value.

Parameters:
fieldValue - the field value to validate
Returns:
true if the constraint is satisfied, and false otherwise

getErrorMessage

public java.lang.String getErrorMessage()
Returns:
the error message associated with this constraint

getMessageOrParameterName

public java.lang.String getMessageOrParameterName()

getFieldName

public java.lang.String getFieldName()

getPreconditionedEnumerationName

public java.lang.String getPreconditionedEnumerationName()

getPreconditionedEnumerationValue

public java.lang.String getPreconditionedEnumerationValue()

getDefaultValue

public int getDefaultValue()
Returns:
a default value for the field this constraint is specified for


Copyright © 2009. All Rights Reserved.