Java Doc for JEnable.java in  » XML » jibx-1.1.5 » jenable » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » jibx 1.1.5 » jenable 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jenable.JEnable

JEnable
public class JEnable (Code)
Source configuration processor program. This program processes a set of Java source files (or standard input to standard output, if no source files are specified), scanning for configuration control lines. A control line is a line that starts with "//#token*" (valid only as the first line of a file), "//#token{" (beginning an option block), "//#}token{" (inverting an option block), or "//#token} (closing an option block). The first two formats also allow a '!' immediately before the token in order to invert the token state.

The token strings to be processed are specified on the command line as either enabled or disabled. See the program documentation for more details of the command line options and usage.

Nested option blocks are allowed, but overlapping option blocks are an error. In order to ensure proper processing of nested option blocks, the user should generally specify every token used for the nested blocks as either enabled or disabled if any of them are either enabled or disabled. It is an error if an indeterminant beginning of block token (one with a token which is not on either list) is immediately contained within a block with an enabled token. In other words, the case:

 //#a{
 //#b{
 //#c{
 //#c}
 //#b}
 //#a}
 
gives an error if "a" is on the enabled list and "b" is not on either list, or if "a" is not on the disabled list, "b" is on the enabled list, and "c" is not on either list.
author:
   Dennis M. Sosnoski
version:
   0.8


Field Summary
final protected static  StringBACKUP_DIR_ERR
     Error text for unable to rename file to backup directory.
final protected static  StringBACKUP_FILE_ERR
     Error text for unable to rename file within directory.
final protected static  StringBADELSE_ERR
     Error text for block else token not matching block start token.
final protected static  intBLOCK_COMMENT_OPTION
     Return code for block comment option line.
final protected static  intBLOCK_ELSE_OPTION
     Return code for block else option line.
final protected static  intBLOCK_END_OPTION
     Return code for block end option line.
final protected static  intBLOCK_START_OPTION
     Return code for block start option line.
final protected static  intCOPY_BUFFER_SIZE
     Size of buffer used to copy file.
final protected static  StringDELETE_ERR
     Error text for unable to delete original file.
final protected static  StringDUAL_USE_ERR
     Error text for token in both sets.
final protected static  StringEXTENSION_ERR
     Error text for file option line with unknown file extension.
final protected static  intFILE_OPTION
     Return code for file option line.
final protected static  StringFILE_OPTION_ERR
     Error text for file option not on first line.
final protected static  StringINDETERM_ERR
     Error text for indeterminant token nested in enabled block.
final protected static  intLEAD_LENGTH
     Length of lead text for option token.
final protected static  StringNESTED_SAME_ERR
     Error text for token nested within block for same token.
final protected static  intNOT_OPTION
     Return code for not an option line.
final protected static  StringOLD_BACKUP_ERR
     Error text for unable to delete old backup file.
final protected static  StringOPTION_LEAD
     Lead text for option token.
final protected static  StringRENAME_ERR
     Error text for unable to rename original file.
final protected static  StringSTAMP_ERR
     Error text for unable to change file modify timestamp.
final protected static  StringTEMP_DELETE_ERR
     Error text for unable to delete temporary file.
final protected static  StringTEMP_RENAME_ERR
     Error text for unable to rename temp file.
final protected static  StringUNBALANCED_ERR
     Error text for block end token not matching block start token.
final protected static  StringUNCLOSED_ERR
     Error text for end of file with open block.
final protected static  StringUNKNOWN_OPTION_ERR
     Error text for unknown option token type.
protected  Filem_backupDir
     Backup root path (null if not backing up).
protected  Hashtablem_disabledTokens
     Map for disabled tokens (values same as keys).
protected  Hashtablem_enabledTokens
     Map for enabled tokens (values same as keys).
protected  booleanm_keepStamp
     Preserve timestamp on modified files flag.
protected  booleanm_listModified
     List modified files flag.
protected  booleanm_listProcessed
     List all files processed flag.
protected  booleanm_listSummary
     List file summary by path flag.
protected  booleanm_markBackup
     Mark backup file with tilde flag.
protected  intm_matchedCount
     Number of files matched.
protected  intm_modifiedCount
     Number of files modified.

Constructor Summary
protected  JEnable(boolean keep, boolean mark, boolean mods, boolean quiet, boolean verbose, File backup, Hashtable enabled, Hashtable disabled)
     Constructor.

Method Summary
protected  intcheckOptionLine(int lnum, String line)
     Check if line is an option.
protected  booleanisNameMatch(String name, String pattern)
     Checks if file name matches a pattern.
protected  booleanisPathMatch(String name, String pattern)
     Checks if file or directory name directly matches a pattern.
protected static  booleanisTokenBodyChar(char chr)
     Checks for valid body character of token.
protected static  booleanisTokenLeadChar(char chr)
     Checks for valid first character of token.
public static  voidmain(String[] argv)
     Test driver, just reads the input parameters and executes the source checks.
protected  voidmatchPathSegment(File base, String path)
     Process files matching path segment.
protected static  voidparseTokenList(String list, Vector tokens)
     Parse comma-separated token list.
protected  booleanprocessFile(File file)
     Processes source options for a file.
protected  voidprocessPath(String path)
     Process all files matching path and print summary.
protected  booleanprocessStream(BufferedReader in, String lead, BufferedWriter out)
     Processes source options for a text stream.
protected  voidthrowError(int lnum, String line, String msg)
     Convenience method for generating an error report exception.

Field Detail
BACKUP_DIR_ERR
final protected static String BACKUP_DIR_ERR(Code)
Error text for unable to rename file to backup directory.



BACKUP_FILE_ERR
final protected static String BACKUP_FILE_ERR(Code)
Error text for unable to rename file within directory.



BADELSE_ERR
final protected static String BADELSE_ERR(Code)
Error text for block else token not matching block start token.



BLOCK_COMMENT_OPTION
final protected static int BLOCK_COMMENT_OPTION(Code)
Return code for block comment option line.



BLOCK_ELSE_OPTION
final protected static int BLOCK_ELSE_OPTION(Code)
Return code for block else option line.



BLOCK_END_OPTION
final protected static int BLOCK_END_OPTION(Code)
Return code for block end option line.



BLOCK_START_OPTION
final protected static int BLOCK_START_OPTION(Code)
Return code for block start option line.



COPY_BUFFER_SIZE
final protected static int COPY_BUFFER_SIZE(Code)
Size of buffer used to copy file.



DELETE_ERR
final protected static String DELETE_ERR(Code)
Error text for unable to delete original file.



DUAL_USE_ERR
final protected static String DUAL_USE_ERR(Code)
Error text for token in both sets.



EXTENSION_ERR
final protected static String EXTENSION_ERR(Code)
Error text for file option line with unknown file extension.



FILE_OPTION
final protected static int FILE_OPTION(Code)
Return code for file option line.



FILE_OPTION_ERR
final protected static String FILE_OPTION_ERR(Code)
Error text for file option not on first line.



INDETERM_ERR
final protected static String INDETERM_ERR(Code)
Error text for indeterminant token nested in enabled block.



LEAD_LENGTH
final protected static int LEAD_LENGTH(Code)
Length of lead text for option token.



NESTED_SAME_ERR
final protected static String NESTED_SAME_ERR(Code)
Error text for token nested within block for same token.



NOT_OPTION
final protected static int NOT_OPTION(Code)
Return code for not an option line.



OLD_BACKUP_ERR
final protected static String OLD_BACKUP_ERR(Code)
Error text for unable to delete old backup file.



OPTION_LEAD
final protected static String OPTION_LEAD(Code)
Lead text for option token.



RENAME_ERR
final protected static String RENAME_ERR(Code)
Error text for unable to rename original file.



STAMP_ERR
final protected static String STAMP_ERR(Code)
Error text for unable to change file modify timestamp.



TEMP_DELETE_ERR
final protected static String TEMP_DELETE_ERR(Code)
Error text for unable to delete temporary file.



TEMP_RENAME_ERR
final protected static String TEMP_RENAME_ERR(Code)
Error text for unable to rename temp file.



UNBALANCED_ERR
final protected static String UNBALANCED_ERR(Code)
Error text for block end token not matching block start token.



UNCLOSED_ERR
final protected static String UNCLOSED_ERR(Code)
Error text for end of file with open block.



UNKNOWN_OPTION_ERR
final protected static String UNKNOWN_OPTION_ERR(Code)
Error text for unknown option token type.



m_backupDir
protected File m_backupDir(Code)
Backup root path (null if not backing up).



m_disabledTokens
protected Hashtable m_disabledTokens(Code)
Map for disabled tokens (values same as keys).



m_enabledTokens
protected Hashtable m_enabledTokens(Code)
Map for enabled tokens (values same as keys).



m_keepStamp
protected boolean m_keepStamp(Code)
Preserve timestamp on modified files flag.



m_listModified
protected boolean m_listModified(Code)
List modified files flag.



m_listProcessed
protected boolean m_listProcessed(Code)
List all files processed flag.



m_listSummary
protected boolean m_listSummary(Code)
List file summary by path flag.



m_markBackup
protected boolean m_markBackup(Code)
Mark backup file with tilde flag.



m_matchedCount
protected int m_matchedCount(Code)
Number of files matched.



m_modifiedCount
protected int m_modifiedCount(Code)
Number of files modified.




Constructor Detail
JEnable
protected JEnable(boolean keep, boolean mark, boolean mods, boolean quiet, boolean verbose, File backup, Hashtable enabled, Hashtable disabled)(Code)
Constructor.
Parameters:
  keep - preserve timestamp on modified files flag
Parameters:
  mark - mark backup files with tilde flag
Parameters:
  mods - list modified files flag
Parameters:
  quiet - do not list file summaries by path flag
Parameters:
  verbose - list all files processed flag
Parameters:
  backup - root back for backup directory tree (null ifno backups)
Parameters:
  enabled - map of enabled tokens
Parameters:
  disabled - map of disabled tokens




Method Detail
checkOptionLine
protected int checkOptionLine(int lnum, String line) throws IOException(Code)
Check if line is an option. Returns a code for the option line type (or "not an option line"), with the actual token from the line stored in the instance variable. Ugly technique, but the only easy way to return multiple results without using another class.
Parameters:
  lnum - line number within file (used for error reporting)
Parameters:
  line - source line to check for option return code for option line type
throws:
  IOException - on option line error



isNameMatch
protected boolean isNameMatch(String name, String pattern)(Code)
Checks if file name matches a pattern. This works a little differently from the general path matching in that if the pattern does not include an extension both ".java" and ".javx" file extensions are matched. If the pattern includes an extension ending in '*' it is blocked from matching with a tilde final character in the file name as a special case.
Parameters:
  name - file or directory name
Parameters:
  pattern - match pattern true if any file modified, false if not



isPathMatch
protected boolean isPathMatch(String name, String pattern)(Code)
Checks if file or directory name directly matches a pattern. This method accepts one or more '*' wildcard characters in the pattern, calling itself recursively in order to handle multiple wildcards.
Parameters:
  name - file or directory name
Parameters:
  pattern - match pattern true if any pattern matched, falseif not



isTokenBodyChar
protected static boolean isTokenBodyChar(char chr)(Code)
Checks for valid body character of token. All body characters must be an alpha, digits, or underscore.
Parameters:
  chr - character to be validated true if valid body character, falseif not



isTokenLeadChar
protected static boolean isTokenLeadChar(char chr)(Code)
Checks for valid first character of token. The first character must be an alpha or underscore.
Parameters:
  chr - character to be validated true if valid first character, falseif not



main
public static void main(String[] argv)(Code)
Test driver, just reads the input parameters and executes the source checks.
Parameters:
  argv - command line arguments



matchPathSegment
protected void matchPathSegment(File base, String path)(Code)
Process files matching path segment. This method matches a single step (directory specification) in a path for each call, calling itself recursively to match the complete path.
Parameters:
  base - base directory for path match
Parameters:
  path - file path remaining to be processed



parseTokenList
protected static void parseTokenList(String list, Vector tokens)(Code)
Parse comma-separated token list. Parses and validates the tokens, adding them to the supplied list. errors are signalled by throwing IllegalArgumentException.
Parameters:
  list - comma-separated token list to be parsed
Parameters:
  tokens - list of tokens to add to
throws:
  IllegalArgumentException - on error in supplied list



processFile
protected boolean processFile(File file)(Code)
Processes source options for a file. Starts by checking the first line of the file for a file option and processing that. If, after processing the file option, the file has a ".java" extension, it is processed for other option lines.

This saves the output to a temporary file, then if processing is completed successfully first renames or moves the original file (if backup has been requested), or deletes it (if backup not requested), and then renames the temporary file to the original file name.

Processing errors are printed to System.err, and any results are discarded without being saved.
Parameters:
  file - source file to be processed true if source modified, false if not




processPath
protected void processPath(String path)(Code)
Process all files matching path and print summary. The file path format is similar to Ant, supporting arbitrary directory recursion using '**' separators between '/' separators. Single '*'s may be used within names for wildcarding, but aside from the special case of the directory recursion matcher only one '*' may be used per name.

If an extension is not specified for the final name in the path both ".java" and ".javx" extensions are checked, but after checking for file option lines (which may change the file extension) only ".java" extensions are processed for other source options.
Parameters:
  path - file path to be processed




processStream
protected boolean processStream(BufferedReader in, String lead, BufferedWriter out) throws IOException(Code)
Processes source options for a text stream. If an error occurs in processing, this generates an IOException with the error information (including input line number).
Parameters:
  in - input reader for source data
Parameters:
  lead - first line of file (previously read for checking file enableor disable)
Parameters:
  out - output writer for modified source data true if source modified, false if not



throwError
protected void throwError(int lnum, String line, String msg) throws IOException(Code)
Convenience method for generating an error report exception.
Parameters:
  lnum - line number within file
Parameters:
  line - source line to check for option
Parameters:
  msg - error message text
throws:
  IOException - wrapping the error information



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.