|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.frame4j.util.App
de.frame4j.FuR
@MinDoc(copyright="Copyright 2000 - 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="find and replace multiple texts in multiple files")
public class FuR
Find texts in files and replace them.
to do: to be translated — apologises for now.
This application visits text files in a start directory and optionally
(option -r) also recursively in subdirectories. All file and
directory criteria available for Frame4J applications may be used.
In every file visited all occurrences of old text patterns are searched
for and replaced by a new or substitute pattern. The old pattern may be
specified as single text (properties "old"), in the sense
of:
replace every occurrence of "<br>" (old) by
"<br \>" (new).
On the other hand every text pattern to be replaced can be specified
as bracketed by two sequences (old and oldEnd) with arbitrary content in
between, in the sense of:
replace everything between
"<!--" (old) abd "-->" (oldEnd) by
nothing "" (new).
The regular expression for the example would be
""<!--".*"-->"".
One single replacement task (for every specified file)
oldText, [oldEnd,] newText
can be specified by start parameters (command line / script). The
application can also handle up to 150 replacement orders specified in
an extra .properties file. These are worked through per file content
sequentially.
The properties
old, [end,] new|newFile [ignoreCase] [ignoreWS] [keepBraces]
are the given in the form
old0, [end0,] new0 to (max.) old150, [end150,] new150
governed by Prop's syntax for indexed properties (new150 and
new[150] would both be recognised, e.g.).
The meaning hereby is
keepFileDate = true) the
modification date of a modified file will be set to the maximum
of it's own old file date and that of all used replacement files
for which that property is true. (In other words: it's possible
if a newer file is inserted into an older one, to set the
newer include file's date.)TextHelper.fUr(CharSequence, ..) used, of course, in this application's
FileVisitors.java FuR de.a_weinert de.a_weinert -i .\+.java -rjava FuR "<br>" "<br \>" -i -r .\+.htmljava FuR api\ api/ -i
-v jdk1.3\docs\aweinertbib\+.html api\
by api/ so repairing a fault done by quite
many javaDoc.exe versions while doing relative linking.
App,
AppBase,
Prop| Field Summary | |
|---|---|
String |
directory
Start directory. |
protected String[] |
fileNs
Replacement text / substitute file name; (multiple). |
protected boolean[] |
ignCase
Ignore case for search text matching (multiple). |
String |
ignFilesWith
Exclude text. |
String |
ignFilesWith2
Exclude text (number 2). |
boolean |
ignoreCase
Ignore case for search text matching. |
boolean |
ignoreWS
Ignore white spaces for search text matching. |
protected boolean[] |
ignWS
Ignore white spaces search text matching (multiple). |
boolean |
incFileDate
Add (only) 1/2 s the last file in case of replacements. |
protected boolean[] |
keepBrace
Keep the braces, when replacing text (multiple). |
boolean |
keepBraces
Keep the braces, when replacing text. |
boolean |
keepFileDate
Keep the file date even after replacements. |
protected long[] |
newModif
Modification date for the substitute (multiple). |
protected String[] |
newT
Replacement text; substitute (multiple). |
String |
newText
Replacement text; substitute. |
protected String[] |
oldE
Search text, end (multiple). |
String |
oldEnd
Search text (end). |
protected String[] |
oldT
Search text (multiple). |
String |
oldText
Search text (begin). |
boolean |
recursion
Recursively visit subdirectories. |
String |
types
File types to regard. |
boolean |
useNewModif
Use the modification time of the replacement text or substitute. |
| 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 |
| Method Summary | |
|---|---|
int |
doIt()
Working method of FuR. |
static void |
main(String[] args)
Start method of FuR . |
boolean |
parsePartial()
FuR requests only partial start parameter parsing by Prop. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public boolean recursion
public String oldText
oldEndpublic String oldEnd
oldEnd not null or empty, then oldText and
oldEnd form braces to find a spot for replacement. An
exemplary use would be two distinct HTML comments to mark a spot for
inserting or replacing a new text (block).
public String newText
public boolean useNewModif
keepFileDate is true)keepFileDate is
false.
public boolean keepFileDate
incFileDatepublic boolean incFileDate
keepFileDate, but with a tiny increase of the last
file modification date.Update might otherwise refrain from from necessary
updates.
public boolean ignoreCase
public boolean ignoreWS
protected String[] oldT
oldTextprotected String[] oldE
oldEndprotected boolean[] ignCase
ignoreCaseprotected boolean[] ignWS
ignoreWSprotected String[] newT
protected String[] fileNs
protected long[] newModif
public boolean keepBraces
protected boolean[] keepBrace
public String ignFilesWith
ignFilesWith not null or empty, files containing this text
as is will not be touched (even if matching the visitor's file and
directory criteria).FuR that's the
procedure to inhibit multiple works on the same file.
public String ignFilesWith2
ignFilesWith. (Both excluding conditions are
ORed.)
public String directory
public String types
| Method Detail |
|---|
public boolean parsePartial()
parsePartial in class Apppublic static void main(String[] args)
args - Command line start parameterspublic int doIt()
doIt in class AppProp,
App.go(String[], boolean),
App.go(String[], String, boolean, CharSequence),
App.mainThread
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||