[x3d-public] X3DJSAIL added further methods to determine presence of child SFNode/MFNode

Don Brutzman brutzman at nps.edu
Sun Feb 26 15:44:01 PST 2017


Added boolean hasSomeFieldName() methods to indicate whether each SFNode/MFNode field contains either strongly typed node(s) or ProtoInstance node(s).

These convenience methods help Java programmers avoid
(a) more-verbose null-value/null-protoinstance checks, or else
(b) Null Pointer Exception (NPE) if that intermediate SF/MFNode value is not present.

These are helpful prior to dereferencing such a field, such as the following example-code snippet.

/**
  * Find contained field statement by name, if present in contained ProtoInterface.
  * @param fieldName is name attribute for field of interest
  * @return fieldObject reference of interest, null otherwise
  */
public fieldObject findFieldByName (String fieldName)
{
	if  (hasProtoInterface())
		 return getProtoInterface().findFieldByName(fieldName);
	else return null;
}

Sample javadoc:

	X3DObject hasHead(), hasScene()
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html#hasHead--
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3DObject.html#hasScene--

	GroupObject hasChildren() hasMetadata()
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Grouping/GroupObject.html#hasChildren--
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Grouping/GroupObject.html#hasMetadata--

	ShapeObject hasAppearance() hasGeometry() hasMetadata()
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Shape/ShapeObject.html#hasAppearance--
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Shape/ShapeObject.html#hasGeometry--
	http://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Shape/ShapeObject.html#hasMetadata--

Online at

	http://www.web3d.org/specifications/java/X3DJSAIL.html

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