[x3d-public] bug in X3D Java SAI. comparing string arrays

yottzumm at gmail.com yottzumm at gmail.com
Wed Jan 4 14:05:15 PST 2017


Changing this code is useful, because the Java SAI may be used from another language, say Python, from which converting from DOM to Python, the constants are not immediately available (but perhaps in the Object Model??).  We should allow for programmers to NOT use the constants, I think, in an understandable way, perhaps by providing our own equals method or by converting both Arrays to strings and then comparing the strings.

John

Sent from Mail for Windows 10

From: yottzumm at gmail.com
Sent: Tuesday, January 3, 2017 11:01 PM
To: Don Brutzman; Roy Walmsley; x3d-public at web3d.org
Subject: bug in X3D Java SAI. comparing string arrays

The following code shows the problem with comparing string arrays.  The equals returns false, so the exception is thrown.
Please revamp this code, then apply to stylesheet code to create better SAI.

John

package org;

import java.util.*;

public class X3DObject {
        public static final ArrayList<String> JUSTIFY_MIDDLE_MIDDLE = new ArrayList<>(Arrays.asList("\"MIDDLE\",\"MIDDLE\""));
        public X3DObject() {
        }
        public void setStringArray(String [] array) throws Exception {
               if (!(Arrays.asList(array).equals(JUSTIFY_MIDDLE_MIDDLE))) {
                       throw new Exception("Illegal "+ Arrays.toString(array));
               }
        }
        public static void main(String [] args) throws Exception {
               new X3DObject().setStringArray(new String[] {"MIDDLE", "MIDDLE"});
        }
}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170104/9a13f7a7/attachment.html>


More information about the x3d-public mailing list