Xj3D 2.0 VRML/X3D Code API

org.web3d.vrml.parser
Class VRMLParserFactory

java.lang.Object
  extended by org.web3d.vrml.parser.VRMLParserFactory
Direct Known Subclasses:
DefaultVRMLParserFactory

public abstract class VRMLParserFactory
extends java.lang.Object

Representation of a parser factory for VRML content.

This is the representation of a basic VRML parser. An parser implementation would extend this instance to provide a specific parser. The implementation class is specified by defining a system property

    org.web3d.vrml.parser.file.factory
 
The value of this property is the fully qualified class name of that implementation. When the newVRMLParserFactory() method is called it will read that property and create a new instance using reflection. The implementation must have a public, zero argument constructor in order to be loaded.

Each time the newVRMLParserFactory() method is called, it will re-read the property and create an instance of the class. This allows you to create different parser instances for each call within the one JVM instance. If no property is defined then the default implementation is used.

All factories are required to support the feature name "VRML-utf8". The version is the VRML specification version supported in the UTF8 encoding (it is also possible the binary version may use this, but definitely not XML encoding).

The following a standard properties that may be required of all factories and readers

NameValuesDefaultDescription
Required-Version "2.0", "3.0" NULL When defined it says that the VRMLReader provided must only support the given version. If it is not supplied then the reader will do its best effort to adapt it's parsing to the version supplied in the stream's header
Required-Format "VRML", "X3D" NULL When defined it says to use this specific file format for the specification.

Version:
$Revision: 1.10 $
Author:
Justin Couch

Field Summary
static java.lang.String FACTORY_CLASS_PROP
          Property name for the factory instance
protected  java.util.Map propertyMap
          The list of properties that have been set.
static java.lang.String REQUIRE_FORMAT_PROP
          Property defining the required file type
static java.lang.String REQUIRE_VERSION_PROP
          Property defining a required version
static java.lang.String VRML_FEATURE
          Feature name for the required VRML feature
static java.lang.String X3D_FEATURE
          Feature name for the required VRML feature
 
Constructor Summary
protected VRMLParserFactory()
          Construct a default instance of this factory.
 
Method Summary
 java.lang.Object getProperty(java.lang.String prop)
          Get the value of the named property.
abstract  boolean hasFeature(java.lang.String feature, java.lang.String version)
          Check to see if this implementation has the nominated feature.
static VRMLParserFactory newVRMLParserFactory()
          Create a new factory parser instance each time this method is called.
abstract  VRMLReader newVRMLReader()
          Request a new instance of a VRMLReader to parse documents.
 void setProperty(java.lang.String name, java.lang.Object value)
          Set the value of the named property to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY_CLASS_PROP

public static final java.lang.String FACTORY_CLASS_PROP
Property name for the factory instance

See Also:
Constant Field Values

VRML_FEATURE

public static final java.lang.String VRML_FEATURE
Feature name for the required VRML feature

See Also:
Constant Field Values

X3D_FEATURE

public static final java.lang.String X3D_FEATURE
Feature name for the required VRML feature

See Also:
Constant Field Values

REQUIRE_VERSION_PROP

public static final java.lang.String REQUIRE_VERSION_PROP
Property defining a required version

See Also:
Constant Field Values

REQUIRE_FORMAT_PROP

public static final java.lang.String REQUIRE_FORMAT_PROP
Property defining the required file type

See Also:
Constant Field Values

propertyMap

protected java.util.Map propertyMap
The list of properties that have been set. Initially empty

Constructor Detail

VRMLParserFactory

protected VRMLParserFactory()
Construct a default instance of this factory.

Method Detail

newVRMLParserFactory

public static VRMLParserFactory newVRMLParserFactory()
                                              throws FactoryConfigurationError
Create a new factory parser instance each time this method is called. Looks up the sytem property and builds a new instance on demand.

Returns:
An instance of the factory
Throws:
FactoryConfigurationError - The class could not be found for some reason or other startup error.

newVRMLReader

public abstract VRMLReader newVRMLReader()
Request a new instance of a VRMLReader to parse documents.

Returns:
A new reader instance

getProperty

public java.lang.Object getProperty(java.lang.String prop)
                             throws SAVNotSupportedException
Get the value of the named property. VRMLReaders are not required to support any specific property names.

Parameters:
prop - The name of the property to get the value of
Returns:
The value of the set property or null if not set
Throws:
SAVNotSupportedException - The VRMLReader does not recognize or does not support this property name.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws SAVNotSupportedException
Set the value of the named property to the given value. VRMLReaders are not required to support any specific property names. Using a value of null will clear the currently set property value. Setting this value here will ensure that the value is set in each instance of VRMLReader before it is returned to the user after creation.

Parameters:
name - The name of the property to set
value - The value of this property
Throws:
SAVNotSupportedException - The VRMLReader does not recognize or does not support this property name.

hasFeature

public abstract boolean hasFeature(java.lang.String feature,
                                   java.lang.String version)
Check to see if this implementation has the nominated feature. If there is no version information passed, it will look for features of all versions.

Parameters:
feature - The name of the feature requested
version - The version of the feature required or null for none
Returns:
true if the feature and version is supported

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium