de.frame4j
Class MakeIndex

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

@MinDoc(copyright="Copyright 1998 - 2008, 2009  A. Weinert",
        author="Albrecht Weinert",
        version="V.23",
        lastModified="15.02.2010",
        lastModifiedBy="A. Weinert",
        usage="start as Java application (-? for help)",
        purpose="generate or update HTML file tables")
public class MakeIndex
extends App

Generate or update HTML file tables.

This application generates or updates file tables in HTML format listing all or selected files (see FileCriteria of one or more directories.

The content of every table line will be the file name as (clickable) link, size, modification date, and prose remark and description. Image files will get additionally the size in pixel and a picture (minified if required)in the last content column (instead of hand written prose). The pictures may be made as clickable link too.
If the picture has to be minified there is a choice of displaying the original file rendered smaller conserving ratio or using a thumb mail file generated by this application.

Those index tables generated or updated will usually be embedded in a HTML or XML page to be made or updated accordingly. Such page may contain up to twelve file tables, equally layouted and headlined. By updating the following action will be taken

The second point, the updating of existing entries for existing files will even work for files in another directory if adressed relatively to the directory to be indexed (href="../otherdir/file").

As said the (sorting or hand made) order of existing entries will not be spoiled by updating.


Remarks on the text based approach

For the spotting and manipulation certain tables and table lines within a XML or HTML document would call for regular expressions or XML parsing / manipulating; see @link XMLconf}, XMLio). In spite of that this application uses a text approach (well a bit sophisticated, see TextHelper, but nevertheless simpler). This has two effects. An updated HTML page remains 100% unchanged outside the updated / added file table lines. And on the other hand even frumpish HTML pages and tables are processed (and made better at the updated spots) that would fail on regular expressions (of comprehensible complexity) and on all XML parsers.
This aspect was material for the predecessor tool's users. Its importance would fade if with todays tools and support everybody would write or generated only well formed XML / (X)HTML. But, alas .. that is not so (see the javadoc.exe output and you'll believe).


© Copyright 1998 - 2008   Albrecht Weinert

See Also:
trDescribe(), App, Prop, DataFile, ImageInfo

Field Summary
 boolean cklickImg
          Make thumbnail pictures clickable.
 String dest
          Name of the destination index file.
 String dirThumbnail
          Directory for separately generated miniaturised pictures (thumb nails).
 String dirThumbnailGif
          Directory for separately generated miniaturised pictures (thumb nails).
 String endOfKeep
          Search criterion for re-start of text updates.
 int firstColToKeep
          From this column up keep the texts found.
 int genThumbnail
          Generate a separated miniaturised picture (thumb nail).
 String indDir
          The directory to be indexed.
 boolean loCaseNames
          Generate file names and links in lower case.
 boolean makePage
          Generate a new HTML page (no update).
 boolean makeTable
          Generate a new HTML table (no update).
 int MAX_TABS
          Maximum number of index tables to be updated.
 boolean mixEntries
          Mix (row) texts in case of update.
 String noLCforTypes
          Avoid lower casing names for specified types.
 boolean noNew
          Update the index file without generating new table entries.
 boolean replGifByPNG
          Make png miniaturised pictures (thumb nails) for gif.
static CleverSSS rkTableEnd
          A RK to search for "</table>" ignoring white space and case.
static CleverSSS rkTagAend
          A RK to search for "></a>" case.
static CleverSSS rkTdStart
          A RK to search for "<td" case.
static CleverSSS rkThStart
          A RK to search for "<th " ignoring case.
static CleverSSS rkThStartShort
          A RK to search for "<th" ignoring case.
static CleverSSS rkThStartTag
          A RK to search for "<th>" ignoring case.
static CleverSSS rkTrEnd
          A RK to search for "</tr>" ignoring white space and case.
static CleverSSS rkTrStart
          A RK to search for "<tr" case.
 boolean sdsc
          Put file size and date into the same table column.
 int showHeight
          Maximum height for miniaturised pictures (thumb nails).
 int showWidth
          Maximum width for miniaturised pictures (thumb nails).
 String source
          The source index file's name.
 String tableHeader
          The index table's header (and the search criterion for update).
 String tableStart
          The start table tag for a new index table (if no update).

tableStart is the beginning of an index table, i.e.
 String TH
          The index table's standard header (German default).
 String TH_SHORT
          The index table's short standard header (German default).
 String timeForm
          Format string for last modification time.
 boolean update
          Update the index file instead of generate a new one.
 boolean useDir
          Destination index file specification is relative to the directory to be indexed.
 
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
MakeIndex()
           
 
Method Summary
 int doIt()
          Working method of MakeIndex.
static void main(String[] args)
          Start method of MakeIndex.
protected  String trDescribe(DataFile fi)
          Describe a file (in HTML).
 
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, parsePartial, 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

indDir

public String indDir
The directory to be indexed.


dest

public String dest
Name of the destination index file.


source

public String source
The source index file's name.

In case of update true it will be set to dest.


useDir

public boolean useDir
Destination index file specification is relative to the directory to be indexed.


update

public boolean update
Update the index file instead of generate a new one.

If update is true the index tables found in the input file source will be updated. This will also set App.outMode to overwrite.


noNew

public boolean noNew
Update the index file without generating new table entries.

If noNew is true, the existing table entries for existing files will be updated (size, modification date) as for update true. But new table entries for new files will not be generated (and hence not added at the end of the last table).

noNew true implies update true.

default: false


cklickImg

public boolean cklickImg
Make thumbnail pictures clickable.

If in case of image files the last table column is to contain a picture this will be made a link to this (original if minified) file.

default: true


makePage

public boolean makePage
Generate a new HTML page (no update).

If this property is true, a complete new plain HTML page is made containing one generated table of the files to be indexed. makePage implies makeTable.

Default: false (work an an existing HTML page)


makeTable

public boolean makeTable
Generate a new HTML table (no update).

If this property is true, a complete new plain HTML table the files to be indexed will be made.

Default: false (work an an existing HTML table / page)

See Also:
makePage

sdsc

public boolean sdsc
Put file size and date into the same table column.

Writing modification date and size (which may include width and height in pixel) into the the same table element makes this multi-line. In combination with usually multi-line descriptive (hand written) texts this will be the better layout and be it only for saving one column in favour of the prose.

Default: false (nevertheless)


tableStart

public String tableStart
The start table tag for a new index table (if no update).

tableStart is the beginning of an index table, i.e. the tag <table ...>. It shall make all denotations for lines, borders, spacings and margins / padding. If a number of columns is specified it has to be consistent with tableHeader. A summary (attribute) will be demanded by some checkers.

This property is usually set via the .properties file. If null or empty it will be generated according to tableHeader.


tableHeader

public String tableHeader
The index table's header (and the search criterion for update).

tableHeader is the headline of an index table. It is a sequence of <th>-</th> tags in a lt;tr>-</tr> tag. This headline will also be used as textual search criterion for the start of index tables within a HTML text file to modify or update..

This field will be set by the corresponding .properties file entry. If set to null or empty this way it defaults to either TH_SHORT or TH according to the setting of sdsc.

This property tableHeader determines the number of columns used for a file describing table line (made by trDescribe()).
Allowed are at least three or four if sdsc is true and at least four or five if false. For the smaller number the column on "usage / hints" is omitted.

For the search for existing index tables only the last column headline
(e.g. <th> Content </th></tr>
)
is taken as search pattern. If that should match to many tables in the respective HTML file it is recommended to make the index tables unambiguous by a comment
(e.g. <th> Content </th><!-- MakeIndex --></tr>)

A criterion with an added comment like this will be shortened to
</th><!-- MakeIndex --></tr>
if no table at all would be found.

default: null (hence use one of the standard table headers)


TH

public final String TH
The index table's standard header (German default).

The HTML table header (tr & th tags) look (in the default setting) like this:
The table line has 5 columns:
  1. Name (with link)
  2. Size
  3. Time of last modification
  4. Usage/Hints
  5. Content

Value: <tr><th> Datei </th><th> Größe </th>
    <th> Änderung </th><th> Nutzung/Hinweise </th><th> Inhalt </th>
See Also:
Constant Field Values

TH_SHORT

public final String TH_SHORT
The index table's short standard header (German default).

The main difference to TH is that the size column and the time of last modification column are unified to one.

Value: <tr><th> Datei </th><th> Größe <br />
    Änderung </th><th> Nutzung/<br />Hinweise </th><th> Inhalt </th>
See Also:
Constant Field Values

mixEntries

public boolean mixEntries
Mix (row) texts in case of update.

If exiting index tables are to be updated on an existing entry (line) all text from column firstColToKeep on until the last occurrence of the pattern endOfKeep will be kept untouched as is.

The rationale behind is that there usually are columns that have been edited by hand containing describing text on the file in case. This text, of course, shall be kept even if size and time of modification (in the columns before firstColToKeep and a generated thumbnail plus link (if any; after endOfKeep) may have to be changed.

default: true


firstColToKeep

public int firstColToKeep
From this column up keep the texts found.

If exiting index tables are to be updated (update), on an existing entry (line) all text from column firstColToKeep on (until the last occurrence of endOfKeep) will be kept.

The column count starts at 1 (not 0).

The standard setting is 4 or 3 (at sdsc true). That would mean the columns containing size and time of file modification will be updated and the columns following will be kept.

default: 3 or 4


endOfKeep

public String endOfKeep
Search criterion for re-start of text updates.

If exiting index tables are to be updated (update) and the text stating with column firstColToKeep is to be kept for each indexed file, than this text endOfKeep is the pattern from which on the modification / updating will start again.

The standard setting is "<img": that means an used thumbnail image will be used in the newly generated form. That makes sense as a modified file might have a different look and size.


loCaseNames

public boolean loCaseNames
Generate file names and links in lower case.

If this property is true, all names and links for files will to be made in lower case even if the (true) file name contains upper case characters.

default: false


noLCforTypes

public String noLCforTypes
Avoid lower casing names for specified types.

This property noLCforTypes has no effect if it is null or if loCaseNames is false.

But if loCaseNames is true and noLCforTypes is a not empty list of types, files of that type will get names and links according their original name.

default: .class;.java


timeForm

public String timeForm
Format string for last modification time.

default: "j.m.Y H:i""

See Also:
ConstTime.toString(CharSequence)

showHeight

public int showHeight
Maximum height for miniaturised pictures (thumb nails).

Default: 48


showWidth

public int showWidth
Maximum width for miniaturised pictures (thumb nails).

Default: 99


genThumbnail

public int genThumbnail
Generate a separated miniaturised picture (thumb nail).

If a minified picture is called for that does not yet exist and if the original image file is larger than genThumbnail bytes, that baby picture is generated.

Value 0 means no thumbnail generation.
Other values make sense between 4000 and 100000.

default: 8000


dirThumbnail

public String dirThumbnail
Directory for separately generated miniaturised pictures (thumb nails).

Minified pictures will be generated in a directory that is relative by dirThumbnail to the directory containing the original image file.

This directory will be used for jpg and png.

default: thumb-nails


dirThumbnailGif

public String dirThumbnailGif
Directory for separately generated miniaturised pictures (thumb nails).


Minified pictures for .gif will be generated in a directory that is relative by dirThumbnailGif to the directory containing the original image file.

This directory will be used for gif.

default: thumb-nails


replGifByPNG

public boolean replGifByPNG
Make png miniaturised pictures (thumb nails) for gif.

As some Java imageIO are able to read but not to generate .gif the thumbnails made for gif will be either jpg or png. This property is the choice.

default: false (jpg)


MAX_TABS

public final int MAX_TABS
Maximum number of index tables to be updated.

Value: 12

See Also:
Constant Field Values

rkTableEnd

public static final CleverSSS rkTableEnd
A RK to search for "</table>" ignoring white space and case.


rkTrEnd

public static final CleverSSS rkTrEnd
A RK to search for "</tr>" ignoring white space and case.


rkThStartTag

public static final CleverSSS rkThStartTag
A RK to search for "<th>" ignoring case.


rkThStart

public static final CleverSSS rkThStart
A RK to search for "<th " ignoring case.


rkThStartShort

public static final CleverSSS rkThStartShort
A RK to search for "<th" ignoring case.


rkTrStart

public static final CleverSSS rkTrStart
A RK to search for "<tr" case.


rkTdStart

public static final CleverSSS rkTdStart
A RK to search for "<td" case.


rkTagAend

public static final CleverSSS rkTagAend
A RK to search for "></a>" case.

Constructor Detail

MakeIndex

public MakeIndex()
Method Detail

main

public static void main(String[] args)
Start method of MakeIndex.

Execute: MakeIndex [Options] Directory [Input] output

Parameters:
args - command line parameter

doIt

public int doIt()
Working method of MakeIndex.

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

trDescribe

protected String trDescribe(DataFile fi)
Describe a file (in HTML).

A HTML table line (<tr...<td...</tr>) is made. Number and usage of the columns is determined by the properties tableHeader and sdsc. By default the table line has five columns:
  1. Name with link
  2. Size in bytes and for some image types additionally in pixel. (If it is a directory the full path name uses the two first columns.)
  3. Time of the last modification (If the file is a directory the word Directory is put here.)
  4. Usage/Hints: preset by {filename}} (multiply if extra columns were specified)
  5. Content: empty or preset by a baby picture or maximal showHeight * showWidth pixels


If sdsc is true zhe second and third column are combined in one.

The "4. column" may appear multiply, The number of those columns is determined by the number of <th> tags in the property tableHeader. The number of those (4.) columns may be 0 but not less.

Parameters:
fi - the file to describe
Returns:
the describing HTML table row