Changeset 6351


Ignore:
Timestamp:
2004-01-06T11:47:14+13:00 (20 years ago)
Author:
cs025
Message:

Improved abstraction & layout changes...

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java

    r6288 r6351  
    5959    child.setParent(this);
    6060
     61    /*
    6162    if (this.id == null) {
    6263      System.out.println(child.id.toString() + " added to root");
     
    6566      System.out.println(child.id.toString() + " added to " + this.id);
    6667    }
     68    */
    6769  }
    6870
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/GS2HierarchyClassifier.java

    r6288 r6351  
    157157    this.hierarchy = handler.getHierarchy();
    158158    this.fields = new ArrayList();
    159     System.out.println("loaded hierarchy for "+ file.toString());
     159    //    System.out.println("loaded hierarchy for "+ file.toString());
    160160    this.database = null;
    161161  }
     
    246246      }
    247247
    248       System.out.println("Matching " + values.get(0).toString());
     248      //      System.out.println("Matching " + values.get(0).toString());
    249249
    250250      if (documentID == null) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/HierarchyClassifier.java

    r6104 r6351  
    4040  class HierarchyNode
    4141  { String descriptor;    // the textual descriptor used on screen or long-hand
    42     String name;          // the index number, letter assignment or other item
     42    String path;          // the index number, letter assignment or other item
    4343                          //   used to identify the position of the item in the
    4444                          //   hierarchy
    45     String id;            // an identifier used by the GLI for maintenance
     45    String name;          // an identifier used by the GLI for maintenance
    4646                          //   purposes; this plays no active role in the
    4747                          //   rebuilding process (at the moment)
     
    5858    { this.descriptor = null;
    5959      this.name       = null;
    60       this.id         = null;
     60      this.path       = null;
    6161      this.childNodes = new ArrayList();
    6262      this.childDocs  = new ArrayList();
     
    8585    }
    8686
    87     public void setID(String id)
    88     { this.id = id;
     87    public void setPath(String path)
     88    { this.path = path;
    8989    }
    9090
     
    134134  { StringBuffer description;
    135135    StringBuffer name;
    136     StringBuffer id;
     136    StringBuffer path;
    137137    StringBuffer match;
    138138    boolean inElement;
    139139    HierarchyNode rootNode = null;
    140140    HierarchyNode currentNode = null;
     141    List          rootNodes = null;
    141142
    142143    HierarchyHandler()
     
    145146      this.name        = null;
    146147      this.description = null;
    147       this.id          = null;
     148      this.path        = null;
    148149      this.match       = null;
     150      this.rootNodes   = new ArrayList();
    149151    }
    150152
     
    155157
    156158    // Initialise the tree
    157     if (currentNode == null)
    158     { if (this.rootNode == null) // which it should be
    159       { this.rootNode = node;
    160       }
    161       else // insert a new root node, and set this as the peer
    162            // of the original root...
    163       { HierarchyNode newRoot = new HierarchyNode();
    164         newRoot.addChild(this.rootNode);
    165         newRoot.addChild(node);
    166         this.rootNode = newRoot;
    167       }
     159    if (this.currentNode == null)
     160    { this.rootNode = node;
    168161    }
    169162        // Add the node
     
    176169      { this.name = new StringBuffer();
    177170      }
    178       else if (localName.equals("ID"))
    179       { this.id   = new StringBuffer();
     171      else if (localName.equals("Path"))
     172      { this.path   = new StringBuffer();
    180173      }
    181174      else if (localName.equals("Description"))
     
    192185    public void endElement(String URI, String localName, String qName)
    193186    { if (localName.equals("Classification"))
    194       { this.currentNode = this.currentNode.getParent();
     187      { if (this.currentNode.getParent() == null) {
     188          this.rootNodes.add(this.currentNode);
     189        }
     190    this.currentNode = this.currentNode.getParent();
    195191      }
    196192      else if (localName.equals("Name"))
     
    198194        this.name = null;
    199195      }
    200       else if (localName.equals("ID"))
    201       { this.currentNode.setID(XMLTools.cleanString(this.id.toString()));
    202         this.id = null;
     196      else if (localName.equals("Path"))
     197      { this.currentNode.setPath(XMLTools.cleanString(this.path.toString()));
     198        this.path = null;
    203199      }
    204200      else if (localName.equals("Description"))
     
    217213    public void characters(char c[], int start, int length)
    218214    { String string = new String(c, start, length);
    219       if (this.id != null)
    220       { this.id.append(string);
     215      if (this.path != null)
     216      { this.path.append(string);
    221217      }
    222218      else if (this.name != null)
     
    238234  private HierarchyNode hierarchy;
    239235  private List          fields;
    240 
    241   public HierarchyClassifier(File basefile, List fields)
     236  private String        sort;
     237
     238  public HierarchyClassifier(File basefile, List fields, String sort)
    242239  {
    243240    try
     
    253250      this.hierarchy = handler.getHierarchy();
    254251      this.fields = fields;
     252      this.sort   = sort;
    255253    }
    256254    catch (SAXException saxException)
Note: See TracChangeset for help on using the changeset viewer.