org.basex.query.var
Enum VarUsage

java.lang.Object
  extended by java.lang.Enum<VarUsage>
      extended by org.basex.query.var.VarUsage
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<VarUsage>

public enum VarUsage
extends java.lang.Enum<VarUsage>

A tri-state encoding the number of usages of a variable.

Author:
BaseX Team 2005-12, BSD License, Leo Woerteler

Enum Constant Summary
MORE_THAN_ONCE
          More than one usage.
NEVER
          No usages.
ONCE
          Exactly one usage.
 
Method Summary
 VarUsage max(VarUsage other)
          Combines the usages for two alternative branches.
static VarUsage maximum(Var v, Expr... es)
          Checks how often the given variable is used in any of the given expressions.
 VarUsage plus(VarUsage other)
          Combines the usages for two expressions that are both executed.
static VarUsage sum(Var v, Expr... es)
          Checks how often the given variable is accessed in all of the given expressions.
 VarUsage times(long count)
          Number of usages of the variable if the code is executed count times.
static VarUsage valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static VarUsage[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NEVER

public static final VarUsage NEVER
No usages.


ONCE

public static final VarUsage ONCE
Exactly one usage.


MORE_THAN_ONCE

public static final VarUsage MORE_THAN_ONCE
More than one usage.

Method Detail

values

public static VarUsage[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (VarUsage c : VarUsage.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static VarUsage valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

max

public VarUsage max(VarUsage other)
Combines the usages for two alternative branches.

Parameters:
other - usage count to be combined
Returns:
number of usages for the disjunction of both branches

plus

public VarUsage plus(VarUsage other)
Combines the usages for two expressions that are both executed.

Parameters:
other - usage count to be combined
Returns:
number of usages of both expressions combined

times

public VarUsage times(long count)
Number of usages of the variable if the code is executed count times.

Parameters:
count - number of executions, may be -1 if not known
Returns:
number of usages

sum

public static VarUsage sum(Var v,
                           Expr... es)
Checks how often the given variable is accessed in all of the given expressions.

Parameters:
v - variable
es - expressions
Returns:
number of accesses to the variable in all expressions combined

maximum

public static VarUsage maximum(Var v,
                               Expr... es)
Checks how often the given variable is used in any of the given expressions.

Parameters:
v - variable
es - expressions
Returns:
maximum number of accesses in any given expression