tribble.net.ftp.shell
Class BlockDef

java.lang.Object
  extended by tribble.net.ftp.shell.BlockDef
All Implemented Interfaces:
CommandCodes

 class BlockDef
extends java.lang.Object
implements CommandCodes

FTP command begin/end block or func definition.

Since:
API 1.0, 2007-03-16
Version:
$Revision: 1.9 $ $Date: 2007/08/12 16:33:29 $
Author:
David R. Tribble (david@tribble.com).

Copyright ©2007 by David R. Tribble, all rights reserved.
Permission is granted to any person or entity except those designated by by the United States Department of State as a terrorist, or terrorist government or agency, to use and distribute this source code provided that the original copyright notice remains present and unaltered.

See Also:
CommandExec, ExecFrame

Field Summary
(package private)  int m_depth
          Scope nesting depth.
(package private)  int m_lineNo
          Source line number.
(package private)  java.lang.String m_name
          Name of this block definition.
(package private)  BlockDef m_outer
          Outer block containing this block definition.
(package private)  CommandNode m_parent
          Parent command enclosing this block.
(package private)  java.lang.String m_type
          Block type (begin/end, foreach, repeat).
(package private) static java.lang.String REV
          Revision information.
 
Fields inherited from interface tribble.net.ftp.shell.CommandCodes
CMD__UNDEF, CMD_ADD, CMD_AND, CMD_APPEND, CMD_BINARY, CMD_BLOCK, CMD_BREAK, CMD_BUILTIN, CMD_CALL, CMD_CDUP, CMD_CHDIR, CMD_CLOSE, CMD_CONCAT, CMD_COND, CMD_CONNECT, CMD_CONTINUE, CMD_DEBUG, CMD_DECR, CMD_DELETE, CMD_DIR, CMD_DIV, CMD_ECHO, CMD_EQ, CMD_EXEC, CMD_EXIT, CMD_FALSE, CMD_FILENAME, CMD_FOR, CMD_FOREACH, CMD_FUNC, CMD_FUNC_FORMAT, CMD_FUNC_INDEX, CMD_FUNC_LCASE, CMD_FUNC_LEN, CMD_FUNC_NORM, CMD_FUNC_REPL, CMD_FUNC_RINDEX, CMD_FUNC_SUB, CMD_FUNC_TRIM, CMD_FUNC_UCASE, CMD_GE, CMD_GET, CMD_GLOB, CMD_GOTO, CMD_GT, CMD_HELP, CMD_IF, CMD_INCR, CMD_LABEL, CMD_LCHDIR, CMD_LE, CMD_LOCAL, CMD_LT, CMD_MATCH, CMD_MGET, CMD_MKDIR, CMD_MOD, CMD_MPUT, CMD_MUL, CMD_NE, CMD_NEG, CMD_NMATCH, CMD_NO_N, CMD_NOP, CMD_NOT, CMD_OPEN, CMD_OR, CMD_POS, CMD_PRINT, CMD_PUT, CMD_PWD, CMD_READ, CMD_REMOTE, CMD_RENAME, CMD_REPEAT, CMD_RETURN, CMD_RMDIR, CMD_SET, CMD_SHELL, CMD_SLEEP, CMD_STATUS, CMD_STREQ, CMD_SUB, CMD_SUBSCR, CMD_SYSTEM, CMD_TEST, CMD_TEST_DIR, CMD_TEST_EXEC, CMD_TEST_EXISTS, CMD_TEST_FILE, CMD_TEST_MODTIME, CMD_TEST_READ, CMD_TEST_SIZE, CMD_TEST_WRITE, CMD_TEXT, CMD_TIMEOUT, CMD_TOK, CMD_TRUE, CMD_USER, CMD_VAR, CMD_WAITFOR, CMD_WHILE, CMD_WRITE, CMD_X_INTERRUPT, CMD_X_SESSIONS, CMD_X_STACK, CMD_X_STOP, CMD_X_VARS, CMD_X_VERBOSE, VAL_EMPTY, VAL_FALSE, VAL_FALSE_WD, VAL_ONE, VAL_TRUE, VAL_TRUE_WD, VAL_ZERO
 
Constructor Summary
BlockDef(java.lang.String name, int lineNo, BlockDef outer, CommandNode cmd)
          Constructor.
 
Method Summary
(package private)  boolean addFuncDef(java.lang.String name, CommandNode cmd)
          Add a local func definition to this block definition.
(package private)  boolean addLabelDef(java.lang.String name, CommandNode cmd)
          Add a local label definition to this block definition.
(package private)  boolean addVarDef(java.lang.String name, CommandNode cmd)
          Add a local var definition to this block definition.
(package private)  BlockDef findFuncBlock(java.lang.String name)
          Find the block containing a func definition.
(package private)  CommandNode findFuncDef(java.lang.String name)
          Retrieve a func definition within this block's scope.
(package private)  BlockDef findLabelBlock(java.lang.String name)
          Find the block containing a label definition.
(package private)  CommandNode findLabelDef(java.lang.String name)
          Retrieve a local label definition in this block definition.
(package private)  BlockDef findVarBlock(java.lang.String name)
          Find the block containing a var definition.
(package private)  CommandNode findVarDef(java.lang.String name)
          Retrieve a var definition within this block's scope.
(package private)  boolean isFunc()
          Determine if this block definition is a func body.
(package private)  void printTree(java.io.PrintWriter out)
          Pretty-print this block definition and its subordinate blocks.
(package private)  void scrub()
          Release objects that are no longer needed by this block definition after a successful parse.
(package private)  void setCmds(CommandNode cmds)
          Establish the commands (statements) for this block definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

m_name

java.lang.String m_name
Name of this block definition.


m_type

java.lang.String m_type
Block type (begin/end, foreach, repeat).


m_outer

BlockDef m_outer
Outer block containing this block definition.


m_parent

CommandNode m_parent
Parent command enclosing this block.


m_lineNo

int m_lineNo
Source line number.


m_depth

int m_depth
Scope nesting depth.

Constructor Detail

BlockDef

BlockDef(java.lang.String name,
         int lineNo,
         BlockDef outer,
         CommandNode cmd)
Constructor.

Parameters:
name - Name of this block. Funcs have user-defined names, while begin/end block have names such as ".42".
lineNo - Source line number where the block is defined.
outer - Begin/end block or func containing this block. This is null for the outermost (file) scope, which has no outer scope.
cmd - Parent command containing this block. This is null for the outermost (file) scope, and for block commands having no controlling command.
Since:
1.7, 2007-08-02
Method Detail

setCmds

void setCmds(CommandNode cmds)
Establish the commands (statements) for this block definition.

Parameters:
cmds - First command (statement) defined within the begin/end block or func, or null if there are no commands.
Since:
1.1, 2007-03-16

isFunc

boolean isFunc()
Determine if this block definition is a func body.

Since:
1.2, 2007-03-21

addFuncDef

boolean addFuncDef(java.lang.String name,
                   CommandNode cmd)
Add a local func definition to this block definition.

Parameters:
name - Func name.
cmd - Command (CMD_FUNC) containing the func definition.
Returns:
True if the func was added successfully, or false if it is already defined within this block definition.
Since:
1.1, 2007-03-16

findFuncDef

CommandNode findFuncDef(java.lang.String name)
Retrieve a func definition within this block's scope.

Parameters:
name - Func name.
Returns:
The command node (CMD_FUNC) containing the func definition, or null if no such func exists within the scope of this block definition.
Since:
1.1, 2007-03-16

findFuncBlock

BlockDef findFuncBlock(java.lang.String name)
Find the block containing a func definition.

Parameters:
name - Var name.
Returns:
The block definition containing the func definition ('func' command), or null if the func is not defined within the scope of this block or any of its outer blocks.
Since:
1.6, 2007-04-10

addVarDef

boolean addVarDef(java.lang.String name,
                  CommandNode cmd)
Add a local var definition to this block definition.

Parameters:
name - Var name.
cmd - Command (CMD_VAR) containing the var definition.
Returns:
True if the var was added successfully, or false if it is already defined within this block definition.
Since:
1.1, 2007-03-16

findVarDef

CommandNode findVarDef(java.lang.String name)
Retrieve a var definition within this block's scope.

Parameters:
name - Var name.
Returns:
The command node (CMD_VAR) containing the var definition, or null if no such var exists in the scope of this block definition.
Since:
1.1, 2007-03-16

findVarBlock

BlockDef findVarBlock(java.lang.String name)
Find the block containing a var definition.

Parameters:
name - Var name.
Returns:
The block definition containing the var definition ('var' command), or null if the var is not defined within the scope of this block or any of its outer blocks.
Since:
1.4, 2007-04-06

addLabelDef

boolean addLabelDef(java.lang.String name,
                    CommandNode cmd)
Add a local label definition to this block definition.

Parameters:
name - Label name.
cmd - Command (CMD_LABEL) containing the statement label definition.
Returns:
True if the label was added successfully, or false if it is already defined within this block definition.
Since:
1.1, 2007-03-16

findLabelDef

CommandNode findLabelDef(java.lang.String name)
Retrieve a local label definition in this block definition.

Parameters:
name - Label name.
Returns:
The command node (CMD_LABEL) containing the statement label, or null if no such label exists in this block definition.
Since:
1.1, 2007-03-16

findLabelBlock

BlockDef findLabelBlock(java.lang.String name)
Find the block containing a label definition.

Parameters:
name - Label name.
Returns:
The block definition containing the label definition, or null if the label is not defined within the scope of this block or any of its outer blocks. Blocks outside func bodies are not searched.
Since:
1.5, 2007-04-09

scrub

void scrub()
Release objects that are no longer needed by this block definition after a successful parse.

Since:
1.8, 2007-08-05

printTree

void printTree(java.io.PrintWriter out)
Pretty-print this block definition and its subordinate blocks.

Since:
1.9, 2007-08-07