j3d.org Code

org.j3d.loaders.c3d
Class C3DParameter

java.lang.Object
  extended by org.j3d.loaders.c3d.C3DParameter
Direct Known Subclasses:
C3DByteParameter, C3DFloatParameter, C3DIntParameter, C3DStringParameter

public abstract class C3DParameter
extends java.lang.Object

Base representation of a single parameter.

There are different data types of parameters, and this base class represents all the types, from which individual data types are derived.

Version:
$Revision: 1.1 $
Author:
Justin Couch

Field Summary
static int BYTE_TYPE
          This parameter type is a byte type
static int CHAR_TYPE
          This parameter type is a character (string) type
protected  java.lang.Object data
          The raw data array/object storage.
protected  java.lang.String description
          The description string, if set
protected  int[] dimensions
          The dimensions of this parameter data
static int FLOAT_TYPE
          This parameter type is a float type
protected  int id
          The integer ID value of this parameter
static int INT_TYPE
          This parameter type is a integer type
protected  boolean locked
          Indicating if the parameter is locked
protected static java.lang.String LOCKED_PARAM_MSG
          Message when attempting to write to a locked group
protected  java.lang.String name
          The name of the parameter
 
Constructor Summary
protected C3DParameter(int type, java.lang.String name, boolean locked, int id)
          Construct a new group that represents the given name
 
Method Summary
 boolean equals(java.lang.Object o)
          Compare this parameter for equality to the given object.
 java.lang.String getDescription()
          Get the description used for this group.
 int[] getDimensions()
          Get the descriptions of the size of the dimensions of the object.
 int getId()
          Get the assigned ID of this parameter.
 java.lang.String getName()
          Get the name of the parameter.
 int getType()
          Get the base data type of this parameter.
 java.lang.Object getValue()
          Get the data representation object.
 boolean isLocked()
          Check to see if this parameter is marked as being locked (not editable).
 int numDimensions()
          Get the number of dimensions that this object has.
 void setDescription(java.lang.String desc)
          Set the description string.
 void setLocked(boolean state)
          Changed the locked state of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_TYPE

public static final int CHAR_TYPE
This parameter type is a character (string) type

See Also:
Constant Field Values

BYTE_TYPE

public static final int BYTE_TYPE
This parameter type is a byte type

See Also:
Constant Field Values

INT_TYPE

public static final int INT_TYPE
This parameter type is a integer type

See Also:
Constant Field Values

FLOAT_TYPE

public static final int FLOAT_TYPE
This parameter type is a float type

See Also:
Constant Field Values

LOCKED_PARAM_MSG

protected static final java.lang.String LOCKED_PARAM_MSG
Message when attempting to write to a locked group

See Also:
Constant Field Values

name

protected java.lang.String name
The name of the parameter


locked

protected boolean locked
Indicating if the parameter is locked


id

protected int id
The integer ID value of this parameter


description

protected java.lang.String description
The description string, if set


dimensions

protected int[] dimensions
The dimensions of this parameter data


data

protected java.lang.Object data
The raw data array/object storage. For primitives (parameters with no dimensions), this will be the java.lang object wrapper.

Constructor Detail

C3DParameter

protected C3DParameter(int type,
                       java.lang.String name,
                       boolean locked,
                       int id)
Construct a new group that represents the given name

Parameters:
name - The name this parameter represents
locked - true if this is a locked group
id - The ID of this parameter
Method Detail

equals

public boolean equals(java.lang.Object o)
Compare this parameter for equality to the given object. Will be equals if the ID, type and name are the same. It does not look at the number of dimensions or the data itself. If this is needed, override this method to add the required functionality.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object instance of compare against
Returns:
true if these are the same parameter by the above definition

getType

public int getType()
Get the base data type of this parameter. Returns one of the _TYPE constants defined at the top of this class.

Returns:
A type identifier

getName

public java.lang.String getName()
Get the name of the parameter.

Returns:
The name string

isLocked

public boolean isLocked()
Check to see if this parameter is marked as being locked (not editable).

Returns:
true if this is locked

setLocked

public void setLocked(boolean state)
Changed the locked state of the object.

Parameters:
state - true to make the object locked

getId

public int getId()
Get the assigned ID of this parameter. The will only be positive because negative values indicate groups.

Returns:
An positive integer parameter ID

getDescription

public java.lang.String getDescription()
Get the description used for this group. If none is set, this returns null.

Returns:
The current description string, or null if none

setDescription

public void setDescription(java.lang.String desc)
                    throws java.lang.IllegalStateException
Set the description string. A value of null clears the string. An exception is generated if the user is attempting to write a locked group.

Parameters:
desc - The new description string to use
Throws:
java.lang.IllegalStateException - The object is locked and cannot be changed

getValue

public java.lang.Object getValue()
Get the data representation object. Since there are so many different types that could be assigned, this allows returning of any of the types. The derived class will have methods to set the type-specific objects. It will be up to the end user to understand the various parameter types and cast to the appropriate object based on the data type and number of dimensions. If the number of dimensions is 0, this returns a primitive wrapper object for the data type.

Returns:
The current parameter object

numDimensions

public int numDimensions()
Get the number of dimensions that this object has. In the C3D file format, a maximum of 7 dimensions are allowed. A value of 0 means this is a primitive type.

Returns:
A value between 0 and 7

getDimensions

public int[] getDimensions()
Get the descriptions of the size of the dimensions of the object. If the parameter has no dimensions, this returns null, otherwise it will be an array of length numDimensions(). Each index in the array contains the number of elements in that dimension. Dimensions are implicitly set from the parameter data.

Returns:
The dimensions array or null

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org