[x3d-public] summary changes to JSAIL. handling type for fieldValue strings

Don Brutzman brutzman at nps.edu
Sat Mar 11 17:09:07 PST 2017


cc: group

i think i see the issue now.

fieldValue is currently designed to only handle string inputs, thus matching XML syntax.

not sure how to create setters/getters for all different types.  might be able to create utility methods to return or set a typed object, not sure yet.

meanwhile am going to publicly expose .setValueByString(newValue)  method for field type objects, e.g. SFVec3fObject et al., since the method wasn't usable with exposure limited to package scope. have added further type checks in there so it is run-time safe, at least.  strongly typed methods preferred.

example field object:

	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/fields/MFBoolObject.html#setValueByString-java.lang.String-

will also look at building up an example, current examples in HelloWorldProgram only tests SFString type.


On 3/11/2017 4:57 PM, yottzumm at gmail.com wrote:
> Coming from this XML:
>
>
>
> <ProtoInstance name="title_text"><fieldValue name="txt" value=""Acetic Acid: C2 H4 O2""></fieldValue>
>
>
> I wouldn’t mind changing the XML, but perhaps there’s an issue with the field type in the ProtoDeclare/ProtoInterface?
>
>
>
> It’s a matter of looking at the actual field type.
>
>
>
> “\”” is actually “ in Java, not \” (see actual Java code created, not XSLT).  So I think you may be adding an extra \.  I am not really sure, and would have to go through some examples of output JSON and compare to the original JSON.  If you can give me some JSON files to look at I will run them through my process.
>
>
>
> 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: *Saturday, March 11, 2017 7:46 PM
> *To: *Don Brutzman <mailto:brutzman at nps.edu>
> *Subject: *RE: summary changes to JSAIL. Please review and apply, if correct.
>
>
>
> You finally encouraged me to look a the actual example.  It’s where an MFString is used in place of an string:  Here’s what the code looks like:
>
>
>
>                         )
>
>                         .addChild(new ProtoInstanceObject()
>
>                                 .setName("title_text")
>
>                                 .addFieldValue(new fieldValueObject()
>
>                                         .setName("txt")
>
>                                         .setValue("\"Acetic Acid: C2 H4 O2\"")
>
>                                 )
>
>                         )
>
>
>
> From:
>
>
>
>     { "ProtoInstance":
>
>                         {
>
>                           "@name":"title_text",
>
>                           "fieldValue": [
>
>                             {
>
>                               "@name":"txt",
>
>                               "@value":["Acetic Acid: C2 H4 O2"]
>
>                             }
>
>                           ]
>
>                         }
>
>                       }
>
>
>
> There’s no way to pass an MFString to setValue() for  fieldVAlueObject.
>
>
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
>
>
>
> *From: *John Carlson <mailto:yottzumm at gmail.com>
> *Sent: *Saturday, March 11, 2017 7:34 PM
> *To: *Don Brutzman <mailto:brutzman at nps.edu>
> *Subject: *Re: summary changes to JSAIL. Please review and apply, if correct.
>
>
>
> AceticAcid.java...
>
>
>
> On Mar 11, 2017 7:32 PM, "John Carlson" <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>
>     Try Basic/ChemicalMarkupLanguage/Acetic acid.java.  And strings/String arrays therein.
>
>
>
>     On Mar 11, 2017 7:28 PM, "Don Brutzman" <brutzman at nps.edu <mailto:brutzman at nps.edu>> wrote:
>
>         cc: Roy
>
>         On 3/11/2017 4:14 PM, John Carlson wrote:
>
>             Since when are comments SFString?
>
>
>         CommentsBlock, SFString and MFString are using the same XML conventions and escaping code.
>
>         http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter02-GeometryPrimitives/TextIndex.html
>         http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter02-GeometryPrimitives/TextSpecialCharactersIndex.html
>
>         http://x3dgraphics.com/slidesets/X3dForWebAuthors/Chapter02-GeometryPrimitives.pdf
>         (see second half of slideset for notes version)
>
>             Give me an example where it works with an MFString with one embedded SFString.   You can handle comments separately.
>
>
> two test lines in HelloWorldProgram.java
>
>    messageText.setString("Hello single line of text");             // test alternate method
>    messageText.setString(new SFStringObject("Hello single line")); // test alternate method
>
> all the best, Don
> --
> Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu <mailto:brutzman at nps.edu>
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149 <tel:%2B1.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