TreeSet, TreeMap or Comparable?

I'm simply tackling this problem concerning a list of employee's and their division # within a company...
Misino, John          8
Nguyen, Viet                          14
Punchenko, Eric          6
Dunn, Michael          6
Deusenbery, Amanda          14
Taoubina, Xenia          6They're suppose to be stored in alphabetical order...My thing is, should this be approached using TreeSet, TreeMap or Comparable...From what I understand each one is, both TreeSet and TreeMap are both red/black tree implemenations of a binary search tree and TreeSet stores data with an element and a TreeMap a seperate key is created and stored in the collection while the data is stored somewhere else...Comparable seems to be used by either method considering that they are sorted and put into order in either case...Inputs anyone? I believe the information above is true, but they seem very similiar in characteristic, to me at least...

If you're going to put it into a TreeSet or TreeMap,
either it needs to implement Comparable, or you need
to provide a Comparator.
Implement Comparable if there's a sensible "natural"
way to sort it--e.g. by last name then first, or by
employee ID. Provide a Comparator if you want to sort
by some arbitrary criteria that aren't necessarily a
"natural" way to sort this class--e.g. years of
service.
Whether you use the Set or the Map depends on how you
will access the elements. Will you just iterate over
them sequentially (Set) or will you need to access
them at random by some key (Map)?This list will be sorted by last name only...And yeah, I suppose a lot of the factor using either Set or Map depends on the accessing of elements - In general though, I think that TreeMap would be sufficient because doesn't it provides guaranteed log(n) time cost for the containsKey, find/get, insert and remove/delete operations...

Similar Messages

  • Problem in using TreeSet with a Comparator

    Hello,
    There seems to be a bug in the implementation of TreeSet, while using a specific Comparator to sort its elements.
    Here's the problem I got into: the Comparator I use has a type parameter which defines, of course, the type of objects that may be compared. These objects have an integer field 'value'. In the redefinition of 'compare' method inside the Comparator, if the values are equal, 0 is returned, otherwise returns -1 or 1.
    Now, I want to add objects into my TreeSet having this Comparator. But, when I call add for an object that has the field 'value' equal to a value from an object that is already in the Tree Set, it doesn't add it. I red the API documentation, which says that a non-null object o1 is not added into the tree set if there is already an object o2 such that o1.equals(o2) returns true. Or, my objects are far from being equal: the references are different, there are even some fields different.
    Nevertheless, all my elements are comparable.
    Am I ignoring something or is there a bug?
    Thanks.

    When I call add for an object that has the field 'value' equal to a value from an object that is already in the Tree Set, it doesn't add it.Correct. That's how it is supposed to behave. A Set cannot contain duplicates.
    I read the API documentationEvidently not all of it ;-)

  • TreeSet/TreeMap problem

    Hi everyone!
    I'm trying to implement a Scheduler which insert some Deadline in a TreeSet (sorted by expiration timestamp): another Thread "read" TreeSet in order to remove Deadline expired. For this purpose my Deadline class implements Comparable interface and the its method compareTo in this way:
            public int compareTo (Object obj) {
                Deadline d = (Deadline) obj;
                if (this.deadline > d.deadline)
                    return 1;
                else if (d.deadline > this.deadline)
                    return -1;
                else {
                    if (this.equals(obj))
                        return 0;
                    else
                        return 1;
            }My class Deadline doesn't extends any other class and doesn't re-implements method equals.
    Belove part of my "killer" thread which "read" TreeSet:
                   while (v.size() > 0) {
                        dl = (Deadline) v.first();
                        if (dl.deadline <= last) {
                             v.remove(dl);
              ans = dl.deadline;
                                    else {
                                        ans = dl.deadline;
                                        break;
    .........In some cases (probably when timestamp deadline of Deadline class is equal to that of another Deadlne) removal of Deadline is not performed: TreeSet method first() give me a Deadline, but then I can't remove it from TreeSet. So TreeSet size is never decremented and I hava an infinite while cicle. Probably the problem is my implementation of method compareTo but I can't understand what is wrong!
    Can somenone help me?
    Thank you all in advance!
    Diego

    I want to insert in my TreeSet Deadline with the same timestamp deadline, because this can happen. When timestamp is equal, get/remove method of TreeMap should navigate in its internal tree and search, between all Deadline with the same timestamp, that which satisfy equals check.

  • Any simple example for comparator for treemap

    I have a treemap collection stored some data like
    a:4
    b:7
    c:5
    d:7
    e:1
    f:3
    The Treemap helped me to sort by key value like above.
    But what I want is sort by value , it should be like this
    b:7
    d:7
    c:5
    a:4
    f:3
    e:1
    I know comparator object can help me about the sorting mechanism in treemap, it is used like
    comp is comparator
    TreeMap tm = new TreeMap(comp)
    but I don't know how to construct this comparator object to help me sort by value.
    Any one can help me here??
    Thank you

    Here's a sample that demonstrates the issue. Note that when you run this that the comparator class never sees the data items (in this case 'a' - 'f'), only the numbers.
    Also notice that both sets that are returned (keySet and entrySet) are appropriately sorted.
    Finally, it is interesting to note that it looks like the TreeMap.get() method walks the tree to find the entry (no surprise), but the entrySet method returns both the keys and data in one shot. This implies that there may be a performance blip gained by asking for the entrySet and getting the values that way, rather than the first technique using the keySet and get().
    import java.util.*;
    public class x
         public static void main(String args[])
              TreeMap t = new TreeMap(new Comparator() {
                   public int compare(Object o1, Object o2) {
                        Comparable c1 = (Comparable) o1;
                        Comparable c2 = (Comparable) o2;
                        System.out.println("Comparing " + c1 + " - " + c2);
                        return c1.compareTo(c2);
                   public boolean equals(Object o) {
                        return false;
              String s;
              t.put("1", "f");
              t.put("2", "e");
              t.put("3", "d");
              t.put("4", "c");
              t.put("5", "b");
              t.put("6", "a");
              Iterator i;
              Set keys = t.keySet();
              i = keys.iterator();
              while(i.hasNext()) {
                   s = (String)i.next();
                   System.out.println(s + " - " + t.get(s));
              Set entries = t.entrySet();
              i = entries.iterator();
              while(i.hasNext()) {
                   System.out.println(i.next());

  • Treeset and Comparator

    I am trying to implement a schedule using a TreeSet and a Comparator.
    The TreeSet constructor receives a Comparator.
    Then I start adding objects that implement an Interface called ScehdulableInterface.
    All objects that implement this interface have a method:
    Public Date getDate()
    The Comparator compare method is defined like this:
    public int compare(Object o1, Object o2) {
    return ((SchedulableInterface)o1).getEndDate().compareTo(((SchedulableInterface)o2).getEndDate());
    My problem is the TreeSet is not accepting objects in the same date. Is there any other Collection that accepts the Comparator interface and accepts objects with the same date ?
    Thanks.
    Eli

    Of course with something like this:public int compare(Object o1, Object o2) {
       // checks for null and other error handling omitted...
       SchedulableInterface si1 = (SchedulableInterface) o1;
       SchedulableInterface si2 = (SchedulableInterface) o2;
       int endDateCompare = s1.getEndDate().compareTo(s2.getEndDate();
       if (endDateCompare == 0) {
           return s1.getSubject().compareTo(s2.getSubject());
       } else {
           return endDateCompare;

  • How to get TreeSet from TreeMap?

    Hi,
    I tried the following:
    (TreeSet)treeMap.keySet()Is there a way to get the treeset from treemap without creating a new instance of treeset and adding all values from this keySet?

    leden wrote:
    Hi,
    I tried the following:
    (TreeSet)treeMap.keySet()Is there a way to get the treeset from treemap without creating a new instance of treeset and adding all values from this keySet?No, as is quite clear from the docs. TreeMap's keySet() method is only guaranteed to return some Set implementation. If you want a specific implementation, you have to create it. Is that a problem, and if so, why?

  • Sorting TreeMap

    Hi,
    I've been trying to work this out and can't seem to find a solution. I have a treemap of object and I want to sort them by their names, such as lastname. These object hold all these datas. I wrote myself a comparator class like this:
    import java.util.*;
    import java.io.*;
    public class PatientComparator implements Comparator {
    public int compare(Object obj1, Object obj2) throws ClassCastException {
    System.out.println(obj1.getClass()); //use to see what is passing in to compare
    Patient a = (Patient)obj1;
    Patient b = (Patient)obj2;
    String nameA = a.getName();
    String nameB = b.getName();
    String firstName = nameA.substring(0,nameA.indexOf(",",0)-1);
    String lastName = nameA.substring(nameA.indexOf(",",0)+1,nameA.length()-1);
    String firstName2 = nameB.substring(0,nameB.indexOf(",",0)-1);
    String lastName2 = nameB.substring(nameB.indexOf(",",0)+1,nameB.length()-1);
    int result = 0;
    if ( !(lastName.equals(lastName2)) )
         result = lastName.compareTo(lastName2);
    else
    result = firstName.compareTo(firstName2);
    return result;
    I have to use TreeMap or HashMap right now because they both utilize the assigned key to identify object quicker. But the culprit is how do I sort this TreeMap in term of object properties(like name, age). Here is the class I implement it:
    public class DoctorsOffice {
    private String office_name;
    private int ID = 1000; //start out with id # 1000
    private SortedMap active = new TreeMap(new PatientComparator());
    //private SortedSet inactive = new TreeSet();
    * Constructor for a DoctorsOffice object.
    * @param name Name of this Dr's Office
    public DoctorsOffice (String name) {
    office_name = name;
    * Add a new patient to the office. The identification
    * number is uniquely generated and is returned when the
    * Patient object is added to the database. ID numbers
    * start at 1000 and increment by one for each new Patient
    * added.
    * @param firstName first name of this patient
    * @param lastName last name of this patient
    * @param age age of this patient
    * @return the ID number assigned to this Patient
    public int addPatient (String firstName, String lastName, int age) {
    Patient new_patient = new Patient( firstName,lastName,age );
    active.put( new Integer(ID), new_patient );
    ID++;
    return (ID - 1);
    * Remove this patient from the master database. Removed patients are
    * archived in an "inactive" database which maintains Patron
    * objects in the order in which they were removed from the master
    * database.
    * @param patientNo     Patient number assigned
    * @exception throws a NoSuchPatientException
    * if this patient does not exist
    public void removePatient (int patientNo)
    throws NoSuchPatientException {
    * Add a new medication for this patient.
    * @param patientNo     Patient number
    * @param medicationName     Name of this medication
    * @param isGeneric     True if a generic drug
    * @exception throws NoSuchPatientException if
    * this patient ID does not exist.
    public void addMedication(int patientNo, String medicationName,
         boolean isGeneric ) throws NoSuchPatientException {
    if ( active.containsKey(new Integer(patientNo)) ) {
    ((Patient)active.get(new Integer(patientNo))).recordNewMed(
    medicationName, isGeneric );
    else
         throw new NoSuchPatientException();
    * Print the medication detail for this patient. Print
    * the patient's full name (lastname COMMA SPACE firstName)
    * then each medication (each one on a new line). To print
    * the medications, simply call your toString() method in
    * the Medication class.
    * If this patient has no medication history, print "No Medications
    * Prescribed".
    * @param patientNo     Patient number
    * @exception throws NoSuchPatientException
    * if patient does not exist.
    public void printMedicationDetail (int patientNo)
         throws NoSuchPatientException {
    Integer patientID = new Integer(patientNo);
    if ( active.containsKey(patientID) ) {
    System.out.println( ( (Patient)active.get(patientID)).getName() );
    ((Patient)active.get(patientID)).printMedicationHistory();
    else
    throw new NoSuchPatientException();
    * Print all patients ordered by last name, then first name if
    * you encounter two patients with the same last name.
    * To print the Patient objects, simply call your toString() method
    * in the Patient class.
    public void listByName() {        
         // Collection coll = active.values();
    // List temp = new ArrayList(coll);
         // sort(temp,new PatientComparator());
    // Set s = temp.keySet();
    Iterator iterator = active.iterator();
    while( iterator.hasNext() ){
         // String key = (String)iterator.next();     
         System.out.println(iterator.next());     
    }

    I guess I go with the easiest way to do it. But here's
    another culprit, since values() method turn my
    TreeMap into a collection(interface), It doesn't turn the TreeMap into anything. That is, the original TM still exists, exactly as you left it. There's just a new Collection created that refers to each of the TM's values.
    and the sort()
    method is in class Collections, how do I call the
    sort(), and also the sort() method has two parameters
    (List list, Comparator C)If your values implement Comparable, and you want to use the natural sort order (for instance, the values are Strings and you just want them sorted alphabetically), then you just call the sort method that takes a single List parameter. Otherwise (for instance, you want to reverse the sort order, or sort by length, etc.), you have to write a Comparator for your values.
    >
    1st) I don't have any list to put as parameter.Both LinkedList and ArrayList take a Collection as a constructor arg, I think, so you can construct one from the Collection returned by values().
    2nd) Comparator C will keep comparing two keys from
    the treemap or in the collection?
    Collection coll = active.values();
    Collections.sort( , new
    PatientComparator());The TreeMap's Comparator will do that. The values List will sort however you tell it to, regardless of how the TreeMap sorts its keys.
    I don't think the sort is able to be called this way,
    and what do I substitute in for a parameter list when
    I have a treemap right now? Huh?

  • Unchecked call to TreeSet

    So, I'm trying to do something which I thought was fairly simple.
    I have a very simple record class who's only members are two strings and then there are the usual set/get methods. Let us call it class Foo.
    Now, I want to have a set of Foo's which keeps ordering based on first member, second member (e.g., like lastname, firstname). So, I build FooComparator which implements compare and equals. I then create my set class like this:
    public class FooSet extends TreeSet {
            public FooSet() {
            super(new FooComparator());
    }and I get:
    FooSet.java:23: warning: [unchecked] unchecked call to TreeSet(java.util.Comparator<? super E>) as a member of the raw type java.util.TreeSet
    super(new FooComparator());
    FooComparator looks like this:
    public class FooComparator implements Comparator, Serializable {  
            public FooComparator() {
            super();
        //impl of compare() and equals()
    }My two questions are:
    1) Is this warning ignorable?
    2) If not, what is the correct fix?
    Thanks, everyone.
    Best,
    Glenn

    The warning isn't a biggie... I'm pretty sure it's because you're not using generics. So lets say your your record class is called FooRecord. If you changed your code around to this, it should be fine.
    public class FooSet extends TreeSet<FooRecord> {
            public FooSet() {
                super(new FooComparator());
    }There might be a cleaner way to implement this (I'm not too clear on generics) but I'm pretty sure that'll do the trick. Once you get into generics they're awesome and make things a hell of a lot easier.
    -Thomas

  • ClassCastException error from wlpi..

    Hello,
    I get the following error for when I am running some of my workflows ..any
    clues..??
    <Nov 7, 2002 2:33:44 PM EST> <Notice> <WebLogicServer> <ListenThread
    listening o
    n port 7001>
    <Nov 7, 2002 2:33:46 PM EST> <Notice> <WebLogicServer> <Started WebLogic
    Admin S
    erver "myserver" for domain "wlidomain" running in Development Mode>
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl_WLSkel.invoke(Unk
    nown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
    ef.java:93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:267)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
    .java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl_WLSkel.invoke(Unk
    nown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
    ef.java:93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:267)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
    .java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl_WLSkel.invoke(Unk
    nown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
    ef.java:93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:267)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
    .java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl_WLSkel.invoke(Unk
    nown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
    ef.java:93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:267)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
    .java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl_WLSkel.invoke(Unk
    nown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
    ef.java:93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:267)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
    .java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl_WLSkel.invoke(Unk
    nown Source)
    at
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
    at
    weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
    ef.java:93)
    at
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
    a:267)
    at
    weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
    .java:22)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    <Nov 7, 2002 2:34:24 PM EST> <Error> <WLPI> <<wlpirequest>
    <started>2002-11-07 14:34:22.476</started>
    <requestor>ips admin</requestor>
    <templateid>20010</templateid>
    <template-name>DeviceConfig</template-name>
    <templatedefinitionid>21010</templatedefinitionid>
    <instanceid>118001</instanceid>
    <actions>
    <error time="2002-11-07 14:34:24.058">ClassCastException: An error
    occurred
    during exception handler processing.
    java.lang.NoClassDefFoundError</error>
    </actions>
    <completed>2002-11-07 14:34:24.058</completed>
    </wlpirequest>
    >
    java.lang.ClassCastException: java.lang.NoClassDefFoundError
    at
    com.bea.wlpi.common.ClassInvocationDescriptor.invokeMethod(ClassInvoc
    ationDescriptor.java:542)
    at
    com.bea.wlpi.server.workflow.action.ActionBusinessOperation.execute(A
    ctionBusinessOperation.java:274)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Decision.activate(Decision.java:72)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDoit.execute(ActionTask
    Doit.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at
    com.bea.wlpi.server.workflow.action.ActionCondition.execute(ActionCon
    dition.java:95)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.activate(Task.java:119)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.activateS
    uccessors(WorkflowProcessorBean.java:1344)
    at com.bea.wlpi.server.workflow.Task.markDone(Task.java:164)
    at
    com.bea.wlpi.server.workflow.action.ActionTaskDone.execute(ActionTask
    Done.java:50)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.executeAc
    tions(WorkflowProcessorBean.java:1194)
    at com.bea.wlpi.server.workflow.Task.executeActions(Task.java:90)
    at com.bea.wlpi.server.workflow.Task.doit(Task.java:138)
    at com.bea.wlpi.server.workflow.Workflow.taskDoit(Workflow.java:686)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean$3.invoke(
    WorkflowProcessorBean.java:790)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.performWi
    thErrorHandling(WorkflowProcessorBean.java:1132)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean.taskDoit(
    WorkflowProcessorBean.java:783)
    at
    com.bea.wlpi.server.workflowprocessor.WorkflowProcessorBean_h7kt4j_EO
    Impl.taskDoit(WorkflowProcessorBean_h7kt4j_EOImpl.java:474)
    at
    com.bea.wlpi.server.worklist.WorklistBean.taskExecute(WorklistBean.ja
    va:512)
    at
    com.bea.wlpi.server.worklist.WorklistBean_1nnm8f_EOImpl.taskExecute(W
    orklistBean_1nnm8f_EOImpl.java:782)
    at
    com.dset.ngp.wf.wlpi.WfProcessImpl.startProcess(WfProcessImpl.java:10
    6)
    at com.dset.ncx.wf.WfHelper.createProcess(WfHelper.java:102)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:175)
    at
    com.dset.ncx.session.ConfiguratorBean.generateScripts(ConfiguratorBea
    n.java:149)
    at
    com.dset.ncx.session.ConfiguratorBean_m2uo2d_EOImpl.generateScripts(C
    onfiguratorBean_m2uo2d_EOImpl.java:487)

    Thanks for the help abnormal. In my full code I had instantiated TreeSet with a Comparator, but I must have had a problem in the compare() code. I'll have to look into it more closely; as the stack trace did indicate an error in the compare() method in TreeMap. This would also explain why a single object can be added before there is a problem, because a compare wouldn't happen until there is more than one object. One other question: when comparing objects in the compare() method of the Comparator, can I choose any member of the object to compare for ordering or is there some standard I must follow when comparing objects?
    Thanks again.

  • Can someone explan to me

    this method is part of my lab, it should sort words in alphabetical order from
    from A to Z . .
    i don;t undersatand why did we use .compareTo in this method??
    could someone explain what does this method mean
    public static void sortList()
              String temp;          
              for(int k = 0; k < count-1; k++)
             for(int p = k+1; p < count; p++)
              if(list[k].compareTo(list[p]) > 0)
                        temp = list[k];
                        list[k] = list[p];
                        list[p] = temp;
    }

    If all of the elements in a collection implement the Comparable interface, which defines the compareTo method, then the sorting can be done automatically using a TreeSet( ), TreeMap( ), or Collections.sort( ) method. For example:
    public class MyClass
    implements Comparable
       public int compareTo( Object o )
          if( equals( o ) ) return 0;
          if( o == null ) return -1;
          if( !(o instanceof MyClass) ) throw new ClassCastException( );
          MyClass that = (MyClass)o;
          if( this.getValue( ).lessThan( that.getValue( ) )
              return -1;
          else
              return 1;
    public class SomeOtherClass
        public void someMethod( )
            List myClassList = new ArrayList( );
            for( int i = 0; i < 10; i++ ) myClassList.add( new MyClass( ) );
            // Sorts myClassList by casting each element to Comparable
            // and calling compareTo( )
            List sortedList = Collections.sort( myClassList );
    }

  • JProgressBar Shows Up Too Late--How Do I Update the Display Immediately?

    My application has a split pane, the bottom page of which is a panel containing an image that takes a long time to load. For that reason, I want the bottom pane to be a panel with a progress bar until the image is ready.
    Here's a simple version of my code:
    JPanel progressBarPanel = new JPanel();
    JProgressBar progressBar = new JProgressBar(0, 1);
    progressBar.setIndeterminate(true);
    progressBarPanel.add(progressBar);
    splitPane.setBottomComponent(progressBarPanel);  // line A
    splitPane.invalidate();
    JPanel imagePanel = createImagePanelSlowly();  // line B
    splitPane.setBottomComponent(imagePanel);
    splitPane.invalidate();However, this doesn't work; the display isn't updated until the image is ready. What do I need to put in between lines A and B so that the progress bar shows up before line B starts executing? I've tried validate(), repaint(), using threads and setting the size of the frame to zero and back again, but none of those seem to work. If I pop up a dialog after I add the progress bar to the split pane, the progress bar shows up as soon as the dialog shows up.
    This code is inside a ListSelectionListener on a table elsewhere on the GUI, in case that's relevant.
    I think I don't understand some basic principle about how to get the GUI to be updated immediately after I make some change.

    As suggested, I have prepared a compilable demonstration. I figured out that the
    problem I was having before was that I was trying to join the background and
    event-processing threads (I had been using threads, but I didn't show that code in the
    version I posted since it didn't seem to matter). After I eliminated the join, the progress
    bar is displayed, but the user can do other things while the image is loading. I want to
    prevent the user from doing that. I switched the cursor to a wait cursor, but that doesn't
    seem to prevent it.
    In particular, while it is loading, the user should be able to:
    * resize the window
    * minimize the window and bring it back up
    * ideally, adjust the split pane, but that isn't critical
    but NOT:
    * select a different row in the table
    * sort the table
    * use the menus
    Any attempt by the user to perform the disallowed actions should have no effect either
    while the image is loading or after it has finished.
    (That is, the disallowed events should not simply be queued for later.)
    I wonder if there is a simple way to accomplish that.
    Here is a demo (3 classes):
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Cursor;
    import java.awt.Font;
    import java.awt.GraphicsEnvironment;
    import java.awt.Rectangle;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.Enumeration;
    import java.util.Vector;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JProgressBar;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.UIManager;
    import javax.swing.border.Border;
    import javax.swing.border.EtchedBorder;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableColumn;
    * <p>Copyright (C) 2006
    * <p>All rights reserved.
    public class DisableGUIDemo extends JFrame {
         static final Rectangle SCREEN_SIZE = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
         static final Color HYACINTH = new Color(160, 96, 192);
         static final Color LAVENDER = new Color(224, 208, 232);
         Vector<Vector<String>> demoTableData = new Vector<Vector<String>>();
         Vector<String> demoColumnNames = new Vector<String>();
         protected JTable dataTable;
         protected JScrollPane tablePane;
         protected JSplitPane mainPane;
         protected JPanel imageArea;
         private DefaultTableModel dataModel;
          * This creates a new <code>DisableGUIDemo</code> instance, builds the UI
          * components and displays them.
         private DisableGUIDemo(){
              super();
              setTitle("Demo");
              // Ugly:  Initialize the table with demo data.
              Vector<String> demoTableFirstRow = new Vector<String>();
              demoTableFirstRow.add("18");
              demoTableFirstRow.add("13");
              demoTableFirstRow.add("11");
              demoTableFirstRow.add("19");
              demoTableFirstRow.add("19");
              demoTableData.add(demoTableFirstRow);
              Vector<String> demoTableSecondRow = new Vector<String>();
              demoTableSecondRow.add("5");
              demoTableSecondRow.add("3");
              demoTableSecondRow.add("4");
              demoTableSecondRow.add("1");
              demoTableSecondRow.add("3");
              demoTableData.add(demoTableSecondRow);
              Vector<String> demoTableThirdRow = new Vector<String>();
              demoTableThirdRow.add("11");
              demoTableThirdRow.add("12");
              demoTableThirdRow.add("10");
              demoTableThirdRow.add("18");
              demoTableThirdRow.add("18");
              demoTableData.add(demoTableThirdRow);
              demoColumnNames.add("Column 0");
              demoColumnNames.add("Column 1");
              demoColumnNames.add("Column 2");
              demoColumnNames.add("Column 3");
              demoColumnNames.add("Column 4");
              dataModel = new DefaultTableModel(demoTableData, demoColumnNames);
              initialize(); 
          * The <code>initialize</code> method builds and displays up the GUI.
         private void initialize() {
              addWindowListener(new WindowAdapter()  {
                        public void windowClosing(WindowEvent e)  {
                             System.exit(0);
              // Build the GUI panels.
              setJMenuBar(menuBar());
              createSplitPane(true);
              setLocation(SCREEN_SIZE.x, SCREEN_SIZE.y);
              setSize(SCREEN_SIZE.width, SCREEN_SIZE.height - 20);
              setVisible(true); 
          * This creates and returns the menu bar.  The actions to take in response to menu-option selections are
          * specified here.
          * @return the menu bar
         private JMenuBar menuBar(){
              JMenuBar menuBar = new JMenuBar();
              JMenu fileMenu = new JMenu("File");
              fileMenu.setFont(fileMenu.getFont().deriveFont(10.0f));
              JMenuItem reset = new JMenuItem("Reset");
              reset.setFont(reset.getFont().deriveFont(10.0f));
              reset.addActionListener(new ActionListener(){
                        // When the user resets the display, the configuration panel is recreated.
                        public void actionPerformed(ActionEvent e){
                             dataModel = new DefaultTableModel(demoTableData, demoColumnNames);
                             createSplitPane(true);
                             int oldWidth = getWidth();
                             int oldHeight = getHeight();
                             setSize(0, 0);
                             setSize(oldWidth, oldHeight);
                             repaint();
                             JOptionPane.showMessageDialog(DisableGUIDemo.this,
                                                                                                        "The display should be reset.",
                                                                                                        "Reset",
                                                                                                        JOptionPane.PLAIN_MESSAGE);
              fileMenu.add(reset);
              fileMenu.addSeparator();
              JMenuItem saveTable = new JMenuItem("Save Table");
              saveTable.setFont(saveTable.getFont().deriveFont(10.0f));
              saveTable.setEnabled(false);
              fileMenu.add(saveTable);
              menuBar.add(fileMenu);
              menuBar.add(Box.createHorizontalGlue());
              JMenu helpMenu = new JMenu("Help");
              helpMenu.setFont(helpMenu.getFont().deriveFont(10.0f));
              JMenuItem help = new JMenuItem("Documentation");
              help.setFont(help.getFont().deriveFont(10.0f));
              help.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             JOptionPane.showMessageDialog(DisableGUIDemo.this, "There is no documentation available for the demo.");
              helpMenu.add(help);
              menuBar.add(helpMenu);
              return menuBar;
          * The <code>createSplitPane</code> method creates the table and image area and displays them in a split pane.
          * @param createNewTable whether to create a new table (should be false if the table has already been created)
         private void createSplitPane(boolean createNewTable){
              if (createNewTable){
                   dataTable = dataTable();
                   tablePane = new JScrollPane(dataTable);
                   Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, LAVENDER, HYACINTH);
                   tablePane.setBorder(etchedBorder);
              int tablePaneWidth = tablePane.getPreferredSize().width;
              int selectedRow = dataTable.getSelectedRow();
              imageArea
                   = (selectedRow == -1)
                   ? new JPanel()
                   : imageArea((String) dataTable.getValueAt(selectedRow, 0),
                                                 (String) dataTable.getValueAt(selectedRow, 2));
              imageArea.setMinimumSize(imageArea.getPreferredSize());
              mainPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tablePane, imageArea);
              getContentPane().removeAll();
              getContentPane().add(mainPane);
          * The <code>dataTable</code> method returns the data table.
          * @return the data table
         private JTable dataTable(){
              JTable table = new JTable(dataModel);
              table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              ListSelectionModel rowSM = table.getSelectionModel();
              rowSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                             if (e.getValueIsAdjusting()){
                                  return;  // Ignore extra events.
                             ListSelectionModel lsm =
                (ListSelectionModel) e.getSource();
                             if (! lsm.isSelectionEmpty()){
                                  final int selectedRow = dataTable.getSelectedRow();
                                  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                                  JPanel progressBarPanel = new JPanel();  // This should have a border layout.
                                  JProgressBar progressBar = new JProgressBar(0, 1);
                                  progressBar.setIndeterminate(true);
                                  progressBarPanel.add(progressBar);
                                  mainPane.setBottomComponent(progressBarPanel);
                                  mainPane.invalidate();
                                  mainPane.validate();
                                  Thread backgroundThread = new Thread(){
                                            public void run(){
                                                 JPanel imageDisplay = imageArea((String) dataTable.getValueAt(selectedRow, 0),
                                                                                                                                 (String) dataTable.getValueAt(selectedRow, 2));
                                                 mainPane.setBottomComponent(imageDisplay);
                                                 mainPane.invalidate();
                                                 setCursor(null);
                                  backgroundThread.start();
                                  // The following code, before being commented out, caused the GUI to be unresponsive while the image was
                                  // being loaded.  However, without it, the user can do other things while the image is loading, which is
                                  // not desired.
    //                               try{
    //                                    backgroundThread.join();
    //                               catch (InterruptedException ie){
    //                                    // N/A
              if (dataModel != null){
                   table.sizeColumnsToFit(-1);
                   table.getTableHeader().setReorderingAllowed(false);
                   SpecialHeaderRenderer headerRenderer = new SpecialHeaderRenderer(this);
                   SpecialCellRenderer bodyCellRenderer = new SpecialCellRenderer();
                   int i = 0;
                   for (Enumeration<TableColumn> columns = table.getColumnModel().getColumns(); columns.hasMoreElements(); /** */){
                        int columnWidth = 0;
                        TableColumn nextColumn = columns.nextElement();
                        nextColumn.setHeaderRenderer(headerRenderer);
                        nextColumn.setCellRenderer(bodyCellRenderer);
                        nextColumn.sizeWidthToFit();
                        Component comp = headerRenderer.getTableCellRendererComponent(table, nextColumn.getHeaderValue(),
                                                                                                                                                                                   false, false, 0, 0);
                        columnWidth = comp.getPreferredSize().width;
                        for (int j = 0; j < dataModel.getRowCount(); j++){
                             comp = table.getCellRenderer(j, i).getTableCellRendererComponent(table, dataModel.getValueAt(j, i),
                                                                                                                                                                                              false, false, j, i);
                             columnWidth = Math.max(comp.getPreferredSize().width, columnWidth);
                        nextColumn.setPreferredWidth(columnWidth);
                        nextColumn.setMinWidth(columnWidth);
                        i++;
              return table;
          * The <code>imageArea</code> method returns a panel in which an image is shown in the real application.
          * In the demo application, it is replaced by a text label; an artificial delay is used to simulate the
          * delay that would occur during image loading.  The image is loaded when the user selects a row in the table.
          * @param parameter1 a parameter to image creation
          * @param parameter2 a parameter to image creation
          * @return a panel in which a text label stands in for an image
         private JPanel imageArea(String parameter1, String parameter2){
              try{
                   Thread.sleep(3000);
              catch (InterruptedException ie){
                   // N/A
              JPanel imagePanel = new JPanel();
              JLabel substituteLabel = new JLabel("Image for " + parameter1 + ", " + parameter2);
              imagePanel.add(substituteLabel);
              return imagePanel;
          * @param args
         public static void main (String[] args) {
              UIManager.put("Table.font", new Font("DialogInput", Font.PLAIN, 10));
              UIManager.put("Label.font", new Font("Dialog", Font.BOLD, 10));
              UIManager.put("TextField.font", new Font("DialogInput", Font.PLAIN, 10));
              UIManager.put("ComboBox.font", new Font("Dialog", Font.BOLD, 10));
              UIManager.put("Button.font", new Font("Dialog", Font.BOLD, 10));
              UIManager.put("List.font", new Font("Dialog", Font.BOLD, 10));
              try {           
                   new DisableGUIDemo();
              catch (Throwable e) {
                   e.printStackTrace();
                   System.exit(0);
         } // end of main ()
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Font;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.Rectangle;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.Comparator;
    import java.util.TreeSet;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import javax.swing.SwingConstants;
    import javax.swing.UIManager;
    import javax.swing.border.EmptyBorder;
    import javax.swing.table.TableCellRenderer;
    * <p>Copyright (C) 2006
    * <p>All rights reserved.
    public class SpecialHeaderRenderer extends JPanel implements TableCellRenderer {
         static final Color MAUVE = new Color(192, 160, 208);
         static final Insets ZERO_INSETS = new Insets(0, 0, 0, 0);
         static final EmptyBorder EMPTY_BORDER = new EmptyBorder(ZERO_INSETS);
         private GridBagConstraints constraints = new GridBagConstraints();
         final TreeSet<MouseEvent> processedEvents = new TreeSet<MouseEvent>(new Comparator<MouseEvent>(){
              public int compare(MouseEvent o1, MouseEvent o2){
                   return o1.hashCode() - o2.hashCode();
         final private JFrame owner;
      public SpecialHeaderRenderer(JFrame ownerWindow) {
        setOpaque(true);
        setForeground(Color.BLACK);
              setBackground(MAUVE);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
              setLayout(new GridBagLayout());
              constraints.fill = GridBagConstraints.NONE;
              constraints.gridx = 0;
              setAlignmentY(Component.CENTER_ALIGNMENT);
              owner = ownerWindow;
      public Component getTableCellRendererComponent(final JTable table, Object value, boolean isSelected,
                                                                                                                             boolean hasFocus, int row, final int column){
              if (table != null){
                   removeAll();
                   String valueString = (value == null) ? "" : value.toString();
                   JLabel title = new JLabel(valueString);
                   title.setHorizontalAlignment(SwingConstants.CENTER);
                   title.setFont(title.getFont().deriveFont(12.0f));
                   constraints.gridy = 0;
                   constraints.insets = ZERO_INSETS;
                   add(title, constraints);
                   final JPanel buttonPanel = new JPanel();
                   buttonPanel.setLayout(new GridLayout(1, 2));
                   buttonPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
                   buttonPanel.setBackground(MAUVE);
                   final JButton sortAscendingButton = new JButton("V");
                   sortAscendingButton.setMargin(ZERO_INSETS);
                   sortAscendingButton.setBorder(EMPTY_BORDER);
                   constraints.gridy = 1;
                   constraints.insets = new Insets(5, 0, 0, 0);
                   buttonPanel.add(sortAscendingButton);
                   final JButton sortDescendingButton = new JButton("^");
                   sortDescendingButton.setMargin(ZERO_INSETS);
                   sortDescendingButton.setBorder(EMPTY_BORDER);
                   buttonPanel.add(sortDescendingButton);
                   add(buttonPanel, constraints);
                   table.getTableHeader().addMouseListener(new MouseAdapter(){
                             public void mouseClicked(MouseEvent e) {
                                  Rectangle panelBounds = table.getTableHeader().getHeaderRect(column);
                                  Rectangle buttonPanelBounds = buttonPanel.getBounds();
                                  Rectangle buttonBounds = sortAscendingButton.getBounds();
                                  buttonBounds.translate(buttonPanelBounds.x, buttonPanelBounds.y);
                                  buttonBounds.translate(panelBounds.x, panelBounds.y);
                                  if (buttonBounds.contains(e.getX(), e.getY()) && processedEvents.add(e)){
                                       // The click was on this button and has not yet been processed.
                                       JOptionPane.showMessageDialog(owner,
                                                                                                                  "The table would be sorted in ascending order of column " + column + ".",
                                                                                                                  "Sorted Ascending",
                                                                                                                  JOptionPane.PLAIN_MESSAGE);
                                       table.invalidate();
                                       table.revalidate();
                                       table.repaint();
                                  buttonBounds = sortDescendingButton.getBounds();
                                  buttonBounds.translate(buttonPanelBounds.x, buttonPanelBounds.y);
                                  buttonBounds.translate(panelBounds.x, panelBounds.y);
                                  if (buttonBounds.contains(e.getX(), e.getY()) && processedEvents.add(e)){
                                       // The click was on this button and has not yet been processed.
                                       JOptionPane.showMessageDialog(owner,
                                                                                                                  "The table would be sorted in descending order of column " + column + ".",
                                                                                                                  "Sorted Descending",
                                                                                                                  JOptionPane.PLAIN_MESSAGE);
                                       table.invalidate();
                                       table.revalidate();
                                       table.repaint();
              return this;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.util.HashMap;
    import javax.swing.BorderFactory;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import javax.swing.SwingConstants;
    import javax.swing.border.EmptyBorder;
    import javax.swing.border.LineBorder;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellRenderer;
    * <code>SpecialCellRenderer</code> is the custom renderer for all
    * rows except the header row.
    * <p>Copyright (C) 2006
    * <p>All rights reserved.
    public class SpecialCellRenderer extends JPanel implements TableCellRenderer {
         protected Color backgroundColor = Color.PINK; // This means the rows for the first row will be white.
         protected HashMap<Object, Color> rowColors = new HashMap<Object, Color>();
      public SpecialCellRenderer(){
        setOpaque(true);
        setForeground(Color.BLACK);
              setBackground(Color.WHITE);
              setFont(new Font("Monospaced", Font.PLAIN, 10));
              setAlignmentX(Component.RIGHT_ALIGNMENT);
              setBorder(new EmptyBorder(0, 2, 0, 2));
      public Component getTableCellRendererComponent(final JTable table, Object value, boolean isSelected,
                                                                                                                             boolean hasFocus, final int row, final int column){
              String columnName = table.getColumnName(column);
              JLabel text = new JLabel();
              text.setOpaque(true);
              if (table != null){
                   DefaultTableModel model = (DefaultTableModel) table.getModel();
                   if (model == null){
                        System.out.println("The model is null!!");
                        System.exit(1);
                   if (table.isCellSelected(row, column)){
                        setBorder(BorderFactory.createMatteBorder((column < 2) ? 0 : 1,
                                                                                                                                 (column == 2) ? 1 : 0,
                                                                                                                                 (column < 2) ? 0 : 1,
                                                                                                                                 (column == table.getColumnCount() - 1) ? 1 : 0,
                                                                                                                                 Color.BLUE));
                   else{
                        setBorder(BorderFactory.createEmptyBorder());
                   final String rowIdentifier = (String) model.getValueAt(row, 0);
                   if (! rowColors.containsKey(rowIdentifier)){
                        rowColors.put(rowIdentifier, nextBackgroundColor());
                   text.setBackground(rowColors.get(rowIdentifier));
                   text.setFont(getFont().deriveFont(Font.PLAIN));
                   String valueString = (value == null) ? "" : value.toString();
                   text.setText(valueString);
                   try{
                        Double.parseDouble(valueString);
                        text.setHorizontalAlignment(SwingConstants.TRAILING);
                   catch (NumberFormatException nfe){
                        text.setHorizontalAlignment(SwingConstants.LEADING);
                   setLayout(new GridLayout(1, 1));
                   removeAll();
                   add(text);
                   setBackground(text.getBackground());
                   if (table.getRowHeight() < getMinimumSize().height){
                        table.setRowHeight(getMinimumSize().height);
              return this;
         protected Color nextBackgroundColor(){
              backgroundColor = backgroundColor.equals(Color.WHITE) ? Color.PINK : Color.WHITE;
              return backgroundColor;
    }

  • Order-column needs to be numeric?

    Hi,
    I've got a List attribute mapped as one-to-many that I want ordered by a
    date column, but I am getting an exception saying that the order-column
    specified is not numeric. Does my order-column really have to be numeric?
    Why can't I order by a date column (or a varchar for that matter)?
    Thanks,
    Alex

    Abe,
    I would like to propose ordering lists by any column in the next feasible
    version of Kodo. This would be very useful. It would be more efficient
    than in-memory sorting. I can't forsee any problems with it - it would
    simply translate to an "order by" SQL clause.
    Meantime I will use a TreeSet with custom Comparator as you suggest.
    Thanks,
    Alex

  • Nested TokenStreamException: antlr.TokenStreamIOException

    HI,
    We have a JSP in place for last 2-3 years. Till 1-2 days back everything was fine but suddenly it has started giving us error as
    weblogic.utils.ParsingException: nested TokenStreamException: antlr.TokenStreamIOException
    at weblogic.servlet.jsp.JspLexer.parse()V(Optimized Method)
    at weblogic.servlet.jsp.JspParser.doit()V(Optimized Method)
    at weblogic.servlet.jsp.JspParser.parse(Ljava.io.Reader;)V(JspParser.java:234)
    at weblogic.servlet.jsp.Jsp2Java.outputs([Ljava.lang.Object;)Ljava.util.Enumeration;(Jsp2Java.java:125)
    at weblogic.utils.compiler.CodeGenerator.generate([Ljava.lang.Object;)[Ljava.lang.String;(CodeGenerator.java:258)
    at weblogic.servlet.jsp.JspStub.compilePage(Lweblogic.servlet.internal.RequestCallback;)V(JspStub.java:388)
    at weblogic.servlet.jsp.JspStub.prepareServlet(Lweblogic.servlet.internal.RequestCallback;Z)V(JspStub.java:238)
    at weblogic.servlet.jsp.JspStub.prepareServlet(Lweblogic.servlet.internal.RequestCallback;)V(JspStub.java:188)
    at weblogic.servlet.internal.ServletStubImpl.getServlet(Lweblogic.servlet.internal.RequestCallback;)Ljavax.servlet.Servlet;(ServletStubImpl.java:535)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;Lweblogic.servlet.internal.FilterChainImpl;)V(ServletStubImpl.java:373)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(ServletStubImpl.java:315)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(RequestDispatcherImpl.java:322)
    at org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(Ljava.lang.String;Ljavax.servlet.ServletContext;Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(PerformForward.java:113)
    at org.apache.struts.chain.commands.servlet.PerformForward.perform(Lorg.apache.struts.chain.contexts.ActionContext;Lorg.apache.struts.config.ForwardConfig;)V(PerformForward.java:96)
    at org.apache.struts.chain.commands.AbstractPerformForward.execute(Lorg.apache.struts.chain.contexts.ActionContext;)Z(AbstractPerformForward.java:54)
    at org.apache.struts.chain.commands.ActionCommandBase.execute(Lorg.apache.commons.chain.Context;)Z(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(Lorg.apache.commons.chain.Context;)Z(ChainBase.java:190)
    at org.apache.commons.chain.generic.LookupCommand.execute(Lorg.apache.commons.chain.Context;)Z(LookupCommand.java:304)
    at org.apache.commons.chain.impl.ChainBase.execute(Lorg.apache.commons.chain.Context;)Z(ChainBase.java:190)
    at org.apache.struts.chain.ComposableRequestProcessor.process(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doGet(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(ActionServlet.java:449)
    at javax.servlet.http.HttpServlet.service(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse;)V(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava.lang.Object;(ServletStubImpl.java:1006)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;Lweblogic.servlet.internal.FilterChainImpl;)V(ServletStubImpl.java:419)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;)V(ServletStubImpl.java:315)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava.lang.Object;(WebAppServletContext.java:6718)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction;)Ljava.lang.Object;(SecurityManager.java:121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic.servlet.internal.ServletRequestImpl;Lweblogic.servlet.internal.ServletResponseImpl;)V(WebAppServletContext.java:3764)
    at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic.kernel.ExecuteThread;)V(ServletRequestImpl.java:2644)
    The most intersting part of this error is that it is not permannent rather it comes 8 out of 10 times (last 1-2 days only)
    Please give me any pointers about the same. I have googled through the same but did not get any concrete answer on the issue :(
    ~Aman

    This is huge code.. I dont know.. whether it will be usefull for u..
    And as u can see.. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    is there in code.
    Also we ran the EAR on different app server and it is working fine there.
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ page import="java.util.ArrayList" %>
    <%@ page import="java.util.Map.Entry"%>
    <%@ page import="java.util.Set" %>
    <%@ page import="java.util.Iterator" %>
    <%@ page import="java.util.Map" %>
    <%@ page import="java.util.TreeMap"%>
    <%@ page import="java.util.StringTokenizer"%>
    <%@ page errorPage ="/jsp/error.jsp" %>
    <%
    request.setAttribute(RangingConstants.ERROR_NUMBER, RangingError.UNKNOWN_ERROR_IN_JSP);
    request.setAttribute(RangingConstants.ERROR_DESCRIPTION, RangingConstants.UNDEFINED_ERRORMSG_INJSP);
    response.setHeader("Pragma", "No-cache");
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    %>
    <%
    //values for various fields in this screen
    HashMap hmArea                     = new HashMap();
    HashMap hmRegion                = new HashMap();
    HashMap hmRegionArea              = new HashMap();
    HashMap hmBrand                = new HashMap();
    HashMap hmMktDiv                = new HashMap();
    HashMap hmMktSegUnSorted          = new HashMap();
    HashMap hmACMUnsorted               = new HashMap();
    HashMap hmBU                    = new HashMap();
    HashMap hmAreaACM               = new HashMap();
    HashMap hmMktSegACM               = new HashMap();
    HashMap hmAcmMktSeg               = new HashMap();
    HashMap hmMktDivMktSeg               = new HashMap();
    HashMap hmNotificationType           = new HashMap();
    HashMap hmMktDivBU                = new HashMap();
    ArrayList alstNotificationCode          = new ArrayList();
    ArrayList alstNotificationDesc          = new ArrayList();
    ArrayList alstSeasonPrefCode     = new ArrayList();
    HashMap  hmAllSeasonData          = new HashMap();
    TreeMap  hmAllSeasonValue          = new TreeMap();
    HashMap hmComData     =     new HashMap();
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_SEASON_PREF)!=null)
         alstSeasonPrefCode =(ArrayList)request.getAttribute(RangingConstants.USER_PREFERENCES_SEASON_PREF);
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_ALL_DATA)!=null)
         hmAllSeasonData =(HashMap)request.getAttribute(RangingConstants.USER_PREFERENCES_ALL_DATA);
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_ALL_VALUE)!=null)
         hmAllSeasonValue =(TreeMap)request.getAttribute(RangingConstants.USER_PREFERENCES_ALL_VALUE);
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_ALL_COMDATA)!=null)
         hmComData =(HashMap)request.getAttribute(RangingConstants.USER_PREFERENCES_ALL_COMDATA);
    if(request.getAttribute(RangingConstants.MASTER_MAP_AREA)!=null)
         hmArea = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_AREA);
    if(request.getAttribute(RangingConstants.MASTER_MAP_REGION)!=null)
         hmRegion = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_REGION);
    if(request.getAttribute(RangingConstants.MASTER_MAP_REGIONAREA)!=null)
         hmRegionArea = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_REGIONAREA);
    if(request.getAttribute(RangingConstants.MASTER_MAP_BRAND)!=null)
         hmBrand = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_BRAND);
    if(request.getAttribute(RangingConstants.MASTER_MAP_MKTDIVISION)!=null)
         hmMktDiv = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_MKTDIVISION);
    if(request.getAttribute(RangingConstants.MASTER_MAP_MKTSEGMENT)!=null)
         hmMktSegUnSorted = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_MKTSEGMENT);
    if(request.getAttribute(RangingConstants.MASTER_MAP_ACM)!=null)
         hmACMUnsorted = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_ACM);
    if(request.getAttribute(RangingConstants.MASTER_MAP_BU)!=null)
         hmBU = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_BU);
    if(request.getAttribute(RangingConstants.MASTER_MAP_AREAACM)!=null)
         hmAreaACM = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_AREAACM);
    if(request.getAttribute(RangingConstants.MASTER_MAP_MKTSEGACM)!=null)
         hmMktSegACM = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_MKTSEGACM);
    if(request.getAttribute(RangingConstants.MASTER_MAP_ACMMKTSEG)!=null)
         hmAcmMktSeg = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_ACMMKTSEG);
    if(request.getAttribute(RangingConstants.MASTER_MAP_MKTDIVMKTSEGMENT)!=null)
         hmMktDivMktSeg = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_MKTDIVMKTSEGMENT);
    if(request.getAttribute(RangingConstants.NOTIFICATION_TYPES)!=null)
         hmNotificationType = (HashMap)request.getAttribute(RangingConstants.NOTIFICATION_TYPES);
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_ARRAY_LIST_NOTIFICATION_CODE)!=null)
         alstNotificationCode =(ArrayList)request.getAttribute(RangingConstants.USER_PREFERENCES_ARRAY_LIST_NOTIFICATION_CODE);
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_ARRAY_LIST_NOTIFICATION_DESC)!=null)
         alstNotificationDesc = (ArrayList)request.getAttribute(RangingConstants.USER_PREFERENCES_ARRAY_LIST_NOTIFICATION_DESC);
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_MARKETING_DIV_BU)!=null)
         hmMktDivBU = (HashMap)request.getAttribute(RangingConstants.USER_PREFERENCES_MARKETING_DIV_BU);
    HashMap hmBrandArea          = new HashMap();
    if(request.getAttribute(RangingConstants.BRAND_AREA_MAPPING)!=null)
         hmBrandArea = (HashMap)request.getAttribute(RangingConstants.BRAND_AREA_MAPPING);
    HashMap hmBrandMktSeg          = new HashMap();
    if(request.getAttribute(RangingConstants.BRAND_MKTSEG_MAPPING)!=null)
         hmBrandMktSeg = (HashMap)request.getAttribute(RangingConstants.BRAND_MKTSEG_MAPPING);
    HashMap hmBrandAssigned          = new HashMap();
    if(request.getAttribute(RangingConstants.BRAND_ASSIGNED)!=null)
         hmBrandAssigned = (HashMap)request.getAttribute(RangingConstants.BRAND_ASSIGNED);
    HashMap mktSegMktDiv          = new HashMap();
    if(request.getAttribute(RangingConstants.USER_PREFERENCES_MARKETING_SEG_MARKETING_DIV)!=null)
         mktSegMktDiv = (HashMap)request.getAttribute(RangingConstants.USER_PREFERENCES_MARKETING_SEG_MARKETING_DIV);
    HashMap hmProductDivision                = new HashMap();
    if(request.getAttribute(RangingConstants.MASTER_MAP_REGION)!=null)
         hmProductDivision = (HashMap)request.getAttribute(RangingConstants.MASTER_MAP_PRODDIVISION);
    //preselected values for various fields
    String strMarketSegmentFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MARKET_SEGMENT_FLAG);
    String strColorwayFlag                = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_COLORWAY_FLAG);
    String strModelNameFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MODEL_NAME_FLAG);
    String strModelNumberFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MODEL_NUMBER_FLAG);
    String strRangeComponentFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_RANGE_COMPONENT_FLAG);
    String strExclusivityFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_EXCLUSIVITY_FLAG);
    String strProdDivFlag                = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_PROD_DIVISION_FLAG);
    String strMktDivFlag                = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MARKET_DIVISION_FLAG);
    String strRegionFlag                = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_REGION_FLAG);
    String strAreaFlag                = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_AREA_FLAG);
    String strMsgCreatedFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MSG_CREATED_FLAG);
    String strMsgDatedFlag               = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MSG_DATED_FLAG);
    String strBusinessModelFlag           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_BUSINESS_MODEL_FLAG);
    String strMarketClassificationFlag      = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_MARKET_CLASSFICATION_FLAG);
    String strDefaultHistoryDate           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_DEFAULT_HISTORY_DATE);
    String strSelectedHistoryDate           = (String) request.getAttribute(RangingConstants.USER_PREFERENCES_HISTORY_LIMIT);
    String strYear           = (String)(request.getAttribute("year"));
    String strSeason      = (String)(request.getAttribute("season"));
    String strArea          = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_AREA));
    String strRegion      = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_REGION));
    String strBrand      = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_BRAND));
    String strMktDiv      = (String)(request.getAttribute("mktDivision"));
    String strMktDivSeg     = (String)(request.getAttribute("mktDivSegment"));
    String strACM          = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_ACM));
    String strtmBU          = (String)(request.getAttribute("tmBU"));
    String strRegionCode     = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_REGION_CD));
    String strAreaCode     = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_AREA_CD));
    String strUserId      = (String)session.getAttribute(RangingConstants.CBO_USERID);
    String strOnloadFlag = (String)(request.getAttribute("OnloadFlag"));
    String strQuarter      = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_QUARTER));
    String strProductDivision      = (String)(request.getAttribute(RangingConstants.USER_PREFERENCES_PRODUCT_DIV));
    // sorting product Division
    Set set = hmProductDivision.entrySet();
    Iterator ite = set.iterator();
    TreeMap tmProductDivision = new TreeMap(new Comparator()
              public int compare(Object o1, Object o2)
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0)
                        return -1;
                   else
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getKey()==null)
              mpentr = (Map.Entry)(ite.next());
         tmProductDivision.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    //Sorting ACM
    set = hmACMUnsorted.entrySet();
    ite = set.iterator();
    TreeMap tmACM = new TreeMap(
         new Comparator() {
              public int compare(Object o1, Object o2) {
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0){
                             return -1;
                   else{
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getValue()==null)
              mpentr = (Map.Entry)(ite.next());
         tmACM.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    //Sorting Marketing Segment
    set = hmMktSegUnSorted.entrySet();
    ite = set.iterator();
    TreeMap mktSeg = new TreeMap(
         new Comparator() {
             public int compare(Object o1, Object o2) {
                   String s1 = (String) o1;
                   String s2 = (String) o2;
                   return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         mktSeg.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    // sorting business unit hashmap
    set = hmBU.entrySet();
    ite = set.iterator();
    TreeMap tmBU = new TreeMap(
         new Comparator() {
              public int compare(Object o1, Object o2) {
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0)
                        return -1;
                   else
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getKey()==null)
              mpentr = (Map.Entry)(ite.next());
         tmBU.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    hmBU = null;
    //Sorting Brand
    set = hmBrand.entrySet();
    ite = set.iterator();
    TreeMap tmBrand = new TreeMap(new Comparator()
              public int compare(Object o1, Object o2)
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0)
                        return -1;
                   else
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getKey()==null)
              mpentr = (Map.Entry)(ite.next());
         tmBrand.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    //Sorting Marketing Division
    set = hmMktDiv.entrySet();
    ite = set.iterator();
    TreeMap tmMktDiv = new TreeMap(new Comparator()
              public int compare(Object o1, Object o2)
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0)
                        return -1;
                   else
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getKey()==null)
              mpentr = (Map.Entry)(ite.next());
         tmMktDiv.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    // sorting hmMktDivBU
    set = hmMktDivBU.entrySet();
    ite = set.iterator();
    TreeMap tmMktDivBU = new TreeMap(
         new Comparator() {
              public int compare(Object o1, Object o2) {
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0)
                        return -1;
                   else
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getKey()==null)
              mpentr = (Map.Entry)(ite.next());
         tmMktDivBU.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    // sorting hmBrandAssigned
    set = hmBrandAssigned.entrySet();
    ite = set.iterator();
    TreeMap tmBrandAssigned = new TreeMap(new Comparator()
              public int compare(Object o1, Object o2)
                   String s1 = ((String) o1).toUpperCase();
                   String s2 = ((String) o2).toUpperCase();
                   if(s1.compareTo(s2) == 0)
                        return -1;
                   else
                        return s1.compareTo(s2);
    while (ite.hasNext())
         Map.Entry mpentr = (Map.Entry)(ite.next());
         while(mpentr.getKey()==null)
              mpentr = (Map.Entry)(ite.next());
         tmBrandAssigned.put ((String)mpentr.getValue(), (String)mpentr.getKey());
    %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE>User Preferences</TITLE>
    <LINK rel="StyleSheet" type="text/css" href="<%=RangingConstants.CONTENT_PATH%>/jsp/RangePlan/stylesAreaPLP.css">
    <LINK rel="StyleSheet" type="text/css" href="<%=RangingConstants.CONTENT_PATH%>/jsp/UserPreferenceScreen/UserPreferenceScreen.css">
    <SCRIPT type="text/javascript" src="<%=RangingConstants.CONTENT_PATH%>/common/loadingWait.js"></SCRIPT>
    <script language=JavaScript for=document event=oncontextmenu>return true</script>
    <SCRIPT>
    var arrRegionArea     = new Array();
    var arrArea           = new Array();
    var arrAcmMktSeg      = new Array();
    var areaACM           = new Array();
    var acmArray          = new Array();
    var arrACM           = new Array();
    var arracm           = new Array();
    var arrMktSegACM      = new Array();
    var arrMktSeg          = new Array();
    var arrMktDiv          = new Array();
    var arrMktSegMktDiv          = new Array();
    var arrMktDivMktSeg     = new Array();
    var arrMktDivBU      = new Array();
    var arrBU           = new Array();
    var arrFields          = new Array();
    var arrFieldsDesc     = new Array();
    var arrFieldsMaster     = new Array();
    arrFieldsMaster1 = ["Marketing Segment","Colorway","Model Name","Model Number","Range Component","Exclusivity","Business Model","Market Classification","Product Division","Marketing Division","Region","Area","Message Triggered by","Message Creation Date (HZA Time)"]
    arrFieldsDesc = ["mktSeg","colorWay","modelName","modelNo","rangeComponent","exclusivity","businessModel","marketClassification","productDivision","mktDiv","region","area","msgTriggeredBy","msgCreationDate"]
    for(i=0;i<14;i++)
         arrFieldsMaster[i] = new Array();
         arrFieldsMaster[0]=arrFieldsMaster1[i];
         arrFieldsMaster[i][1]="Y";
         arrFieldsMaster[i][2]= arrFieldsDesc[i];
    var strChangeFlag = "N";
    var str;
    var tempStr;
    var i;
    var selectedACM = "";
    var selectedMktDiv = "";
    var selectedMktSeg = "";
    var arrBrandArea     = new Array();
    var arrBrandMktSeg     = new Array();
    //Brand Area mapping
    <logic:iterate id="element" collection="<%=hmBrandArea%>" scope="request" indexId="count">
         arrBrandArea[<%=count%>] = new Array();
         arrBrandArea[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str = '<bean:write name="element" property="value"/>';
         if (str.indexOf(",") != -1)
              tempStr=str.split(",");
              for (i = 0; i < tempStr.length; i++) {
                   arrBrandArea[<%=count%>][ i+1 ] = tempStr[i];
         else
              arrBrandArea[<%=count%>][1] = str;
    </logic:iterate>
    //Brand Marketing Segment mapping
    <logic:iterate id="element" collection="<%=hmBrandMktSeg%>" scope="request" indexId="count">
         arrBrandMktSeg[<%=count%>] = new Array();
         arrBrandMktSeg[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str = '<bean:write name="element" property="value"/>';
         if (str.indexOf(",") != -1)
              tempStr=str.split(",");
              for (i = 0; i < tempStr.length; i++) {
                   arrBrandMktSeg[<%=count%>][ i+1 ] = tempStr[i];
         else
              arrBrandMktSeg[<%=count%>][1] = str;
    </logic:iterate>
    //Marketing Division BU mapping
    <logic:iterate id="element" collection="<%=tmMktDivBU%>" scope="request" indexId="count">
         arrMktDivBU[<%=count%>] = new Array();
         arrMktDivBU[<%=count%>][0] = '<bean:write name="element" property="value"/>';
         str = '<bean:write name="element" property="key"/>';
              if (str.indexOf(",") != -1)
                   tempStr=str.split(",");
                   for (i = 0; i < tempStr.length; i++) {
                        arrMktDivBU[<%=count%>][ i+1 ] = tempStr[i];
              else
                   arrMktDivBU[<%=count%>][1] = str;
    </logic:iterate>
    <logic:iterate id="element" collection="<%=tmBU%>" scope="request" indexId="count">
         arrBU[<%=count%>] = new Array();
         arrBU[<%=count%>][0] = '<bean:write name="element" property="value"/>';
         arrBU[<%=count%>][1] = '<bean:write name="element" property="key"/>';
    </logic:iterate>
    <logic:iterate id="element" collection="<%=mktSegMktDiv%>" scope="request" indexId="count">
         arrMktSegMktDiv[<%=count%>] = new Array();
         arrMktSegMktDiv[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         arrMktSegMktDiv[<%=count%>][1] = '<bean:write name="element" property="value"/>';
    </logic:iterate>
    //Region area mapping
    <logic:iterate id="element" collection="<%=hmRegionArea%>" scope="request" indexId="count">
         arrRegionArea[<%=count%>] = new Array();
         arrRegionArea[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str = '<bean:write name="element" property="value"/>';
         if (str.indexOf(",") != -1)
              tempStr=str.split(",");
              for (i = 0; i < tempStr.length; i++) {
                   arrRegionArea[<%=count%>][ i+1 ] = tempStr[i];
         else
              arrRegionArea[<%=count%>][1] = str;
    </logic:iterate>
    <logic:iterate id="element" collection="<%=hmArea%>" scope="request" indexId="count">
         arrArea[<%=count%>] = new Array();
         arrArea[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         arrArea[<%=count%>][1] = '<bean:write name="element" property="value"/>';
    </logic:iterate>
    //Area ACM mapping
    <logic:iterate id="element" collection="<%=hmAreaACM%>" scope="request" indexId="count">
         areaACM[<%=count%>] = new Array();
         areaACM[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str1 = '<bean:write name="element" property="value"/>';
         tempACM=str1.split(",");
         for (i = 0; i < tempACM.length; i++) {
              areaACM[<%=count%>][ i+1 ] = tempACM[i];
    </logic:iterate>
    <logic:iterate id="element" collection="<%=tmACM%>" scope="request" indexId="count">
         arracm[<%=count%>] = new Array();
         arracm[<%=count%>][0] = '<bean:write name="element" property="value"/>';
         arracm[<%=count%>][1] = '<bean:write name="element" property="key"/>';
    </logic:iterate>
    // MktSeg ACM mapping
    <logic:iterate id="element" collection="<%=hmMktSegACM%>" scope="request" indexId="count">
         arrMktSegACM[<%=count%>] = new Array();
         arrMktSegACM[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str3 = '<bean:write name="element" property="value"/>';
         acmTemp=str3.split(",");
         for (i = 0; i < acmTemp.length; i++) {
              arrMktSegACM[<%=count%>][ i+1 ] = acmTemp[i];
    </logic:iterate>
    <logic:iterate id="element" collection="<%=tmACM%>" scope="request" indexId="count">
         acmArray[<%=count%>] = new Array();
         acmArray[<%=count%>][0] = '<bean:write name="element" property="value"/>';
         acmArray[<%=count%>][1] = '<bean:write name="element" property="key"/>';
    </logic:iterate>
    //ACM MktSeg mapping
    <logic:iterate id="element" collection="<%=hmAcmMktSeg%>" scope="request" indexId="count">
         arrAcmMktSeg[<%=count%>] = new Array();
         arrAcmMktSeg[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str2 = '<bean:write name="element" property="value"/>';
         tempMktSeg=str2.split(",");
         for (i = 0; i < tempMktSeg.length; i++) {
              arrAcmMktSeg[<%=count%>][ i+1 ] = tempMktSeg[i];
    </logic:iterate>
    <logic:iterate id="element" collection="<%=mktSeg%>" scope="request" indexId="count">
         arrMktSeg[<%=count%>] = new Array();
         arrMktSeg[<%=count%>][0] = '<bean:write name="element" property="value"/>';
         arrMktSeg[<%=count%>][1] = '<bean:write name="element" property="key"/>';
    </logic:iterate>
    // MktDiv MktSeg mapping
    <logic:iterate id="element" collection="<%=hmMktDivMktSeg%>" scope="request" indexId="count">
         arrMktDivMktSeg[<%=count%>] = new Array();
         arrMktDivMktSeg[<%=count%>][0] = '<bean:write name="element" property="key"/>';
         str3 = '<bean:write name="element" property="value"/>';
         acmTemp=str3.split(",");
         for (i = 0; i < acmTemp.length; i++) {
              arrMktDivMktSeg[<%=count%>][ i+1 ] = acmTemp[i];
    </logic:iterate>
    <logic:iterate id="element" collection="<%=tmMktDiv%>" scope="request" indexId="count">
         arrMktDiv[<%=count%>] = new Array();
         arrMktDiv[<%=count%>][0] = '<bean:write name="element" property="value"/>';
         str = '<bean:write name="element" property="key"/>';
              if (str.indexOf(",") != -1)
                   tempStr=str.split(",");
                   for (i = 0; i < tempStr.length; i++) {
                        arrMktDiv[<%=count%>][ i+1 ] = tempStr[i];
              else
                   arrMktDiv[<%=count%>][1] = str;
    </logic:iterate>
    </SCRIPT>
    </head>
    <body>
    <html:form action="/queryuserPreferences" styleId="UserPreferenceForm" >
    <input type="hidden" name="actionMode" id="actionMode" value = -1>
    <html:hidden property="strCheckOnLoad" styleId = "checkOnLoad"/>
    <input type="hidden" name="actionModeSave" id="actionModeSave" value = "<%=RangingConstants.ACTION_SAVE%>">
    <!--<input type="hidden" name="hdnFlag" id="hdnFlag" value="Y"/> -->
    <DIV id="topBar">
    <TABLE border="0" width="982" cellpadding=0 cellspacing=0>
         <TR height=27>
              <TD width=186><IMG src="<%=RangingConstants.CONTENT_PATH%>/images/logo5.gif" ></TD>
              <TD width=186><IMG src="<%=RangingConstants.CONTENT_PATH%>\images\userpreferences_header.gif"></TD>
              <TD width=635 style="COLOR: white" align=right background ="<%=RangingConstants.CONTENT_PATH%>/images/header_bg.gif">
              Home   |  Logout  </TD>
         </TR>
    </TABLE>
    </DIV>
    <DIV id="topBar_1">
    <TABLE width="100%" align=center border=1 cellpadding=10 cellspacing=0 style="BORDER-BOTTOM-COLOR: #97a2cd; BORDER-LEFT-COLOR: #97a2cd; BORDER-RIGHT-COLOR: #97a2cd; BORDER-TOP-COLOR: #97a2cd ">
         <TR>
              <TD width="100%">
                   <TABLE width="100%" align=center border=0 cellpadding=0 cellspacing=0>
                        <TR class="tableheadings" bgcolor="#cdd3e7">
                             <TD colspan="2" width="100%"><strong>Notification Configuration Preferences</strong></TD>
                        </TR>
                        <TR class="text1">
                             <TD align="left" width="22%"><strong>History Limit for Messages (in Days)</strong></TD>
                             <TD align="left">
                             <html:select styleClass="boxwithborder" styleId="historyCombo" property = "selectedHistoryId" style="HEIGHT: 18px; WIDTH: 100px" onchange="javascript:fnChangeFlag();">
                                  <%
                                            if(strSelectedHistoryDate != null && strSelectedHistoryDate.equals("1"))
                                  %>
                                                 <option value="0">--- select ---</option>
                                                 <Option value="1" selected> 1</Option>
                                                 <Option value="5"> 5</Option>
                                  <%
                                            else if(strSelectedHistoryDate != null && strSelectedHistoryDate.equals("5"))
                                  %>
                                                 <option value="0">--- select ---</option>
                                                 <Option value="1"> 1</Option>
                                                 <Option value="5" selected> 5</Option>
                                  <%
                                            else
                                  %>
                                                 <option value="0">--- select ---</option>
                                                 <Option value="1"> 1</Option>
                                                 <Option value="5"> 5</Option>
                                  <%
    %>
                             </html:select>
                             </TD>
                        </TR>
                        <TR class="tableheadings"><TD colspan="2"><strong>Notification Types</strong></TD></TR>
                   </TABLE>
                   <TABLE width="70%" cellpadding= 0 cellspacing=0 border=0 align="center">
                        <TR class="tableheadings">
                             <TD width="40%" ><CENTER><B><BR>Available Notifications<BR></B></CENTER></TD>
                             <TD width="10%"></TD>
                             <TD width="40%"><CENTER><B><BR>Displayed on Message Screen<BR></B></CENTER></TD>
                             <TD></TD>
                        </TR>
                        <TR>
                   <td>
                             <select styleId ="notificationType" class="selectBoxStyle" name="sel1" multiple="multiple" size= "10" >
                             </select> </td>
                             <TD align= middle style="CURSOR: hand" id="showCell"><IMG id="Right" src="<%=RangingConstants.CONTENT_PATH%>\images\right.gif" onclick="javascript:fnmove(sel1,sel2);fnChangeFlag();" />
    <IMG id="Left" src="<%=RangingConstants.CONTENT_PATH%>\images\left.gif" onclick="javascript:fnmove(sel2,sel1);fnChangeFlag();" />
    </TD>
                             <TD><select class="selectBoxStyle" name="sel2" multiple="multiple" size= "10">
                             </select></TD>
                             <TD align= middle style="CURSOR: hand" id="showCell"><IMG id="Up" src="<%=RangingConstants.CONTENT_PATH%>\images\up.gif" onclick="javascript:fnUp(sel2);fnChangeFlag();" />
    <IMG id="Down" src="<%=RangingConstants.CONTENT_PATH%>\images\down.gif" onclick="javascript:fnDown(sel2);fnChangeFlag();" />
    </TD>
                        </TR>
                   </TABLE>
                   <TABLE>
                        <TR class="tableheadings"><TD><strong>Other Attributes</strong></TD></TR>
                   </TABLE>
                   <TABLE width="70%" cellpadding= 0 cellspacing=0 border=0 align="center">
                        <TR class="tableheadings">
                             <TD width="40%"><CENTER><B><BR>Available Fields<BR></B></CENTER></TD>
                             <TD width="10%"></TD>
                             <TD width="40%"><CENTER><B><BR>Displayed on Message Screen<BR></B></CENTER></TD>
                             <TD></TD>
                        </TR>
                        <TR >
                             <TD>     <select class="selectBoxStyle" name="sel3" multiple="multiple" size= "10">
                                  </select>
                             </TD>
                             <TD align= middle style="CURSOR: hand" id="showCell"><IMG id="Right" src="<%=RangingConstants.CONTENT_PATH%>\images\right.gif" onclick="javascript:fnmoveFields(sel3,sel4);fnChangeFlag();" />
    <IMG id="Left" src="<%=RangingConstants.CONTENT_PATH%>\images\left.gif" onclick="javascript:fnmoveFields(sel4,sel3);fnChangeFlag();" />
    </TD>
                             <TD><select class="selectBoxStyle" name="sel4" multiple="multiple" size= "10" maxlength="50">
                             </select></TD>
                             <TD align="center">  </TD>
                        </TR>
                   </TABLE>
                   <TABLE>
                   <TR> </TR>
                        <TR class="tableheadings"><TD><strong>Seasons Selection for Notifications</strong></TD></TR>
                   </TABLE>
                   <TABLE width="70%" cellpadding= 0 cellspacing=0 border=0 align="center">
                        <TR class="tableheadings">
                             <TD width="40%" ><CENTER><B><BR>Available Seasons<BR></B></CENTER></TD>
                             <TD width="10%"></TD>
                             <TD width="40%"><CENTER><B><BR>Displayed on Message Screen<BR></B></CENTER></TD>
                             <TD></TD>
                        </TR>
                        <TR>
                             <TD>
                             <select styleId ="SeasonPref" class="selectBoxStyle" name="sel5" multiple="multiple" size= "10" >
                             </select> </TD>
                             <TD align= middle style="CURSOR: hand" id="showCell"><IMG id="Right" src="<%=RangingConstants.CONTENT_PATH%>\images\right.gif" onclick="javascript:fnmove(sel5,sel6);fnChangeFlag();" />
    <IMG id="Left" src="<%=RangingConstants.CONTENT_PATH%>\images\left.gif" onclick="javascript:fnmove(sel6,sel5);fnChangeFlag();" />
    </TD>
                             <TD><select class="selectBoxStyle" name="sel6" multiple="multiple" size= "10">
                             </select></TD>
                             <TD align="center">  </TD>
                        </TR>
                   </TABLE>
              </TABLE>
    </DIV>
    <DIV id="topCombo">
         <TABLE width="100%" align=center border=1 cellpadding=10 cellspacing=0 style="BORDER-BOTTOM-COLOR: #97a2cd; BORDER-LEFT-COLOR: #97a2cd; BORDER-RIGHT-COLOR: #97a2cd; BORDER-TOP-COLOR: #97a2cd ">
                   <TABLE width="100%" align=center border=0 cellpadding=0 cellspacing=0>
                        <TR> </TR>
                        <TR class="tableheadings" bgcolor="#cdd3e7">
                             <TD width="100%"><strong>Search Criteria Preferences</strong></TD>
                        </TR>
                   </TABLE>
                   <TABLE width="100%" align=center border=0 cellpadding=0 cellspacing=0>
                        <TR><TD> </TD></TR>
                        <TR>
                             <TD class=tableheadings align=right > Year  </TD>
                             <TD align=left >
                                  <html:select property = "year" styleId="yearCombo" styleClass="boxwithborder" style="HEIGHT: 18px; WIDTH: 200px" onchange="javascript:fnChangeFlag();">
                                       <Option value="-1">-------select-------</Option>
                                  <SCRIPT>
                                       </SCRIPT>
                                  </html:select>
                             </TD>
                             <TD class=tableheadings align=right>       Season  </TD>
                             <TD align=left >
                                  <html:select property="season" styleId="Season" styleClass="boxwithborder" style="HEIGHT: 18px; WIDTH: 200px" onchange="javascript:fnChangeFlag();fnLoadQuarter()">
                             <%
                                       if(strSeason != null && strSeason.equals(RangingConstants.SPRING_SUMMER))
                             %>
                                                      <Option value="-1">-------select-------</Option>
                                                      <Option value="<%=RangingConstants.SPRING_SUMMER%>" selected>Spring/Summer</Option>
                                                      <Option value="<%=RangingConstants.FALL_WINTER%>" >Fall/Winter</Option>
                             <%
                                       else if(strSeason != null && strSeason.equals(RangingConstants.FALL_WINTER))
                             %>
                                                      <Option value="-1">-------select-------</Opt

  • Please offer help on indexing a textbook

    I really need help on an assignment. It is supposed to create an index for a textbook and it has to be implemnted using trees.
    Generate an index for a book.
    The Input:
    The input file is specified as a command-line argument (use args). Be certain to check the validity of the file.
    The input file consists of a set of index entries. Each line consists of the string IX:, followed by an index entry name enclosed in braces, followed by a page number that is enclosed in braces. Each ! in an index entry name represets a sub-level. A |( represents the start of a range and a |) represents the end of the range. Occasionally, this will be the same page, and in that case, only output a single page number. Otherwise, do not collapse or expand ranges on your own. As an example, here's a sample input:
    IX: Series {2}
    IX: {Series!geometric|(} {4}
    IX: {Euler's constant} {4}
    IX: {Series!geometric|)} {4}
    IX: {Series!arithmetic|(} {4}
    IX: {Series!arithmetic|)} {5}
    IX: {Series!harmonic|(} {5}
    IX: {Euler's constant} {5}
    IX: {Series!harmonic|)} {5}
    IX: Series {5}
    The corresponding output is:
    Euler's constant: 4, 5
    Series: 2-5
    arithmetic: 4-5
    geometric: 4
    harmonic: 5
    (1)You must construct a general tree with a root node(the value stored in the root node will just be the word INDEX which should be the first item printed out - this is in addition to the output specification in the text) and its children consisting of top-level index terms, the next level of children consisting of sub -level index terms and so on;
    (2)Each node(except the root) must store the index term and page ranges;
    (3)In the general tree implementation the siblings need to be stored in a certain way so that a certain tree traversal algorithm will print out the index in the correct way.
       import java.io.*;          
    // BinaryTree class; stores a binary tree.
    // CONSTRUCTION: with (a) no parameters or (b) an object to
    //    be placed in the root of a one-element tree.
    // *******************PUBLIC OPERATIONS**********************
    // Various tree traversals, size, height, isEmpty, makeEmpty.
    // Also, the following tricky method:
    // void merge( Object root, BinaryTree t1, BinaryTree t2 )
    //                        --> Construct a new tree
    // *******************ERRORS*********************************
    // Error message printed for illegal merges.
    * BinaryTree class that illustrates the calling of
    * BinaryNode recursive routines and merge.
        public class BinaryTree //extends BinaryNode
          BinaryNode name = new BinaryNode();
           public static void main(String []args)
             String denem = "flag";
             BinaryTree index = new BinaryTree(denem);
             BinaryTree.insert(denem);
             System.out.println(index.infix(denem));
             System.exit(0);
           public BinaryTree( )
             name = null;
           public BinaryTree( String rootItem )
             BinaryNode name = new BinaryNode( rootItem, null, null );
           public void printInOrder( )
             //if( root != null )
             name.printInOrder( );
           public BinaryNode insert(String str, BinaryNode t)
             if(t == null)
                t = new BinaryNode(str, null, null);
             else if(str.compareTo(t.root) < 0)
                t.left = insert(str, t.left);
             else if(str.compareTo(t.root) > 0)
                t.right = insert(str, t.right);     
             return t;
           public BinaryNode insert(String str)
             BinaryNode n = root;
             return insert(str, n);
          // allows the pages to be printed out
           public String toString()
             String concat = name.getRoot();  
             return concat;
           public static void infix(BinaryNode t)     
             if (t != null)
                System.out.print("(");
                infix(t.getLeft());
                System.out.print(t);
                infix(t.getRight());
                System.out.print(")");
       // Class binary node
        final class BinaryNode
          protected String root;    //the name
          protected BinaryNode left;
          protected BinaryNode right;
          //protected String pages;
           public BinaryNode( )
             this( null, null, null); //, null);
           public BinaryNode( String root, BinaryNode left, BinaryNode right) //, String pages )
             root    = this.root;
             left    = this.left;
             right   = this.right;
           //  pages   = this.pages;
          * Return the size of the binary tree rooted at t.
           public static int size( BinaryNode t )
             if( t == null )
                return 0;
             else
                return 1 + size( t.left ) + size( t.right );
          * Return the height of the binary tree rooted at t.
           public static int height( BinaryNode t )
             if( t == null )
                return -1;
             else
                return 1 + Math.max( height( t.left ), height( t.right ) );
          // Print tree rooted at current node using inorder traversal.
           public void printInOrder( )
             if( left != null )
                left.printInOrder( );            // Left
             System.out.println( root );       // Node
             if( right != null )
                right.printInOrder( );          // Right         
           public String getRoot( )
             return root;
           public BinaryNode getLeft( )
             return left;
           public BinaryNode getRight( )
             return right;
           /*public void setElement( Object x )
             element = x;
           public void setLeft( BinaryNode t )
             left = t;
           public void setRight( BinaryNode t )
             right = t;
       } // end of class node
    This is the solution done using linked lists and treemap.
       import java.io.*;                         // to read the file
      A red-black tree is a binary search tree where every node has two children or is a leaf.
      It ensures O(log N) search times, at a cost of a more complicated insertion (and deletion)
      process. In a red-black tree, every node is colored either red or black, with a black root
      node, though a black root node isn't a requirement. In addition, if a node is red, its
      children must be black and every path from root to leaf (or null child node) must
      contain the same number of black nodes. These rules allow balancing
       import java.util.TreeMap;
       import java.util.Comparator;
       import java.util.StringTokenizer;
       public interface Iterator An iterator over a collection. Iterator takes the place of
       Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:
       Iterators allow the caller to remove elements from the underlying collection during the iteration
       with well-defined semantics.
       import java.util.Iterator;
       import java.util.LinkedList;
       import java.util.ArrayList;
        public class IndexGenerator3
          private static final String START    = "|(";
          private static final String END      = "|)";
          private static final String SUBTOPIC = "!";
          private static final char SUBTOP= SUBTOPIC.charAt(0);
            private static final String INPUT = "hw3.in";     
          //private static final String INPUT = "input.txt";
           private static class Section
             public String name;
             public int start = -1;
             public int end = -1;
             //public int page;
        private LinkedList pages = new LinkedList();
             //constructor
              public Section(String name, int start, int end, int page)
                this.name = name;
                this.start = start;
                this.end = end;
                if(page >= 0) //this is for error checking
                   addPage(page);
              public void addPage(int page)
                pages.add(new Integer(page));
              public boolean isValid()
                return (start >= 0 && end >= 0 && pages.size() == 0) || pages.size() > 0;
          // allows the pages to be printed out
              public String toString()
                String concat = "";
                String szName = name;
                while(name.indexOf(SUBTOPIC) >= 0)      // returns tbe index of the first occurrence of the character. it takes a string or character as input parameter
                   concat += " ";
                   name = name.substring(name.indexOf(SUBTOPIC) +1);
                } //end of while
                concat += name + ": ";
                if (start >= 0)
                   concat += String.valueOf(start);
                   if (end >= 0 && end != start)
                      concat += "-" +end;
                else if (end >= 0)
                   concat += String.valueOf(end);
                else
                   Iterator iterator = pages.iterator();
                   while (iterator.hasNext())
                      concat += iterator.next() + ", ";
                   if (end < concat.length())
                      concat= concat.substring(0, concat.length()-2);
                return concat;
           public static void main(String[] args)
             try
                FileReader fr = new FileReader(INPUT);
                BufferedReader inFile = new BufferedReader(fr);
                TreeMap map = new TreeMap(
                       new Comparator()
                          public int compare(Object o1, Object o2)
                            String s1= (String) o1;
                            String s2= (String) o2;
                            s1.replace(SUBTOP, ' ');
                            s2.replace(SUBTOP, ' ');
                            s1.toLowerCase();
                            s2.toLowerCase();
                            return s1.compareTo(s2);
                            //return s1.compareToIgnoreCase(s2);     //Compares two strings lexicographically, ignoring case considerations.
                          public boolean equals(Object obj)
                            return false;
                String line = null;
                for (int i = 0; (line = inFile.readLine()) != null; i++)
                   StringTokenizer st = new StringTokenizer(line, "{}");
                   //if (st.countTokens() != 4)
                      //System.err.println("Error, Please correct: '" +line +"'");
                      //continue;
                   st.nextToken();
                   String name= st.nextToken();
                   st.nextToken();
                   String szPage= st.nextToken();
                   int start= -1;
                   int end= -1;
                   int page= -1;
                   if (name.endsWith(START))
                      name= name.substring(0, name.length() -START.length());
                      start= Integer.parseInt(szPage);
                   else if (name.endsWith(END))  //string built in function endsWith()
                      name= name.substring(0, name.length() - END.length());
                      end= Integer.parseInt(szPage);
                   else
                      page = Integer.parseInt(szPage); //convet the string into integers
                   Section section = (Section) map.get(name); //???????????
                   if (section == null)    //if object section is null, create new section object and initialize
                      section = new Section(name, start, end, page); //start cannot be omitted
                      map.put(name, section);
                   else if (start >= 0)   //if more pages under
                      section.start= start;
                   else if (end >= 0)   //if more pages under same heading are found
                      section.end = end;  // overwrite ???
                   else if (page >= 0)     //if there are more pages under the same heading add a page. euler s constant
                      section.addPage(page);
                fr.close();                //close the input stream
                System.out.println("\nIndex:");
                ArrayList invalid= new ArrayList(); // prevents marginal occurences of repetitive header lines
                Iterator sections= map.values().iterator();
                while (sections.hasNext())
                   Section section= (Section) sections.next();
                   if (section.isValid())
                      System.out.println(" " + section);
                   else
                      invalid.add(section);
                 catch(FileNotFoundException exception)
                { System.err.println("File not found"); }
                 catch (IOException exception)
                { System.out.println(exception); }
          }// end of main
       //     public void
       }  // end of class index generator
       I'm even offering the buy the program to make it more proffessional...the payment is as much duke dollars as i can give...We can also negotiate on e bay using real dollars, but the assignemtn is due tonite and i don t have much time... If someone will most kindly take a look, i will be greatly indebted and humbled...isn t there anyone on this site who actually loves solving this kinda stuff?

    actually, your solution was how I found about this forum. go to google,
    type in "index a textbook" + java, the forum pops up. Your solution has helped me a lot, I based my assignment on yours, just look at my main file. The difference was, I had to use a tree. That was more confusing than a linked list.

  • Off Topic: Hidden Features of Java

    Happy Friday everyone,
    I stumbled upon this conversation on Stack Overflow last night about "hidden" features of Java. Although I knew about most of them (mostly learned from reading posts here in the past few months), thinking about less-often used features of the language is a fun refresher (at least for me).
    Can anybody think of any more "hidden" features of Java? Or just something interesting that not many people are familiar with?
    Here's the link: [http://stackoverflow.com/questions/15496/hidden-features-of-java|http://stackoverflow.com/questions/15496/hidden-features-of-java]
    Edit- To make things a bit more interesting, I'll throw some Dukes at people who show me interesting things.
    Edited by: kevinaworkman on Nov 13, 2009 7:56 AM

    dcminter wrote:
    Here's one I banged my shins on the other day. Comparator may change Set semantics:It's always bothered me that TreeSet relies on Comparator to define equality.
    Note that the ordering maintained by a set (whether or not an explicit comparator is provided) must be consistent with equals if it is to correctly implement the Set interface. It bugs me because it's not an explicit requirement of Comparable or Comparable. Therefore, if I did:
    set.add("Hello");
    System.out.println(set.contains("World"));I would expect false to be printed (in other words, like HashSet, I would expect it to do a final equals() to make sure). But it's not.
    However, in your example, it's easy to see why TreeSet could not possibly allow that. If you added 2 Objects that were comparatively equal, it would be impossible to traverse the tree to find anything.

Maybe you are looking for