At least in this instance, your method is returning a CSpValue that is
_not_ a CSpString.

If you want to guarantee that you get a CSpString result, you would have to
do:
CSpString min = new CSpString(fdMinInputSizeBank.get( fieldName )
.stringValue());

If you have reason to believe that the method would actually return a
CSpString a good deal of the time, and don't want to incur the overhead of
instantiating a new one all the time, you could test:
CSpValue min1 = ( fdMinInputSizeBank.get( fieldName ));
CSpString min = min1 instanceof CSpString ? min1 : new
CSpString(min1.stringValue());

-- Curt Springer, Team ND

At 05:15 AM 4/16/99 -0800, Pat_ORourke wrote:
>I am trying to cast a CSpValue to a CSpString and the below code is giving
me the following error.
>
>'Unexpected Exception (java.lang.ClassCastException:
spider.session.CSpLong) caught. 
>Top of stack: |java.lang.ClassCastException: spider.session.CSpLong'
>
>
>// Exception thrown here               
>CSpString min = (CSpString)  (fdMinInputSizeBank.get( fieldName ) );
>
>// I placed this debug code in the function to check that a value exists.
>// This prints the value from the database table (eg '10')  to the log
file with no exception
>CSpValue min1 = ( fdMinInputSizeBank.get( fieldName ));
>CSpLog.send( "pgBoResellerDetails", CSpLog.ERROR, min1 );
>               
>
>(Aside : fdMinInputSizeBank is a hash table that stores the minimum value 
>for a particular field) 
>
>Any ideas would be appreciated,
>Thanks,
>Pat.
>_________________________________________________________________________
>
>For help in using, subscribing, and unsubscribing to the discussion
>forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
>For dire need help, email: [EMAIL PROTECTED]
> 
_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to