home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 January / maximum-cd-1999-01.iso / Benchmarks / 12 Step / MusicMatch Jukebox / mmsetup.EXE / data1.cab / Help_Files / WebHelp.cab / hhapplet / SiteMapParserToContents.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-03-27  |  3.9 KB  |  230 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.Color;
  5. import java.awt.Image;
  6. import java.net.MalformedURLException;
  7. import java.util.Vector;
  8. import sitemap.SiteMapParserOutput;
  9. import treeview.ImageSet;
  10. import treeview.SiblingChildTree;
  11. import treeview.TreeView;
  12. import treeview.TreeViewNode;
  13.  
  14. public class SiteMapParserToContents implements SiteMapParserOutput {
  15.    protected TreeViewNode root_tree = new TreeViewNode();
  16.    protected int ind;
  17.    protected int real_ind;
  18.    protected Vector parent_list = new Vector();
  19.    protected boolean done_a_node;
  20.    protected boolean in_global = true;
  21.    protected Image[] images;
  22.    // $FF: renamed from: a java.applet.Applet
  23.    protected Applet field_0;
  24.    protected TreeView m_tvTheTree;
  25.    protected String default_frame_name;
  26.    protected boolean use_folder_images;
  27.    protected String name;
  28.    protected String local;
  29.    protected String url;
  30.    protected String frame_name;
  31.    protected boolean new_topic;
  32.    private int m_nItems;
  33.  
  34.    public void end() {
  35.       this.getTree();
  36.       this.m_tvTheTree.setFilled(true);
  37.       this.field_0.showStatus("Done");
  38.       if (this.m_tvTheTree.isVisible()) {
  39.          this.m_tvTheTree.requestFocus();
  40.          this.m_tvTheTree.repaint();
  41.       }
  42.  
  43.    }
  44.  
  45.    public void object_start() {
  46.       this.in_global = false;
  47.    }
  48.  
  49.    public void indent(int var1) {
  50.       if (var1 == 1) {
  51.          ++this.real_ind;
  52.          if (this.done_a_node) {
  53.             ++this.ind;
  54.          }
  55.       } else if (var1 == -1) {
  56.          this.real_ind += -1;
  57.          this.ind = this.real_ind;
  58.       }
  59.  
  60.       this.done_a_node = false;
  61.    }
  62.  
  63.    public TreeView getTree() {
  64.       if (this.m_tvTheTree == null) {
  65.          this.m_tvTheTree = new TreeView(new ImageSet(this.images), this.root_tree);
  66.       }
  67.  
  68.       this.m_tvTheTree.setApplet(this.field_0);
  69.       this.m_tvTheTree.setBackground(Color.white);
  70.       return this.m_tvTheTree;
  71.    }
  72.  
  73.    public void start() {
  74.       if (this.m_tvTheTree != null) {
  75.          this.m_tvTheTree.setFilled(false);
  76.          this.m_tvTheTree.requestFocus();
  77.       }
  78.  
  79.    }
  80.  
  81.    public SiteMapParserToContents(Applet var1, Image[] var2) {
  82.       this.field_0 = var1;
  83.       this.images = var2;
  84.       this.parent_list.setSize(1);
  85.       this.parent_list.setElementAt(this.root_tree, 0);
  86.    }
  87.  
  88.    public void object_end() {
  89.       if (this.ind < 1 && this.m_tvTheTree.isVisible()) {
  90.          this.m_tvTheTree.repaint();
  91.       }
  92.  
  93.       ContentsTree var1 = new ContentsTree(this.field_0, this.images, this.name, this.local, this.url, this.frame_name == null ? this.default_frame_name : this.frame_name, this.use_folder_images, this.new_topic);
  94.       this.parent_list.setSize(this.ind + 2);
  95.       TreeViewNode var2 = (TreeViewNode)this.parent_list.elementAt(this.ind);
  96.       ((SiblingChildTree)var2).addChild(var1);
  97.       this.parent_list.setElementAt(var1, this.ind + 1);
  98.       this.done_a_node = true;
  99.       if (this.m_nItems % 20 == 0) {
  100.          this.field_0.showStatus("Loading Table of Contents...");
  101.       }
  102.  
  103.       ++this.m_nItems;
  104.       this.name = null;
  105.       this.local = null;
  106.       this.frame_name = null;
  107.       this.new_topic = false;
  108.    }
  109.  
  110.    public void param(String var1, String var2) {
  111.       if (this.in_global) {
  112.          if (var1.equalsIgnoreCase("ImageType")) {
  113.             this.use_folder_images = var2.equalsIgnoreCase("Folder");
  114.             return;
  115.          }
  116.  
  117.          if (var1.equalsIgnoreCase("FrameName")) {
  118.             this.default_frame_name = var2;
  119.             return;
  120.          }
  121.       } else {
  122.          try {
  123.             switch (Character.toUpperCase(var1.charAt(0))) {
  124.                case 'F':
  125.                   if (var1.equalsIgnoreCase("FrameName")) {
  126.                      this.frame_name = var2;
  127.                      return;
  128.                   }
  129.                   break;
  130.                case 'L':
  131.                   if (var1.equalsIgnoreCase("Local")) {
  132.                      this.local = var2;
  133.                      return;
  134.                   }
  135.                   break;
  136.                case 'N':
  137.                   if (var1.equalsIgnoreCase("Name")) {
  138.                      this.name = this.fixSpecialCharacters(var2);
  139.                      return;
  140.                   }
  141.  
  142.                   if (var1.equalsIgnoreCase("New")) {
  143.                      this.new_topic = var2.equalsIgnoreCase("1");
  144.                      return;
  145.                   }
  146.                   break;
  147.                case 'U':
  148.                   if (var1.equalsIgnoreCase("URL")) {
  149.                      this.url = var2;
  150.                      return;
  151.                   }
  152.             }
  153.          } catch (MalformedURLException var3) {
  154.          }
  155.       }
  156.  
  157.    }
  158.  
  159.    String fixSpecialCharacters(String var1) {
  160.       int var2 = var1.indexOf(38);
  161.       if (var2 < 0) {
  162.          return var1;
  163.       } else {
  164.          String var3 = "";
  165.  
  166.          while(var2 > -1 && var2 < var1.length() - 2) {
  167.             var3 = var3 + var1.substring(0, var2);
  168.             String var4 = var1.substring(var2);
  169.             int var5 = var4.indexOf(59);
  170.             if (var5 < 0) {
  171.                var3 = var3 + var4;
  172.                break;
  173.             }
  174.  
  175.             if (var5 < var4.length() - 1) {
  176.                var1 = var4.substring(var5 + 1);
  177.             } else {
  178.                var1 = "";
  179.             }
  180.  
  181.             var4 = var4.substring(1, var5);
  182.             switch (Character.toUpperCase(var4.charAt(0))) {
  183.                case 'A':
  184.                   if (var4.equalsIgnoreCase("amp")) {
  185.                      var4 = "&";
  186.                   }
  187.                   break;
  188.                case 'C':
  189.                   if (var4.equalsIgnoreCase("copy")) {
  190.                      var4 = "(c)";
  191.                   }
  192.                   break;
  193.                case 'G':
  194.                   if (var4.equalsIgnoreCase("gt")) {
  195.                      var4 = ">";
  196.                   }
  197.                   break;
  198.                case 'L':
  199.                   if (var4.equalsIgnoreCase("lt")) {
  200.                      var4 = "<";
  201.                   }
  202.                   break;
  203.                case 'N':
  204.                   if (var4.equalsIgnoreCase("nbsp")) {
  205.                      var4 = " ";
  206.                   }
  207.                   break;
  208.                case 'Q':
  209.                   if (var4.equalsIgnoreCase("quot")) {
  210.                      var4 = "\"";
  211.                   }
  212.                   break;
  213.                case 'R':
  214.                   if (var4.equalsIgnoreCase("reg")) {
  215.                      var4 = "(R)";
  216.                   }
  217.             }
  218.  
  219.             var3 = var3 + var4;
  220.             var2 = var1.indexOf(38);
  221.             if (var2 < 0) {
  222.                var3 = var3 + var1;
  223.             }
  224.          }
  225.  
  226.          return var3;
  227.       }
  228.    }
  229. }
  230.