Supposed to be simple: XQuery issue mapping array of objects

I've been having an issue having a web service return a repeating set of elements.
The xsd seems correctly formatted with the right structure and maxOccurs set to
ounbounded etc.
This is the actual service:
public RecArea[] getAllRecAreas()
throws Exception
RecArea[] recAreas = recAreasControl.getRecAreas();
return recAreas;
The RecArea class has public variables as required:
public class RecArea {    
public BigDecimal recareaid;
public String recareaname;
When I use the XQuery mapper and connect at the RecArea level and recareaname
level, this is generated:
declare namespace ns0 = "http://www.openuri.org/"
declare namespace ns1 = "http://<deleted>/<deleted>/"
<ns1:RecAreas>
for $RecArea in $input/ns0:getAllRecAreasResult/ns0:RecArea
return
<ns1:RecArea>
<ns1:RecAreaName>{ data($RecArea/ns0:recareaname) }</ns1:RecAreaName>
</ns1:RecArea>
</ns1:RecAreas>
I have of course verifed in the debugger that recAreas is populated by the function
call and has data. The response from the service is:
<arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/"></arc:RecAreas>
In other words, it's not enumerating the recAreas.
I also tried tying just the recareaname attribute. This creates an XQuery like
this:
<ns1:RecAreas>
<ns1:RecArea>
<ns1:RecAreaName>{ data($input/ns0:getAllRecAreasResult/ns0:RecArea[1]/ns0:recareaname)
}</ns1:RecAreaName>
</ns1:RecArea>
</ns1:RecAreas>
This looks like it wants to only return the one element.
The result is:
<arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/">
<arc:RecArea>
<arc:RecAreaName></arc:RecAreaName>
</arc:RecArea>
</arc:RecAreas>
My sense is that regardless of the schema, the XQueries being generated above
are just not doing what is expected.
I have verified that the default query works. I.E. with no schema mapping the
results appear.
This should be simple. What am I missing?
Also, I would love to have some WebService examples going from database to xml
with schemas that have repeating elements.
Thank you kindly,
- Thomas

Hi Thomas,
Have you tried running autotype [2] on your actual service? What does
the types.xml file look like, could you post it?
You might take a look at this tutorial [1]
Sorry for the late reply,
Bruce
[1]
http://e-docs.bea.com/workshop/docs81/doc/en/integration/dttutorial/tutWLIDataTransIntro.html
[2]
http://edocs.bea.com/wls/docs81/webserv/anttasks.html#1080062
Thomas Charuhas wrote:
>
I've been having an issue having a web service return a repeating set of elements.
The xsd seems correctly formatted with the right structure and maxOccurs set to
ounbounded etc.
This is the actual service:
public RecArea[] getAllRecAreas()
throws Exception
RecArea[] recAreas = recAreasControl.getRecAreas();
return recAreas;
The RecArea class has public variables as required:
public class RecArea {
public BigDecimal recareaid;
public String recareaname;
When I use the XQuery mapper and connect at the RecArea level and recareaname
level, this is generated:
declare namespace ns0 = "http://www.openuri.org/"
declare namespace ns1 = "http://<deleted>/<deleted>/"
<ns1:RecAreas>
for $RecArea in $input/ns0:getAllRecAreasResult/ns0:RecArea
return
<ns1:RecArea>
<ns1:RecAreaName>{ data($RecArea/ns0:recareaname) }</ns1:RecAreaName>
</ns1:RecArea>
</ns1:RecAreas>
I have of course verifed in the debugger that recAreas is populated by the function
call and has data. The response from the service is:
<arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/"></arc:RecAreas>
In other words, it's not enumerating the recAreas.
I also tried tying just the recareaname attribute. This creates an XQuery like
this:
<ns1:RecAreas>
<ns1:RecArea>
<ns1:RecAreaName>{ data($input/ns0:getAllRecAreasResult/ns0:RecArea[1]/ns0:recareaname)
}</ns1:RecAreaName>
</ns1:RecArea>
</ns1:RecAreas>
This looks like it wants to only return the one element.
The result is:
<arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/">
<arc:RecArea>
<arc:RecAreaName></arc:RecAreaName>
</arc:RecArea>
</arc:RecAreas>
My sense is that regardless of the schema, the XQueries being generated above
are just not doing what is expected.
I have verified that the default query works. I.E. with no schema mapping the
results appear.
This should be simple. What am I missing?
Also, I would love to have some WebService examples going from database to xml
with schemas that have repeating elements.
Thank you kindly,
- Thomas

Similar Messages

  • Supposed to be simple: XQuery issue mapping array of objects (duplicate)

    I've been having an issue having a web service return a repeating set of elements.
    The xsd seems correctly formatted with the right structure and maxOccurs set to
    ounbounded etc.
    This is the actual service:
    public RecArea[] getAllRecAreas()
    throws Exception
    RecArea[] recAreas = recAreasControl.getRecAreas();
    return recAreas;
    The RecArea class has public variables as required:
    public class RecArea {    
    public BigDecimal recareaid;
    public String recareaname;
    When I use the XQuery mapper and connect at the RecArea level and recareaname
    level, this is generated:
    declare namespace ns0 = "http://www.openuri.org/"
    declare namespace ns1 = "http://<deleted>/<deleted>/"
    <ns1:RecAreas>
    for $RecArea in $input/ns0:getAllRecAreasResult/ns0:RecArea
    return
    <ns1:RecArea>
    <ns1:RecAreaName>{ data($RecArea/ns0:recareaname) }</ns1:RecAreaName>
    </ns1:RecArea>
    </ns1:RecAreas>
    I have of course verifed in the debugger that recAreas is populated by the function
    call and has data. The response from the service is:
    <arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/"></arc:RecAreas>
    In other words, it's not enumerating the recAreas.
    I also tried tying just the recareaname attribute. This creates an XQuery like
    this:
    <ns1:RecAreas>
    <ns1:RecArea>
    <ns1:RecAreaName>{ data($input/ns0:getAllRecAreasResult/ns0:RecArea[1]/ns0:recareaname)
    }</ns1:RecAreaName>
    </ns1:RecArea>
    </ns1:RecAreas>
    This looks like it wants to only return the one element.
    The result is:
    <arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/">
    <arc:RecArea>
    <arc:RecAreaName></arc:RecAreaName>
    </arc:RecArea>
    </arc:RecAreas>
    My sense is that regardless of the schema, the XQueries being generated above
    are just not doing what is expected.
    I have verified that the default query works. I.E. with no schema mapping the
    results appear.
    This should be simple. What am I missing?
    Also, I would love to have some WebService examples going from database to xml
    with schemas that have repeating elements.
    Thank you kindly,
    - Thomas

    Found a bug in Workshop causing the problem:
    It generated: $input/ns0:getAllRecAreasResult/ns0:RecArea
    but should have generated
    $input/ns0:RecArea
    After scrutinizing $input it was clear that the extra token was superflouous.
    "Thomas Charuhas" <[email protected]> wrote:
    >
    I've been having an issue having a web service return a repeating set
    of elements.
    The xsd seems correctly formatted with the right structure and maxOccurs
    set to
    ounbounded etc.
    This is the actual service:
    public RecArea[] getAllRecAreas()
    throws Exception
    RecArea[] recAreas = recAreasControl.getRecAreas();
    return recAreas;
    The RecArea class has public variables as required:
    public class RecArea {    
    public BigDecimal recareaid;
    public String recareaname;
    When I use the XQuery mapper and connect at the RecArea level and recareaname
    level, this is generated:
    declare namespace ns0 = "http://www.openuri.org/"
    declare namespace ns1 = "http://<deleted>/<deleted>/"
    <ns1:RecAreas>
    for $RecArea in $input/ns0:getAllRecAreasResult/ns0:RecArea
    return
    <ns1:RecArea>
    <ns1:RecAreaName>{ data($RecArea/ns0:recareaname) }</ns1:RecAreaName>
    </ns1:RecArea>
    </ns1:RecAreas>
    I have of course verifed in the debugger that recAreas is populated by
    the function
    call and has data. The response from the service is:
    <arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/"></arc:RecAreas>
    In other words, it's not enumerating the recAreas.
    I also tried tying just the recareaname attribute. This creates an XQuery
    like
    this:
    <ns1:RecAreas>
    <ns1:RecArea>
    <ns1:RecAreaName>{ data($input/ns0:getAllRecAreasResult/ns0:RecArea[1]/ns0:recareaname)
    }</ns1:RecAreaName>
    </ns1:RecArea>
    </ns1:RecAreas>
    This looks like it wants to only return the one element.
    The result is:
    <arc:RecAreas xmlns:arc="http://<deleted>/<deleted>/">
    <arc:RecArea>
    <arc:RecAreaName></arc:RecAreaName>
    </arc:RecArea>
    </arc:RecAreas>
    My sense is that regardless of the schema, the XQueries being generated
    above
    are just not doing what is expected.
    I have verified that the default query works. I.E. with no schema mapping
    the
    results appear.
    This should be simple. What am I missing?
    Also, I would love to have some WebService examples going from database
    to xml
    with schemas that have repeating elements.
    Thank you kindly,
    - Thomas

  • Having issues mapping network drives

    Having issues mapping network drives to my Mac. I trying to use samba, the name of the server is Media_Server and I want it to connect to volume_1. So I put int smb://mediaserver/volume1 and I get an error.
    Can anyone tell me what I'm doing wrong?

    I'm not sure, but when I want to connect to the desktop my other Mac on my home LAN I use:
    smb://192.168.1.105/johna/desktop

  • When some one calls the caller ID shows the name twice as we'll as when I receive texts it shows up twice.  I'm sure it's a simple setting issue. Any thoughts ???

    When some one calls the caller ID shows the name twice as we'll as when I receive texts it shows up twice.  I'm sure it's a simple setting issue. Any thoughts ???

    have the same issue on my 9630 after upgrading to 624 version. It momentarily shows the previously callers information before showing the new caller's info.

  • Determining which method to call from an array of Objects

    Hi All,
    Lets suppose I have an interface, a string method name, and an array of Objects indicating the parameters which should be passed to the method.
    What Im trying to work out is a way to quickly determine which method should be invoked.
    I can see that Class has getDeclaredMethod(String, Class[]), but that wont help me as I dont know the formal class types (the method may take X, but I might get passed Y which extends X in the array of objects).
    Does anyone know of a quick way I can determine this?
    All I can think of at the moment is going thru each method of the class one by one, and seeing if the arg is assignable, then, after getting all my matched methods, determining if there are any more 'specific' matches.
    Any ideas?
    Much appreciated,
    Dave

    you might want to take a look at the dynamic proxy apiCheers for the suggestion, but Im actually already using the dynamic proxy API.
    What I have is a MockObjectValidator which allows mock objects to be configuered with expected calls, exceptions to throw etc etc.
    I thought developers on my project would get tired using an interface like this:
    myValidator.setExpectedCall("someMethod", new Class[] { typeA, typeB }, new Object[] { valueA, valueB} );
    I.e, I wanted to cut out having to pass the class array, so they could just use:
    myValidator.setExpectedCall("someMethod", new Object[] { valueA, valueB} );
    The problem there is that I then need to pick the best Method from the class given the object arguments.
    When the mock object is in use, its no problem as the InvocationHandler interface provides the Method. The problem I have is selecting what method a user is talking about from an array of Objects.
    Ive written a simple one now, it just does primitive type class -> wrapper substitution, and then finds ** A ** match. If there is more than one match (ie, all params are assignable to a class' method params), I dont let that method be used.
    Shortly I'll update it to actually make the correct selection in those cases.
    cheers
    Dave

  • How to bind bar chart(columns) to array list object in c# win form

    how to bind bar chart(columns) to array list  object in c#win form

    Hi Ramesh,
    Did you want to bind list object to bar chart? I made a simple code to achieve binding list to bar chart.
    public partial class Form0210 : Form
    public Form0210()
    InitializeComponent();
    private void Form0210_Load(object sender, EventArgs e)
    BindData();
    public void BindData()
    List<int> yValues = new List<int>(new int[] { 20, 30, 10, 90, 50 });
    List<string> xValues = new List<string>(new string[] { "1:00", "2:00", "3:00", "4:00", "5:00" });
    chart1.Series[0].Points.DataBindXY(xValues, yValues);
    The links below might be useful to you:
    # Data Binding Microsoft Chart Control
    http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx
    # Series and Data Points (Chart Controls)
    https://msdn.microsoft.com/en-us/library/vstudio/dd456769(v=vs.100).aspx
    In addition, if I misunderstood you, please share us more information about your issue.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • Help populating an array of objects

    New here, trying to figure this out.
    I'm trying to create an array of objects, then populate the array defining fields. I stripped this down as far as i could to simplify the problem but I get the following error when I compile (i tweaked the carrot placment, formating issues i guess):
    PointsTest.java:41: ']' expected
    cubeArray[0] = new Point();
    ^
    PointsTest.java:41: invalid method declaration; return type required
    cubeArray[0] = new Point();
    ^
    2 errors
    My code:
    class PointsTest{
        public static void main(String[] args) {
                   //So far, this works.
                //convert 3 numbers to point coordinates held in temp variables
                float xT = (Float.valueOf(args[0])).floatValue();
                float yT = (Float.valueOf(args[1])).floatValue();
                float zT = (Float.valueOf(args[2])).floatValue();
                Point point1 = new Point(xT, yT, zT);
                point1.printXYZ(); 
    class Point {
        //A BASIC point class
        //fields defined
        float x, y, z;
        //a constructor that sets initial XYZ values
        Point(float startX, float startY, float startZ) {
                x = startX;
                y = startY;
                z = startZ;
        //a no argument constructor for defualt states
        Point () {
            x = 0;
            y = 0;
            z = 0;
        //method
        void printXYZ(){
            System.out.println("coordinates: " + x + " " + y + " " + z);
    class Cube{
         Point cubeArray[] =  new Point[9];
         cubeArray[0] = new Point();
    }I've looked for answers online without much luck, I'm not worried about using a loop to populate the array at the moment (you can do it one at a time, right?). Didn't see any obvious listings in the java tutorials about arrays of objects. Any help would be appreciated.

    You need to put operations inside of a method instead of just floating them around inside the top-level of your Cube class. The errors you are getting are related to the fact that only class data members or methods are supposed to be inside the top-level of a class definition.
    Something like this should get you started:
    class Cube{
            private Point[] cubeArray;
            public Cube(){
             cubeArray =  new Point[9];
    }Regards,
    -MF

  • How to pass a array of object to oracle procedure using callable

    Hi,
    I am calling a oracle stored procedure using callable statement which has IN and OUT parameter of same type.
    IN and OUT are array of objects. (ie) IN parameter as Array of Objects and OUT parameter as Array of Objects
    here are the steps i have done as advised from oracle forum. correct me if i am in wrong direction
    ORACLE types and Stored Procedure
    CREATE OR REPLACE
    TYPE APPS.DEPARTMENT_TYPE AS OBJECT (
    DNO NUMBER (10),
    NAME VARCHAR2 (50),
    LOCATION VARCHAR2 (50)
    CREATE OR REPLACE
    TYPE APPS.DEPT_ARRAY AS TABLE OF department_type;
    CREATE OR REPLACE package body APPS.insert_object
    IS
    PROCEDURE insert_object_prc (d IN dept_array, d2 OUT dept_array)
    IS
    BEGIN
    d2 := dept_array ();
    FOR j IN 1 .. d.COUNT
    LOOP
    d2.EXTEND;
    d2 (j) := department_type (d (j).dno, d (j).name, d(j).location);
    END LOOP;
    END insert_object_prc;
    END insert_object;
    JAVA CODE
    Value Object
    package com.custom.vo;
    public class Dep {
    public int empNo;
    public String depName;
    public String location;
    public int getEmpNo() {
    return empNo;
    public void setEmpNo(int empNo) {
    this.empNo = empNo;
    public String getDepName() {
    return depName;
    public void setDepName(String depName) {
    this.depName = depName;
    public String getLocation() {
    return location;
    public void setLocation(String location) {
    this.location = location;
    to call stored procedure
    package com.custom.callable;
    import com.custom.vo.Dep;
    import oracle.jdbc.OracleCallableStatement;
    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.OracleTypes;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.sql.ARRAY;
    import oracle.sql.ArrayDescriptor;
    import oracle.sql.Datum;
    import oracle.sql.STRUCT;
    import oracle.sql.StructDescriptor;
    public class CallableArrayTryOut {
    private static OracleDataSource odcDataSource = null;
    public static void main(String[] args) {
    OracleCallableStatement callStatement = null;
    OracleConnection connection = null;
    try {
    odcDataSource = new OracleDataSource();
    odcDataSource
    .setURL("......");
    odcDataSource.setUser("....");
    odcDataSource.setPassword("....");
    connection = (OracleConnection) odcDataSource.getConnection();
    } catch (Exception e) {
    System.out.println("DB connection Exception");
    e.printStackTrace();
    Dep[] dep = new Dep[2];
    dep[0] = new Dep();
    dep[0].setEmpNo(100);
    dep[0].setDepName("aaa");
    dep[0].setLocation("xxx");
    dep[1] = new Dep();
    dep[1].setEmpNo(200);
    dep[1].setDepName("bbb");
    dep[1].setLocation("yyy");
    try {
    StructDescriptor structDescriptor = new StructDescriptor(
    "APPS.DEPARTMENT_TYPE", connection);
    STRUCT priceStruct = new STRUCT(structDescriptor, connection, dep);
    STRUCT[] priceArray = { priceStruct };
    ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
    "APPS.DEPT_ARRAY", connection);
    ARRAY array = new ARRAY(arrayDescriptor, connection, priceArray);
    callStatement = (OracleCallableStatement) connection
    .prepareCall("{call insert_object.insert_object_prc(?,?)}");
    ((OracleCallableStatement) callStatement).setArray(1, array);
    callStatement.registerOutParameter(2, OracleTypes.ARRAY,
    "APPS.DEPT_ARRAY");
    callStatement.execute();
    ARRAY outArray = callStatement.getARRAY(2);
    Datum[] datum = outArray.getOracleArray();
    for (int i = 0; i < datum.length; i++) {
    oracle.sql.STRUCT os = (oracle.sql.STRUCT) datum[0];
    Object[] a = os.getAttributes();
    for (int j = 0; j < a.length; j++) {
    System.out.print("Java Data Type :"
    + a[j].getClass().getName() + "Value :" + a[j]
    + "\n");
    connection.commit();
    callStatement.close();
    } catch (Exception e) {
    System.out.println("Mapping Error");
    e.printStackTrace();
    THE ERROR
    Mapping Errorjava.sql.SQLException: Inconsistent java and sql object types
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1130)
    at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:823)
    at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1735)
    at oracle.sql.STRUCT.<init>(STRUCT.java:136)
    at com.custom.callable.CallableArrayTryOut.main(CallableArrayTryOut.java:48)

    You posted this question in the wrong forum section. There is one dedicated to Java that was more appropriate.
    Anyway here is a link that describes what you should do.
    http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/oraarr.htm#i1049179
    Bye Alessandro

  • Core Data Services in ABAP : No URI-Mapping defined for object type DDLS

    Hi ,
    When creating a DDL source , I get the error
    " No URI-Mapping defined for object type DDLS and object name ZCDSV_01_06".
    Can you please suggest what the issue could be?
    Thanks,
    Chakram Govindarajan

    Now I am able to proceed to the next step. Not sure how this started working. However, I get the below error when I open the DDL source editor for one particular ABAP system added in the eclipse environment. I however do not get the error when I open the DDL source editor for another system ( AH4) .I am providing the log error details . I updated the ADT installation. However the issue has not been resolved. Also I tried implementing the Note: 1834948. However I cannot find the option "Team -> Share project..." in the ABAP project.
    Thanks,
    Chakram Govindarajan

  • Array of Object Refs

    I am doing exercises in a book (a couple books) to learn Java. I am a procedural pgmr and want to learn Java.
    Question 3 in Chapter 4 says:
    Create an array of object references of the class you created in Exercise 2, but don't actually create objects to assign into the array. When you run the program, notice whether the initialization messages from the constructor calls are printed.
    In exercise 2, I created an created an overloaded constructor. There are two constructors one that takes an argument and one that doesn't. I think I understand that I am being asked to look to see the values of the variables before the object is actually created but after initialization.
    My question is that I am not sure I understand what is being asked in question 3. I have to create an array of object references. I understand object references to be the varable names that hole the contents of the object. I don't understand what I am supposed to put into each (the two) elements of the array.
    Here is program written for exercise 2:
    //: c04:J402.java
    /* This has overloaded constructors. However, the argument must be given. Without it, there is an exception at runtime. */
    class Bird {
    Bird() {
    System.out.println("The object is an egg");
    Bird(String age) {
    System.out.println("The object is " + age + " months old");
    public class J402 {
    public static void main(String[] args) {
    String age = args[0];
    new Bird(age);
    } ///:~
    Thank you so much for any help.

    My question is that I am not sure I understand what is
    being asked in question 3. I have to create an array
    of object references. I understand object references
    to be the varable names that hole the contents of the
    object. I don't understand what I am supposed to put
    into each (the two) elements of the array.
    You need to make three different concepts clear to yourself: objects, object references, and reference variables.
    Objects are objects are objects. They are self contained entities that live somewhere in the memory. But, as you can't manipulate the memory directly (there are many good reasons for that), you can't manipulate objects directly.
    To get to objects you need references (or pointers). A reference is like a memory address. It normally points to the memory location of an object, but if the reference can also be a special 'null' reference that doesn't point to any object (or to every possible object, depending on how you want to look at it). The JVM takes care of talking to the underlaying object through the reference.
    An object can have many references pointing to it but a reference can point to only one object (or no / any object in the case of a null reference).
    Reference variables, then, are the ones you have in source code. Here's an example of a reference variable:Bird tweety;
    tweety = new Bird("I thought I saw a pussy cat!");(given a hypotetical class that can take a String object as an argument to the constructor)
    "tweety" is a reference variable. A reference variable is a variable that can hold a reference -- surprise! :). If not set to any particular reference, it's value may be null. If you now do something likeBird bird2 = tweety;
    tweety = new Bird();you first define a new ref. variable "bird2" and set its value to tweety's ref. Then you reset the var. tweety to point to a new Bird object. What happens to bird2? Nothing!! ... but if instead of "tweety = new Bird();" you had written "tweety.setChirp("TWEET!!!");" and then called bird2.chirp(), it would have chirped with "TWEET!!!" because the references of bird2 and tweety point to the same object.
    But, you can have references outside reference variables. In reference arrays (or "object arrays", the terminology can be confusing), for instance. Then, the codeBird[] flock = new Bird[2];0) Creates, allocates and initializes a new reference array object.
    1) Creates a new reference variable called "flock" and assigns it to a reference that points to the object that was created in 0).
    2) Creates 2 more references to Bird objects, initially set to null. No further objects are created. These references can be used like reference variables through flock[0] and flock[1].
    (not necessarily in this order)
    Now this should answer the excersise 3. The references of flock[0] and flock[1] are left as null and they don't point to any objects - They will only if you do something like "flock[0] = new Bird("chirp!");" or "flock[1] = tweety;"

  • Printing a listing from an array of objects

    I know I'm missing something simple here but for the life of me I can't spot it. The code below should print a list of student names to the screen. At the moment it only prints the last name entered into the array. I will kick myself when I see the answer but can anyone suss this out ? Many thanks for any help.
    // A Program called StudentDetails3.java which inserts student names into an array according to
    // a calculated hash Index and then prints out the name list in this order
    import javax.swing.JOptionPane;
    public class StudentDetails3
    // Member Section
    // Private members
    private static String studentName;
    // Public members
    public static String input = JOptionPane.showInputDialog(" Please enter the number of students in the class : - ");
    public static int maxNum = Integer.parseInt(input);
    public static int hashIndex = 0;
    // Constructor Section
    StudentDetails3 ( String newStudentName )
    studentName = newStudentName.toUpperCase();
    // Method Section
    public int hashCalc()
    int total = 0;
    for( int charNo = 0; charNo < studentName.length(); charNo ++ )
    char letter = studentName.charAt(charNo);
    int asciiVal = letter;
         if( studentName.charAt(charNo) ==' ')
         asciiVal = 0;
         total = total + asciiVal;
    hashIndex = total % maxNum;
    return hashIndex;
    public void output()
    System.out.println(" The student's name and hash index is " + studentName + " " + hashIndex );
    static class DetailsStorage
    // Member Section containing the array into which the student objects will be inserted
    private Object [] array;
    private int current;
    // Constructor
    DetailsStorage ( int noOfStudents )
    array = new Object[ noOfStudents ];
    current = 0;
    // Method for adding name to array
    public void add ( Object StudentDetails3 )
    {  if ( array [ hashIndex] == null )
    array [ hashIndex ] = StudentDetails3;
    else if ( (hashIndex + 1) <= (array.length-1) )
    do
    { hashIndex = ( hashIndex + 1 );
         if ( array [ hashIndex ] == null )
         {   array [ hashIndex ] = StudentDetails3;
         break;
    } while ( (hashIndex + 1) <= (array.length-1) );
         else
              for ( int firstLp = 0; firstLp < array.length; firstLp ++ )
         if ( array [ firstLp ] == null )
         {   array [ firstLp ] = StudentDetails3;
                   break;
    public void printOut ( )
    {   int loop = 0;
    System.out.println ( " Name\t\tCourse " );
    System.out.println ( "____\t\t_________ " );
         for ( loop = 0; loop < array.length; loop ++ )
         System.out.println ( ( ( StudentDetails3 ) array [ loop ] ).studentName );
    // Main Program for testing
    public static void main( String[] args )
    {   String  name;                                              
    // Obtain list of names from the user
    DetailsStorage nameList = new DetailsStorage( maxNum );
    for( int lp = 0; lp < maxNum; lp++ )
    {   name =  JOptionPane.showInputDialog(" Please enter the name of student in full ( e.g. Gareth Edwards )");
    StudentDetails3 newDetails = new StudentDetails3( name );
    newDetails.hashCalc();
         nameList.add ( newDetails );
    newDetails.output();
    nameList.printOut();
    System.exit(0);
    }

    You've made the student name a static field, which means that there's only one for the whole class.
    So the last one you input is the one you use for everybody.

  • Turning a resultset into an array of objects.

    First I will give some background on the situation...
    I have a table in which has many lines of data. Each line of data has a boolean (for a jcheckbox) we will call that "A" and then a bunch of other attributes that are related...we will call those B, C, and D. On a later screen there will be a reduced table in which has only the lines from the original table that were selected. This is why the whole row in the table has to be an object.
    So I have a query like this:
    ResultSet rs = stmt.executeQuery("SELECT A, B, C, D FROM tableName WHERE A= '1'");and then I would like to use:
    String ObjectRef;
                Boolean A;
                String B;
                String C;
                String D;
                while (rs.next()) {
                     A = rs.getString("A");
                     B = rs.getString("B");
                     C = rs.getString("C");
                    D = rs.getString("D");At this point I need to create an ArrayList or an Array of objects....each object having A, B, C, and D. how do I do that in this while condition?
    Or if someone knows a better way of goign about this please let me know. The main objective is to populate this table with objects containing each of of the above attributes. I tried to keep the scenario as simple as possible, so if it was confusing or I need to explain more, just ask.
    Thanks in advance.

    Atreides wrote:
    At this point I need to create an ArrayList or an Array of objects....each object having A, B, C, and D. how do I do that in this while condition?Create the list before you start the while loop. Then, inside the while loop, after extracting A..D, do something like this:
    MyClass mine = new MyClass(A, B, C, D); // or a no-arg c'tor and then a bunch of setters.
    list.add(mine);

  • H:dataTable value as array of Strings vs array of objects

    I'm trying to use a h:dataTable with an h:inputText as one of the columns. If my bean returns an array of Strings, then the h:dataTable can't update them. (I added a submit button that just updates the fields and returns to the current page.) If I use an array of objects, in this case a simple wrapper class, it works. Why is this?
    This won't work:
    public class EmailBean {
        private String[] m_emails;
        public String[] getEmails() {
            return m_emails;
        public void setEmails(String[] emails) {
            m_emails = emails;
    }But this will:
    public class EmailBean {
        private Email[] m_emails;
        public EmailBean() {
            m_emails = new Email[] {
                    new Email("[email protected]"),
                    new Email("[email protected]"),
                    new Email("[email protected]")
        public Email[] getEmails() {
            return m_emails;
        public void setEmails(Email[] emails) {
            m_emails = emails;
    }

    public class Email {
        private String email;
        public Email(String email) {
            this.email = email;
        public String getEmail() {
            return email;
        public void setEmail(String email) {
            this.email = email;
    }For the one that uses the Email class, I use this:
    <h:dataTable value="#{emailTestBean.emails}"
                                  var="email">
         <h:column>
              <f:facet name="header">
                   <h:outputText value="Email Address" />
              </f:facet>
              <h:inputText value="#{email.email}" />
         </h:column>
         <f:facet name="footer">
              <h:commandButton value="Submit" />
         </f:facet>
    </h:dataTable>Otherwise I don't need the extra ".email":
    <h:dataTable value="#{emailTestBean.emails}"
                                  var="email">
         <h:column>
              <f:facet name="header">
                   <h:outputText value="Email Address" />
              </f:facet>
              <h:inputText value="#{email}" />
         </h:column>
         <f:facet name="footer">
              <h:commandButton value="Submit" />
         </f:facet>
    </h:dataTable>

  • TypeError: Error #1006: when rearranging array of objects

    I have an array of objects, which I call in a loop thus:
    myObjectArray[index].method()
    However, when I splice one object from the array and put it
    at the front via unshift, it no longer understands the method call
    and spouts a Type Error#1006 :value is not a function:
    Looks like a bug to me. Or am I missing something?

    Thanks for the quick reply
    tried this but got Coercion failed message:
    var arrayObj:*;
    arrayObj=altArray.splice(altToTop,1);
    AlternativeGUI(arrayObj); //coercion failed
    var newlength:int=altArray.unshift(arrayObj);
    All objects held by altArray are subclasses of AlternativeGUI
    However, even simpler to avoid that untyped arrayObj returned
    by the splice:
    altArray.unshift(altArray[altToTop]);
    altArray.splice(altToTop+1,1);
    now it works!

  • Storing an array of objects?

    Right... I need my table to store a series of product ID's, quantities, and serial numbers. At the moment, I'm using a column for each time, and using a StringTokenizer to retrieve them from strings such as "3;4;2;5". However, I'd like to store all 3 values in one column, so that I can store effectively an array of objects in one column field. Is this in any way possible?
    Thanks
    Stu

    Sorry, perhaps I wasn't clear enough.
    The table I am using is designed so that each row
    tracks a single technical services job (I'm writing
    this for a computer repair/maintenance firm). As such,
    I need to track what hardware items are used/sold with
    a tech services job.
    At the moment I have three columns:
    ProductID ProductSerial
    ProductQuantity
    1;2;3;4; 111;222;333;444;
    5;6;7;8
    The above three columns & values contain data for 4
    separate sales within the job:
    ProductID 1, serial 111, quantity 5
    ProductID 2, serial 222, quantity 6
    ProductID 3, serial 333, quantity 7
    ProductID 4, serial 444, quantity 8
    To generate the info for the first sale, I take the
    first token of all 3 columns, and so on, and then map
    them to a two-dimensional array that will look as
    follows:
    (assume they're all strings for now)
    String[][] sales = new String[][]
    new String[] { "1", "111", "5" },
    new String[] { "2", "222", "6"}
    }; This works as I want. However, I suspect there's a way
    to condense all three of my current columns into one
    column... one that I can't myself fathom, and would
    greatly appreciate help for.
    -fuzzy- how could I redesign the database to implement
    such a thing?
    All help appreciated
    Stuas pointed out the design is terrible.
    here is a proper design that will make your life much easier...
    Table - Sale
    id- Primary Key
    Table - SaleItem
    saleid - Foriegn Key from Sale - also part of Primary Key
    productid - other part of primary key
    productserial
    productquantiy
    so your data would look like this in these tables...
    Sale
    id
    1
    SaleItem
    saleid productid productserial productquantity
    1 1 111 5
    1 2 222 6
    1 3 333 7
    1 4 444 8
    as a side note i think productid is probably a spurious field.. using are using it i think as unique id... wouldn't the serial numbers be unique? I would use just them if they are...
    anyway hope this helps.

Maybe you are looking for

  • How do I transfer my iPad playlist to iTunes?

    I have the latest version of iTunes and I have an iPad 2. I want to transfer my playlist from my iPad to iTunes without using a third party software. I remember there used to be a way!!  Can anyone help?

  • Purchase order item of maintenance order still without final billing indic

    In maintenance process, while closing the Maintenance order after MIRO and Payment, system is giving warning message as : "Purchase order item 4520000023 00010 of order 4000020 still without final billing indic. Message no. IW215 Diagnosis An invoice

  • How deploying a simple report as .jsp

    Hi, i have read the last days many document, and messages on this board. But I could not find answers. My problem is: I create a simple report with reportbuilder and save this to mysample.jsp. I copy this file to Oracle Application Server j2ee\OC4J_B

  • BI Platform 4.1 SP1 on Redhat Linux 6.5 DB2v9 Data Access Driver Error in IDT

    Hi, I am new to SAP BusinessObject BI Platform 4.1 and trying to create a JDBC relational connection in Information Design Tool to connect to a DB2 v9 database on Redhat Linux 6.5 environment. I used the follow steps to create my relational connectio

  • Any good table for Capacity Planning?

    HI all, Is there any table for capacity planning? we want to do some development to get capacity requirements data for each work center, don't like using CM01. Thanks! Harvey