140 lines
7.7 KiB
HTML
140 lines
7.7 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Format and FormatProperties classes" />
|
|
<meta name="abstract" content="" />
|
|
<meta name="description" content="" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="rzahhcommtraceformat" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Format and FormatProperties classes</title>
|
|
</head>
|
|
<body id="rzahhcommtraceformat"><a name="rzahhcommtraceformat"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Format and FormatProperties classes</h1>
|
|
<div><p></p>
|
|
<div class="section"><p>The <a href="javadoc/com/ibm/as400/util/commtrace/Format.html">Format class</a> serves as the interface between the calling
|
|
program and the frames of the trace. The <a href="javadoc/com/ibm/as400/util/commtrace/FormatProperties.html">FormatProperties class</a> enables you to set and retrieve
|
|
properties that determine how the Format object behaves when it encounters
|
|
information in the Frames of the trace.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Format class</h4><p>Use the format class to read both the
|
|
raw trace data and the trace data that you have already formatted by using
|
|
the commtrace classes.</p>
|
|
<div class="note"><span class="notetitle">Note:</span> You cannot use the commtrace classes to read
|
|
a communications trace that you formatted by using the Print Communications
|
|
Trace (PRTCMNTRC) control language command.</div>
|
|
<p>Use the Format class
|
|
to parse and format the information in a trace, then send that formatted
|
|
information to a file or a print device. Additionally, you might want to
|
|
create a graphical front end that displays the information in a standalone
|
|
application or within a browser. When you want to select only specific data,
|
|
use the Format class to supply that information to your Java™ program.
|
|
For example you could use the Format class to read IP addresses out of a
|
|
trace and then use that data in your program.</p>
|
|
<p>The Format constructors
|
|
accept arguments that represent unformatted data, such as an IFSFileInputStream
|
|
object, a local file, or the binary trace file. To display a trace that you
|
|
have already formatted, use the default Format constructor, then use Format.openIFSFile()
|
|
or Format.openLclFile() to specify the formatted file that you want to display.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Examples</h4><div class="p">The following examples show how you can
|
|
display a saved trace or format a binary trace. <div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
|
example disclaimer</a> for important legal information.</div>
|
|
</div>
|
|
<p><strong>Example:
|
|
Displaying a saved trace</strong></p>
|
|
<pre> Format fmt = new Format();
|
|
fmt.openLclFile("/path/to/file");
|
|
|
|
// Read the Prolog
|
|
System.out.println(fmt.getRecFromFile());
|
|
// The total number of records in the trace TCP and non-TCP
|
|
System.out.println("Total Records:" + fmt.getIntFromFile());
|
|
String rec;
|
|
// Read in records until we reach the end.
|
|
while((rec = fmt.getRecFromFile())!=null) {
|
|
System.out.println(rec);</pre>
|
|
<p><strong>Example: Formatting a binary
|
|
trace</strong></p>
|
|
<pre> // Create a FormatProperties. By default display everything.
|
|
FormatProperties fmtprop = new FormatProperties();
|
|
|
|
|
|
Format fmt = new Format("/path/to/file");
|
|
// Sets the filtering properties for this format
|
|
fmt.setFilterProperties(fmtprop);
|
|
fmt.setOutFile("/path/to/output/file");
|
|
// Format the prolog
|
|
fmt.formatProlog();
|
|
// Format the trace and send data to the specified file
|
|
fmt.toLclBinFile();</pre>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Running Format as a standalone utility</h4><p>You can also
|
|
run the Format class as a standalone utility program. For more information,
|
|
see the following topic:</p>
|
|
<blockquote><a href="rzahhcommformatutil.htm#rzahhcommformatutil">Running
|
|
Format as a standalone program</a></blockquote>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">FormatProperties class</h4><p>Use the FormatProperties
|
|
class to specify and retrieve the properties for your Format object. In other
|
|
words, when you use the Format class to send information to a file, use the
|
|
FormatProperties class to filter the information that you want to send.</p>
|
|
<p>These
|
|
properties specify how you want your Format object to handle the information
|
|
that it encounters in the Frames of the communications trace. The default
|
|
behavior is for the Format object to ignore properties for which you have
|
|
not given a specific value.</p>
|
|
<p>The FormatProperties class provides constants
|
|
that you use to set properties. Setting properties enables the Format object
|
|
to verify which filters you want to use. For example, the following code
|
|
sets a Format object to display a progess dialog and not display broadcast
|
|
frames:</p>
|
|
<pre> FormatProperties prop = new FormatProperties();
|
|
prop.setProgress(FormatProperties.TRUE);
|
|
prop.setBroadcast(FormatProperties.NO);</pre>
|
|
<p>Most of the properties
|
|
are available to your Format object as filters that you set to explicitly
|
|
include specific data. Once you set the filters, the Format object displays
|
|
only data that matches those filters. For example, the following code set
|
|
a filter to display frames that occurred between a particular start and end
|
|
time: </p>
|
|
<pre> FormatProperties prop = new FormatProperties();
|
|
// Set the filter to start and end times of 22 July, 2002,
|
|
// 2:30 p.m. and 2:45 p.m. GMT.
|
|
// The time is expressed as a Unix<sup>(TM)</sup> timestamp, which is
|
|
// based on the standard epoch of 01/01/1970 at 00:00:00 GMT.
|
|
prop.setStartTime("1027348200");
|
|
prop.setEndTime("1027349100");</pre>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Example</h4><p>The following example shows how you can
|
|
use many of the commtrace classes, including the Format and FormatProperties
|
|
classes, to display trace information to your monitor:</p>
|
|
<blockquote><a href="rzahhcommtraceexample.htm#rzahhcommtraceexample">Example: Using the commtrace classes</a></blockquote>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Javadoc reference documentation</h4><p>For more information
|
|
about the Format and FormatProperties classes, see the following Javadoc
|
|
reference documentation:</p>
|
|
<blockquote> <p><a href="javadoc/com/ibm/as400/util/commtrace/Format.html">Format</a></p>
|
|
<p><a href="javadoc/com/ibm/as400/util/commtrace/FormatProperties.html">FormatProperties</a></p>
|
|
</blockquote>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |