|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object acm.util.JTFTools
public class JTFTools
This class provides a collection of static utility methods that are used elsewhere in the ACM packages.
Method Summary | |
---|---|
static void |
cancelMail(PrintStream out)
Cancels the mail-sending process without sending the message. |
static boolean |
checkIfLoaded(String className)
Returns true if the specified class is already loaded. |
static void |
copyBytes(InputStream in,
OutputStream out,
long nBytes)
Copies the specified number bytes from the input stream to the output stream. |
static void |
copyFile(File oldFile,
File newFile)
Copies a file from oldFile to newFile . |
static Container |
createEmptyContainer()
Returns an empty lightweight container. |
static Color |
decodeColor(String name)
Decodes a color name. |
static Font |
decodeFont(String str)
Decodes a font in the style of Font.decode . |
static Font |
decodeFont(String str,
Font oldFont)
Decodes a font in the style of Font.decode . |
static boolean |
executeExportAction(Program program,
String command)
Checks to see if the action command corresponds to one of the export actions. |
static void |
exportJar(File jarFile,
File dir,
String imports,
Object transformer)
Exports a jar file consisting of all the .class |
static String |
findFontFamily(String str)
Finds the first font family in the string str that exists in
the current GraphicsEnvironment . |
static Applet |
getApplet()
Returns the current applet. |
static String |
getCommandLine()
Returns the command line that invoked this program, or null
if no command line is available. |
static Frame |
getEnclosingFrame(Component comp)
Returns the frame that encloses the specified component. |
static String[] |
getFontList()
Returns an array of the available font family names. |
static String |
getLocalHostName()
Returns the canonical name of the local host. |
static String |
getMainClass()
Returns the name of the main class. |
static Font |
getStandardFont(Font font)
Returns a font that will approximate the specified font in this environment. |
static boolean |
isAnonymous(Thread t)
Returns true if the supplied thread is an anonymous
one created automatically by the system. |
static boolean |
matchFilenamePattern(String filename,
String pattern)
Determines whether the filename matches the specified pattern. |
static OutputStream |
openBase64OutputStream(PrintStream printStream)
Opens an output stream that allows the client to write data using Base64 encoding, which is the most common encoding for mail attachments. |
static OutputStream |
openHexByteOutputStream(PrintStream printStream)
Opens an output stream that allows the client to write data using pairs of hex characters. |
static PrintStream |
openMailStream(String smtpServer,
String from,
String to)
Opens a mail-sending process using the specified SMTP server, which will send a message from the specified sender to the recipient. |
static void |
padBase64OutputStream(OutputStream out)
Pads the data in the specified output stream without closing it. |
static void |
pause(double milliseconds)
Delays the calling thread for the specified time, which is expressed in milliseconds. |
static void |
registerApplet(Applet applet)
Adds this applet to a table indexed by the current thread. |
static void |
registerApplet(Applet applet,
Thread thread)
Adds this applet to a table indexed by the specified thread. |
static void |
sendStandardHeaders(PrintStream out,
String senderName,
String subject)
Adds the standard "To", "From", "Subject", and "Date" headers to the message. |
static void |
setDebugOptions(String options)
Sets the debugging options in place for this run. |
protected static void |
submitProject(Program program,
JProgressBar progress)
Submits this project as a mail message. |
static void |
terminateAppletThreads(Applet applet)
Terminates all of the threads that are registered as belonging to the specified applet. |
static boolean |
testDebugOption(String option)
Tests to see whether the current program was invoked with a debug
parameter that contains the specified string as a lexical unit in a string
delimited by + signs. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void cancelMail(PrintStream out)
out
- The output stream returned by openMailStream
public static boolean checkIfLoaded(String className)
className
- The name of the class
public static void copyBytes(InputStream in, OutputStream out, long nBytes) throws IOException
in
- The input streamout
- The output streamnBytes
- The number of bytes to copy
IOException
public static void copyFile(File oldFile, File newFile)
oldFile
to newFile
.
oldFile
- A File
object indicating the existing filenewFile
- A File
object indicating the new filepublic static Container createEmptyContainer()
public static Color decodeColor(String name)
Color.decode
except in that it allows named colors and system colors.
name
- The string name of the color
public static Font decodeFont(String str)
Font.decode
.
str
- The string to decode
public static Font decodeFont(String str, Font oldFont)
Font.decode
. The only difference
is that this method takes a font parameter that gives default values for
the different parts of the font. If the family, size, or style is specified
as an asterisk, the corresponding value is taken from the supplied font.
str
- The string to decodeoldFont
- The font whose properties are used as defaults
public static boolean executeExportAction(Program program, String command)
true
;
if not, the method returns false
.
program
- The program to which the action is appliedcommand
- The command name being executed
public static void exportJar(File jarFile, File dir, String imports, Object transformer)
.class files
in the directory, including those embedded inside jar files.
If the transformer
method is not null
, its
transform
method is called to dump the bytes of the class
instead of simply copying them.
- Parameters:
jarFile
- A File
object indicating the destination jar filedir
- The directory being exportedimports
- A semicolon-separated list of .jar
files to include (or null
)transformer
- An object to transform class data (or null
)
public static String findFontFamily(String str)
str
that exists in
the current GraphicsEnvironment
. As in HTML font tags, the
str
consists of a set of font names separated by semicolons.
The findFontFamily
method returns the first family name that
exists in the list of loaded fonts, or null
if there are none.
str
- The list of family names separated by semicolons
null
if nonepublic static Applet getApplet()
init
method of a program,
which is the only context in which it is applied in the JTF tools.
public static String getCommandLine()
null
if no command line is available.
public static Frame getEnclosingFrame(Component comp)
comp
- The component at which to start the search
Frame
objectpublic static String[] getFontList()
public static String getLocalHostName()
null
if unavailablepublic static String getMainClass()
public static Font getStandardFont(Font font)
Serif
, SansSerif
, and Monospaced
.
font
- The font being checked
public static boolean isAnonymous(Thread t)
true
if the supplied thread is an anonymous
one created automatically by the system.
t
- The thread being testedpublic static boolean matchFilenamePattern(String filename, String pattern)
? | Matches any single character |
* | Matches any sequence of characters |
[...] | Matches any of the specified characters |
[^...] | Matches any character except the specified ones |
a-z
.
filename
- The filename being testedpattern
- The pattern including wildcards
true
if the filename matches the patternpublic static OutputStream openBase64OutputStream(PrintStream printStream)
OutputStream
that the client can use to which the client
can send binary data, which is then written in encoded form to the underlying
PrintStream
object. Closing the stream automatically pads the
data to complete a Base64 unit. To pad the data without closing the stream (as
one would need to do for a multi-attachment message, for example), call the
padBase64OutputStream
method.
printStream
- The underlying PrintStream
to which data is written
OutputStream
for writing binary datapublic static OutputStream openHexByteOutputStream(PrintStream printStream)
OutputStream
that
the client can use to which the client can send binary data, which is then
written in encoded form to the underlying PrintStream
object.
printStream
- The underlying PrintStream
to which data is written
OutputStream
for writing binary datapublic static PrintStream openMailStream(String smtpServer, String from, String to)
PrintStream
that the client can use to write the data
in the message, including the headers. Closing the stream sends the message.
To cancel the message without sending it, use the cancelMail
method.
smtpServer
- A string indicating the host name of the SMTP serverfrom
- A string indicating the e-mail address of the senderto
- A string indicating the e-mail address of this recipient
PrintStream
suitable for sending the message datapublic static void padBase64OutputStream(OutputStream out)
PrintStream
.
out
- The output stream returned by openBase64OutputStream
public static void pause(double milliseconds)
Thread.sleep
, this method never throws an
exception.
milliseconds
- The sleep time in millisecondspublic static void registerApplet(Applet applet)
applet
- The applet being registeredpublic static void registerApplet(Applet applet, Thread thread)
applet
- The applet being registeredthread
- The thread used as the keypublic static void sendStandardHeaders(PrintStream out, String senderName, String subject)
out
- The output stream returned by openMailStream
senderName
- The real name of the sendersubject
- The subject linepublic static void setDebugOptions(String options)
+
sign character.
options
- The names of the enabled options separated by plus signsprotected static void submitProject(Program program, JProgressBar progress)
program
- The program being submittedprogress
- An optional progress bar to keep track of the operationpublic static void terminateAppletThreads(Applet applet)
applet
- The applet whose threads are being terminatedpublic static boolean testDebugOption(String option)
debug
parameter that contains the specified string as a lexical unit in a string
delimited by +
signs.
option
- The name of the option
true
if the specified debug option is in effect
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |