Converting object wrapper type array into equivalent primary type array

Hi All!
My question is how to convert object wrapper type array into equivalent prime type array, e.g. Integer[] -> int[] or Float[] -> float[] etc.
Is sound like a trivial task however the problem is that I do not know the type I work with. To understand what I mean, please read the following code -
//Method signature
Object createArray( Class clazz, String value ) throws Exception;
//and usage should be as follows:
Object arr = createArray( Integer.class, "2%%3%%4" );
//"arr" will be passed as a parameter of a method again via reflection
public void compute( Object... args ) {
    a = (int[])args[0];
//or
Object arr = createArray( Double.class, "2%%3%%4" );
public void compute( Object... args ) {
    b = (double[])args[0];
//and the method implementation -
Object createArray( Class clazz, String value ) throws Exception {
     String[] split = value.split( "%%" );
     //create array, e.g. Integer[] or Double[] etc.
     Object[] o = (Object[])Array.newInstance( clazz, split.length );
     //fill the array with parsed values, on parse error exception will be thrown
     for (int i = 0; i < split.length; i++) {
          Method meth = clazz.getMethod( "valueOf", new Class[]{ String.class });
          o[i] = meth.invoke( null, new Object[]{ split[i] });
     //here convert Object[] to Object of type int[] or double[] etc...
     /* and return that object*/
     //NB!!! I want to avoid the following code:
     if( o instanceof Integer[] ) {
          int[] ar = new int[o.length];
          for (int i = 0; i < o.length; i++) {
               ar[i] = (Integer)o;
          return ar;
     } else if( o instanceof Double[] ) {
     //...repeat "else if" for all primary types... :(
     return null;
Unfortunately I was unable to find any useful method in Java API (I work with 1.5).
Did I make myself clear? :)
Thanks in advance,
Pavel Grigorenko

I think I've found the answer myself ;-)
Never thought I could use something like int.class or double.class,
so the next statement holds int[] q = (int[])Array.newInstance( int.class, 2 );
and the easy solution is the following -
Object primeArray = Array.newInstance( token.getPrimeClass(), split.length );
for (int j = 0; j < split.length; j++) {
     Method meth = clazz.getMethod( "valueOf", new Class[]{ String.class });
     Object val = meth.invoke( null, new Object[]{ split[j] });
     Array.set( primeArray, j, val );
}where "token.getPrimeClass()" return appropriate Class, i.e. int.class, float.class etc.

Similar Messages

  • How can i convert object to byte array very*100 fast?

    i need to transfer a object by datagram packet in embeded system.
    i make a code fallowing sequence.
    1) convert object to byte array ( i append object attribute to byte[] sequencailly )
    2) send the byte array by datagram packet ( by JNI )
    but, it's not satisfied my requirement.
    it must be finished in 1ms.
    but, converting is spending 2ms.
    network speed is not bottleneck. ( transfer time is 0.3ms and packet size is 4096 bytes )
    Using ObjectOutputStream is very slow, so i'm using this way.
    is there antoher way? or how can i improve?
    Edited by: JongpilKim on May 17, 2009 10:48 PM
    Edited by: JongpilKim on May 17, 2009 10:51 PM
    Edited by: JongpilKim on May 17, 2009 10:53 PM

    thanks a lot for your reply.
    now, i use udp socket for communication, but, i must use hardware pci communication later.
    so, i wrap the communication logic to use jni.
    for convert a object to byte array,
    i used ObjectInputStream before, but it was so slow.
    so, i change the implementation to use byte array directly, like ByteBuffer.
    ex)
    public class ByteArrayHelper {
    private byte[] buf = new byte[1024];
    int idx = 0;
    public void putInt(int val){
    buf[idx++] = (byte)(val & 0xff);
    buf[idx++] = (byte)((val>>8) & 0xff);
    buf[idx++] = (byte)((val>>16) & 0xff);
    buf[idx++] = (byte)((val>>24) & 0xff);
    public void putDouble(double val){ .... }
    public void putFloat(float val){ ... }
    public byte[] toByteArray(){ return this.buf; }
    public class PacketData {
    priavte int a;
    private int b;
    public byte[] getByteArray(){
    ByteArrayHelper helper = new ByteArrayHelper();
    helper.putInt(a);
    helper.putInt(b);
    return helper.toByteArray();
    but, it's not enough.
    is there another way to send a object data?
    in java language, i can't access memory directly.
    in c language, if i use struct, i can send struct data to copy memory by socket and it's very fast.
    Edited by: JongpilKim on May 18, 2009 5:26 PM

  • Convert Object return type columns

    Hi Team
    Hi,
    I have created a object type as
    create type emp_obj_dtl as OBJECT (ename varchar2(50),mgr NUMBER)
    create type emp_dtl_obj_typ as TABLE of emp_obj_dtl
    Using the these object i have created on function as
    CREATE OR REPLACE FUNCTION emp_test_func (peno NUMBER)
    RETURN emp_dtl_obj_typ
    AS
    lv_emp_dtl emp_dtl_obj_typ := emp_dtl_obj_typ ();
    BEGIN
    SELECT emp_dtl_obj_typ(emp_obj_dtl (ename, mgr))
    INTO lv_emp_dtl
    FROM emp
    WHERE empno = peno;
    RETURN lv_emp_dtl;
    END;
    Now if i am executig query as
    SELECT empno, emp_test_func (empno) emp_dtls
    FROM emp
    It is returning me the data as
    EMPNO | EMP_DTLS
    7500 | (DATASET)
    7382 | (DATASET)
    7569 | (DATASET)
    7800 | (DATASET)
    But I want the result set as
    EMPNO | ENAME | MGR
    7500 | SMITH | 7863
    7382 | JAMES | 7896
    7569 | KING | 7856
    7800 | SANGR | 7456
    Appricate your help to get the resultset as above.
    thank you & Rgrds
    VIKAS ARORA

    Don't really like the approach you've used in your sample code - in effect, that is caching SQL data using very expensive PL memory (called PGA). It is wrong for performance reasons. It is wrong for scalability reasons.
    It is returning me the data as
    EMPNO | EMP_DTLS
    7500 | (DATASET)Correct. As the dataset is not a scalar data type like varchar2, date or number, but a complex object type. And not just a object type, but a collection (table) object type.
    You need to decide how you want to treat that object data that the SQL projection returns.
    Here's a more comprehensive example:
    SQL> create or replace type TPerson as object (ename varchar2(50), empno number );
      2  /                                                                           
    Type created.
    SQL>           
    SQL> create or replace type TDirectReports as table of TPerson;
      2  /                                                        
    Type created.
    SQL>           
    SQL> create or replace function DirectReports( manager number ) return TDirectReports as
      2  -- returns list of employees that directly reports to manager                     
      3          list    TDirectReports;                                                   
      4  begin                                                                             
      5          select                                                                    
      6                  TPerson( InitCap(e.ename), e.empno ) bulk collect into list       
      7          from    emp e                                                             
      8          where   e.mgr = manager                                                   
      9          order by ename;                                                           
    10                                                                                    
    11          return( list );                                                           
    12  end;                                                                              
    13  /                                                                                 
    Function created.
    SQL>
    SQL> col ENAME format a10
    SQL> col DIRECT_REPORTS format a100
    SQL> select ename, DirectReports(empno) as "DIRECT_REPORTS" from emp;
    ENAME      DIRECT_REPORTS(ENAME, EMPNO)
    SMITH      TDIRECTREPORTS()                                                                                   
    ALLEN      TDIRECTREPORTS()                                                                                   
    WARD       TDIRECTREPORTS()                                                                                   
    JONES      TDIRECTREPORTS(TPERSON('Ford', 7902), TPERSON('Scott', 7788))                                      
    MARTIN     TDIRECTREPORTS()                                                                                   
    BLAKE      TDIRECTREPORTS(TPERSON('Allen', 7499), TPERSON('James', 7900), TPERSON('Martin', 7654), TPERSON('Tur
               ner', 7844), TPERSON('Ward', 7521))                                                                
    CLARK      TDIRECTREPORTS(TPERSON('Miller', 7934))
    SCOTT      TDIRECTREPORTS(TPERSON('Adams', 7876))
    KING       TDIRECTREPORTS(TPERSON('Blake', 7698), TPERSON('Clark', 7782), TPERSON('Jones', 7566))
    TURNER     TDIRECTREPORTS()                                                                     
    ADAMS      TDIRECTREPORTS()                                                                     
    JAMES      TDIRECTREPORTS()                                                                     
    FORD       TDIRECTREPORTS(TPERSON('Smith', 7369))                                               
    MILLER     TDIRECTREPORTS()
    14 rows selected.Note that the dataset is a collection object - that contains zero or more nested objects. In this case, a list of employees that directly reports to the current employee.
    How can we use this collection object? Here is a basic example:
    SQL> col 1ST_EMPLOYEE format a15
    SQL> with MANAGER_LIST as(
      2          select ename, DirectReports(empno) as "DIRECT_REPORTS" from emp
      3  )
      4  select
      5          l.ename,
      6          (select count(*) from TABLE(l.direct_reports)) as "NO_OF_EMPLOYEES",
      7          (select d.ename from TABLE(l.direct_reports) d where rownum = 1) as "1ST_EMPLOYEE",
      8          (select max(d.empno) from TABLE(l.direct_reports) d ) as "LAST_EMPLOYEE"
      9  from       manager_list l
    10  /
    ENAME      NO_OF_EMPLOYEES 1ST_EMPLOYEE    LAST_EMPLOYEE
    SMITH                    0
    ALLEN                    0
    WARD                     0
    JONES                    2 Ford                     7902
    MARTIN                   0
    BLAKE                    5 Allen                    7900
    CLARK                    1 Miller                   7934
    SCOTT                    1 Adams                    7876
    KING                     3 Blake                    7782
    TURNER                   0
    ADAMS                    0
    JAMES                    0
    FORD                     1 Smith                    7369
    MILLER                   0
    14 rows selected.Just note that this example merely illustrates how to use and reference objects in SQL. This is not the preferred way to address the problem it does - as the same could have been a lot easier achieved using a simple self-join.
    So make sure that when you use objects in SQL, it is for the right technical reasons.

  • Multi-table mapping is not inserting into the primary table first.

    I have an inheritance mapping where the children are mapped to the parent table oids with the "Multi-Table Info" tab.
    One of children is not inserting properly. Its insert is attempting to insert into one of the tables from the "Additional Tables" of "Multi-Table Info" instead of the primary table that it is mapped to.
    The other children insert correctly. This child is not much different from those.
    I looked through the forums, but found nothing similiar.

    I would expect the Children to be inserted into both the primary table and the Additional Table? Is the object in question inserted into the primary table at all? Is the problem that it is being inserted into the Additional Table first? If it is, are the primary key names different? Is it a foreign key relationship?
    If the object in question has no fields in the additional table is it mapped to the additional table? (it should not be)
    Perhaps providing the deployment XML will help determine the problem,
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • SOS: XAML binding Error: Converter failed to convert value of type '...' to to type '...'

    Hi, I'm working on a small Windows store App project using C# + XAML, and encountered a really weird problem with data binding in XAML. The error message is:
    Error: Converter failed to convert value of type 'Neptune.MyMatch, SkyNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' to type
    'ProgressableBase'; BindingExpression: Path='' DataItem='Neptune.MyMatch, SkyNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'MyControls.ProgressableViewControl' (Name='root'); target property is 'Progressable'
    (type 'ProgressableBase').
    Error: Converter failed to convert value of type 'Neptune.MyMatch, SkyNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' to type
    'IMatchWrapper'; BindingExpression: Path='' DataItem='Neptune.MyMatch, SkyNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'MyControls.MatchScoreControl' (Name='root'); target property is 'Match' (type 'IMatchWrapper').
    the XAML code snippet involved is:
    <local:MatchScoreControl Match="{Binding Converter={StaticResource TestConverter}}" />
    here:
    1) The type of the 'Match' property of 'MatchScoreControl' is 'IMatchWrapper', the type of the DataContext is 'MyMatch';
    2) 'MyMatch' is derived from 'ProgressableBase' and implemented
    'IMatchWrapper';
    3) below is the definition of 'MatchScoreControl' and its dependency property 'Match':
    public sealed partial class MatchScoreControl : UserControl
    public IMatchWrapper Match
    get { return (IMatchWrapper)GetValue(MatchProperty); }
    set { SetValue(MatchProperty, value); }
    public static readonly DependencyProperty MatchProperty =
    DependencyProperty.Register("Match", typeof(IMatchWrapper), typeof(MatchScoreControl), new PropertyMetadata(null, OnMatchPropertyChanged));
    private static void OnMatchPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    // this line will never get called
    Debug.WriteLine(e.NewValue.GetType().FullName);
    } //more code...
    4) TestConverter is a dummy value converter(IValueConverter) which does nothing just to make sure the binding object and target type is as expected:
    public sealed class TestConverter : IValueConverter
    public object Convert(object value, Type targetType, object parameter, string language)
    if (targetType != typeof(IMatchWrapper))
    throw new NotImplementedException("Error: targetType is not IMatchWrapper.....");
    if (!(value is IMatchWrapper))
    throw new NotImplementedException("Error: value is not IMatchWrapper...");
    return (IMatchWrapper)value;
    public object ConvertBack(object value, Type targetType, object parameter, string language)
    throw new NotImplementedException();
    When I run the app, none of the two exceptions in the TestConverter.Convert() is thrown, which is right and as expected. But the out window keeps throwing the error message as above. This is pretty weird!
    I've tried adding a parameterless constructor to the class 'MyMatch', but it doesn't work.
    Any suggestion would be appreciated!

    Good to know you have the solution and thanks for sharing the experience.
    --James
    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.

  • How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers? (history data from a chart)

    Hello,
    in my vi I have a chart with 5 Plots displaying measurement data.
    The user should be able to save all the history data from the chart at anytime. (e.g. the user watches the chart and some event happens, then he presses a "save"-button)
    I know, that I can read out the history data with a property node. That is not the problem. The problem is, how do I handle the data? The type of the history data is a 1-D array of cluster of 5 elements.
    I have to convert that data somehow into a 2 D-array of numbers or strings, so that I can easily save it in a text-file.
    How do I convert a 1-D array of cluster of 5 elements into a 2-D array of numbers?
    I use LabVIEW 7.1
    Johannes
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Solved!
    Go to Solution.

    Gerd,
    thank you for the quick response and the easy solution.
    Look what I did in the meantime. I solved the problem too, but muuuch more complicate :-)
    And I have converted the numbers to strings, so that I can easily write them into a spreasheet file.
    Johannes
    Message Edited by johanneshoer on 04-28-2009 10:39 AM
    Greetings Johannes
    Using LabVIEW 7.1 and 2009 recently
    Attachments:
    SaveChartHistory.JPG ‏57 KB
    SaveChartHistory.JPG ‏57 KB

  • Converting objects into Strings

    How would someone convert an object of say (String, int, double, String) into a readable string. I tried the toString() method but all I get is something like this
    Student@1f12c4e

    ..I'm not sure I understand "how" to override. The whole point of this project is to use quicksort on a list of students, unfortunately all I get is the address whenever I use the .toStrings() method.
    Here's what I have, any help would be greatly appreciated-so very close
    import cs1.Keyboard;
    import java.io.*;
    import java.util.*;
    public class StudentTraverse
    public static void main(String[] args)
    String newName;
    int newSocial;
    double newGPAs;
    String newMajors;
    System.out.println("How many Students would you like to add");
    Student newStudent;
    StudentList12 WORK = new StudentList12();
    int total = Keyboard.readInt();
    for(int number = total; number > 0; number--)
    System.out.println("Name?");
    newName = Keyboard.readString();
    System.out.println("Social?");
    newSocial = Keyboard.readInt();
    System.out.println("GPA?");
    newGPAs = Keyboard.readDouble();
    System.out.println("Major?");
    newMajors = Keyboard.readString();
    newStudent = new Student(newName, newSocial, newGPAs, newMajors);
    System.out.println("Inserting: "+newStudent.toString());
    WORK.add(newStudent);
    for(total = 0; total < WORK.size(); total++)
    System.out.println("top" total": "+WORK.top(total).toString());
    try
    BufferedReader in = new BufferedReader(new FileReader("LIST.out"));
    while (in.ready())
    // Print file line to scree
    System.out.println (in.readLine());
    in.close();
    catch (Exception e)
    System.err.println("File input error");
    public class StudentNode
    public Student student;
    public StudentNode next;
    public StudentNode()
    next = null;
    student = null;
    public StudentNode(Student d, StudentNode n)
    student = d;
    next = n;
    public void setNext(StudentNode n)
    next = n;
    public void setData(Student d)
    data = d;
    public StudentNode getNext()
    return next;
    public Student getData()
    return data;
    public String toString()
    return ""+data;
    public StudentNode(Student newStudent)
    METHOD NAME: StudentNode
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Acts as a node for the Student list
    ALGORITHM:Acts as node for the list
    INSTANCE VARIABLES: none
    student = newStudent;
    next = null;
    public class Student
    private String name;
    private int social;
    private double GPA;
    private String Major;
    public Student(String newName, int newSocial, double newGPAs, String newMajors)
    METHOD NAME: Student
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: The actual Student class, determines what is allowed in the array
    ALGORITHM:Declare what variables will be needed for the program
    INSTANCE VARIABLES: String name, int social, double GPA, String Major
    name = newName;
    social = newSocial;
    GPA = newGPAs;
    Major = newMajors;
    import java.io.*;
    import cs1.Keyboard;
    import java.io.BufferedWriter;
    import java.util.*;
    public class StudentList12
    private StudentNode list;
    static int i = 0;
    public StudentList12()
    METHOD NAME: StudentList12
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Declares the Node
    ALGORITHM:Declare the Node
    INSTANCE VARIABLES: none
    list = null;
    public boolean isEmpty()
    return list == null;
    public int size()
    return i;
    public void add(Student newStudent)
    METHOD NAME: add
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Let's users add objects to the array of objects
    ALGORITHM:Traverses the current list and adds object to the end
    INSTANCE VARIABLES: none
    list = new StudentNode(newStudent, list);
    i++;
    current = current.next;
    current.next = node;
    public Student remove()
    if(isEmpty())
    return null;
    StudentNode tmp = list;
    list = tmp.getNext();
    i--;
    return tmp.getData();
    public void insertEnd(Student newStudent)
    if(isEmpty())
    add(newStudent);
    else
    StudentNode t = list;
    while(t.getNext() != null)
    t=t.getNext();
    StudentNode tmp = new StudentNode(newStudent, t.getNext());
    t.setNext(tmp);
    i++;
    public Student removeEnd()
    if(isEmpty())
    return null;
    if(list.getNext() == null)
    return remove();
    StudentNode t = list;
    while(t.getNext().getNext() != null)
    t = t.getNext();
    Student newStudent = t.getNext().getData();
    t.setNext(t.getNext().getNext());
    i--;
    return newStudent;
    public Student top(int n)
    StudentNode t = list;
    for(int i = 0; i <n && t != null; i++)
    t = t.getNext();
    return t.getData();
    public void writeToFile(int n)
    int z = n;
    try
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("LIST.out")));
    for(int counter = z; counter >= 0; counter--)
    System.out.println(counter);
    out.close();
    catch(Exception e)
    System.err.println("Couldn't Write File");
    try
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("LIST.out")));
    out.write(list.toString());
    out.close();
    catch(Exception e)
    System.err.println("Couldn't Write File");
    }

  • Converting a string of numbers into an array of booleans

    For a homework assignment, I need to convert a string of numbers into an array of booleans.  The string is a bunch of random numbers (0-9) in sequence, with no spaces.  It looks something like this: 0123452348949230740329817438120947392147809231419.  I need to make it so that each even number represents a "True" boolean and so that each odd number represents a "False" boolean.  I think that I first need to convert each element of the string into a number, and then use a case structure (or something) to say, for each element of the array, "If even, then true.  If odd, then false," but I could be wrong.  Any suggestions?

    billko wrote:
    Hooovahh wrote:
    billko wrote:
    Sounds reasonable.  Think about the definition of "odd" and "even" and it will make life a lot easier. 
    I know you are trying to be vague but I'd like to give a key hint.  Use the Quotient and Remainder function.
    LOL maybe that was one of the objectives of the homework. 
    To be fair it sounds like there is more work that is needed.  A new user of LabVIEW will have a hard time figuring out how to process each character one at a time when it isn't in an array.  
    It's just that most people (me at least) stopped thinking about division with quotient and remainder after basic algebra.  I then of course changed my way of thinking when I used LabVIEW.  Still most of the time when you use division you want to know the fractional part as a decimal.  Thinking this way makes the problem more difficult then it needs to be.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Invoke Web service - WSDL error "Object of type 'System.Int32' cannot be converted to type 'System.UInt64'."

    Hello,
    I'm having a problem when I try to load the WSDL file for the "Invoke Web Service" activity.
    I'm trying to create a connection between Orchestrator 2012 R2 and Cisco Unified CM through a Web Services. When I click the WSDL file and I click the "Format Hint" button appears the following error "Object of type 'System.Int32' can not be
    converted to type 'System.UInt64'."
    The WSDL file that Cisco Unified CM I exported another work tools, tested and working well. In Orchestrator just gives the error.
    Can anyone help with this?
    Thank you
    Rui

    Hi,
    You're going to have to use Get-AzureVM to get your specific VM object and then pipe it into Add-AzureDataDisk. See the examples here:
    http://msdn.microsoft.com/en-us/library/windowsazure/dn495298.aspx
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Convert String variable value  to an Object referece type

    Hi all,
    I want to know that if there any possible way to convert String variable value to a Object reference type in java. I'll explain by example if this is not clear.
    Let's think that there is a string variable name like,
    String name="HelloWorld";
    and there is a class name same to the variable value.
    class HelloWorld
    I am passing this string variable value to a method which is going to make a object of helloworld;
    new convertobj().convert("HelloWorld");
    class convertobj{
    public void convert(String name){
    // in hert it is going to create the object of HelloWorld;
    // HelloWorld hello=new HelloWorld(); just like this.
    now i want to do this from the name variable value.( name na=new name()) like wise.
    please let me know if there any possible way to do that.
    I am just passing the name of class by string variable then i wanted to make a instance of the class which come through the variable value.
    thanx.

    Either cast the object to a HelloWorld or use the reflection API (Google it) - with the reflection API you can discover what methods are available.
    Note: if you are planning to pass in various string arguments and instantiate a class which you expect to have a certain method... you should define an interface and have all of your classes that you will call in this way implement the interface (that way you're sure the class has a method of that name). You can then just cast the object to the interface type and call the method.
    John

  • Querying the data type of objects in an Array?

    I'm able to determine that an argument is an Array using the following query:
    SELECT DATA_TYPE
    FROM all_arguments
    WHERE OBJECT_NAME = 'MY_PROCEDURE' AND ARGUMENT_NAME = 'MY_ARRAY_PARAM'
    DATA_TYPE will be 'PL/SQL TABLE' if the argument/parameter is an array.
    My question is: Is there a way to query what the type of the objects in the array should be? Like NVARCHAR2, VARCHAR2, RAW, DECIMAL, etc.
    Any help is very appreciated!

    I guess the part I'm having trouble with is when the
    Array is defined in a package because the type
    doesn't get listed in "all_coll_types". well, the workaround here would be - the parsing of PACKAGE text - and finding your needed type of array:
    SQL> create or replace package TEST_PACK as
      2          TYPE test_type is table of varchar2(100);
      3   end test_pack;
      4  /
    Package created
    SQL>
    SQL> create or replace package body TEST_PACK as
      2    vc_array test_type;
      3    begin
      4     null;
      5    end;
      6  /
    Package body created
    SQL>
    SQL> select * from user_source t
      2   where name = 'TEST_PACK'
      3  /
    NAME                           TYPE               LINE TEXT
    TEST_PACK                      PACKAGE               1 package TEST_PACK as
    TEST_PACK                      PACKAGE               2         TYPE test_type is table of varchar2(100);
    TEST_PACK                      PACKAGE               3  end test_pack;
    TEST_PACK                      PACKAGE BODY          1 package body TEST_PACK as
    TEST_PACK                      PACKAGE BODY          2   vc_array test_type;
    TEST_PACK                      PACKAGE BODY          3   begin
    TEST_PACK                      PACKAGE BODY          4    null;
    TEST_PACK                      PACKAGE BODY          5   end;
    8 rows selected
    SQL>

  • How to convert a Image object to byte Array?

    Who can tell me, how to convert Image object to byte Array?
    Example:
    public byte[] convertImage(Image img) {
    byte[] b = new byte...........
    return b;

    Hello,
    any way would suit me, I just need a way to convert Image or BufferedImage to a byte[], so that I can save them. Actually I need to save both jpg and gif files without using any 3rd party classes. Please help me out.
    thanx and best wishes

  • Converting premitive data types into strings

    Hello everybody,
    I have a small doubt. Is it possible to convert all data types like int, boolean etc to strings. I know it is possible to convert them individually. But I would like to have it a common method to convert them all. Because I am reading the whole line, so it is taking as strings. I am unable to read their original data types, all are reading as strings.
    Can anybody tell me how to solve this problem?
    Thank you in advance,
    Kashi.

    Hi all,
    Thanx for your answers. But as I told you before I don't know the exact data type of those. Because I am reading whole file by using DataInputStream's readLine() method. It returns the whole line as String. If there are any integer or boolean etc, it converts them as strings. So I could not read the exact data type of them.
    for example:
    int a = 10;
    boolean b = true;
    String str = "The Values are" + a + b;
    this code is in one file. If I read this file from another file, the line
    String str = "The Values are" + a + b;
    reads as a string, but I couldn�t get the 'a' as ineger and 'b' as boolean. it gives they are of strings.
    Thanx,
    Kashi.

  • Converting vector to string array

    How can I convert values in a vector into a string array?
    Vector formsVector = new Vector();
    while (rs.next())
    {formsVector.add(rs.getString("forms"));}
    String forms[] = (String[])formsVector.toArray();
    I tried the above line but it did not work. Any input please?
    Thanks

    .... What is the difference between the two as
    according to online help, both are same.
    String forms[] = (String [])formsVector.toArray();
    String forms[] = (String [])formsVector.toArray( new
    String[0] );The difference lies in the type of the object returned from toArray. The first form you list, formsVector.toArray(), always returns an Object[]. In your example, you'll get a ClassCastException at runtime when you cast to String[].
    The second form will try to use the array you pass in. If it's not big enough, it'll create a new one of the same type as that array. This is what's happening when passing a zero-length array into toArray.
    My personal preference is to save an extra instantiation and build the array to the proper size to begin with:String forms[] = (String [])formsVector.toArray( new String[formsVector.size()] );

  • Object tables/associative arrays are using lots of memory what is alternate

    I'm using mostly object tables/associative arrays in my package and it is using lots of server memorey so i want to use a different technicque to save momorey .
    like using create global temporary table or nested Table Store as or creating table run time at the start and droping it in the end .
    do have any suggestion for this ?
    for this package i'm retriving data from different table into object tables and do calculation in memorey before i send data to front end for reporting using reference cursor .
    give me your suggetion or if you know any example code for this type of process using different technique please let us know .
    thank you very much
    regards
    shailen Patel

    You can create a global temporary table like this:
    CREATE GLOBAL TEMPORARY TABLE AR_TRIAL_RCPT(
      LOC_ACCT_ID NUMBER(12),  
      ACCT_ID NUMBER(12),  
      CURRENCY_ID NUMBER(12),  
      AMT NUMBER(13,   4),  
      AMT_PRIMARY NUMBER(13,   4)
    [ON COMMIT PRESERVE ROWS]
    ;If you want the table truncated on COMMITs leave out the part in brackets other wise leave off the brackets and the table won't be truncated until your session terminates or you explicitly truncate the table.
    You can also define indexes, primary keys, foreign keys, check constraints, etc. on your temporary table if need be to improve processing.
    Now when it comes to inserting into your newly minted global temporary table, you should be able to use one of insert statements from the following anonymous PL/SQL block:
    CREATE GLOBAL TEMPORARY TABLE AR_TRIAL_RCPT(
      LOC_ACCT_ID NUMBER(12),  
      ACCT_ID NUMBER(12),  
      CURRENCY_ID NUMBER(12),  
      AMT NUMBER(13,   4),  
      AMT_PRIMARY NUMBER(13,   4)
    --[ON COMMIT PRESERVE ROWS]
    CREATE GLOBAL succeeded.
    declare
    l_open_receipt_select_1 varchar2(4000) :=
        'select 1, 1, 1, 12.05, 12.05 from dual';
    l_open_receipt_select_2 varchar2(4000) :=
        'select 2, 2, 1, 17.05, 17.05 from dual';
    l_open_receipt_select_3 varchar2(4000) :=
        'select 3 loc_acct_id,
      1 currency_id,
      27.05 amt,
      3 acct_id,
      27.05 amt_primary
      from dual';
    l_open_receipt_select_4 varchar2(4000) :=
        'select 4 loc_acct_id,
      1 currency_id,
      24.35 amt,
      4 acct_id,
      24.35 amt_primary
      from dual';
    l_ins_stmt varchar2(4000);
    begin
      -- If the column order is known ahead of time and is consistent
      -- You can use this form:
      l_ins_stmt :=
        'insert into ar_trial_rcpt (
      loc_acct_id, acct_id, currency_id, amt, amt_primary
      ) '||l_open_receipt_select_1||
      ' union all '||
      l_open_receipt_select_2;
      execute immediate l_ins_stmt;
      -- If the column order is NOT known ahead of time or is INconsistent
      -- You can use this form:
      l_ins_stmt :=
        'insert into ar_trial_rcpt (
      loc_acct_id, acct_id, currency_id, amt, amt_primary
      select loc_acct_id
      , acct_id
      , currency_id
      , amt
      , amt_primary
      from ('||l_open_receipt_select_3||')
      union all
      select loc_acct_id
      , acct_id
      , currency_id
      , amt
      , amt_primary
      from ('||l_open_receipt_select_4||')';
      execute immediate l_ins_stmt;
    end;
    anonymous block completed
    select * from ar_trial_rcpt
    LOC_ACCT_ID ACCT_ID  CURRENCY_ID AMT    AMT_PRIMARY
    1           1        1           12.05  12.05      
    2           2        1           17.05  17.05      
    3           3        1           27.05  27.05      
    4           4        1           24.35  24.35      
    4 rows selected

Maybe you are looking for

  • Computer gets HOT!

    I have my MacBook Pro on for about 20 minutes before the back left part of the computer gets extremely hot. It's been constantly updated, etc. Also, I've reset/shut down the computer for several hours to cool down. It still gets hot even when I have

  • Upgrade the SCVMM 2008 R2 to SCVMM 2012 R2

    Hello ,  i want to upgrade my SCVMM 2008 R2 to SCVMM 2012 R2 . My Actual SCVMM 2008 R2  manage 3 nodes Hyper-V 2.0 What's the best way to upgrade My SCVMM? Thanks. prince

  • "Join Kerberos"

    Hi, I am trying to Join Kerberos in Open Directory in Server Admin. On this machine (Xserve running 10.4.11 server), I went to server admin, open directory, entered the information to "bind now" to Active Directory, and all 5 of the steps were succes

  • No-Archive to Archive Mode Conversion.

    Hi How can I change the mode of my Database From No-Archive to Archive. Because I want to take consistent backups online. Wishes Jawad

  • Serious IE problem

    Hi I have been building a huge series of games at work using Edge Animate that include heavy amounts of Javascript. The first few I built had no issues across all browsers, however every single game since works perfectly across all browsers except on