Enum Class VarUsage

java.lang.Object
java.lang.Enum<VarUsage>
org.basex.query.var.VarUsage
All Implemented Interfaces:
Serializable, Comparable<VarUsage>, java.lang.constant.Constable

public enum VarUsage extends Enum<VarUsage>
A tri-state encoding the number of usages of a variable or context reference.
Author:
BaseX Team 2005-21, BSD License, Leo Woerteler
  • Enum Constant Details

    • 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 Details

    • values

      public static VarUsage[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static VarUsage valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      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 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 var, Expr... exprs)
      Checks how often a variable or context reference is accessed in all of the given expressions.
      Parameters:
      var - variable (Var reference) or context (null) to inline
      exprs - 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 inline
      exprs - expressions
      Returns:
      maximum number of accesses in any given expression