home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / IFC_112 / netscape / application / TextViewHTMLElement.java < prev    next >
Encoding:
Text File  |  1999-05-28  |  2.8 KB  |  87 lines  |  [TEXT/CWIE]

  1. // TextViewHTMLElement.java
  2. // By Ned Etcode
  3. // Copyright 1996, 1997 Netscape Communications Corp.  All rights reserved.
  4.  
  5. package netscape.application;
  6. import netscape.util.*;
  7.  
  8. /** This abstract class describes an HTML element.
  9.   * It also provides some general conveniences to produce some strings
  10.   * and attributes for TextView.
  11.   * You never subclass TextViewHTMLElement directly. You subclass
  12.   * TextViewHTMLString, TextViewHTMLMarker or TextViewHTMLContainer.
  13.   *
  14.   * @note 1.0 changes
  15.   */
  16. public abstract class TextViewHTMLElement implements HTMLElement{
  17.  
  18.     /** Convenience to convert an attribute string to an attribute Hashtable
  19.      *  return null if the string is empty or does not contain
  20.      *  HTML attributes syntax.
  21.      */
  22.     public Hashtable hashtableForHTMLAttributes(String attr) {
  23.         Hashtable h = null;
  24.         if( attr != null ) {
  25.             try {
  26.                 h = HTMLParser.hashtableForAttributeString(attr);
  27.             } catch (HTMLParsingException e) {
  28.                 h = null;
  29.             }
  30.         }
  31.         return h;
  32.     }
  33.  
  34.     /** Convenience to extract a font from a TextView attribute dictionary.
  35.      *  If the dictionary contains a font, this font will be returned. Otherwise,
  36.      *  this method will try the TextView's default font. If no font is found,
  37.      *  return Font.defaultFont()
  38.      */
  39.     public Font fontFromAttributes(Hashtable attr,TextView textView) {
  40.         Font f = (Font)attr.get(TextView.FONT_KEY);
  41.         if( f == null ) {
  42.             attr = textView.defaultAttributes();
  43.             f = (Font)attr.get(TextView.FONT_KEY);
  44.             if( f == null )
  45.                 f = Font.defaultFont();
  46.         }
  47.         return f;
  48.     }
  49.  
  50.     /** Return it's string according to a context */
  51.     public abstract String string(Hashtable context);
  52.  
  53.     /** Append the string for the component */
  54.     abstract void appendString(Hashtable context,FastStringBuffer fb);
  55.  
  56.  
  57.     /** Set the attributes for the string starting at index index */
  58.     abstract void setAttributesStartingAt(int index, Hashtable initialAttributes,TextView target,
  59.                                           Hashtable context);
  60.  
  61.     /** This method is called with the marker in argument if appropriate.
  62.      * @private
  63.      */
  64.     public void setMarker(String aString) { }
  65.  
  66.     /** This method is called with the attributes in argument if appropriate
  67.      * @private
  68.      */
  69.     public void setAttributes(String attributes) { }
  70.  
  71.     /** This method is called with the string in argument if appropriate.
  72.      * @private
  73.      */
  74.     public void setString(String aString) { }
  75.  
  76.     /** This method is called if the HTMLElement is a container.
  77.      * child[] contains some other HTML elements.
  78.      * null is sent to this method if the container has no children
  79.      * @private
  80.      */
  81.     public void setChildren(Object child[]) { }
  82. }
  83.  
  84.  
  85.  
  86.  
  87.