[kepler-users] problem in output port data type

[BE] Ufuk Utku Turuncoglu turuncu at be.itu.edu.tr
Tue Aug 14 04:09:53 PDT 2007


At last, i convert the string to double. my actor gets input from 'file 
reader' (in ArrayType(string)) which is reads multi column latitude, 
longitide array, and output specified column as double array type. The 
conversion part of the java code is,

            ArrayToken inputArray = (ArrayToken) input.get(0);
            Token[] outputArray = new Token[inputArray.length()/dimsCount];
            int j=0;
            for (int i = indexValue; i < inputArray.length(); 
i+=dimsCount) {
                String tmp = ((StringToken) 
inputArray.getElement(i)).stringValue();
                outputArray[j] = new DoubleToken(tmp);
                j=j+1;
            }
            output.send(0, new ArrayToken(BaseType.DOUBLE, outputArray));

thank you again,
best wishes

ufuk


Christopher Brooks wrote:
> Hi,
>
> Double is a wrapper class for the double primitive type.
> For more information, see: 
> http://java.sun.com/docs/books/tutorial/java/data/numberclasses.html
>
> You have something like:
>      _data[j] = Double.valueOf(inputValue.getElement(i).toString()).doubleValue();
> You could do something like:
>      _data[j] = Double.valueOf(inputValue.getElement(i).toString());
>
> However, this does use the type system very effectively.  Are you sure
> you want data[j] to be of type Double?  If it was of type Token, 
> then your class could pass it as an output.  If you want performance,
> you could call this actor ArrayDoubleColumn and have the array be
> double _data[j].  
>
> Take a look at the ptolemy/actor/lib/Array*.java classes for ideas.
>
> _Christopher
>
>
>
> --------
>
>     Hi,
>     
>     As you said, i am using the Double class to parse the string but i get 
>     following error messages,
>     
>     compile:
>         [javac] Compiling 1 source file to 
>     /SFS/users/turuncu/progs/cvs/kepler/build/classes
>         [javac] 
>     /SFS/users/turuncu/progs/cvs/kepler/build/src/edu/tutorial/turuncu/ArrayCol
>    umn.java:114: 
>     incompatible types
>         [javac] found   : double
>         [javac] required: java.lang.Double
>         [javac]                 _data[j] = 
>     Double.valueOf(inputValue.getElement(i).toString()).doubleValue();
>         
>     [javac]                                                                    
>                           
>     ^
>         [javac] 1 error
>     
>     the inputValue variable is ArrayToken type and _data is in Double array 
>     type. Double.valueOf expect a String argument but it is not working in 
>     this way. I study sume examples that use Double.valueOf method in 
>     Ptolemy actor directory but in my case i am not using stringTokenizer.
>     
>     thank you again for your help
>     best regrads,
>     
>     ufuk
>     _______________________________________________
>     Kepler-users mailing list
>     Kepler-users at ecoinformatics.org
>     http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-users
> --------
>   




More information about the Kepler-users mailing list