public class JarInfo
extends java.lang.Object
implements javax.swing.event.ListSelectionListener
Modifier and Type | Field and Description |
---|---|
protected java.net.URL |
manifestURL
URL for accessing the JAR manifest file.
|
protected java.util.Properties |
props
Values from 'jarinfo.properties' file (optional).
|
protected javax.swing.tree.DefaultMutableTreeNode |
rootNode
The tree root node.
|
protected javax.swing.tree.DefaultTreeModel |
treeModel
Model of the unit list.
|
Constructor and Description |
---|
JarInfo()
Constructor method for the manifest display.
|
Modifier and Type | Method and Description |
---|---|
static java.awt.Point |
centerForWindow(java.awt.Window parent,
int width,
int height)
Calculates the position for a dialog window on the screen.
|
static java.util.Vector |
extractAll(java.lang.String string,
java.lang.String regex)
Searches strings for certain patterns and returns all results.
|
boolean |
extractZipArchive(javax.swing.JFrame frame,
java.io.File zipfile,
java.io.File targetdir,
java.util.ResourceBundle bundle)
This extracts a given local ZIP/JAR file directly to a specified directory.
|
static void |
main(java.lang.String[] args)
This can be used for the application be executed standalone.
|
static int |
replace(java.lang.StringBuffer buffer,
java.lang.String pattern,
java.lang.String substitute)
Replaces a specific pattern (sub-string) in a
String . |
static boolean |
saveZIPEntry(java.util.zip.ZipFile archive,
java.util.zip.ZipEntry entry,
java.io.File target)
This method stores the content of a ZIP/JAR entry to a local file.
|
static int |
searchIndex(java.lang.String tosearch,
java.lang.String pattern)
Searches a
String for a specific pattern (sub-string). |
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
Called whenever the value of the selection changes.
|
protected java.net.URL manifestURL
protected java.util.Properties props
protected javax.swing.tree.DefaultMutableTreeNode rootNode
protected javax.swing.tree.DefaultTreeModel treeModel
public static java.awt.Point centerForWindow(java.awt.Window parent, int width, int height)
null
then the point is calculated for the whole desktop automatically.
parent
- The parent window to center the dialog, for desktop if null
width
- The width of the dialog to be centeredheight
- The height of the dialog to be centeredpublic boolean extractZipArchive(javax.swing.JFrame frame, java.io.File zipfile, java.io.File targetdir, java.util.ResourceBundle bundle)
ZipFile
has only constructor with File
parameter).
This method uses the name of the ZIP archive directly. Then the file is extracted.
frame
- The parental windowzipfile
- ZIP/JAR archive to extracttargetdir
- The local destination directorybundle
- The stringstrue
, if saving worked, false
elsepublic static boolean saveZIPEntry(java.util.zip.ZipFile archive, java.util.zip.ZipEntry entry, java.io.File target)
archive
- ZIP/JAR archive to copy file fromentry
- Source to be copiedtarget
- The local file to store the contenttrue
, if saving workedpublic static java.util.Vector extractAll(java.lang.String string, java.lang.String regex)
string
- The string to be searchedregex
- The regular expression pattern to be searched forpublic static int replace(java.lang.StringBuffer buffer, java.lang.String pattern, java.lang.String substitute)
String
.
The return value counts the replacements. If the substitute
parameter is null
the found pattern substrings are simply
removed from string. Since this method uses the fast searching routines
by Knuth-Morris-Pratt the searched String
objects may be
large.
buffer
- The StringBuffer
object for search & replacepattern
- This sub-string is the search targetsubstitute
- The found patterns are substituted by thispublic static int searchIndex(java.lang.String tosearch, java.lang.String pattern)
String
for a specific pattern (sub-string).
It does a pattern matching therefore. Since the brute-force
algorithm is much too slow for our purpose we use the well-known
Knuth-Morris-Pratt algorithm here for very fast searching. This
method is directly derived from the PXINDEX project by the same
author ;-) This method variation does not only give the response
if the pattern was found or not, but returns the next index which
has not been processed after the substring was found. So calling
methods may replace the sub-string and start searching again. If
the pattern was not found within the search string the method
returns -1.
tosearch
- The string to be searchedpattern
- This sub-string is the search targetpublic static void main(java.lang.String[] args)
args
- Array of strings with console argumentspublic void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in interface javax.swing.event.ListSelectionListener
e
- Event object referenceCopyright © 2005-2023 Leisenfels GmbH. All rights reserved.