Fill and object array

I have too many books and not enough understanding on this subject.
I am trying to fill an object type array with values and am totally confused. In my application, I successfully create a constructor in one file and test the object with some values in another file. I have two objects for employee and would like to place the object values into an object array. There is plenty of information on int[] arrays, but little on object arrays.
After I can do the array fill:
I would like to provide object values with JOptionPane.
Change the print display to show all array elements
But one thing at a time.
I was thinking that objects exist first, then are loaded or filled into an object array. I seem to misunderstand as I am not performing the array fill very well. Following a book example seems to confuse me only more.
Thank you
//emp.java
import java.util.*;
public class Emp {
   private int id;
   private String name;
   private double salary;
   public Emp(int ident, String nm, double sal) {
     id = ident;
     name = nm;
     salary = sal;
   // method raise salary by 5 percent
   double raise() { return salary * 1.05;} // ends raise method
   // setters and getters
   public String getName()              { return(name); }
   public double getSalary()            { return(salary); }
   public int getID()                   { return(id); }
   public void setName(String nm)       { name = nm; }
   public void setSalary(double sal)    { salary = sal; }
   public void setID(int ident)         { id = ident; }
}The test file
//EmpTest.java
import javax.swing.JOptionPane;
public class EmpTest {
   public static void main(String[] args_) {
             // Create object based on EmployeeTest2 class
             // to add employee data to the array called empArray
             Emp emp1 = new Emp(1,"Smith",2000);
             Emp emp2 = new Emp(2,"Jones",2500);
             //test and confirm the objects emp1 and emp2
                 int i;
                 String n;
                 double s;
                 double newsal;
                 // get the salary after the 5 percent raise
                 i = emp1.getID();
                 n = emp1.getName();
                 s = emp1.getSalary();
                 newsal = emp1.raise();
                 System.out.println("object Employee 1 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: " + newsal);
                 i = emp2.getID();
                 n = emp2.getName();
                 s = emp2.getSalary();
                 newsal = emp2.raise();
                 System.out.println("object Employee 2 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: " + newsal);
     // get the number of employees with JOptionPane
     String employeeCountString = JOptionPane.showInputDialog(
         "Employee Database " +
         "\nEnter the number of employees: ");
     // convert into an integer empcount
     int employeeCount = Integer.parseInt(employeeCountString);
     // initialize the empArray.
     Employee2[] empArray = new Employee2[employeeCount];
     fill(empArray);
     printContents(empArray);
   } //end main method
   private static void fill(Object[] my_arr) {
       int i;
       for (i = 0; i < my_arr.length; i = i + 1) {
     // get the name from the keyboard
     String employeeName = JOptionPane.showInputDialog(
         "Enter the employee name: ");
         // do something here to set the array element to employeeName
     // get the salary
     String employeeSalaryString = JOptionPane.showInputDialog(
         "Enter the employee monthly salary: ");
     //convert into a double
     double employeeSalary = Double.parseDouble(employeeSalaryString);
        //do something here to set array for salary
          my_arr[i] = new Employee2(1,"S1",5); // temporary values here
       } //ends for loop
   } // ends method
   private static void printContents(Object[] the_arr) {
      int i;
      for (i = 0; i < the_arr.length; i = i + 1) {
        System.out.print("Element: " + i);
        //System.out.println(" has the value : " + the_arr);
System.out.println(" has the value : " + i);
} //ends for loop
} // ends printContents method
} // ends EmpTest class

what's the matter ?
Try this :
import javax.swing.JOptionPane;
public class EmpTest {
     public static void main(String[] args_) {
          // Create object based on EmployeeTest2 class
          // to add employee data to the array called empArray
          Emp emp1 = new Emp(1, "Smith", 2000);
          Emp emp2 = new Emp(2, "Jones", 2500);
          // test and confirm the objects emp1 and emp2
          int i;
          String n;
          double s;
          double newsal;
          // get the salary after the 5 percent raise
          i = emp1.getID();
          n = emp1.getName();
          s = emp1.getSalary();
          newsal = emp1.raise();
          System.out.println("object Employee 1 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: "
                    + newsal);
          i = emp2.getID();
          n = emp2.getName();
          s = emp2.getSalary();
          newsal = emp2.raise();
          System.out.println("object Employee 2 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: "
                    + newsal);
          // get the number of employees with JOptionPane
          String employeeCountString = JOptionPane.showInputDialog("Employee Database "
                    + "\nEnter the number of employees: ");
          // convert into an integer empcount
          int employeeCount = Integer.parseInt(employeeCountString);
          // initialize the empArray.
          Emp[] empArray = new Emp[employeeCount];
          fill(empArray);
          printContents(empArray);
     } // end main method
     private static void fill(Object[] my_arr) {
          int i;
          for (i = 0; i < my_arr.length; i = i + 1) {
               // get the name from the keyboard
               String employeeName = JOptionPane.showInputDialog("Enter the employee name: ");
               // do something here to set the array element to employeeName
               // get the salary
               String employeeSalaryString = JOptionPane.showInputDialog("Enter the employee monthly salary: ");
               // convert into a double
               double employeeSalary = Double.parseDouble(employeeSalaryString);
               // do something here to set array for salary
               my_arr[i] = new Emp(1, employeeName, employeeSalary); // temporary values here
          } // ends for loop
     } // ends method
     private static void printContents(Object[] the_arr) {
          int i;
          for (i = 0; i < the_arr.length; i++) {
               System.out.print("Element # "+i+" Name= "+ ((Emp)the_arr).getName());
               System.out.print("Salary # "+i+" Salary = "+ ((Emp)the_arr[i]).getSalary());
          } // ends for loop
     } // ends printContents method
} // ends EmpTest class

Similar Messages

  • Sort and Object array of Arrays

    Hi,
    I have an object array that contains a String[] and an int[].
    Object[String[], int[]]
    The values in the Strings array must be in the same position in the array as those in the int array i.e
    String [0] is the string representation of int[0].
    Its for a bar chart.
    That is all working beautifully.
    Now however I want to sort the int array in descending order by the value of the ints in the array and thus the order or the String array has to mirror this.
    I am using a comparator to do this but it just wont work. I'm sure this is the way but how should it look?
    Has anybody got any ideas?
    Thanks in advance,
    L.

    use the bubblesort:
        for (int i = a.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (a[j][1] > a[j+1][1]) {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
        }

  • Object array

    what do i have to do to create and object array in a class of other class. i tried to created an object of that class first and the create the array by the compiler complains that there is a problem. here is the code.
    classJTBar---------------------------------------------------
    ackage JTShapes;
    import java.awt.*;
    public class JTBar extends JTFilledRectangle{
         int height=20; int length=0;//i will use the inheritated methods
         public JTBar(){//contructor that will be called on creating object
    setHeight(20);//method of class JTRectangle
    setWidth(0);//method of class JTRectangle
         public void setLengh (int x){
              length = x;
         public void incLengh(int y){
              length = length+y;
    }//end class     
    User class
    port JTShapes.*;
    import JTUtils.*;
    import javax.swing.*;
    public class User extends JTUser{
         public void begin(){
    JTBar jtbarobject= new JTBar();
         JTBar[] arrayObj= new JTBar[8];
         String[] weekDay= {"Monday", "Tuesday", "Wednesday", "Thuersday",
         "Friday", "Saturday", "Sunday"};

    You don't have to do this:
    String[] weekDay = new String[]{"Monday", "Tuesday", "Wednesday", "Thuersday", "Friday", "Saturday", "Sunday"};
    This works fine:
    String[] weekDay= {"Monday", "Tuesday", "Wednesday", "Thuersday", "Friday", "Saturday", "Sunday"};
    What kind of Exception are you getting? I'm guessing you're getting a NullPointerException?
    Looks like you're declaring your array correctly, but you are not initializing it:
    JTBar[] arrayObj= new JTBar[8];
    for (int i = 0; i < arrayObj.length; i++) {
    arrayObj[i] = new JTBar();
    }

  • Object Array --- Collection

    Is there any way to directly convert and object Array to a Collection object. Basically i need to create a ArrayList from Object Array. The ArrayList has a constructor and also provides a method addAll() that accept Collection as parameter. So the problem becomes , how to convert Object Array to collection. As per my understanding all arrays should be essentially Collection Interface subclass.
    So why am i not able to cast?
    What is wrong in calling Object Array a sub class of Collection?
    // OrderLineItem[] is the object array that i wish to have as ArrayList
    // This code generates error -
    //"ErpOrder.java": Error #: 364 : cannot cast gal.ERP.OrderLineItem[] to java.util.Collection
      public void setLineItems( OrderLineItem[] arrOrderLineItem ) {
        m_arrLineItems = new ArrayList((Collection)arrOrderLineItem);
      }Is there no way except iterating through the array and adding individual Objects to ArrayList?

    By "Object array" do you mean an Array class, or do you mean an Object[]? They are different. The Array class wraps an Object[] and provides useful methods to manipulate it.
    There is no such thing as a Collection object, per say. "Collection" is an interface implemented by many objects such as LinkedList, Vector, ArrayList, HashSet, and TreeSet.
    The Collection interface is designed to be an interface to any object that can keep a mutable list of other Objects, check to see if an Object is in that list, and iterate through all Objects in the list.
    As far as resources go, I suggest the API reference at http://java.sun.com/j2se/1.4.1/docs/api/index.html.

  • Fill the 'Objects and Attachments ' in Decision step with milestone detils

    My requirement is to fill the 'Objects and Attachments ' in Decision step with a display milestone details as seen in cj20n transactiobn.
    I am using business object MLST_NETW but display method does not show detsils of milestone .
    is there any other way i could  possibly show th emilestone detsils as seen in cj20n transction.

    Yes th ebinding is correctly done when I chcek in SBWP for that item it displays the link with the milestone no and when i cleck on the link it asks me the milstone no also but it does not display any detils of milestone or does not navigate to th emilestone page.
    I tried testing the display method of the stnadard business object MLST_NETW independly but i see even here the milestone detils page not appearing .Is there some other bO which has to be used or some way through which i colud navigate to the milestone detsils page transaction is CJ20n

  • Can�t open array and object manager

    Hello,
    i�ve done a fresh install of SGD 4 on Fedora Core 3.
    Here I am not able to open array and object manager. I see them running in
    the webtop but get no display.
    I get the following logs:
    in wm_errors: X connection to unix:10.0 broken (explicit kill or server
    shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:12.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    ..skipping...
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:12.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    ~
    and in error.log
    2005/03/01 18:31:54.951 (pid 20049) pem/circuit #0
    Tarantella Secure Global Desktop Enterprise Edition(4.0) ERROR:
    An error occurred reading on circuit fdcircuit. Reason: (9) Bad file
    descriptor.
    The current operation has failed.
    If persistent, restart the server.
    Restarting the server doesn�t help.
    I�ve also set the xscecurity flag to 0.
    This all works fine with Fedora Core 2
    Anyone any Idea?
    Thanks a lot

    Hi Matthias,
    I had similar problems with (local) X apps.
    via ssh, and I mean they arose with tta vers.
    3.42. The problem seems to appear, because
    both tta and ssh (with X forwarding) are
    using a X-display range from :10 upward.
    So, one simply can resolve this by using a different X-display offset for
    ssh, by setting:
    X11DisplayOffset 100
    (for exsample) in sshd_config.
    Then tta still uses displays :10, :11, ...
    but ssh is using :100, :101, ...,
    (assuming that 90 X/RDP emulator-session are enough in this installation!)
    Don't forget to send a SIGHUP to the master
    sshd after changing sshd_config, telling
    'him' to re-read it's config-file.
    One can verify the effect, by calling
    'ssh localhost' and executing: echo $DISPLAY
    this should give something like:
    localhost:100.0
    Kind regards,
    Tankred
    Matthias wrote:
    Hello,
    not all login authorities are disabled. I have only NT auth. enabled. This
    works fine in EE 3.40 on RH 9 and on SGD4.0 on Fedora Core 2. But seems
    not to run on Fedora Core 3.
    Matthias
    Carmelo wrote:
    Mattias,>>
    >
    http://www.tarantella.com/support/documentation/sgd/ee/4.0/help/en-us/base/indepth/disabled_all_login_authorities.html
    Regards,
    Matthias wrote:
    I think I�ve fixed it.
    I just edited ssh_conf and enabled X11forwarding and it works for me.
    But now I have changed the login authority only to NT auth. and I am no
    longer able to log in to tarantella....
    Matthias wrote:
    Hello,
    i�ve done a fresh install of SGD 4 on Fedora Core 3.
    Here I am not able to open array and object manager. I see them running
    in
    the webtop but get no display.
    I get the following logs:
    in wm_errors: X connection to unix:10.0 broken (explicit kill or server
    shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:12.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    ...skipping...
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    X connection to unix:12.0 broken (explicit kill or server shutdown).
    X connection to unix:10.0 broken (explicit kill or server shutdown).
    ~
    and in error.log
    2005/03/01 18:31:54.951 (pid 20049) pem/circuit #0
    Tarantella Secure Global Desktop Enterprise Edition(4.0) ERROR:
    An error occurred reading on circuit fdcircuit. Reason: (9) Bad file
    descriptor.
    The current operation has failed.
    If persistent, restart the server.
    Restarting the server doesn�t help.
    I�ve also set the xscecurity flag to 0.
    This all works fine with Fedora Core 2
    Anyone any Idea?
    Thanks a lot

  • Has anyone experienced Labview 8.2 crashing when attempting wire a cluster filled with object and task references?

    I am getting a complete shutdown (crash) of Labview 8.2 when placing the wiring tool over a cluster that is filled with task and object references.  The crash occurs on all computers I have attempted it on and happens throughout all VIs in all classes that distribute multiple references throughout the VI using a cluster.  The entire project I am developing is programmed in GOOP.  Has anyone experienced anything like this?  I have provided a screen shot of the place where the crash is generated.  Let me know if anyone has any insights. 
    B
    Attachments:
    LV screenshot.JPG ‏156 KB

    There are several known crashes with LVClasses. One of the easiest
    fixes is to load your application into memory and then hit
    ctrl+shift+click on the Run arrow of your top-level VI. Then do
    File>>Save All. You might also try selecting that wire (with the
    selection tool -- use the Tools Palette to explicitly select a tool
    other than wiring) and deleting it and then rewiring those terminals.

  • Abstract  object array  initialization

    Hi everybody!
    I have a question, I know you can help me.
    I created an abstract class called publication, and two other clases called Tape and Book that derive from the publication class. Now, in the application I have :
    Publication BookTape[];
    when I compile my program I have one error which is that I haven't initialize the BookTape[] object array. My question is How I can initialize an object that comes from an abstract class? could you help me?
    Thank you !!!

    Publication bookTapes[] = new Publication[10];That will create your array (note, this has nothing to do with instantiating abstract classes).
    If you actually want to have something in your array, you need to fill it with subclasses of Publication since it's an abstract class.
    So.
    for(int i = 0;i < bookTapes.length;i++)
       bookTapes[i] = new SubclassOfPublication();

  • Table with object array data provider

    hi!
    i use the studio creator table and want to fill it with an object array data provider!
    i have an array and the getter:
      public TanData[] getTanDataArray()
            return tanDataArray;    
        }i choosed this for the data provider and in table layout i choose the dataprovider, but when i run my application there are no datas found although the array isn't empty!

    maybe this is a problem:
    i got my data from a database table and i store it in a vector.
    in the example they have a class WeekBean and they fill their array with
       WeekBean[] weeks = {
                new WeekBean(1),
                new WeekBean(2),
                new WeekBean(3),
                new WeekBean(4)
            };and i tried to do this:
        private Vector<TanData> tanDataList = new Vector();
        private TanData[] tanDataArray;
       getTanDataList().copyInto(tanDataArray);could it be that that isn't correct?

  • Returning an Object Array

    I am unable to figure out the way in which I can return an object
    array from a cpp file to java. Is there any obvious error which you can spot in
    my CPP file?
    When I try to return a single object in the native function,
    it works fine but when I try to extend it and return an array of the object, it
    throws an error.
    Please find below the details
    h1. Java Class
    public class Flight {
    public String ID;
    public class InterfaceClass {
    private native Flight[] GetFlights();
    public static void main(String[] args)
    Flight[] objFlight = new
    InterfaceClass().GetFlights();
    System.+out+.println(objFlight[0].ID);
    static {
    System.+loadLibrary+("main");
    h1. CPP File
    JNIEXPORT jobjectArray JNICALL Java_InterfaceClass_GetFlights(JNIEnv env, jobject obj)
    //1. ACCESSING THE FLIGHT CLASS
    jclass cls_Flight = env->FindClass("LFlight;");
    //2. CONSTRUCTOR FOR FLIGHT CLASS
    jmethodID mid_Flight = env->GetMethodID(cls_Flight,"<init>", "()V");
    //3. CREATING AN OBJECT OF THE FLIGHT CLASS
    jobject objFlight = env->NewObject(cls_Flight, mid_Flight);
    //4. ACCESSING THE FLIGHT's "ID" FIELD
    jfieldID fid_ID = env->GetFieldID(cls_Flight, "ID","Ljava/lang/String;");
    //5. SETTING THE VALUE TO THE FLIGHT's "ID" FIELD
    env->SetObjectField(objFlight,fid_ID, env->NewStringUTF("ABC"));
    //6. ACCESSING THE FLIGHT ARRAY CLASS
    jclass cls_Flight_Array = env->FindClass("[LFlight;");
    if(cls_Flight_Array == NULL)
    printf("Error-1");
    //7. CREATING A NEW FLIGHT ARRAY OF SIZE 1 jobjectArray arrFlightArray = env->NewObjectArray(1,cls_Flight_Array,NULL);
    if(arrFlightArray == NULL)
    printf("Error-2");
    //8. INSERTING A FLIGHT BJECT TO THE ARRAY
    env->SetObjectArrayElement(arrFlightArray,0,objFlight);
    return arrFlightArray;
    h1. Error
    # A fatal error has been detected by the Java Runtime Environment:
    # EXCEPTION_ACCESS_VIOLATION
    (0xc0000005) at pc=0x6d9068d8, pid=1804, tid=3836
    # JRE version: 6.0_18-b07
    # Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode, sharing
    windows-x86
    # Problematic frame:
    # V [jvm.dll+0x1068d8]
    # An error report file with more information is saved as:
    # C:\Users\Amrish\Workspace\JNI Test\bin\hs_err_pid1804.log
    # If you would like to submit a bug report, please visit:
    http://java.sun.com/webapps/bugreport/crash.jsp
    C:\Users\Amrish\Workspace\JNI Test\bin>java -Djava.library.path=.
    InterfaceClass
    Exception in thread "main" java.lang.ArrayStoreException
    at
    InterfaceClass.GetFlights(Native Method)
    at
    InterfaceClass.main(InterfaceClass.java:6)
    C:\Users\Amrish\Workspace\JNI Test\bin>java -Djava.library.path=.
    InterfaceClass
    Exception in thread "main" java.lang.ArrayStoreException
    at
    InterfaceClass.GetFlights(Native Method)
    at
    InterfaceClass.main(InterfaceClass.java:6)
    Edited by: amrish_deep on Mar 18, 2010 7:40 PM
    Edited by: amrish_deep on Mar 18, 2010 7:40 PM

    //6. ACCESSING THE FLIGHT ARRAY CLASS
    jclass cls_Flight_Array = env->FindClass("[LFlight;");The argument to NewObjectArray is the +element+ class of the array you're about to create, not the +array+ class itself.

  • Multiple fill blank objects on one question slide?

    Hellou CP users, is it possible to put multiple fill blank objects on one question slide? And if, how can I manage them for quiz reporting and correct results?
    Yarik

    I think indeed that you want a score for each fill-in-the-blank object, and that is not possible with the default FIB question slides. Only MCQ has partial scoring.
    With TEB's and advanced actions that is possible. Also with the TextArea widget, as I explained in this blog post:
    http://blog.lilybiri.com/widgets-and-custom-questions-part-2
    http://blog.lilybiri.com/extended-textarea-widget-more-functionality
    TEB's have the advantage that as interactive objects, you can attach a score to them which is not the case for the TextArea widgets. But I would recommend getting Jim Leichliter's enhanced version of the TEB's as well, so that you can control what is shown in the TEB if you want to create a question with multiple attempts. I have described a use case recently in these forums but cannot remember exactly which thread. Jim's widget is free:
    http://captivatedev.com/2012/09/16/adobe-captivate-6-x-free-widget-text-entry-box-with-var iables/

  • Java Null Pointer Exception when assigning a value to an Object Array

    I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
    I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. I get the following error: Exception during processing: java.lang.NullPointerException
    Any assistance would be greatly appreciated.
    Here's my class:
    public class ComparatorBO  implements Comparable {
         private SingleOwnerRequestNodeDetail nodeDetailInfo;
         private int orderNbr;
         public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
              return nodeDetailInfo;
         public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
              this.nodeDetailInfo = nodeDetailInfo;
         public int getOrderNbr() {
              return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
         public void setOrderNbr (int orderNbr) {
              this.orderNbr = orderNbr;
         public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
              if (!(anotherNodeDetailInfo instanceof ComparatorBO))
                   throw new ClassCastException ("An single owner request node detail object is expected");
              int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
              return this.orderNbr - anotherNodeDetailOrderNbr;
    }Here's the code where I read in the objects and attempt to place them in the comparableBO[]
    ComparatorBO[] comparatorBOArray = null;
    comparatorBOArray = new ComparatorBO[requestInfo.length];
              for (int i=0; i < requestInfo.length; i++)
                   SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
                   ComparatorBO comparatorBO = new ComparatorBO();
                   nodes.setSingleOwnerRequestNodeID(requestInfo.getSingleOwnerRequestNodeID());
                   nodes.setSingleOwnerRequestNodeType(requestInfo[i].getSingleOwnerRequestNodeType());
                   nodes.setSingleOwnerRequestOpCode(requestInfo[i].getSingleOwnerRequestOpCode());
                   nodes.setSingleOwnerRequestOrderNbr(requestInfo[i].getSingleOwnerRequestOrderNbr());
                   comparatorBO.setNodeDetailInfo(nodes);                         
                   *comparatorBOArray[i].setNodeDetailInfo(comparatorBO.getNodeDetailInfo());*
                   comparatorBOArray[i].setOrderNbr(Integer.parseInt(nodes.getSingleOwnerRequestOrderNbr()));

    imadeveloper wrote:
    I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
    I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. I get the following error: Exception during processing: java.lang.NullPointerException
    Any assistance would be greatly appreciated.
    Here's my class:
    public class ComparatorBO  implements Comparable {
         private SingleOwnerRequestNodeDetail nodeDetailInfo;
         private int orderNbr;
         public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
              return nodeDetailInfo;
         public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
              this.nodeDetailInfo = nodeDetailInfo;
         public int getOrderNbr() {
              return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
         public void setOrderNbr (int orderNbr) {
              this.orderNbr = orderNbr;
         public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
              if (!(anotherNodeDetailInfo instanceof ComparatorBO))
                   throw new ClassCastException ("An single owner request node detail object is expected");
              int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
              return this.orderNbr - anotherNodeDetailOrderNbr;
    }Here's the code where I read in the objects and attempt to place them in the comparableBO[]
    ComparatorBO[] comparatorBOArray = null;
    comparatorBOArray = new ComparatorBO[requestInfo.length];
              for (int i=0; i < requestInfo.length; i++)
                   SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
                   ComparatorBO comparatorBO = new ComparatorBO();
                   nodes.setSingleOwnerRequestNodeID(requestInfo.getSingleOwnerRequestNodeID());
                   nodes.setSingleOwnerRequestNodeType(requestInfo[i].getSingleOwnerRequestNodeType());
                   nodes.setSingleOwnerRequestOpCode(requestInfo[i].getSingleOwnerRequestOpCode());
                   nodes.setSingleOwnerRequestOrderNbr(requestInfo[i].getSingleOwnerRequestOrderNbr());
                   comparatorBO.setNodeDetailInfo(nodes);                         
                   *comparatorBOArray[i].setNodeDetailInfo(comparatorBO.getNodeDetailInfo());*
                   comparatorBOArray[i].setOrderNbr(Integer.parseInt(nodes.getSingleOwnerRequestOrderNbr()));
    Well normally when someone wont tell me what line the error occured in I copy paste their code into my compiler and find out. But you have other classes which you have not shown us so I cannot help you.
    Incase you missed my point, please tell us where the error occured!

  • Calling a method that returns an object Array

    Hello.
    During a JNICALL , I wish to call a method which returns an object array.
    ie my java class has a method of the form
    public MyObject[] getSomeObjects(String aString){
    MyObject[] theObjects=new MyObject[10];
    return theObjects
    Is there an equivalent to (env)->CallObjectMethod(...
    which returns a jobjectArray instead of a jobject, and if not could somebody suggest a way around this.
    Thanks,
    Neil

    I believe an array oj jobjects is also a jobject. You can then cast it to another class.

  • Object Array problem in Websphere WebServices

    Hi,
    Can someone help me out with a situation that I am stuck with in WebServices.
    I have a WebService which returns a DTO which has a getter and setter for an array of another type of DTO object.
    Sample:-
    public class MyDTO extends AnotherDTO implements Serializable {
    private InnerDTO qcDtoList[] = new InnerDTO[0];
    public MyDTO() {
    public InnerDTO[] getQcDtoList() {
    return qcDtoList;
    public void setQcDtoList(InnerDTO[] resEDXDTOs) {
    qcDtoList = resEDXDTOs;
    But when I generate the WSDL for the webservice using WSAD 5.1 that uses the above DTO, the server side generated skeleton file looks like:-
    public class MyDTO extends AnotherDTO implements java.io.Serializable {
    private InnerDTO[] qcDtoList;
    public MyDTO() {
    public InnerDTO[] getQcDtoList() {
    return qcDtoList;
    public void setQcDtoList(InnerDTO[] qcDtoList) {
    this.qcDtoList = qcDtoList;
    As you can see from above, my initialization info is not available in the generated skeleton. I also tried putting the initialization in the constructor, with no effect.
    What could be the reason for this? And is it possible to initialize my InnerDTO without losing it in the generated skeleton?
    I simply want to initialize the object array.
    If I need to modify my WSDL, what additional annotations should I add on the WSDL to get the desired effect?
    I use WSAD's (Websphere Studio App Developer) IBM Websphere Webservices protocol and the JDK version is 1.3.1 and WSAD version is 5.1.
    I would really appreciate if you can throw light on this?
    Thanx and Regds,
    Prashanth.

    Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array entered
    v_term = Keyword entered
    rs = Result Set
    TYPE tbl_integer IS TABLE OF INTEGER;
    tbl_cat tbl_integer;
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

  • Text filled with objects

    Illustrator
    can anybody help me in this?
    let say we need some text like " CIRCLE" and it should be filled with small circles (Like below) but not clipping mask mean the object should not flash cut on the edge of characters.
    is there any effect, or we need to do it manually?

    Sajid,
    Here is a(nother) way to get a nice and orderly distribution of dots (that do not touch one another). It may be further optimized, beyond what is shown.
    You may (specifics applying to an S):
    1) Create the lettershape or Type>Create Outlines from an existing live Type letter;
    2) If needed (starting with live Type), change from Fill to Stroke and delete the end segments;
    3) If needed (starting with live Type), Ungroup and Object>Compound Path Release and possibly reverse either path so both have the same direction, see below;
    With only the outer paths (which should have matching Anchor Points),
    4) Object>Blend>Options, with Specified Steps set to the number of inner paths (2 in the case shown), and Orientation>Align to path;
    5) Object>Blend>Make
    6) In the Stroke palette, set the Stroke Weight to the desired dot thickness, set Cap>Round Cap, and tick Dashed Line with Dash = 0 and Gap = Stroke Weight+desired gap between dots, corresponding to the gap between the rows of dots;
    7) If needed, adjust the Dashes to fit, inbuilt (in the options) in the newest version, in older versions, you may use the free Adjust Dashes script avaialble here:
    http://park12.wakwak.com/~shp/lc/et/en_aics_script.html
    Below is shown an S in Helvetica Bold at 144pt, with Stroke Weight = 12pt and Gap = 15pt (before adjustment). It may be further optimized.
    To reverse the direction of a path, you may select the path and:
    A) Object>Compound Path>Make;
    B) In the Attributes palette tick Reverse Path Direction On;
    C) Object>Compound Path>Release.
    You can see whether it is needed when you make the blend; if it is messy, reverse either path.
    You can also see the path directions by Effect>Stylize>Add Arrowheads; they should be at the same end.

Maybe you are looking for

  • Table does not exist in system after DB Connect

    Hi Everyone, I must extract data from a oracle db.  I create a source system with DB Connect and it's connect successful. Later, i create a datasource for that source system. but it show the table does not exist in system. I'm sure the table is corre

  • MB Pro only recognizes monitor as TV?

    Hello everyone, So I've been doing ALOT of research on how to get my new samsung p2370 monitor to look its best hooked up to my MB Pro. I just have one question. I've noticed allot of people online have said to make sure color is set to "millions". W

  • CF9.0.1 - Updating 32-bit JRE on 64-bit Windows

    Hi all, Based on this security alert (http://kb2.adobe.com/cps/894/cpsid_89440.html), I am looking to upgrade my CF 9.0.1 install from the default JRE 1.6_17 to 1.6_24. On my Windows 7 64 / CF9.0.1 64 development system I simply downloaded the 64-bit

  • What's with the blue screen.....

    Ok so I went to turn my laptop on a couple days ago and it chimed and did the little circle thing... said it was starting X and then the screen went blue... and stayed blue and did nothing... I restarted... I drained and filled the battery I tried ev

  • Connectin VC to HU2 system

    Hi all, I wanted to connect the VC to the HU2 System. I did the following configuration: •Destination Type: Services Registry •Destination Name: HU2 •System: ABAP •System Name: HU2 •Hostname: iwdf1030 •Installation Number: 0120003411 •Client: 800 •Au