Appendix A - Springer978-1-4471-0629-6/1.pdf · The characters listed in table A.2 cannot be used...
Transcript of Appendix A - Springer978-1-4471-0629-6/1.pdf · The characters listed in table A.2 cannot be used...
Appendix A
lava Packages
Introduction
This appendix gives some details of Java that you may need to know, such as a complete list of reserved words and characters, and details of all the classes in the Java packages.
Reserved words
Reserved words in Java have a special meaning and cannot be used for any other purpose.
TableA.l Reserved words.
abstract continue future long rest transient boolean default generic native return try break do goto new short var byte double if null static void case else implements operator sure volatile cast extends imports outer switch while catch final inner package synchronized char finally instanceof private this class float int protected throw const for interface public throws
Reserved characters
The characters listed in table A.2 cannot be used in a variable name, since they have special meanings in Java.
162
Java Packages
Table A.2 Reserved characters.
+
Java operators
% }
II &
1 *
?
This is a complete list of all the operators in Java.
Table A.3 The Java operators.
0 era tor Meanin 0 erator + Addition. «
Subtraction. » * Multiplication. »> I Division. % Modulus. = < Less than. ++ > Greater than.
>= Greater than or equal to. += <= Less than or equal to. -= -- Equal. *= 1= Not equal. 1= && Logical AND. %=
II Logical OR. &= 1 Logical NOT. 1= & AND. «= 1 OR. »= 1\ XOR. »>=
Java data types
Integer:
• byte 8 bits. • short 16 bits. • int 32 bits. • long 64 bits.
Floating point:
• float 32 bits. • double 64 bits.
163
/ > < =
Meanin Left Shift. Right Shift. Zero fill right shift. Complement. Assignment. Increment. Decrement. Add and assign. Minus and assign. Multiply and assign. Divide and assign. Modulus and assign. AND and assign. OR and assign. Left shift and assign. Right shift and assign. Zero fill, right shift and assi n.
164 Essential Java Fast
Character:
• char 16 bit unsigned integer assigned the Unicode character number.
Boolean:
• boolean true or false.
The Java class library
This section lists the classes and exceptions in the Java class library which is divided into packages.
The java.awt package
This is a complete list of the classes in the java.awt package.
Table A.4 The java.awt package.
Class BorderLayout Button Canvas CardLayout
Checkbox CheckboxG roup
CheckboxMenultem
Choice
Color Component Container Dialog
Dimension Event
FileDialog
FlowLayout
Description A layout manager for organising components. A labelled button component. A Canvas component for drawing. A layout manager for a container that contains several 'cards'. Only one card is visible at a time, allowing you to flip through the cards. A Checkbox component, that has either a true of false state. A group of checkboxes. Only one checkbox, at most, in the group may be set to true, the rest are false. This class produces a checkbox that represents a choice in a menu. A pop-up menu of choices. The current choice is displayed as the title of the menu. A class to encapsulate ROB Colours. A generic Abstract Window Toolkit component. A component that can contain other A WT components. A window that takes input from the user. The default layout for a dialog is BorderLayout A class to encapsulate a width and a height. Event is a platform-independent class that represents events from the user or the system. The FileDialog class displays a file selection dialog and allows the user to make a selection. A layout manager that arranges buttons left to right in a panel.
Java Packages
Font FontMetrics Frame Graphics
GridBagConstraints
G ridBag Layout
GridLayout Image Insets
Label List MediaTracker
Menu
MenuBar M enuComponent Menultem Panel Point Polygon Rectangle
Scrollbar TextArea TextComponent
TextField
Toolkit
Window
A class that produces a representations of fonts. A class for holding information font metrics. A top-level window with a title.
165
Graphics is the abstract base class for producing shapes and objects. GridBagConstraints specifies constraints for components set out using the GridBagLayout class. GridBagLayout is a flexible layout organiser that aligns components vertically and horizontally, without requiring that the components be the same size. Each component is described by a GridBagConstraints instance. A layout manager for a container that sets out grids. The image class is an abstract representation of a bit map. The distance of the container from the inside edges of the window. A component that displays a single line of read-only text. A scrolling list of text items. A utility class to track the status of a number of media objects, such as video and audio. A Menu contains menu items and is a component of a menu bar. A menu container. The super class of all menu related components. A single item in a menu. A Panel is a generic container component. x, y co-ordinates. A list of x and y co-ordinates. A Rectangle defined by the x, y of the top left corner, the width and the height. A Scrollbar component. A scroll able multi-line area for displaying or editing text. A TextComponent is a superclass of all component that allows the editing of some text. A TextField component allows the editing of only one line of text. It is used for binding the abstract A WT classes to a particular implementation. A top-level window with no borders and no menu bar. It is the superclass of the Frame and Dialog classes.
166 Essential Java Fast
Exception index for java.awt
Table A.S Exception index/or java.awt.
Exception Description A WTException Indicates that an A WT exception has occurred.
The java.awt.image package
This is a complete list of the classes in the java.awt.image package.
Table A.6 The java.awt package.
Class ColorModel
CroplmageFilter
DirectColorModel
FilteredlmageSource
ImageFilter
IndexColorModel
MemorylmageSource
PixelGrabber
RGBFiterlmage
Description A class that encapsulates the methods for translating from pixel values to alpha and ROB colour components for an image. A filter class which is used for cropping images. This class extends the Image Filter Class to extract a rectangular region of an image. A ColorModel class that manages a translation from pixel values to alpha and ROB colour components for pixels. An implementation of the ImageProducer interface which takes an existing image and a filter object and produces a filtered version of the original image. This class implements a filter that takes data from an ImageProducer, modifies it and passes it to an Image Consumer. This class specifies a translation from pixel values to alpha, red, green, and blue colour components for pixels which represent indices into a fixed colour map. This class is an implementation of the ImageProducer interface which uses an array to build up an image. The PixelGrabber class implements an Image Consumer which can be attached to an Image or ImageProducer object to retrieve a subset of the pixels in that image. An abstract class for creating an ImageFilter which modifies the pixels of an ROB image.
Exception index for java.awt.image
There are no exceptions for this class.
Java PackaKes 167
The java.awt.peer package
This is a complete list of the interfaces in the java.awt.peer package. Every member of this package has a corresponding class in the java.awt. package.
The names are different in that peer is added to the class name. These interfaces provide a platform independent implementation of the platform specific java.awt classes.
Since the behaviour of these classes is very similar to the class from which they inherit, they are listed below, but not described.
Table A. 7 The java.awt.peer package.
Class Index Class index Class Index ButtonPeer DialogPeer MenultemPeer CanvasPeer FileDialogPeer MenuPeer CheckboxMenultemPeer FramePeer PanelPeer CheckboxPeer LabelPer ScrollbarPeer ChoicePeer ListPeer TextAreaPeer ComponentPeer MenuBarPeer TextComponentPeer ContainerPeer MenuComponentPeer TextFieldPeer
WindowPeer
Exception index for java.awtpeer
There are no exceptions for this class.
The java.io package
This is a complete list of the classes in the java.io package.
Table A.S The java. io package.
Class Index BujferedlnputStream
BujferedOutputStream
Description This stream allows you read in characters from a stream without causing a read to a device such as a disk every time. The data is read into a buffer, so that subsequent reads are carried out faster, as the buffer rather than the disk has to be referenced. This is the converse of the BujferedlnputStream. This stream allows you to write characters to a stream without causing a write to a physical device every time. The data is first written into a buffer. Data is written to the actual stream either when the buffer is full. or when the stream is flushed.
168
ByteArraylnputStream
ByteArrayOutputStream
DatalnputStream
DataOutputStream
File
FileJnputStream
FileOutputStream
FilterlnputStream
FilterOutputStream
InputStream
LineNumberlnputStream OutputStream
PipedlnputStream
PipedOutputStream PrintStream
PushbacklnputStream RandomAccessFile
SequencelnputStream
Essential Java Fast
This class implements an input stream from a byte array. This class implements a buffer that can be used as an output stream. The buffer grows when data is written to the stream. An input stream that lets you read primitive Java data types such as integers from a stream. This class lets you write primitive Java data types to a stream. This class represents a file name of the host file system. If a file name or path is used it is assumed that the host's file name conventions are used. An input stream from a file constructed from a file descriptor or a file name. FileOutputStream, can be constructed from a file descriptor or a file name. An abstract class representing a filtered input stream of bytes. An abstract class representing a filtered output stream of bytes. An abstract class representing an input stream of bytes. All input streams are based on this class. An input stream that keeps track of line numbers. Abstract class representing an output stream of bytes. All output streams are based on this class. A thread reading from a PipedlnputStream receives data from a thread writing to the PipedOutputStream it is connected to. The partner of PipedlnputStream. This class implements an output stream that has additional methods for printing, such as flushing every time a new line character is written. The top 8 bits of 16 bit characters are ignored. An input stream that has a 1 byte push back buffer. Random access files can be constructed from file descriptors, file names, or file objects. This class has methods which allow specified modes of access of read-only or read-write to files. Converts a sequence of input streams into an input stream.
Java Packages
StreamTokenizer StringBu[ferlnputStream
A class to turn an input stream into a stream of tokens. An input stream, from a String buffer.
169
Exception index for java.io
Table A.9 Exception indexfor java.io.
Exception EOFException
FileNotF oundException JOException I nte rruptedl 0 Exception UTFDataF ormatException
The java. lang package
Description Signals that and EOF has been reached unexpectedly during input. Signals that a file was not found. Signals that an I/O exception has occurred. Signals that an I/O operation has been interrupted. Signals that a malformed UTF-8 string has been read in a data input stream.
This is a complete list of the classes in the java.lang package.
Table A.IO The java. lang package.
Class Index Boolean
Character
Class
ClassLoader
Double
Float
Integer Long
Math Number
Description The Boolean class provides an object wrapper for Boolean data values. Since booleans are not objects in Java, they need to be wrapped in a boolean instance. The Character class provides an object wrapper for character data values. Class objects contain runtime representations of classes. Every object in the system is an instance of some class. ClassLoader is an abstract class that can be used to define a policy for loading Java classes into the runtime environment. The Double class provides an object wrapper for double length data values. The Float class provides an object wrapper for floating point data values. The Integer class is a wrapper for integer values. The Long class provides an object wrapper for long data values. The standard Math library for the methods in this class. Number is an abstract superclass for number classes: Integer, Long, Float and Double.
170
Object
Process
Runtime SecurityManager
String String Buffer
System
Thread ThreadGroup Throwable
Essential Java Fast
The root of the class hierarchy. Every class in the system has Object as its parent. This class provides abstract behaviour for spawned processes. This class allows access to the Java run time. An abstract class that can be subclassed to implement a security policy. A general class of objects to represent character strings. This class is a buffer for characters that can automatically grow on demand. This class provides a system-independent interface to system functionality such as the standard input and output streams. This class provides a way of managing threads. A group of threads and thread groups. An object of this class indicates that an exceptional condition has occurred.
Exception index for java. lang
Table A.ll Exception index/or java. lang.
Exception ArithmeticException
ArraylndexOutOfBoundsException
ArrayStoreException
ClassCastException ClassNotFoundException ClimeNotSupportedException
Exception
IllegalAccessException
IllegalArgumentException
Description Indicates that an exceptional arithmetic condition has occurred, for example, dividing by zero. Indicates that an invalid array index has been used. An attempt has been made to store the wrong type of object to an array. Indicates that an invalid cast has occurred. Indicates that a class could not be found. Indicates that an attempt has been made to clone an object that does not want to be cloned. Exception are a form of throwable objects that normal programs may wish to try and catch. Indicates that a particular method could not be found. Indicates that an illegal argument exception has occurred.
Java Packages
IllegalMonitorStateException
IllegalThreadStateException
IndexOutOfBoundsException
InstantiationException
InterruptedException
NegativeArraySizeException
NoSuchMethodException
NullPointerException N umberF ormatException
RuntimeException
SecurityException
171
Indicates that a monitor operation has been attempted when the monitor is in an invalid state. An exception indicating that a thread is not in a legal state for the requested operation. Indicates that an index of some sort is out of bounds. Indicates that an attempt has been made to instantiate an abstract class or an interface and has failed. An exception indicated that some thread has interrupted this thread. Indicates that an attempt has been made to create an array with negative size. Indicates that a particular method could not be found. Indicates the illegal use of a null pointer. Indicates that an invalid number format has occurred. An exception that can reasonably occur during the execution of a Java program by the Virtual machine. Indicates that a security exception has occurred.
StringlndexOutOJBoundsException Signals that a string index is out of range.
The java. util package
This is a complete list of the classes in the java. uti! package.
Table A.12 The java. uti! package.
Class Index BitSet Date Dictionary Hashtable Observable Properties
Random Stack StringTokenizer Vector
Description A set of bits. The set automatically grows as required. A wrapper for a date. An abstract class which maps keys to values. Hashtable class. Maps keys to values. This class should be subclassed by observable objects. This class is basically a hashtable for reading and changing persistent properties of a system or class. A Random class generates a stream of random numbers. A Last-In-First-Out(LIFO) stack of objects. Controls simple linear tokenization of a string. An array of objects.
172 Essential Java Fast
Exception index for java.util
Table A.13 Exception index/or java. uti/,
Exception EmptyStackException NoSuchElementException
The java. net package
Description Indicates that the stack is empty. Indicates that a specified element does not exist.
This is a complete list of the classes in the java.net package.
Table A.14 The java. net package.
Class Index ContentHandler
DatagramPacket
DatagramSocket
InetAddress ServerSocket Socket Socketlmpl
URL
URLConnection
URLEncoder U RLStreamHandler
Description A class to read data from a URLConnection and construct an Object. A class that represents a datagram packet containing packet data, packet length, Internet addresses and port. The datagram socket class implements unreliable datagrams. A class that represents Internet addresses. The server Socket class. The client Socket class. This is the Socket implementation class. It is an abstract class that must be subclassed to provide an actual implementation. The URL represents a Uniform Reference Locator, a reference to an object on the World Wide Web. This is a constant object, once it is created, its fields cannot be changed. A class to represent an active connection to an object represented by a URL. It is an abstract class that must be subclassed to implement a connection. Turns strings of text into URL encoded format. Abstract class for URL stream openers. Subclasses of this class know how to create streams for particular protocol types.
Java Packages 173
Exception index for java. net
Table A.IS Exception index/or java. net.
Exception MalformedURLException ProtocolException
SocketException
U nknownH ostException
UnknownServiceException
Description Signals that a malformed URL has occurred. Signals when connect gets an EPROTO. This exception is specifically caught in the class Socket. Signals that an error occurred while attempting to use a socket. Signals that the address of the server specified by a network client could not be resolved. Signals that an unknown service exception has occurred.
The java.applet package
There is only one class in the java.applet package package.
Table A.I6 The java.applet package.
Class Index Description Applet The base applet class
Exception index for java.applet
There are no exceptions for this class.
Appendix B
Class Hierarchies
Introduction This appendix gives an alphabetical listing of the Java classes and interfaces.
Class hierarchy
174
Class Hierarchies
--lclass java.lang.ClassLoader I ;-iinterface java.lang.Cloneable I Helass java.awt.Color I Helass java.awtimage.ColorModel I
--klass java.awt.image.DirectColorModel I Helass java.awt.image.lndexColorModel I
Helass java.lang.Compiler I Helass java.awt.Component (implements java.awt.image.lmageObserver) I
Helass java.awt.Button I Helass java.awt.Canvas I Helass java.awt.Checkbox I ;-ielass java.awt.Choice I
Helass java.awt.Container I Helass java.awt.Panel I
Yelass java.applet.Applet
Helass java.awt. Window I Helass java.awt.Dialog I
4e1ass java.awt.FileDialog I
11)
yelass java.awt.Frame (implements java.awt.MenuContainer) I Helass java.awt.Label I Helass java.awt.List I Helass java.awt.Scrollbar I L-jelassjava.awt.TextComponent I
Helass java.awt. TextArea I ~e1ass java.awt.TextField I
Hinterface java.awt.peer.ComponentPeer I ;-iInterface sun.tools.java.Constants (extends sun.toolsJava.RuntimeConstants) I Hinterface java.awt.peer.ContainerPeer (extends java.awt.peer.ComponentPeer) I
176
I interface java.util.Enumeration
lclass java.awt.Event I
Essential Java Fast
eer.WindowPeer)
.Cloneable)
eer.WindowPeer)
Class Hierarchies 177
.RemoteStack Variable
178
~cIass java.awt.image.MemorylmageSource I I (implements java.awt.image.lmageProducer)
I interface java.awt.peer.MenuBarPeer (extends I ljava.awt.peer.MenuComponentPeer)
--1cIass java.awt.MenuComponent J
Essential Java Fast
HcIass java.awt.MenuBar (implements java.awt.MenuContainer) I ycIass java.awt.Menultem I
--jcIass java.awt.CheckboxMenultem I
----tcIass java.awt.Menu (implements java.awt.MenuContainer) I Yinterface java.awt.peer.MenuComponentPeer I Hinterface java.awt.MenuContainer I ---{interface java.awt.peer.MenultemPeer (extends java.awt.peer.MenuComjJonentPeer) I ----iinterface java.awt.peer.MenuPeer (extends java.awt.peer.MenultemPeer) I HcIass java.lang.Number I
'---1cIass java.lang.Double I --1cIass java.lang.Float I --klass java.lang.lnteger I ~cIass java.lang.Long I
HcIassjava.util.Observable J Hinterface java.util.Observer I HcIass java.io.OutputStream I
HcIass java.io.ByteArrayOutputStream I HcIass java.io.FileOutputStream I HcIass java.io.FilterOutputStream I
HcIass java.io.BufferedOutputStream I HcIass java.io.DataOutputStream (implements java.io.DataOutput) I ~cIass java.io.PrintStream I
YcIass java.io.PipedOutputStream I ----iinterface java.awt.peer.PaneIPeer (extends java.awt.peer.ContainerPeer) I
Class Hierarchies 179
180 Essential Java Fast
Iclass java.lang.AbstractMethodError
!class java.lang.lnstantiationError
-!class java.langNoSuchFieldError
Class Hierarchies
!class java.lang. UnsatisfiedLinkError
. !class java.lang. VerifyError
!class java.lang. ThreadDeath
181
182 Essential Java Fast
eer.ContainerPeer)
Index
Index A Abstract Windowing Toolkit· See java.awt action method· 125 ALIGN property · 19 animation · 78 applet · 173 argc . See command line arguments args . See command line arguments argv . See command line arguments arrays · 28 attributes· 7 available method· 141 A WT . See java.awt
B block statements · 44 BorderLayout class· 110 break statement · 48 BuJferedlnputStream class · 142 BuJferedOutputStream class· 148 Button component· 98 ByteArraylnpUlStream class · 141 ByteArrayOutpUlStream class · 147
c C++· 159 CardLayout class· III
183
case statement· 45 catch clause . 94 Checkbox component· 102 CheckboxGroup component · 102 class· 26 close method · 145 Color class· 63 command line arguments· 21, 160 conditional operator· 45 constructors . 40 continue statement . 48 conventions· 4 co-ordinate system · 56 cos method . 88
D DatalnputStream class · 142 DataOutputStream class· 149 destroy method · 14 Dialog class· 128, 134 disable method · 134 do loop · 46,47 double buffering · 83, 86 draw3DRect method· 59 drawArc method · 62 drawlmage method· 68 drawLine method· 57, 118 drawOval method . 61 drawPolygon method· 60, 61 drawRect method· 57, 58
184
drawRoundRect method· 58 drawString method· 66
E enable method . 134 event driven programming· 97 exceptions . 92
F FilelnputStream class· 138 FileNotFoundException class· 139 FileOutputStream class· 145 fill Arc method . 62 filiOval method . 61, 78 filiPolygon method . 60 filiRect method . 58 fillRoundRect method . 59 FilterinputStream class· 142 FilterOutputStream class· 147 final· 33, 154 finalize method· 42 finally clause . 96 FlowLayout class· 106 flush method . 145 fonts· 66 for loop· 46, 47 Frame class· 128
G getCodeBase method· 67, 86 getDocumentBase method· 67 getFD method· 138,146 getFontList method· 67 get/mage method· 67, 68 getName method· 71 getPriority method· 77 global variables· 27 GridBagLayout class· 108 GridLayout class· 107
H handleEvent method· 124 HEIGHT attributes· 19 HSPACE attribute· 23 HTML·12 HTMLtag
<!... .. > . 16 <lBODY> ·16 <lHTML>·16 <lTITLE> . 16 <APPLET> . 16 <BODY>· 16 <HTML>·16 <TITLE>· 16
Essential Java Fast
Hyper Text Mark-up Language· See HTML
I if statement· 43 inheritance· 8 init method . 13 InputStream class· 137 instance· 6 IOException class· 139
J java.applet . 173 java.awt· 164 java.awt.Graphics·55 java.awt.image· 166 java.awt.peer· 167 java.io· 137, 167 java. lang . 169 java.net· 172 java.util . 171
K
keyDown event· 122 keyUp event· 122
L Labelcomponent· 100 LineNumberlnputStream class . 143 List component· 103 local variables· 27
M mark method . 141 markSupported method· 141 Math.cos . See cos method Math.random method· See random method
Index
Math.sin . See sin method MenuBar class· 131 menus· 130 methods· 7, 29 mixed mode arithmetic· 35 mouseDown event· 117, 119 mouseDown method· I 19 mouseDrag method· 121 mouseUp event· 117, 119 mouse Up method· I 19 multithreading· 71
N NAME parameter· 22 Netscape·2
bugs· 19 new keyword· 27
o object orientation· 5 objects· 5 00 . See object orientation operators . 163
arithmetic· 34 assignment· 37 bitwise· 49 comparison· 39 decrement· 37 increment· 37 logical· 51 precedence· 52
or operator· 50 OutputStream class· 145 overloading methods· 40, 83 overriding methods· 83,84
p
package· 153 packages
creating· 156 importing· 157 why use them? . 155
paint method· 14,55 passwords· 105 PipedlnputStream class . 144 PipedOutputStream class . ISO Polygon Glass· 60
print method· 148 println method· 148 PrintStream class· 148 private· 30, 152 protected· 30, 153 public· 30, 152 PushbacklnputStream class· 144
R random method· 65, 79 read method· 140, 142 reserved characters . 162 reserved words . 162 reset method· 141, 147 Runnable keyword· 76
s scheduling
pre-emptive· 73 scheduling
non-pre-emptive . 73 Scrollbar component . 100 SequencelnputStream class· 144 setBackground method· 65 setColor method· 64 setEchoCharacter method· 105 setFont method· 66 setForeground method· 64 setPriority method . 77 shift operators· 51 show method . 128 sin method . 88 size method· 147 skip method· 140 start method· 14 static method· 30 stop method· 14 StringBufJerlnputStream class· 141 subclass· 8 Sun's Web site· 3 superclass . 8 switch statement· 45 synchronized· 75
T
TextArea component· 105 TextField component· 104
185
186
this· 34, 69 threads
indefinite postponement· 78 priorities· 76
throws clause· 93 try clause . 94
u unread method· 144
v V ALUE parameter· 22 VSPACE attribute· 23
w what computer? . 3 while loop· 46 WIDTH attributes· 19 Window class . 128 World Wide Web· I write method . 146
x xor operator· 50
y
yield method· 77
Essential Java Fast