[x3d-public] more on MFString enumerations

Don Brutzman brutzman at nps.edu
Wed Feb 22 07:14:17 PST 2017


Here is the code causing the exception:

	.setFamily(new String[] {"\"SANS\""})
	.setJustify(new String[] {"\"MIDDLE\",\"MIDDLE\""})

The extra \"escape quoting\" is not needed.  See previous response on MFString invocation please.

Also note through careful quote counting that you have a single string with a comma in the middle, not a pair of strings separated by a comma.  In other words, you were probably thinking of something like

	.setJustify(new String[] {"\"MIDDLE\"", "\"MIDDLE\""})

Cleaning this kind of thing up is possible to handle in the set method, i.e. stripping extra quotes.  However, what if the author is creating a string for display and they want the quotes to appear in the rendered output?

Possibly we could add stripping of such quotes only in methods where fixed enumeration values are expected.  This would forgive content that is less than perfectly formed in those special cases.  This approach might support program flexibility but avoid mangling author's intent.  In such cases,

	.setJustify(new String[] {"\"MIDDLE\"", "\"MIDDLE\""})

would be handled the same as

	.setJustify(new String[] {"MIDDLE","MIDDLE"})

Possibly even the following could be handled:

	.setJustify(new String[] {"MIDDLE MIDDLE"})
	.setJustify(new String[] {"MIDDLE,MIDDLE"})

However modifying author content is a steep + slippery slope that can easily backfire - and not be detected until run time.  Further if the API is incorrectly "fixing" an author's code, the author can get caught in a vortex of trying to reverse-engineer an unfix to the mistaken fix...  So we should be very conservative about how "forgiving" such methods might be.


On 2/21/2017 9:04 PM, yottzumm at gmail.com wrote:
> Note the line number of the exception.  There are a couple of methods that look similar.
>
>
>
> John
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>
>
>
> *From: *yottzumm at gmail.com <mailto:yottzumm at gmail.com>
> *Sent: *Tuesday, February 21, 2017 11:51 PM
> *To: *Don Brutzman <mailto:brutzman at nps.edu>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>; Roy Walmsley <mailto:roy.walmsley at ntlworld.com>
> *Subject: *Don, please look a this program and tell me what I am doing wrong.Thanks!
>
>
>
> This program compiles but it throws an Exception when you run it.  I’m trying to figure out why?  I don’t want to use a constant.
>
>
>
> Attached.
>
> John
>
>
>
>
>


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