com.jme3.scene.plugins.blender.file
Class Structure

java.lang.Object
  extended by com.jme3.scene.plugins.blender.file.Structure
All Implemented Interfaces:
java.lang.Cloneable

public class Structure
extends java.lang.Object
implements java.lang.Cloneable

A class representing a single structure in the file.


Constructor Summary
Structure(BlenderInputStream inputStream, java.lang.String[] names, java.lang.String[] types, BlenderContext blenderContext)
          Constructor.
 
Method Summary
 java.lang.Object clone()
           
 java.util.List<Structure> evaluateListBase(BlenderContext blenderContext)
          This methos should be used on structures that are of a 'ListBase' type.
 void fill(BlenderInputStream inputStream)
          This method fills the structure with data.
 java.lang.String getFieldName(int fieldIndex)
          This method returns the field name of the given index.
 int getFieldsAmount()
          This method returns the amount of fields for the current structure.
 java.lang.String getFieldType(int fieldIndex)
          This method returns the field type of the given index.
 java.lang.Object getFieldValue(java.lang.String fieldName)
          This method returns the value of the filed with a given name.
 java.lang.Object getFlatFieldValue(java.lang.String fieldName)
          This method returns the value of the filed with a given name.
 java.lang.String getName()
          This method returns the name of the structure.
 java.lang.Long getOldMemoryAddress()
          This method returns the address of the structure.
 java.lang.String getType()
          This method returns the type of the structure.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Structure

public Structure(BlenderInputStream inputStream,
                 java.lang.String[] names,
                 java.lang.String[] types,
                 BlenderContext blenderContext)
          throws BlenderFileException
Constructor. Loads the structure from the given stream during instance creation.

Parameters:
inputStream - the stream we read the structure from
names - the names from which the name of structure and its fields will be taken
types - the names of types for the structure
blenderContext - the blender context
Throws:
BlenderFileException - this exception occurs if the amount of fields, defined in the file, is negative
Method Detail

fill

public void fill(BlenderInputStream inputStream)
          throws BlenderFileException
This method fills the structure with data.

Parameters:
inputStream - the stream we read data from, its read cursor should be placed at the start position of the data for the structure
Throws:
BlenderFileException - an exception is thrown when the blend file is somehow invalid or corrupted

getFieldValue

public java.lang.Object getFieldValue(java.lang.String fieldName)
This method returns the value of the filed with a given name.

Parameters:
fieldName - the name of the field
Returns:
the value of the field or null if no field with a given name is found

getFlatFieldValue

public java.lang.Object getFlatFieldValue(java.lang.String fieldName)
This method returns the value of the filed with a given name. The structure is considered to have flat fields only (no substructures).

Parameters:
fieldName - the name of the field
Returns:
the value of the field or null if no field with a given name is found

evaluateListBase

public java.util.List<Structure> evaluateListBase(BlenderContext blenderContext)
                                           throws BlenderFileException
This methos should be used on structures that are of a 'ListBase' type. It creates a List of structures that are held by this structure within the blend file.

Parameters:
blenderContext - the blender context
Returns:
a list of filled structures
Throws:
BlenderFileException - this exception is thrown when the blend file structure is somehow invalid or corrupted
java.lang.IllegalArgumentException - this exception is thrown if the type of the structure is not 'ListBase'

getType

public java.lang.String getType()
This method returns the type of the structure.

Returns:
the type of the structure

getFieldsAmount

public int getFieldsAmount()
This method returns the amount of fields for the current structure.

Returns:
the amount of fields for the current structure

getFieldName

public java.lang.String getFieldName(int fieldIndex)
This method returns the field name of the given index.

Parameters:
fieldIndex - the index of the field
Returns:
the field name of the given index

getFieldType

public java.lang.String getFieldType(int fieldIndex)
This method returns the field type of the given index.

Parameters:
fieldIndex - the index of the field
Returns:
the field type of the given index

getOldMemoryAddress

public java.lang.Long getOldMemoryAddress()
This method returns the address of the structure. The strucutre should be filled with data otherwise an exception is thrown.

Returns:
the address of the feature stored in this structure

getName

public java.lang.String getName()
This method returns the name of the structure. If the structure has an ID field then the name is returned. Otherwise the name does not exists and the method returns null.

Returns:
the name of the structure read from the ID field or null

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException