Tests: added a method that returns the known blender primary types names. This will be needed in unit tests.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10949 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
Kae..pl 11 years ago
parent 797caf6936
commit c0f46d97c5
  1. 24
      engine/src/blender/com/jme3/scene/plugins/blender/file/Structure.java

@ -31,13 +31,14 @@
*/ */
package com.jme3.scene.plugins.blender.file; package com.jme3.scene.plugins.blender.file;
import com.jme3.scene.plugins.blender.BlenderContext; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.jme3.scene.plugins.blender.BlenderContext;
/** /**
* A class representing a single structure in the file. * A class representing a single structure in the file.
* @author Marcin Roguski * @author Marcin Roguski
@ -71,7 +72,7 @@ public class Structure implements Cloneable {
fields[i] = (Field) structure.fields[i].clone(); fields[i] = (Field) structure.fields[i].clone();
} }
this.blenderContext = blenderContext; this.blenderContext = blenderContext;
this.oldMemoryAddress = structure.oldMemoryAddress; oldMemoryAddress = structure.oldMemoryAddress;
} }
/** /**
@ -93,7 +94,7 @@ public class Structure implements Cloneable {
this.blenderContext = blenderContext; this.blenderContext = blenderContext;
int fieldsAmount = inputStream.readShort(); int fieldsAmount = inputStream.readShort();
if (fieldsAmount < 0) { if (fieldsAmount < 0) {
throw new BlenderFileException("The amount of fields of " + this.type + " structure cannot be negative!"); throw new BlenderFileException("The amount of fields of " + type + " structure cannot be negative!");
} }
if (fieldsAmount > 0) { if (fieldsAmount > 0) {
fields = new Field[fieldsAmount]; fields = new Field[fieldsAmount];
@ -103,7 +104,7 @@ public class Structure implements Cloneable {
fields[i] = new Field(names[nameIndex], types[typeIndex], blenderContext); fields[i] = new Field(names[nameIndex], types[typeIndex], blenderContext);
} }
} }
this.oldMemoryAddress = Long.valueOf(-1L); oldMemoryAddress = Long.valueOf(-1L);
} }
/** /**
@ -117,7 +118,7 @@ public class Structure implements Cloneable {
public void fill(BlenderInputStream inputStream) throws BlenderFileException { public void fill(BlenderInputStream inputStream) throws BlenderFileException {
int position = inputStream.getPosition(); int position = inputStream.getPosition();
inputStream.setPosition(position - 8 - inputStream.getPointerSize()); inputStream.setPosition(position - 8 - inputStream.getPointerSize());
this.oldMemoryAddress = Long.valueOf(inputStream.readPointer()); oldMemoryAddress = Long.valueOf(inputStream.readPointer());
inputStream.setPosition(position); inputStream.setPosition(position);
for (Field field : fields) { for (Field field : fields) {
field.fill(inputStream); field.fill(inputStream);
@ -173,7 +174,7 @@ public class Structure implements Cloneable {
* this exception is thrown if the type of the structure is not 'ListBase' * this exception is thrown if the type of the structure is not 'ListBase'
*/ */
public List<Structure> evaluateListBase(BlenderContext blenderContext) throws BlenderFileException { public List<Structure> evaluateListBase(BlenderContext blenderContext) throws BlenderFileException {
if (!"ListBase".equals(this.type)) { if (!"ListBase".equals(type)) {
throw new IllegalStateException("This structure is not of type: 'ListBase'"); throw new IllegalStateException("This structure is not of type: 'ListBase'");
} }
Pointer first = (Pointer) this.getFieldValue("first"); Pointer first = (Pointer) this.getFieldValue("first");
@ -270,7 +271,7 @@ public class Structure implements Cloneable {
* This enum enumerates all known data types that can be found in the blend file. * This enum enumerates all known data types that can be found in the blend file.
* @author Marcin Roguski (Kaelthas) * @author Marcin Roguski (Kaelthas)
*/ */
/* package */ static enum DataType { /* package */static enum DataType {
CHARACTER, SHORT, INTEGER, LONG, FLOAT, DOUBLE, VOID, STRUCTURE, POINTER; CHARACTER, SHORT, INTEGER, LONG, FLOAT, DOUBLE, VOID, STRUCTURE, POINTER;
/** The map containing the known primary types. */ /** The map containing the known primary types. */
@ -311,5 +312,12 @@ public class Structure implements Cloneable {
} }
throw new BlenderFileException("Unknown data type: " + type); throw new BlenderFileException("Unknown data type: " + type);
} }
/**
* @return a collection of known primary types names
*/
/* package */Collection<String> getKnownPrimaryTypesNames() {
return PRIMARY_TYPES.keySet();
}
} }
} }

Loading…
Cancel
Save