[x3d-public] feature request for X3DJSAIL

Don Brutzman brutzman at nps.edu
Wed Dec 13 09:18:24 PST 2017


Thanks for the interesting suggestion John.  Hmmm...

On 12/10/2017 11:49 PM, John Carlson wrote:
> Provide an argument or CommandLine parameter or ConfigurationProperty which allows you to bypass the validation check, or at least ignore the results, and produce a partial output file (XML and JSON only initially).

It looks like your wish is already granted as part of ConfigurationProperties class, available to X3DJSAIL programmers.  Also some fine-tuning options.

Looking at X3DObject, am finding the following code block under toFileX3D(fileName) method.  Note inclusion of ConfigurationProperties.isValidationExceptionAllowed() call.  Javadoc follows.

==============================================
	public File toFileX3D(String fileName)
	{
		String errorNotice = new String();
		if ((fileName == null || fileName.isEmpty()))
		{
			throw new X3DException("toFileX3D(fileName) fileName not provided;" +
				" be sure to end with extension \"" + FILE_EXTENSION_X3D + "\"");
		}
		if (!fileName.endsWith(FILE_EXTENSION_X3D) && !fileName.endsWith(FILE_EXTENSION_XML))
		{
			throw new X3DException("fileName " + fileName + " does not end with extension " +
                             "\"" + FILE_EXTENSION_X3D + "\" or " +
                             "\"" + FILE_EXTENSION_XML + "\"");
		}
		Path outputFilePath = Paths.get(fileName);
		if (ConfigurationProperties.isDebugModeActive()) // debug check, defaults to local directory
		{
			errorNotice += "[debug] Output file path=" + outputFilePath.toAbsolutePath() + "\n";
			System.out.println (errorNotice);
		}
		
		// http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
		// http://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html
		Charset charset = Charset.forName(ConfigurationProperties.XML_ENCODING_DECLARATION_DEFAULT); // "UTF-8"
									
		try
		{	
			validate(); // strict checks before serializing scene and saving file
		}
		catch (Exception e)
		{
			System.out.println (e); // output exception but allow serialization to continue, file may be editable
			e.printStackTrace();
			if (ConfigurationProperties.isValidationExceptionAllowed())
				 System.out.println ("Output serialization allowed to continue, file may be editable...");
			else throw (e);
		}
[...]

==============================================
public static boolean isValidationExceptionAllowed()

Indicate whether partial results are allowed if validation exception occurs when serializing scene output.

Returns:
     whether validation exceptions are allowed (and operation continues)

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#isValidationExceptionAllowed--

==============================================
public static void setValidationExceptionAllowed(boolean newValidationExceptionAllowed)

Set whether partial results are allowed (and operation continues) if validation exception occurs when serializing scene output. Can be useful technique for debugging, default value is false for strict operation.
Warning: setting value to true permits creation of an invalid scene graph.

Parameters:
     newValidationExceptionAllowed - whether validation exceptions are allowed (and operation continues)

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#setValidationExceptionAllowed-boolean-

==============================================
public static boolean isCreationConnectionValidationExceptionAllowed()

Indicate whether continuation is allowed if validation exception occurs when creating an object.
Warning: TODO experimental.

Returns:
     whether validation exceptions are allowed (and operation continues) during object creation

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#isCreationConnectionValidationExceptionAllowed--

==============================================
public static void setCreationConnectionValidationExceptionAllowed(boolean newCreationConnectionValidationExceptionAllowed)

Set whether partial results are allowed (and operation continues) if validation exception occurs when creating an object. Can be useful technique for debugging, default value is true for permissive order of object creation.
Warning: be sure to validate() this scene once construction is complete.
Warning: TODO experimental.

Parameters:
     newCreationConnectionValidationExceptionAllowed - whether validation exceptions are allowed (and object creation continues)

http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html#setCreationConnectionValidationExceptionAllowed-boolean-

==============================================

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