Xj3D VRML/X3D Code API

org.web3d.vrml.nodes.proto
Class ExternalPrototypeDecl

java.lang.Object
  extended byorg.web3d.vrml.nodes.proto.AbstractProto
      extended byorg.web3d.vrml.nodes.proto.ExternalPrototypeDecl
All Implemented Interfaces:
VRMLExternalNodeType, VRMLExternProtoDeclare, VRMLNodeTemplate, VRMLSingleExternalNodeType
Direct Known Subclasses:
CRExternPrototypeDecl

public class ExternalPrototypeDecl
extends AbstractProto
implements VRMLExternProtoDeclare

ExternalPrototypeDecl is an implementation of the VRMLExternProtoDeclare interface.

The implementation does not provide any events for either type of listener.

Version:
$Revision: 1.16 $
Author:
Alan Hudson
See Also:
VRMLExternProtoDeclare, VRMLProtoInstance

Field Summary
protected  java.lang.String loadedURI
          The URI that was acutally loaded
 
Fields inherited from class org.web3d.vrml.nodes.proto.AbstractProto
BAD_NODE_MSG, errorReporter, FIELD_CLASH_MSG, fieldData, fieldDeclList, fieldIndexMap, isVrml97, nodeName, protoCreator, VRML97_FIELD_MSG, vrmlMajorVersion, vrmlMinorVersion
 
Fields inherited from interface org.web3d.vrml.nodes.VRMLExternalNodeType
LOAD_COMPLETE, LOAD_FAILED, LOADING, NOT_LOADED
 
Constructor Summary
ExternalPrototypeDecl(java.lang.String name, int majorVersion, int minorVersion, NodeTemplateToInstanceCreator creator)
          Create a new instance of a proto that has the given name.
 
Method Summary
 void addContentStateListener(VRMLContentStateListener l)
          Add a listener to this node instance for the content state changes.
 void addUrlListener(VRMLUrlListener l)
          Add a listener to this node instance.
 boolean checkValidContentType(java.lang.String mimetype)
          Check to see if the given MIME type is one that would be supported as content coming into this node.
 VRMLNode createNewInstance(VRMLNode root, boolean isStatic)
          Create a new instance of a real node from this template.
 int getLoadState()
          Ask the state of the load of this node.
 int getPrimaryType()
          Get the primary type of this node.
 VRMLProtoDeclare getProtoDetails()
          Get the real prototype information that this external reference maps to.
 java.lang.String[] getUrl()
          Accessor method to get current value of field url
 java.lang.String getWorldUrl()
          Get the world URL so set for this node.
 void removeContentStateListener(VRMLContentStateListener l)
          Remove a listener from this node instance for the content state changes.
 void removeUrlListener(VRMLUrlListener l)
          Remove a listener from this node instance.
 void setContent(java.lang.String mimetype, java.lang.Object content)
          Set the content of this node to the given object.
 void setLoadedURI(java.lang.String URI)
          Notify the node which URL was used to load the content.
 void setLoadState(int state)
          Set the load state of the node.
 void setProtoDetails(PrototypeDecl proto)
          Set the real prototype information that this external reference maps to.
 void setUrl(java.lang.String[] newUrl, int numValid)
          Set a new value for the url list for this externproto.
 void setWorldUrl(java.lang.String url)
          Set the world URL so that any relative URLs may be corrected to the fully qualified version.
 
Methods inherited from class org.web3d.vrml.nodes.proto.AbstractProto
addNodeListener, appendField, checkNodeType, deleteField, deleteField, fireFieldChanged, getAllFields, getFieldCount, getFieldDeclaration, getFieldIndex, getNumFields, getVRMLNodeName, isVRML97, removeNodeListener, setErrorReporter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.web3d.vrml.lang.VRMLNodeTemplate
appendField, deleteField, deleteField, getAllFields, getFieldCount, getFieldDeclaration, getFieldIndex, getNumFields, getVRMLNodeName, setErrorReporter
 

Field Detail

loadedURI

protected java.lang.String loadedURI
The URI that was acutally loaded

Constructor Detail

ExternalPrototypeDecl

public ExternalPrototypeDecl(java.lang.String name,
                             int majorVersion,
                             int minorVersion,
                             NodeTemplateToInstanceCreator creator)
Create a new instance of a proto that has the given name.

Parameters:
name - The name of the proto to use
majorVersion - The major version number of this scene
minorVersion - The minor version number of this scene
creator - The node creator for generating instances of ourself
Method Detail

createNewInstance

public VRMLNode createNewInstance(VRMLNode root,
                                  boolean isStatic)
                           throws InvalidNodeTypeException
Create a new instance of a real node from this template. This will ensure that all the internals are created as needed, based on the current state of the node. Note that sometimes, creating an instance of this template may result in an invalid node construction. Cases where this could occur is when there's no node definition yet loaded or that the loaded definition does not match this template.

Specified by:
createNewInstance in interface VRMLNodeTemplate
Parameters:
root - The node that represents the root node of the VRMLExecutionSpace that we're in.
isStatic - true if this is created within a StaticGroup
Returns:
A new node instance from this template
Throws:
InvalidNodeTypeException - The root node is not a node capable of representing a root of a scene graph
See Also:
VRMLProtoInstance, VRMLWorldRootNodeType

setProtoDetails

public void setProtoDetails(PrototypeDecl proto)
Set the real prototype information that this external reference maps to. Internally, this class will then deal with all the mapping requirements between the fields. Calling this method is equivalent to calling the setContent() method.

Parameters:
proto - The underlying proto definition

getProtoDetails

public VRMLProtoDeclare getProtoDetails()
Get the real prototype information that this external reference maps to. If the proto information has not been loaded yet, or it is invalid this will return null.

Specified by:
getProtoDetails in interface VRMLExternProtoDeclare
Returns:
The underlying proto definition or null

setUrl

public void setUrl(java.lang.String[] newUrl,
                   int numValid)
Set a new value for the url list for this externproto.

Specified by:
setUrl in interface VRMLSingleExternalNodeType
Parameters:
newUrl - The new set of URLs to use
numValid - number of valid items to fetch from the list

getUrl

public java.lang.String[] getUrl()
Accessor method to get current value of field url

Specified by:
getUrl in interface VRMLSingleExternalNodeType
Returns:
The list of URLs to attempt to load

getLoadState

public int getLoadState()
Ask the state of the load of this node. The value will be one of the constants defined above.

Specified by:
getLoadState in interface VRMLSingleExternalNodeType
Returns:
The current load state of the node

setLoadState

public void setLoadState(int state)
Set the load state of the node. The value must be one of the constants defined above.

Specified by:
setLoadState in interface VRMLSingleExternalNodeType
Parameters:
state - The new state of the node

checkValidContentType

public boolean checkValidContentType(java.lang.String mimetype)
Check to see if the given MIME type is one that would be supported as content coming into this node.

Specified by:
checkValidContentType in interface VRMLSingleExternalNodeType
Parameters:
mimetype - The type to check for
Returns:
true if this is OK, false if not

setWorldUrl

public void setWorldUrl(java.lang.String url)
Set the world URL so that any relative URLs may be corrected to the fully qualified version. Guaranteed to be non-null.

Specified by:
setWorldUrl in interface VRMLExternalNodeType
Parameters:
url - The world URL.

getWorldUrl

public java.lang.String getWorldUrl()
Get the world URL so set for this node.

Specified by:
getWorldUrl in interface VRMLExternalNodeType
Returns:
url The world URL.

setContent

public void setContent(java.lang.String mimetype,
                       java.lang.Object content)
                throws java.lang.IllegalArgumentException
Set the content of this node to the given object. The object is then cast by the internal representation to the form it needs. This assumes at least some amount of intelligence on the part of the caller, but we also know that we should not pass something dumb to it when we can check what sort of content types it likes to handle. We assume the loader thread is operating in the same context as the one that created the node in the first place and thus knows the general types of items to pass through.

Specified by:
setContent in interface VRMLSingleExternalNodeType
Parameters:
mimetype - The mime type of this object if known
content - The content of the object
Throws:
IllegalArguementException - The content object is not supported
java.lang.IllegalArgumentException

setLoadedURI

public void setLoadedURI(java.lang.String URI)
Notify the node which URL was used to load the content. It will be the complete URI with path, query and references parts. This method will be called before setContent.

Specified by:
setLoadedURI in interface VRMLSingleExternalNodeType
Parameters:
URI - The URI used to load this content

getPrimaryType

public int getPrimaryType()
Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements and when trying to determine if the node has been used in the right place. If it is unknown (eg not yet loaded extern proto) then return -1.

Specified by:
getPrimaryType in interface VRMLNodeTemplate
Returns:
The primary type

addUrlListener

public void addUrlListener(VRMLUrlListener l)
Add a listener to this node instance. If the listener is already added or null the request is silently ignored.

Specified by:
addUrlListener in interface VRMLExternalNodeType
Parameters:
l - The listener instance to add

removeUrlListener

public void removeUrlListener(VRMLUrlListener l)
Remove a listener from this node instance. If the listener is null or not registered, the request is silently ignored.

Specified by:
removeUrlListener in interface VRMLExternalNodeType
Parameters:
l - The listener to be removed

addContentStateListener

public void addContentStateListener(VRMLContentStateListener l)
Add a listener to this node instance for the content state changes. If the listener is already added or null the request is silently ignored.

Specified by:
addContentStateListener in interface VRMLExternalNodeType
Parameters:
l - The listener instance to add

removeContentStateListener

public void removeContentStateListener(VRMLContentStateListener l)
Remove a listener from this node instance for the content state changes. If the listener is null or not registered, the request is silently ignored.

Specified by:
removeContentStateListener in interface VRMLExternalNodeType
Parameters:
l - The listener to be removed

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium