edu.cmu.aura.service
Class ReqUtil

java.lang.Object
  |
  +--edu.cmu.aura.service.ReqUtil

public class ReqUtil
extends java.lang.Object

ReqUtil provides various utility functions related to attribute requirements.


Field Summary
static int B_MAX
           
static int B_MIN
           
static int R_ACCURACY
           
static int R_CONFIDENCE
           
static int R_INTERVAL
           
static int R_NONE
           
static int R_UPDATE_TIME
           
 
Constructor Summary
ReqUtil()
           
 
Method Summary
static void checkAllowedReqs(java.util.ArrayList reqs, java.lang.String[] reqNames, int allowedReqs)
          Checks to see if for a list of particular attributes, all reqs applied to these attributes are of a valid type.
static void checkAllowedReqs(java.util.ArrayList reqs, java.lang.String reqName, int allowedReqs)
          Checks to see if for a particular attribute, all reqs applied to that attribute are of a valid type.
static void checkForAllowedAttribs(java.util.ArrayList reqs, java.lang.String[] allowedReqs)
          Make sure that a list of reqs contains only the specified attributes.
static void checkForDups(java.util.ArrayList reqs)
          Throws a RequestException if duplicate attributes are detected.
static boolean getIntervalBounds(java.util.ArrayList reqs, long[] intervalBounds)
          Combines the interval bounds from several different attribute requirements into a single bound encompassing all of the bounds.
static boolean getUpdateTimeBoundsMillis(java.util.ArrayList reqs, long[] bounds)
          Combines the update time bounds from several different attribute requirements into a single bound encompassing all of the bounds.
static void sanityCheckReqs(java.util.ArrayList reqs)
          Perform sanity checks on the given reqs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

B_MIN

public static final int B_MIN
See Also:
Constant Field Values

B_MAX

public static final int B_MAX
See Also:
Constant Field Values

R_NONE

public static final int R_NONE
See Also:
Constant Field Values

R_CONFIDENCE

public static final int R_CONFIDENCE
See Also:
Constant Field Values

R_ACCURACY

public static final int R_ACCURACY
See Also:
Constant Field Values

R_UPDATE_TIME

public static final int R_UPDATE_TIME
See Also:
Constant Field Values

R_INTERVAL

public static final int R_INTERVAL
See Also:
Constant Field Values
Constructor Detail

ReqUtil

public ReqUtil()
Method Detail

sanityCheckReqs

public static void sanityCheckReqs(java.util.ArrayList reqs)
                            throws RequestException
Perform sanity checks on the given reqs. Throw a RequestException if the sanity check failed. Currently the only sanity checks performed are that update min times are <= update max times.

Parameters:
reqs - reqs to sanity check
RequestException

checkForAllowedAttribs

public static void checkForAllowedAttribs(java.util.ArrayList reqs,
                                          java.lang.String[] allowedReqs)
                                   throws RequestException
Make sure that a list of reqs contains only the specified attributes. Throw a RequestException otherwise.

Parameters:
reqs - the list of reqs to check
allowedReqs - the names of reqs that are allowed
RequestException

checkForDups

public static void checkForDups(java.util.ArrayList reqs)
                         throws RequestException
Throws a RequestException if duplicate attributes are detected.

Parameters:
reqs - list of attribute requirements to check for dups
RequestException

getIntervalBounds

public static boolean getIntervalBounds(java.util.ArrayList reqs,
                                        long[] intervalBounds)
Combines the interval bounds from several different attribute requirements into a single bound encompassing all of the bounds.

Parameters:
reqs - list to get bounds for
intervalBounds - used to return the bounds
Returns:
true if an interval was found in the given reqs false if no interval was found

getUpdateTimeBoundsMillis

public static boolean getUpdateTimeBoundsMillis(java.util.ArrayList reqs,
                                                long[] bounds)
Combines the update time bounds from several different attribute requirements into a single bound encompassing all of the bounds.

Parameters:
reqs - list to get bounds for
bounds - used to return the bounds
Returns:
true if an update time requirement was found in the given reqs false if no update time requirement was found

checkAllowedReqs

public static void checkAllowedReqs(java.util.ArrayList reqs,
                                    java.lang.String[] reqNames,
                                    int allowedReqs)
                             throws ReqNotSupportedException,
                                    RequestException
Checks to see if for a list of particular attributes, all reqs applied to these attributes are of a valid type. Note while req lists should not have duplicates this routine does not enforce this.

Parameters:
reqs - the list of attribute requirements to check
allowedReqs - bit field specifying which requirements are allowed
ReqNotSupportedException
RequestException

checkAllowedReqs

public static void checkAllowedReqs(java.util.ArrayList reqs,
                                    java.lang.String reqName,
                                    int allowedReqs)
                             throws ReqNotSupportedException
Checks to see if for a particular attribute, all reqs applied to that attribute are of a valid type. Note while req lists should not have duplicates this routine does not enforce this.

Parameters:
reqs - the list of attribute requirements to check
reqName - name of the attribute to check reqs on
allowedReqs - bit field specifying which requirements are allowed
ReqNotSupportedException