[x3d-public] X3DJSAIL. Setting field value to null. Ambiguous

Don Brutzman brutzman at nps.edu
Thu Feb 16 11:33:13 PST 2017


John, you will find that field-type objects have a clear() method.

The only place NULL is allowed in X3D spec is when an MFNode array or child SFNode is empty.

Usually there are traps that look for empty string or null, setting result to default or else throwing an exception as best seems appropriate.

In general, setting something to null is ambiguous and can easily lead to Null Pointer Exceptions (NPE) if unhandled.  So the library tries to trap all of these accordingly, making it hard to build a broken scene graph.

Hope this helps.


On 2/15/2017 6:11 PM, yottzumm at gmail.com wrote:
> There’s slight ambiguity in setting  field values to null.  We’ll have to cast or provide a
>
> setValueNull() method.   Let me know if an additional method is provided. Attached example.
>
>
>
> NancyPrototypes.java:263: error: reference to setValue is ambiguous
>
>                 field0_2_2_0_35.setValue(null);
>
>                                ^
>
>   both method setValue(String) in fieldObject and method setValue(SFStringObject) in fieldObject match
>
> NancyPrototypes.java:270: error: reference to setValue is ambiguous
>
>                 field0_2_2_0_37.setValue(null);
>
>                                ^
>
>   both method setValue(String) in fieldObject and method setValue(SFStringObject) in fieldObject match
>
> NancyPrototypes.java:544: error: reference to setValue is ambiguous
>
>                 field0_2_6_0_18.setValue(null);
>
>                                ^
>
>   both method setValue(String) in fieldObject and method setValue(SFStringObject) in fieldObject match
>
> 3 errors
>
>
>


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list