[x3d-public] X3DJSAIL. Handling of MFStrings. using string constants, setting an array value with brackets?

Don Brutzman brutzman at nps.edu
Wed Feb 22 06:51:15 PST 2017


hmmm.  the enumerations are autogenerated and available as string constants at

	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Text/FontStyleObject.html#field.summary

	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Text/FontStyleObject.html#JUSTIFY_MIDDLE_MIDDLE

btw programmers can avoid string-syntax errors entirely by using such a value, e.g.

	FontStyleObject.JUSTIFY_MIDDLE_MIDDLE

i prefer this style because typos are caught at compile time, rather than run time.

Wondering, do you have ["square" "brackets"] in the value you are setting?  if so those are illegal.

Am hesitant to strip out square brackets, those would be caught by prior XML validation (and perhaps JSON validation).  Better to fix such errors by not producing them...  this would also be a characteristic of all MF types...

Could put a more descriptive warning in MFString set methods (or perhaps all of the MF set methods) if that seems advisable.

So please let me know what went wrong here (source excerpt would help).

I elaborated the following excerpt from HelloWorldProgram.java

myFontStyle.setFamily (FontStyleObject.FAMILY_SERIF)
		   .setJustify(new String[] {"MIDDLE","MIDDLE"}) // alternate form, but no error checking until run time
		   .setJustify(FontStyleObject.JUSTIFY_MIDDLE_MIDDLE)  // preferred form, error checking at compile time
		   .setTopToBottom(FontStyleObject.TOPTOBOTTOM_DEFAULT_VALUE);


On 2/20/2017 8:39 PM, yottzumm at gmail.com wrote:
> This error came back:
>
>
>
> CoordinateAxes.java
>
> Exception in thread "main" org.web3d.x3d.sai.InvalidFieldValueException: FontStyle justify newValue="["MIDDLE","MIDDLE"]" has illegal value, must use a valid enumeration string.^M
>
>         at org.web3d.x3d.jsail.Text.FontStyleObject.setJustify(FontStyleObject.java:653)^M
>
>         at CoordinateAxes.main(CoordinateAxes.java:135)^M
>
>
>
>
>
> Will send a new batch of error reports when they finish running.  Checking code into X3DJSONLD.
>
>
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>
>
>
> *From: *Don Brutzman <mailto:brutzman at nps.edu>
> *Sent: *Monday, February 20, 2017 12:55 AM
> *To: *yottzumm at gmail.com <mailto:yottzumm at gmail.com>; Roy Walmsley <mailto:roy.walmsley at ntlworld.com>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *Subject: *Re: X3DJSAIL. Handling of MFStrings. First non-quote char trimmedoff.
>
>
>
> bug fixed in recently posted build - thanks!
>
>
>
>
>
> On 2/15/2017 7:01 PM, yottzumm at gmail.com wrote:
>
>> Here’s what output looks like in the JSON:
>
>>
>
>>
>
>>
>
>> "@justify":["IDDLE","MIDDLE\""]
>
>>
>
>>
>
>>
>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>
>>
>
>>
>
>>
>
>> *From: *yottzumm at gmail.com <mailto:yottzumm at gmail.com>
>
>> *Sent: *Wednesday, February 15, 2017 8:27 PM
>
>> *To: *Don Brutzman <mailto:brutzman at nps.edu>; Roy Walmsley <mailto:roy.walmsley at ntlworld.com>; X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
>
>> *Subject: *X3DJSAIL. Handling of MFStrings. First non-quote char trimmed off.
>
>>
>
>>
>
>>
>
>> I notice a problem with the handling of my MFStrings.  Namely, the first character of the first SFString in an MFString is trimmed off, and the final \” is kept on when converting to a JSON array.  It also looks like it happens when defaults are introduced, see @transitionType in cobweb.output.json.  Attached.  No errors on output.
>
>>
>
>>
>
>> Need to verify if this is correct way to specify MFStrings, and if not, can we make it the same between all MFStrings, including text justify constants?  Is append or setString preferred?  Can we reduce the special cases, if any?  If below is the correct way, we need to repair the above paragraph.
>
>>
>
>>
>
>>
>
>>                 Background0_2_4.setBackUrl(new String[] {"\"cubemap/BK.png\",\"http://coderextreme.net/X3DJSONLD/cubemap/BK.png\""});
>
>>
>
>>                 Background0_2_4.setBottomUrl(new String[] {"\"cubemap/BT.png\",\"http://coderextreme.net/X3DJSONLD/cubemap/BT.png\""});
>
>>
>
>>                 Background0_2_4.setFrontUrl(new String[] {"\"cubemap/FR.png\",\"http://coderextreme.net/X3DJSONLD/cubemap/FR.png\""});
>
>>
>
>>                 Background0_2_4.setLeftUrl(new String[] {"\"cubemap/LF.png\",\"http://coderextreme.net/X3DJSONLD/cubemap/LF.png\""});
>
>>
>
>>                 Background0_2_4.setRightUrl(new String[] {"\"cubemap/RT.png\",\"http://coderextreme.net/X3DJSONLD/cubemap/RT.png\""});
>
>>
>
>>                 Background0_2_4.setTopUrl(new String[] {"\"cubemap/TP.png\",\"http://coderextreme.net/X3DJSONLD/cubemap/TP.png\""});
>
>>
>
>>                 NavigationInfo0_2_0.setType(new String[] {"\"EXAMINE\""});
>
>>
>
>>
>
>>
>
>> Thanks,
>
>>
>
>>
>
>>
>
>> 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
>
>
>


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