Package org.basex.query.var
Enum VarUsage
- java.lang.Object
-
- java.lang.Enum<VarUsage>
-
- org.basex.query.var.VarUsage
-
- All Implemented Interfaces:
Serializable
,Comparable<VarUsage>
public enum VarUsage extends Enum<VarUsage>
A tri-state encoding the number of usages of a variable or context reference.- Author:
- BaseX Team 2005-24, BSD License, Leo Woerteler
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MORE_THAN_ONCE
More than one usage.NEVER
No usages.ONCE
Exactly one usage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VarUsage
max(VarUsage other)
Combines the usages for two alternative branches.static VarUsage
maximum(Var var, Expr... exprs)
Checks how often a variable or context reference 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 var, Expr... exprs)
Checks how often a variable or context reference is accessed in all given expressions.VarUsage
times(long count)
Number of usages if the code is executedcount
times.static VarUsage
valueOf(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.
-
-
-
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(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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- 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 if the code is executedcount
times.- Parameters:
count
- number of executions (-1
if not known)- Returns:
- number of usages
-
sum
public static VarUsage sum(Var var, Expr... exprs)
Checks how often a variable or context reference is accessed in all given expressions.- Parameters:
var
- variable (Var
reference) or context (null
) to inlineexprs
- expressions- Returns:
- number of accesses to the variable in all expressions combined
-
maximum
public static VarUsage maximum(Var var, Expr... exprs)
Checks how often a variable or context reference is used in any of the given expressions.- Parameters:
var
- variable (Var
reference) or context (null
) to inlineexprs
- expressions- Returns:
- maximum number of accesses in any given expression
-
-