public class XmlApplet extends java.applet.Applet implements XmlHandler
This class fills in the basic interface, and provides an I/O infrastructure for simple applications and applets.
XmlParser
,
XmlHandler
,
EventDemo
,
TimerDemo
,
DtdDemo
,
StreamDemo
,
Serialized Formjava.applet.Applet.AccessibleApplet
Modifier and Type | Field and Description |
---|---|
boolean |
isApplet
Flag to show whether we're running as an applet or application.
|
XmlParser |
parser |
Constructor and Description |
---|
XmlApplet() |
Modifier and Type | Method and Description |
---|---|
boolean |
action(java.awt.Event ev,
java.lang.Object target)
React to a button press.
|
void |
attribute(java.lang.String name,
java.lang.String value,
boolean isSpecified)
Handle an attribute value specification.
|
void |
charData(char[] ch,
int start,
int length)
Handle character data.
|
void |
doctypeDecl(java.lang.String name,
java.lang.String pubid,
java.lang.String sysid)
Handle a DOCTYPE declaration.
|
void |
endDocument()
Handle the end the document.
|
void |
endElement(java.lang.String name)
Handle the end of an element.
|
void |
endExternalEntity(java.lang.String systemId)
End an external entity.
|
void |
error(java.lang.String message,
java.lang.String url,
int line,
int column)
Handle a parsing error.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Handle ignorable whitespace.
|
void |
init()
Initialise the applet the first time it runs.
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Handle a processing instruction.
|
java.lang.Object |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Resolve an external entity.
|
void |
startDocument()
Handle the start of the document.
|
void |
startElement(java.lang.String name)
Handle the start of an element.
|
void |
startExternalEntity(java.lang.String systemId)
Begin an external entity.
|
void |
startParse()
Start a parse (in response to a button press).
|
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public boolean isApplet
public XmlApplet()
public java.lang.Object resolveEntity(java.lang.String publicId, java.lang.String systemId)
This method could generate a new URL by looking up the public identifier in a hash table, or it could replace the URL supplied with a different, local one; for now, however, just return the URL supplied.
resolveEntity
in interface XmlHandler
publicId
- The public identifier, or null if none was supplied.systemId
- The system identifier.XmlHandler.resolveEntity(java.lang.String, java.lang.String)
public void startExternalEntity(java.lang.String systemId)
XmlHandler
Ælfred will call this method at the beginning of each external entity, including the top-level document entity and the external DTD subset (if any).
If necessary, you can use this method to track the location of the current entity so that you can resolve relative URIs correctly.
startExternalEntity
in interface XmlHandler
systemId
- The URI of the external entity that is starting.XmlHandler.endExternalEntity(java.lang.String)
,
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
public void endExternalEntity(java.lang.String systemId)
XmlHandler
Ælfred will call this method at the end of each external entity, including the top-level document entity and the external DTD subset.
If necessary, you can use this method to track the location of the current entity so that you can resolve relative URIs correctly.
endExternalEntity
in interface XmlHandler
systemId
- The URI of the external entity that is ending.XmlHandler.startExternalEntity(java.lang.String)
,
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
public void startDocument()
Do nothing for now. Subclasses can override this method if they want to take a specific action.
This method will always be called first.
startDocument
in interface XmlHandler
XmlHandler.startDocument()
public void endDocument()
Do nothing for now. Subclasses can override this method if they want to take a specific action.
This method will always be called last.
endDocument
in interface XmlHandler
XmlHandler.endDocument()
public void doctypeDecl(java.lang.String name, java.lang.String pubid, java.lang.String sysid)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
Well-formed XML documents might not have one of these.
The query methods in XmlParser will return useful values only after this callback.
doctypeDecl
in interface XmlHandler
name
- The document type name.pubid
- The public identifier, or null if unspecified.sysid
- The system identifier, or null if unspecified.XmlHandler.doctypeDecl(java.lang.String, java.lang.String, java.lang.String)
public void attribute(java.lang.String name, java.lang.String value, boolean isSpecified)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
attribute
in interface XmlHandler
name
- The name of the attribute.value
- The value of the attribute, or null if the attribute
is #IMPLIED
.isSpecified
- True if the value was specified, false if it
was defaulted from the DTD.XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
public void startElement(java.lang.String name)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
startElement
in interface XmlHandler
name
- The element type name.XmlHandler.startElement(java.lang.String)
public void endElement(java.lang.String name)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
endElement
in interface XmlHandler
name
- The element type name.XmlHandler.endElement(java.lang.String)
public void charData(char[] ch, int start, int length)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
charData
in interface XmlHandler
ch
- The character data.start
- The starting position in the array.length
- The number of characters available.XmlHandler.charData(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
ignorableWhitespace
in interface XmlHandler
ch
- The literal whitespace characters.start
- The starting position in the array.length
- The number of whitespace characters available.XmlHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(java.lang.String target, java.lang.String data)
Do nothing for now. Subclasses can override this method if they want to take a specific action.
processingInstruction
in interface XmlHandler
target
- The target (the name at the start of the PI).data
- The data, if any (the rest of the PI).XmlHandler.processingInstruction(java.lang.String, java.lang.String)
public void error(java.lang.String message, java.lang.String url, int line, int column)
By default, print a message and throw an Error.
Subclasses can override this method if they want to do something different.
error
in interface XmlHandler
message
- The error message.url
- The system identifier of the entity that
contains the error.line
- The approximate line number of the error.column
- The approximate column number of the error.XmlHandler.error(java.lang.String, java.lang.String, int, int)
public void init()
init
in class java.applet.Applet
public boolean action(java.awt.Event ev, java.lang.Object target)
This uses the old event model, so that it will work with existing browsers. It will cause a 'deprecated' warning when you compile.
action
in class java.awt.Component
public void startParse() throws java.lang.Exception
Erase the text area, then start the parser running, using the value of the "url" parameter.
java.lang.Exception
- If thrown by the parser.