Class XmlApplet

  • All Implemented Interfaces:
    XmlHandler, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public class XmlApplet
    extends java.applet.Applet
    implements XmlHandler
    Base class for Ælfred demonstration applications.

    This class fills in the basic interface, and provides an I/O infrastructure for simple applications and applets.

    Since:
    Ptolemy II 0.2
    Version:
    1.1
    Author:
    Copyright (c) 1997, 1998 by Microstar Software Ltd.;, written by David Megginson <dmeggins@microstar.com>
    See Also:
    XmlParser, XmlHandler, EventDemo, TimerDemo, DtdDemo, StreamDemo, Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.applet.Applet

        java.applet.Applet.AccessibleApplet
      • Nested classes/interfaces inherited from class java.awt.Panel

        java.awt.Panel.AccessibleAWTPanel
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean isApplet
      Flag to show whether we're running as an applet or application.
      XmlParser parser  
      • Fields inherited from class java.awt.Component

        BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlApplet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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).
      • Methods inherited from class java.applet.Applet

        destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
      • Methods inherited from class java.awt.Panel

        addNotify
      • Methods inherited from class java.awt.Container

        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
      • Methods inherited from class java.awt.Component

        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, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • isApplet

        public boolean isApplet
        Flag to show whether we're running as an applet or application.
    • Constructor Detail

      • XmlApplet

        public XmlApplet()
    • Method Detail

      • resolveEntity

        public java.lang.Object resolveEntity​(java.lang.String publicId,
                                              java.lang.String systemId)
        Resolve an external entity.

        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.

        Specified by:
        resolveEntity in interface XmlHandler
        Parameters:
        publicId - The public identifier, or null if none was supplied.
        systemId - The system identifier.
        Returns:
        The replacement system identifier, or null to use the default.
        See Also:
        XmlHandler.resolveEntity(java.lang.String, java.lang.String)
      • startDocument

        public void startDocument()
        Handle the start of the document.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        This method will always be called first.

        Specified by:
        startDocument in interface XmlHandler
        See Also:
        XmlHandler.startDocument()
      • endDocument

        public void endDocument()
        Handle the end the document.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        This method will always be called last.

        Specified by:
        endDocument in interface XmlHandler
        See Also:
        XmlHandler.endDocument()
      • doctypeDecl

        public void doctypeDecl​(java.lang.String name,
                                java.lang.String pubid,
                                java.lang.String sysid)
        Handle a DOCTYPE declaration.

        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.

        Specified by:
        doctypeDecl in interface XmlHandler
        Parameters:
        name - The document type name.
        pubid - The public identifier, or null if unspecified.
        sysid - The system identifier, or null if unspecified.
        See Also:
        XmlHandler.doctypeDecl(java.lang.String, java.lang.String, java.lang.String)
      • attribute

        public void attribute​(java.lang.String name,
                              java.lang.String value,
                              boolean isSpecified)
        Handle an attribute value specification.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        Specified by:
        attribute in interface XmlHandler
        Parameters:
        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.
        See Also:
        XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
      • startElement

        public void startElement​(java.lang.String name)
        Handle the start of an element.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        Specified by:
        startElement in interface XmlHandler
        Parameters:
        name - The element type name.
        See Also:
        XmlHandler.startElement(java.lang.String)
      • endElement

        public void endElement​(java.lang.String name)
        Handle the end of an element.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        Specified by:
        endElement in interface XmlHandler
        Parameters:
        name - The element type name.
        See Also:
        XmlHandler.endElement(java.lang.String)
      • charData

        public void charData​(char[] ch,
                             int start,
                             int length)
        Handle character data.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        Specified by:
        charData in interface XmlHandler
        Parameters:
        ch - The character data.
        start - The starting position in the array.
        length - The number of characters available.
        See Also:
        XmlHandler.charData(char[], int, int)
      • ignorableWhitespace

        public void ignorableWhitespace​(char[] ch,
                                        int start,
                                        int length)
        Handle ignorable whitespace.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        Specified by:
        ignorableWhitespace in interface XmlHandler
        Parameters:
        ch - The literal whitespace characters.
        start - The starting position in the array.
        length - The number of whitespace characters available.
        See Also:
        XmlHandler.ignorableWhitespace(char[], int, int)
      • processingInstruction

        public void processingInstruction​(java.lang.String target,
                                          java.lang.String data)
        Handle a processing instruction.

        Do nothing for now. Subclasses can override this method if they want to take a specific action.

        Specified by:
        processingInstruction in interface XmlHandler
        Parameters:
        target - The target (the name at the start of the PI).
        data - The data, if any (the rest of the PI).
        See Also:
        XmlHandler.processingInstruction(java.lang.String, java.lang.String)
      • error

        public void error​(java.lang.String message,
                          java.lang.String url,
                          int line,
                          int column)
        Handle a parsing error.

        By default, print a message and throw an Error.

        Subclasses can override this method if they want to do something different.

        Specified by:
        error in interface XmlHandler
        Parameters:
        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.
        See Also:
        XmlHandler.error(java.lang.String, java.lang.String, int, int)
      • init

        public void init()
        Initialise the applet the first time it runs.
        Overrides:
        init in class java.applet.Applet
      • action

        public boolean action​(java.awt.Event ev,
                              java.lang.Object target)
        React to a button press.

        This uses the old event model, so that it will work with existing browsers. It will cause a 'deprecated' warning when you compile.

        Overrides:
        action in class java.awt.Component
      • startParse

        public void startParse()
                        throws java.lang.Exception
        Start a parse (in response to a button press).

        Erase the text area, then start the parser running, using the value of the "url" parameter.

        Throws:
        java.lang.Exception - If thrown by the parser.