Multidimensional array and chars

Hi again,
My apologies in advance if i can't word my question that well, i will try and be as clear and succinct as possible and hopefully for this newbie you can apprehend what i'm trying to figure out if i come up short.
I'm trying to write a rather large control statement with a while loop and several nested ifs inside it that ultimately returns a single character after all is said and done, and then continually concatenates that character to a string which will eventually be output to a file. The part i'm stuck at is after i've changed the two letter characters into their ASCII values. I need to make the program take those two ASCII values and use them as a reference to a character in a multidimensional array of alphabetic characters, and then that character will be what is returned at the end.
Here's the method, thanks in advance for your time.
public String encode( String cipherKey )
        String textToEncode = input.next();
        String encodedText = " ";
        cipherKey = cipherKey.toUpperCase();
        textToEncode = textToEncode.toUpperCase();
        openFiles();
        int numberOfChars = textToEncode.length();
        int cipherPos = 0;
        int cipherLength = cipherKey.length();
        while (input.hasNext())
            for ( int count = 0; count < numberOfChars; count++ )
                if (Character.isLetter(textToEncode.charAt(count)))
                    cipherPos %= cipherLength;
                    int xChar = (int) textToEncode.charAt(cipherPos);
                    int yChar = (int) textToEncode.charAt(count);
                    xChar -= 65;
                    yChar -= 65;
                    if ((xChar >= 0) && (xChar <= 25))
                        if ((yChar >= 0) && (yChar <= 25))
                    return ' ';
                 encodedText = encodedText +
    return encodedText; 
    }As you can see towards the end there are some incomplete statements where i became lost.

its there, i couldnt c&p the whole program because it went over my character limit. Yeah it did compile but couldn't invoke my encode method without a NullPointerException.
Here are the other methods in the class....
    public String setSource( String in )
        source = in;
        return source;
     Sets the value of the output file
     * @param out A <code>String</code> value representng name of output file.
     * @see #setSource
    public String setDestination( String out )
        destination = out;
        return destination;
     * Method to open both input and output files, and to test for exceptions
     * @see #encode
     * @see #decode
    private void openFiles()
    File inputFile = new File(source);  //Creates new file object from source file
    File outputFile = new File(destination);  //Creates new file object from destination file
        /* Tests whether input file exists and if so enables the Scanner
         * to read the data in from the source file. Catches SecurityException and
         * FileNotFoundException amd prints appropriate messages to user.
        if (inputFile.exists())
            try
                input = new Scanner( new File( source ) );
                FileReader reader = new FileReader(inputFile);
                BufferedReader BufferIn = new BufferedReader(reader);
            catch ( SecurityException securityException )
                System.err.println("You do not have read access to this file.");
                System.exit( 1 );
            catch ( FileNotFoundException filesNotFoundException )
                System.err.println("Error: File does not exist.");
                System.exit( 1 );         
        /* Tests whether output file exists and if it does enables Formatter
         * to write encoded output to file. Catches SecurityException and
         * FileNotFoundException and prints appropriate message to user.
        if (outputFile.exists())
            try
                output = new Formatter( new File( destination ) );
            catch ( SecurityException securityException )
                System.err.println("You do not have write access to this file.");
                System.exit( 1 );
            catch ( FileNotFoundException filesNotFoundException )
                System.err.println("Error: File does not exist.");
                System.exit( 1 );
     * Closes both input and output files after output file has been written
     * to.
     * @see #openFiles
    private void closeFiles()
        if ( output != null )
            input.close();
            output.close();
    }Edited by: fearofsoftware on Apr 17, 2009 8:35 PM

Similar Messages

  • JNI multidimensional Array and OpenCV

    Hello everybody,
    my first post, so lets go..
    At the moment I am writing my thesis in the filed of automatic image classification. The project is written in Java, but I wanna use the OpenCV library from Intel (http://sourceforge.net/projects/opencvlibrary/) for facedetection.
    So far I managed to call the native method from Java. What I do I parse the path of the image to be analyzed as a string to my C++ programm. The faces are being detected and written into a so called CvSeq (http://www.comp.leeds.ac.uk/vision/opencv/opencvref_cxcore.htm#cxcore_ds_sequences) which holds the coordinates of the rectangles surrounding the found faces. Until now I can only call cvSeq->total which gives me the total number of faces as ints. That integer I return to my java api.
    What I don't know is, how to return a multidimensional array (2 dimensions) where the first dim contains the path as a string to the file and the second dimension 3 integers for x,y coordinates and the lenght of each rectangle.
    Or better, I might know how to return that Array, but not how to create it.
    I know this is somewht OpenCV specific, but maybe someone knows anything. Any little help would be greatly appreciated. Thanks a lot!!!!
    Regards
    Carsten
    attached: JNI source code
    /////////////////////////////////////////// source code ///////////////////////////////////////////////
    #include "cv.h"
    #include "highgui.h"
    #include "cxcore.h"
    #include "cxtypes.h"
    #include "cvaux.h"
    #include "org_kimm_media_image_data_JNIOpenCV.h"
    #include <stdio.h>
    JNIEXPORT jint JNICALL
    Java_org_kimm_media_image_data_JNIOpenCV_getFaces(JNIEnv *env, jobject object, jstring path)
    //declarations
    CvHaarClassifierCascade *pCascade = 0;
    CvMemStorage *pStorage = 0;
    CvSeq *pFaceRectSeq;
    int scale=1;
    jobjectArray recPoints;
    const char *str = env->GetStringUTFChars(path, 0);
    //initializations
    IplImage* pInpImg = cvLoadImage(str, CV_LOAD_IMAGE_COLOR);
    IplImage* small_image = pInpImg;
    pStorage = cvCreateMemStorage(0);
    pCascade = (CvHaarClassifierCascade *)cvLoad
         (("C:/OpenCV/data/haarcascades/haarcascade_frontalface_default.xml"),0, 0, 0 );
    //validaste that everything initilized properly
    if( !pInpImg || !pStorage || !pCascade)
         printf("Initialization failed: %s \n",
              (!pInpImg) ? "didn't load image file" :
              (!pCascade) ? "didn't load Haar Cascade --"
                   "make sure Path is correct" :
              "failed to allocate memory for data storage");
         exit(-1);
    //performance boost through reducing image size by factor 2          
              small_image = cvCreateImage( cvSize(pInpImg->width/2,pInpImg->height/2), IPL_DEPTH_8U, 3 );
    cvPyrDown( pInpImg, small_image, CV_GAUSSIAN_5x5 );
    scale = 2;
    //detect faces in image
    pFaceRectSeq = cvHaarDetectObjects(small_image, pCascade, pStorage,
                                            1.1,                                        //increase search scale by 10% each pass
                                            6,                                        //drop group of fewer than three detections
                                            CV_HAAR_DO_CANNY_PRUNING,          //skip regions unlikely to contain faces
                                                 cvSize(50,50));                         //use XML default for smallest search scale
    //initialize array for location of the faces (HERE IS WHERE I GET INTO TROUBLE!!!!!)
    int x = pFaceRectSeq->total;
    jclass intArrCls = env->FindClass ( "[I" ) ;
    recPoints = env->NewObjectArray ( x, intArrCls, NULL ) ;
    //for(int j = 0; j <= x; j++) {
    //   recPoints[j] = (jintArray)env->NewIntArray(3);
    for(int i=0;i<(pFaceRectSeq ? pFaceRectSeq->total:0); i++)
                                       CvRect* r = (CvRect*)cvGetSeqElem(pFaceRectSeq, i);
                                       CvPoint pt1 = {(r->x)*scale, (r->y)*scale};
                                       CvPoint pt2 = {(r->x + r->width)*scale, (r->y + r->height)*scale};
    //env->SetObjectArrayElement(recPoints,i, pt1.x);
    return pFaceRectSeq->total;
    }

    Any Java array you can consider like one-dimensional array of arrays n-1 dimension. For example, you have a 3 dim. array of objects:
    Object[][][] arr = new Object[1][2][6]; It can be considered as a set of one-dimensional arrays:
    ==========================================
    |  dim   |           Type
    ==========================================
      0          1 element, an array of type �[[Ljava/lang/Object;�
      1          1 x 2 elements , an arrays of type �[Ljava/lang/Object;�
    So you can convert three-dimensional array to one-dimensional array like in C++:
    |�[Ljava/lang/Object;� | �[Ljava/lang/Object;� | �[Ljava/lang/Object;�
         6 objects                 6 objects                 6 objects

  • Multidimensional Array and Bubble Sorting

    Goal:
    Bubble sort the array. I want to keep the data organized. So, 70 with aa, 20 with cc, 40 with ee and so foth.
    Example output....
    aa 70
    bb 30
    cc 40
    dd 90
    then..... by number
    ee 10
    cc 20
    bb 30
    ee 40
    Problem:
    I dont know how to bubble sort by letters. AND, a big and..., and I have not done a double array like this. (can you tell?) :)
    package bubleexample;
    public class BubbleSort
         public BubbleSort ()
         public void sortIntArray (int []  pIntArr)
              int     cnt;
              int     tmp = -1;
              for (int a = 0; a < pIntArr.length - 1; a++)
                   for (cnt = 0; cnt < pIntArr.length - 1; cnt++)
                        if (pIntArr [cnt] > pIntArr [cnt + 1])
                             tmp = pIntArr [cnt];
                             pIntArr [cnt] = pIntArr [cnt + 1];
                             pIntArr [cnt + 1] = tmp;
         public void displayArray (int [] pIntArray)
              for (int cnt = 0; cnt < pIntArray.length; cnt++)
                   System.out.println ("Array[" + cnt + "]: " + pIntArray [cnt]);
         public static void main (String []  args)
              int []  myNumberList = { 70, 20, 40, 10, 80, 60, 30 , 50, 30, 90 };
            String [] myLetterList = { "aa", "cc", "ee", "xx", "bb", "tt", "gg", "rr", "jj", "dd" };
              BubbleSort sortIntArray = new BubbleSort ();
              System.out.println ("Before Sorting");
              sortIntArray.displayArray (myNumberList);
            //sortStringtArray.displayArray (myLetterList);
              sortIntArray.sortIntArray (myNumberList);
            //sortStringArray.sortStringArray (myLetterList);
              System.out.println ("\nAfter Sorting");
              sortIntArray.displayArray (myNumberList);
            //sortStringArray.displayArray (myLetterList);
              System.exit (0);
    }If something is unclear, please let me know.

    incomplete example:
    class Movie
         private String name;
         private int rating;
         public Movie( String name, int rating )
              this.name = name;
              this.rating = rating;
         public String getName() { ..... }
         public int getRating() { ...... }
         public String toString() {} // recommended but you don't have to
    } // end of class Movie
    public class SortString2
         public static sort(..) {...}
         public static void main( String args[] )
              String[] names = {"Meet the Fockers","Blade",...};
              int[] ratings = {5,3,4,...}
              Movie[] movies = makeMovieArray( names, ratings );
              sort( movies );
              System.out.println(...);
              for ( Movie movie : movies )
                   System.out.printf( "movie:  %s\nrating:  %d\n\n", movie.getName(), movie.getRating() );
         public static Movie[] makeMovieArray( String[] names, int[] ratings )
              Movie[] movies;
              if ( names.length == ratings.length )
                   movies = new Movie[names.length];
                   for ( int i=0; i<names.length; i++ )
                        movies[i] = new Movie(names,ratings[i]);
                   return movies;
              else
                   return;
    } // end of class SortString2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Multidimensional Arrays + Me + OOP = Fear

    node.java
    class node {
         int[][] grid = new int[0][0];
         void detect(){
              System.out.println(grid);
    game.java
    class game {
         public static void main(String args[]) {
              node a = new node();
              a.detect();
    The output of this code is:
    http://img237.imageshack.us/img237/6556/outputxy7.png
    I am trying to create an imaginary grid so I can implement A* algorithm into my game which will later be an applet.
    Why did the output of this come out so weird? I do not understand multidimensional arrays and I struggle to understand object oriented programming.
    I have known Java since Nov 2006, but I have always dodge some of this difficult stuff. I am totally self taught and I have been learning through the Internet and a very old Java 2 book. So please speak "dumb" to me.
    Thank you,
    Andrew.

    Oh, grow up. If you get insulted this easily, you'll be inconsolable when you have to get a real job. I'm so sick of these children who want help but also want their genius to remain unquestioned.
    Anyway my point wasn't that you altered the image, but rather that you were careless in what you presented as data. Some of the stuff on that image couldn't possibly have worked with the code you posted. (In particular "java node" would not have even run. It wouldn't produce any output at all other than an error message.)
    Part of debugging is gathering real, useful, accurate information. And if you want help debugging you have to share real, useful, and accurate information. If you gather output and then change your code, you should at the very least make this clear.

  • Multidimensional arrays with enhanced for statement

    hello, do you know if it is possible to use enhanced for loop with multidimensional arrays, and if yes, then how?
    for example:
    int[][] arr = {{1,2},{3,4}};
    for(int i[][] : arr){
        doSomethingWith(i[][]);
    }

    The syntax is nice'n'easy:
    void f(int[][] m) {
        for(int[] row : m) {
            for(int x : row) {
    }

  • IndexOf on multidimensional array

    var clipArray:Array = new Array();
    clipArray[0] = new Array();
    clipArray[1] = new Array();
    clipArray[0][0]=2
    clipArray[0][1]=3
    clipArray[1][0]=4
    clipArray[1][1]=5
    trace(clipArray[0].indexOf(3));
    This traces '1' cause 3 can be found in [0][1] of the multidimensional array and 1 is the second value of that 0.
    Using indexOf this way I can determine that second value in which in this case the value 3 can be found.
    I want to to take this one step further and use indexOf somehow to determine the first value of the clipArray variable. So looking for 2 or 3 should trace 0 and looking for 4 or 5 should trace 1. Is there some way to do this?

    the following returns both indices:
    function indexOf2D(a:Array,v:*):Array{
    for(var i:int=0;i<a.length;i++){
    for(var j:int=0;j<a[i].length;j++){
    if(a[i][j]==v){
    return [i,j];
    return [-1,-1];

  • Question on System.arraycopy method and multidimensional array

    I'm trying to copy from single dimensional to multidimensional array using System.arraycopy method. The following is my problem.
    1) I need to specify the index of the multidimensional array while copying. Can I do that ? If yes , how???
    eg ; int a[] = new int[3];
    int b[] = new int[3][2]; I need to copy from a to b
    I tired the following and I'm getting an error.
    System.arraycopy(a,0,b[][1],0,3);
    How Can I achieve the above?? PLease Help --------------

    Java doesn't have multidimensional arrays. When you see an int[][] it's an array of arrays of ints. The arrays of ints might have different lengths like this one:int[][] arr =
    {{1,2,3,4},
    {1,2,3},
    {1,2},
    {1}
    };Do I need to say that arraycopy as you see it would fail in this case?
    If you know what kind of arrays you'll have you can simply implement your own arraycopy method (but it will not be as effecient as System.arraycopy) with a simple for-loop.

  • Inserting Records in an Array and using a constructor with it

    I badly need help on this! Please please please! I have been studying java for a short time only.
    Anyway, here goes: My project requires the following:
    Employee inputs the no. of video in the shelf. They have four classifications: Drama, Comedy, Action, and Thriller. Each video classification has different rates. The employee creates a video record containing the following information: 1. video ID number, 2. video classification, and 3. Price.
    The employee should display the classifications of videos available and the price. Only the available video tapes would be displayed according to the customer's chosen classification. When the customer chooses the video he wants to rent, the program will register and attach the name of the customer to the video number.
    I only need to use arrays, and NOT database to record the information.

    is it ok i i declare the drama_rate outside the video class?
    i have a list of variables on my videoupdate classYes. It's probably best to declare it static & then you can access it directly:
    public static float drama_rate = 100.0;
    rate = <the class name>.drama_rate;
    so, i should also include a customer no. both in the video and customer class.I would. You may want to list a bunch of videos and who currently has them. This way you don't have to search the customers AND the videos to do this.
    thanks =) i don't know either why we had to validate/invalidate,\
    but our applet doesnt refresh when >it is supposed to, so
    we just used this method. It wouldnt slow down the application, would it?Could you just revalidate()?
    the use of arrays. i havent finished with the program yet.
    i have the design already, i just couldnt put it in code.
    im not familiar with the use of multidimensional arrays-
    can i use this for the video and customer records i will need to store?Not sure what you're using arrays for, but here's an example of something I might do. Maybe it will be useful to you.
    Have you looked at HashMaps? You could use "Customer" as the key and then use an ArrayList of checked out Videos as the value:
    HashMap customers = new HashMap();
    ArrayList videos = new ArrayList();
    //Add the checked out videos to the list
    videos.add(video);
    <etc>
    // Add this customer and the list of videos he has checked out.
    customers.put(customer,videos);
    [\code]

  • Trouble with primitive arrays and casting, lesson 521

    hi everyone!
    there is a problem i discovered right now - after years with java where was no necessity to do this.....
    and i'm shure this must have been the topic already, but i couldn't find any helpful resource :-/
    right here we go:
    1. an array is a (special) kind of object.
    2. there are "primitive" arrays and such containing references to objects. of course - and i imagine why - they are treated differently by the VM.
    3. then both are - somehow - subclasses of Object. whereas primitive types are not really, primitive-arrays are. this is hidden to the programmer....
    4. any array can be "pointed" at via local Object variable, like this:
    Object xyz = new int[6];
    5. arrays of Objects (with different dimensions) can be casted, like this:
      Object pointer = null;
      Object[]   o  = new SomeClass[42] ;
      Object[][] oo = new OtherClass[23] [2] ;
      Object[][][] ooo = new OtherClass[23] [2] [9] ;
      o = oo = ooo;     // this is save to do,
                                   //because "n-dimensional" object-arrays
                                  // are just arrays of  other arrays, down to simple array
    pointer = o;         // ok, we are referencing o via Object "pointer"6. but, you cannot do this with primitive types:
      int[]  i1 = new int [99] ;
      int[][] i2 = new int [1] [3] ;
      i1 = i2                  // terror: impossible. this is awful, if you ask me.
                                   // ok, one could talk about "special cases" and
                                   // "the way the VM works", but this is not of interest to me as
                                   // a programmer. i'm not happy with that array-mess!
      pointer = i2;       // now this is completely legal. i2, i1 etc is an object!7. after the preparation, let's get into my main trouble (you have the answer, i know!) :
    suppose i have a class, with methods that should process ANY kind of object given. and - i don't know which. i only get it at runtime from an unknown source.
    let's say: public void BlackBox( Object x );
    inside, i know that there might be regular objects or arrays, and for this case i have some special hidden method, just for arrays... now try to find it out:
    public void BlackBox( Object x )
      if ( x == null)
           return;
       Class c = x.getClass();
       if ( c.isArray() )
              // call the array method if it's an array.........
              BlackBoxes(     (Object [] )  x );         // wait: this is a cast! and it WILL throw an exception, eventually!
              return;
       else
               DoSpecialStuffWith( x );
    }ok ? now, to process any kind of array, the special method you cannot reach from outside:
    private void BlackBoxes( Object[] xs )
       if ( xs != null )
            for ( Object x : xs )
                 BlackBox( x );
    // this will end up in some kind of recursion with more than one array-dimension, or when an Object[] has any other array as element!this approach is perfectly save when processing any (real) Object, array or "multi-dimensional" arrays of Objects.
    but, you cannot use this with primitive type arrays.
    using generics wouldn't help, because internally it is all downcasted to Object.
    BlackBox( new Integer(3) ) ---- does work, using a wrapper class
    BlackBox( new Integer[3] ) ----- yep!
    BlackBox( 3 ) ---- even this!
    BlackBox( new int[42] ) ---- bang! ClassCastException, Object[] != int[]
    i'm stuck. i see no way to do this smoothly. i could write thousands of methods for each primitive array - BlackBox( int[] is ) etc. - but this wouldn't help. because i can't cast an int[][] to int[], i would also have to write countless methods for each dimension. and guess, how much there are?
    suppose, i ultimately wrote thousands of possible primitive-type methods. it would be easy to undergo any of it, writing this:
    BlackBox( (Object) new int[9] [9] );
    the method-signature would again only fit to my first method, so the whole work is useless. i CAN cast an int[] to Object, but there seems no convenient way to get the real array out of Object - in a generic way.
    i wonder, how do you write a serialisation-engine? and NO, i can't rely on "right usage" of my classes, i must assume the worst case...
    any help appreciated!

    thanks, brigand!
    your code looks weird to me g and i think there's at least one false assumption: .length of a multidimensional array returns only the number of "top-level" subarrays. that means, every length of every subarray may vary. ;)
    well i guess i figured it out, in some way:
    an int is no Object;
    int[ ] is an Object
    the ComponentType of int [ ] is int
    so, the ComponentType of an Object int[ ] is no Object, thus it cannot be casted to Object.
    but the ComponentType of int [ ] [ ] IS Object, because it is int [ ] !
    so every method which expects Object[], will work fine with int[ ] [ ] !!
    now, you only need special treatment for 1-dimensional primitive arrays:
    i wrote some code, which prints me everything of everything:
        //this method generates tabs for indentation
        static String Pre( int depth)
             StringBuilder pre = new StringBuilder();
             for ( int i = 0; i < depth; i++)
                  pre.append( "\t" );
             return pre.toString();
        //top-level acces for any Object
        static void Print( Object t)
             Print ( t, 0);
        //the same, but with indentation depth
        static void Print( Object t, int depth)
            if ( t != null )
                 //be shure it is treated exactly as the class it represents, not any downcast
                 t = t.getClass().cast( t );
                if ( t.getClass().isArray() )
                     //special treatment for int[]
                     if ( t instanceof int[])
                          Print( (int[]) t, depth);
                     // everything else can be Object[] !
                     else
                          Print( (Object[]) t, depth );
                     return;
                else
                    System.out.println( Pre(depth) + " [ single object:] " + t.toString() );
            else
                System.out.println( Pre(depth) + "[null!]");
        // now top-level print for any array of Objects
        static void Print( Object [] o)
             Print( o, 0 );
        // the same with indentation
        static void Print( Object [] o, int depth)
            System.out.println( Pre(depth) + "array object " + o.toString() );
            for ( Object so : o )
                    Print( so, depth + 1 );
        //the last 2 methods are only for int[] !
        static void Print( int[] is)
             Print( is, 0 );
        static void Print( int[] is, int depth)
            System.out.println( Pre(depth) + "primitive array object " + is.toString() );
            // use the same one-Object method as every other Object!
            for ( int i : is)
                 Print ( i, depth + 1 );
            System.out.println( "-----------------------------" );
        }now, calling it with
    Print ( (int) 4 );
    Print ( new int[] {1,2,3} );
    Print( new int[][] {{1,2,3}, {4,5,6}} );
    Print( new int[][][] {{{1,2,3}, {4,5,6}} , {{7,8,9}, {10,11,12}}, {{13,14,15}, {16,17,18}} } );
    Print( (Object) (new int[][][][] {{{{99}}}} ) );
    produces this fine array-tree:
    [ single object:] 4
    primitive array object [I@9cab16
          [ single object:] 1
          [ single object:] 2
          [ single object:] 3
    array object [[I@1a46e30
         primitive array object [I@3e25a5
               [ single object:] 1
               [ single object:] 2
               [ single object:] 3
         primitive array object [I@19821f
               [ single object:] 4
               [ single object:] 5
               [ single object:] 6
    array object [[[I@addbf1
         array object [[I@42e816
              primitive array object [I@9304b1
                    [ single object:] 1
                    [ single object:] 2
                    [ single object:] 3
              primitive array object [I@190d11
                    [ single object:] 4
                    [ single object:] 5
                    [ single object:] 6
         array object [[I@a90653
              primitive array object [I@de6ced
                    [ single object:] 7
                    [ single object:] 8
                    [ single object:] 9
              primitive array object [I@c17164
                    [ single object:] 10
                    [ single object:] 11
                    [ single object:] 12
         array object [[I@1fb8ee3
              primitive array object [I@61de33
                    [ single object:] 13
                    [ single object:] 14
                    [ single object:] 15
              primitive array object [I@14318bb
                    [ single object:] 16
                    [ single object:] 17
                    [ single object:] 18
    array object [[[[I@ca0b6
         array object [[[I@10b30a7
              array object [[I@1a758cb
                   primitive array object [I@1b67f74
                         [ single object:] 99
    -----------------------------and i'll have to write 8 methods or so for every primitive[ ] type !
    sounds like a manageable effort... ;-)

  • How to pass a multidimensional array to an Oracle procedure?

    How can I pass a multidimensional array to oracle array?
    Thanx in anticipation,

    Look in to passing user defined type back and forth to Oracle. Any type that oracle supports, you can constract on the java side and send it across. Look into the SQLData class.

  • Converting from spreadshet string to array and then back to spreadsheet string

    My questions is; why is the Spreadsheet string to array function creating more data than the original string had when you change the array back into a spreadsheet string. Im trying to analyze a comma delimited file using array functions since my column and row size is constant, but my data varies. Thus my reason for not using string parsing functions which would get more involved and difficult. So, however, after i convert to a 2D array of data from the comma delimited file I read from, and then I convert back to string using the Array to Spreadsheet String, I get added columns to the file, which prevents another program from receiving these files. Also, the data which I am reading is not all contiguous, it has gaps in some places for empty data. Looking at the file compared to the original after it has gone from string to array and then back to string again, looks almost identical except for the file size which got larger by 400 bytes and where the original file has empty spaces, the new file has a lot of commas added. Any idea?
    Charles

    The result you get is normal when the spreadsheet string contains rows of uneven length. Since the array rows have the same number of elements, nil values are added during the coonversion. And of course, the back to string conversion keep those added values in the string, with the associated commas.
    example : 3 x 3 array
    1,2,3
    4
    5,6,7
    is converted into
    1 2 3
    4 0 0
    5 6 7
    then back to
    1,2,3
    4,0,0
    5,6,7
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • I would like to place an element into a two dimensional array, and I would like to be able to specify which row and column each of the elements will go in.

    In the vi that I am writing I have rise and fall times to post in a very specific pattern. I can initialize an array,and I can replace elements, but in "replace element" I only find that I am given the choice of specifying a single dimensional position. I need to be able to specify BOTH column and row. Can anyone help me?

    Hi Jryan !
    If you wire a 2D array to the input of a "replace element" function, you will see that the function expand to display an additionnal index. The one you are looking for !!
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Read two different arrays and display

    I have a text file, which has 1000 of entries in the way mentioned below:
    Kozos customer
    sabze employee
    I am reading the content of text file and saving as an arrays.
    $global:Content = get-content info.txt
    $global:Name=$Content | foreach {
    $hashTab=@{Name="" ; Info=""}
    $hashTab.Name, $hashTab.Info=$_.Trim() -split '\s+'
    New-Object PSObject -Property $hashTab
    $global:Names=$ServerList | select -ExpandProperty Name
    $global:Infos=$ServerList | select -ExpandProperty Info
    How do I read two arrays, I mean read the values of two arrays one by one and display the result as:
    Names Infos
    Kozos Customer
    sabze employee

    We get that you are unable to do this, but it is still not clear precisely what it is that you want, a two-dimensional array, or a structure such as SeanQuinlan suggested? Also:
    there seems no reason for any of the variables to be global in scope.
    Where is the $serverlist variable defined?
    what relationship is there between the file you mention and the data in the $serverlist variable?
    Your code has three arrays, $name, $names, and $infos; which two of these do you want to combine into a single array? If $names and $infos, would this work for you:
        $namesNinfos = $serverlist | select name,info
    I suggest that you describe your situation without trying to state it in powershell (as that is partly where your problem lies). You could, for example, show sample content of the file and each of the two arrays, and show what this would look like in your
    desired two-dimensional array, perhaps like this:
    file info.txt
    Kozos customer
    sabze employee
    array 1:
    Kozos
    sabze
    array 2:
    customer
    employee
    resultant 2D array
    column 1 2
    row
    1 Kozos customer
    2 sabze employee
    As an aside, it could be that we are getting confused by the term "array". languages such as fortran and basic support multidimensional arrays in which each element is addressed by a set of integer indices, the most common form being row and column, as in
    a spreadsheet.
    In Powershell, arrays are generally one dimensional, with a single numerical index being used to select a single element ($row3 = $array[2]). That element can optionally have multiple values if it is defined as an array or a hash. This is referred to as
    a "jagged array" as each element of the array may not all have the same number of sub-elements as each other.
    Powershell also supports true multidimensional arrays, however, these seem fairly rarely used, I suspect because jagged arrays generally provide more easily used functionality.
    You can get more details on this from
    here and
    here.
    This, then, leads to my final question:
    what type of two-dimensional array are you looking for, and how will your script be processing it?
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

  • Bindind data to multidimensional Array

    I have a multidimensional Array (3D). I have some fields which I want to bind to some TextInputs:
    model.creditosConsumoModel.literaturaCredito[i][j][k]
    And here's a example of the data binding:
    text="{(model.creditosConsumoModel.literaturaCredito[4][12][0] as Apartado).texto}"
    The problem is: When I do a: model.creditosConsumoModel.literaturaCredito = new Array and I define the Array again with new data everything gets blank (all the text Inputs) and I loss the information.
    Resume: It only works the first time, but not the rest of the times.
    Thanks and regards!!!

    @Pauland
    That's what I was thinking as it was an array of arrays.
    @quebequiano
    Generally, for something like this, I make a wrapper object and set the values on that so I don't have to deal with issues like this.  I'm not sure how architecturally sound it is, but it sounds like you are trying to take small pieces of data and prepare them for your view, in which case a wrapper/adapter would provide you with the benefits of databinding.
    P.S Does your name mean "Quebecian" in spanish ?

  • Two instances of quirky behavior: array size of empty array and tab control freeze

    LV 7.1
    Array size of empty array. Adding empty arrays to an array of higher dimension produces a fantom array of non-zero size.
    Tab control freeze. An event structure with checked 'lock front panel until the event case completes' option permanently freezes the front panel in certain special circumstances.
    Zador

    tst wrote:
     Tell me if you still think this makes sense.
    Whew, let me look at this tonight after I activate the 4D module in my brain.
    (I think it makes sense, though ) Generally I look at the product of the dimensions array to determine if an array is empty. You can initialize a multidimensional array with some dimensions at zero and it is reproduced nicely in the array size output. Also the "Empty array" tool correctly identifies it as empty, even if some dimensions are nonzero.
    Message Edited by altenbach on 03-15-200612:42 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    init.png ‏3 KB

Maybe you are looking for