de.frame4j
Class Era

java.lang.Object
  extended by de.frame4j.util.App
      extended by de.frame4j.Era
All Implemented Interfaces:
FileVisitor, AttrSettable, TextHelper.MessageComponents, UIInfo, ActionListener, EventListener, DynamicMBean

@MinDoc(copyright="Copyright 1998 - 2004, 2009  A. Weinert",
        author="Albrecht Weinert",
        version="V.64",
        lastModified="15.05.2012",
        lastModifiedBy="A. Weinert",
        usage="start as Java application (-? for help)",
        purpose="delete files and / or directories specified also by complex criteria")
public class Era
extends App
implements FileVisitor

Delete files.

The application Era deletes files and directories.

Multiple files can be specified in the command line or by a list (text) file preferably generated by FS and edited afterwards. The file specifications allow so called wild cards as well as type lists:
    ..\tmp\+.j+     ..\tmp\class;bak;tmp;obj;map

Options stand for

The ample possibilities for file and directory criteria may (best) be set by Properties. See FileService . set(PropMap).

File denominations are (single threaded) processed in the sequence given as parameters or list files specified. Option parameters on the other hand set this Application's modi beforehand independent of their position. (As the most simple example -h might appear anywhere, and the application does nothing but output the online help.)
The only exception are the options -r, -recursion switching on the recursive descend for all the follows, respectively the options -nr or the denomination of a list file (@listFilename) switching off the recursive descend for all the follows. Example:
    java Era -v -r build/+.class -nr A+.bat -y
would delete all .class files in directory build including all of it's subdirectories as well as all files A*.bat only in the actual directory. For all applies no safety question (-y) and verbose report (-v).


  On the list / response file's syntax

One line per file denomination is expected. The first "word" in a line is it. The rest is ignored and surrounding white space is stripped. If file names contain spaces that congeries has to be put in quotes.
Lines starting by // (no regarding white space) will be ignored as comment lines.
Recursively descending to subdirectories will be switched of when starting to process a list / response file for all that follows (up to the next option -r or -recursion). Any file denotation in one line just specifies one file either absolutely or relative to the working directory specified.
This seems (or is) a restriction wit regard to hand crafted list files but it is the only way to process tool generated list files safely without user interaction. (Otherwise by -r -y @toolGeneratedList one would kill files, the list generating tool would not have meant to.)

A file denomination in a line may contain wildcards or type lists (uhu\html;bak or A*.cl*).

File lists generated by the tool FS may be directly used as file lists for this application Era.


Hints:

To this application Era (source) belongs (as an integral part) a .properties file named Era.properties. Those (base) .properties files normally reside in the same directory as the applications's class file, within the deployment .jar.

For denominating files in the command line so called wildcards may be used:
    ..\tmp\+.j+     ..\tmp\class;bak;tmp;obj;map
Like in the example + may be substituted for *. If you use * or ? the parameter has to be put in quotes. Otherwise the expansion mechanism of Linux shells will spoil all. No clear signal for Windows here: this bug has been meticulously ported ton Windows JREs/JDKs.

© Copyright 1998 - 2004   Albrecht Weinert

See Also:
Prop, App, DataFile, FileCriteria, FileService

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.frame4j.io.FileVisitor
FileVisitor.Ask, FileVisitor.AskConsImpl, FileVisitor.AskGrafImpl
 
Field Summary
 boolean askBefore
          Do ask before a delete.
 boolean fDel
          Delete files.
 String omitDirs
          (Sub-) directories not to consider.
 boolean tDel
          Delete directories (also).
 String workDir
          Specification of a (one) base directory for all deletes.
 
Fields inherited from class de.frame4j.util.App
ano, appBase, appIO, appStartTime, args, bgColor, err, fullClassName, help, icon, INIT_ERROR, jmxRemoteNote, JOB_DONE_OK, log, LOG_OUT_ERROR, MAIN_THREAD_EXC, mainThread, myClass, myFrame, name, NO_PARS_ERROR, objectName, out, outMode, packName, prop, retCode, runFlag, shortClassName, title, verbose, verbosity
 
Fields inherited from interface de.frame4j.net.AttrSettable
ILLEGAL_TYPE, ILLEGAL_VALUE, NO_ATTRIBUTE, NO_KNOWN_ATTRIBUTE, NO_VALUE, OK
 
Constructor Summary
Era()
           
 
Method Summary
 int doIt()
          Era's working method.
static void main(String[] args)
          Era's start method.
 boolean parsePartial()
          Era wants only partial parameter parsing by Prop.
 int visit(DataFile aktDatei)
          File visit.
 
Methods inherited from class de.frame4j.util.App
actionPerformed, allowNoPropertiesFile, clientOrder, condHelpLog, connect, errMeld, errMeld, errorExit, errorExit, errorExit, errorText, formMessage, formMessage, getAbout, getAboutText, getActTime, getAppLogger, getAppStartTime, getArgs, getAttribute, getAttributes, getAuthor, getCopyright, getDbLogger, getExecTimeMs, getExecTimeString, getHelp, getHelpText, getIcon, getLanguage, getLogHandler, getMBeanInfo, getMessageComponent, getMessageComponentsLength, getMyFrame, getName, getNameWithVersDate, getOutMode, getProp, getPurpose, getStartTime, getStateString, getTitle, getUsage, getVerbosity, getVerbosityString, getVersDate, getXMLinput, go, go, go, haveIcon, invoke, isDebug, isHelp, isHelpLog, isNormal, isRunFlag, isSilent, isTest, isVerbose, logVerbose, logVerbose, makeDbLogger, makeMenuBar, makeMenuBar, makeStatusTextEnd, makeStatusTextStart, messageFormat, normalExit, performeAction, postDeregister, postRegister, preRegister, queueAction, registerAsMBean, setAboutText, setAttribute, setAttribute, setAttribute, setAttributes, setAuthor, setBgColor, setCodePages, setCopyright, setHelp, setJmxRemoteNote, setLogOut2, setName, setOutMode, setOutMode, setPurpose, setTitle, setUsage, setVerbose, setVerbose, setVerbosity, setVerbosity, setVerbosityString, setVersDate, stop, threeLineEndMsg, toString, twoLineEndMsg, twoLineStartMsg, valueLang, valueLang, wakeMainThread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

omitDirs

public String omitDirs
(Sub-) directories not to consider.

If given according to the syntax rules of FileCriteria.excludeNames) the specified (sub) directories are excluded from visiting.

Default: null


askBefore

public boolean askBefore
Do ask before a delete.

Default: true


workDir

public String workDir
Specification of a (one) base directory for all deletes.

If given all file specifications have to be relative to the directory specified (and descending). All absolute filenames (beginning with \ or by a drive or computer name) as well as parent directories (beginning by ..\) will be rejected as illegal.

Default: null = no anchor / base directory.


fDel

public boolean fDel
Delete files.

Default: true


tDel

public boolean tDel
Delete directories (also).

Default: false

Constructor Detail

Era

public Era()
Method Detail

parsePartial

public boolean parsePartial()
Era wants only partial parameter parsing by Prop.

Overrides:
parsePartial in class App

visit

public int visit(DataFile aktDatei)
File visit.

Specified by:
visit in interface FileVisitor
Parameters:
aktDatei - the file or directory to act upon or to determine a filter / function response about
Returns:
the response; mostly irrelevant under (pure) action / procedural aspects
See Also:
doUpDate()

main

public static void main(String[] args)
Era's start method.

Exit codes: 0, in case of success and   > 0 if not

Parameters:
args - command line parameter

doIt

public int doIt()
Era's working method.

Specified by:
doIt in class App
See Also:
Prop, App.go(String[], boolean), App.go(String[], String, boolean, CharSequence), App.mainThread