From: <dav...@di...> - 2012-07-18 15:01:04
|
I'm mid-fixing the implementation of the Convert interface and I've noticed a number of inconsistencies in how we handle various things and am wondering whether they ought not be brought in line. 1) When calling convert.getString() on a floating point PVScalars, i.e. PVFloat, PVDouble, you generally get something like "float 256.34" or " Double 1.348E25", with varying precision and uppercase "E", but for floating point PVScalarArrays, i.e. PVFloatArray, you get something like "float [] [256.340]" or "double[] [1.34800e25]", with fixed precision and lowercase "e". Since the AbstractPVField (and all its subclasses) use this function to implement toString() this affects how these PVs are displayed in general. The reason is that for arrays the floating point values are converted using the String.format function before being added to the StringBuilder. Is there any reason for this difference? Should they be brought in line and if so in which direction. In lieu of a good reason for them being different, I would say so they should be the same, but don't have strong opinion which way (no format, %g or even %G). 2) If you attempt to use convert.copyScalar () to copy from a numeric type to a PVBoolean an exception is thrown. For the corresponding arrays convert.copyScalarArray() simply returns 0 (the number of elements copied), as it would if the length of the input or room in the target were 0. Wouldn't it be more consistent to throw an exception here too? The interface says it should. Unless anyone has a strong reason not to change this I'll bring the array implementation in line with the interface description and with the scalar implementation. 3) The convert.toString()/fromString() functions don't permit conversion between strings and numeric types (i.e. throw an exception), but such conversions are allowed by convert.copyScalar(). Is there a reason for this? Let me know if you have a preference about any of these. Dave. -- This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom |