Class BaseExpression

java.lang.Object
org.apache.hadoop.fs.shell.find.BaseExpression
All Implemented Interfaces:
Configurable, Expression

public abstract class BaseExpression extends Object implements Expression, Configurable
Abstract expression for use in the Find command. Provides default behavior for a no-argument primary expression.
  • Constructor Details

    • BaseExpression

      public BaseExpression()
  • Method Details

    • setUsage

      protected void setUsage(String[] usage)
      Sets the usage text for this Expression .
      Parameters:
      usage - usage array.
    • setHelp

      protected void setHelp(String[] help)
      Sets the help text for this Expression .
      Parameters:
      help - help.
    • getUsage

      public String[] getUsage()
      Description copied from interface: Expression
      Returns brief usage instructions for this expression. Multiple items should be returned if there are multiple ways to use this expression.
      Specified by:
      getUsage in interface Expression
      Returns:
      array of usage instructions
    • getHelp

      public String[] getHelp()
      Description copied from interface: Expression
      Returns a description of the expression for use in help. Multiple lines should be returned array items. Lines should be formated to 60 characters or less.
      Specified by:
      getHelp in interface Expression
      Returns:
      array of description lines
    • setOptions

      public void setOptions(FindOptions options) throws IOException
      Description copied from interface: Expression
      Set the options for this expression, called once before processing any items.
      Specified by:
      setOptions in interface Expression
      Parameters:
      options - options.
      Throws:
      IOException - raised on errors performing I/O.
    • prepare

      public void prepare() throws IOException
      Description copied from interface: Expression
      Prepares the expression for execution, called once after setting options and before processing any options.
      Specified by:
      prepare in interface Expression
      Throws:
      IOException - raised on errors performing I/O.
    • finish

      public void finish() throws IOException
      Description copied from interface: Expression
      Finishes the expression, called once after processing all items.
      Specified by:
      finish in interface Expression
      Throws:
      IOException - raised on errors performing I/O.
    • getOptions

      protected FindOptions getOptions()
      Return the options to be used by this expression.
      Returns:
      options.
    • setConf

      public void setConf(Configuration conf)
      Description copied from interface: Configurable
      Set the configuration to be used by this object.
      Specified by:
      setConf in interface Configurable
      Parameters:
      conf - configuration to be used
    • getConf

      public Configuration getConf()
      Description copied from interface: Configurable
      Return the configuration used by this object.
      Specified by:
      getConf in interface Configurable
      Returns:
      Configuration
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isAction

      public boolean isAction()
      Description copied from interface: Expression
      Indicates whether this expression performs an action, i.e. provides output back to the user.
      Specified by:
      isAction in interface Expression
      Returns:
      if is action true, not false.
    • isOperator

      public boolean isOperator()
      Description copied from interface: Expression
      Identifies the expression as an operator rather than a primary.
      Specified by:
      isOperator in interface Expression
      Returns:
      if is operator true, not false.
    • getArguments

      protected List<String> getArguments()
      Returns the arguments of this expression
      Returns:
      list of argument strings
    • getArgument

      protected String getArgument(int position) throws IOException
      Returns the argument at the given position (starting from 1).
      Parameters:
      position - argument to be returned
      Returns:
      requested argument
      Throws:
      IOException - if the argument doesn't exist or is null
    • getChildren

      protected List<Expression> getChildren()
      Returns the children of this expression.
      Returns:
      list of child expressions
    • getPrecedence

      public int getPrecedence()
      Description copied from interface: Expression
      Returns the precedence of this expression (only applicable to operators).
      Specified by:
      getPrecedence in interface Expression
      Returns:
      precedence.
    • addChildren

      public void addChildren(Deque<Expression> exprs)
      Description copied from interface: Expression
      Adds children to this expression. Children are popped from the head of the deque.
      Specified by:
      addChildren in interface Expression
      Parameters:
      exprs - deque of expressions from which to take the children
    • addChildren

      protected void addChildren(Deque<Expression> exprs, int count)
      Add a specific number of children to this expression. The children are popped off the head of the expressions.
      Parameters:
      exprs - deque of expressions from which to take the children
      count - number of children to be added
    • addArguments

      public void addArguments(Deque<String> args)
      Description copied from interface: Expression
      Adds arguments to this expression. Arguments are popped from the head of the deque and added to the front of the child list, ie last child added is the first evaluated.
      Specified by:
      addArguments in interface Expression
      Parameters:
      args - deque of arguments from which to take expression arguments
    • addArguments

      protected void addArguments(Deque<String> args, int count)
      Add a specific number of arguments to this expression. The children are popped off the head of the expressions.
      Parameters:
      args - deque of arguments from which to take the argument
      count - number of children to be added
    • addArgument

      protected void addArgument(String arg)
      Add a single argument to this expression. The argument is popped off the head of the expressions.
      Parameters:
      arg - argument to add to the expression
    • getFileStatus

      protected FileStatus getFileStatus(PathData item, int depth) throws IOException
      Returns the FileStatus from the PathData item. If the current options require links to be followed then the returned file status is that of the linked file.
      Parameters:
      item - PathData
      depth - current depth in the process directories
      Returns:
      FileStatus
      Throws:
      IOException - raised on errors performing I/O.
    • getPath

      protected Path getPath(PathData item) throws IOException
      Returns the Path from the PathData item.
      Parameters:
      item - PathData
      Returns:
      Path
      Throws:
      IOException - raised on errors performing I/O.
    • getFileSystem

      protected FileSystem getFileSystem(PathData item) throws IOException
      Returns the FileSystem associated with the PathData item.
      Parameters:
      item - PathData
      Returns:
      FileSystem
      Throws:
      IOException - raised on errors performing I/O.