From f914018dc557510c715de4c8d672c0dcae52b69f Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Sun, 12 Jun 2011 23:01:19 +0000 Subject: [PATCH] Small fix to name fetching from structure. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7601 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../scene/plugins/blender/data/Structure.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/data/Structure.java b/engine/src/blender/com/jme3/scene/plugins/blender/data/Structure.java index 6e9aff18d..070ac9e4b 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/data/Structure.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/data/Structure.java @@ -241,16 +241,20 @@ public class Structure implements Cloneable { return oldMemoryAddress; } - /** - * 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. - * @return the name of the structure read from the ID field or null - */ - public String getName() { - Structure id = (Structure) this.getFieldValue("ID"); - return id == null ? null : id.getFieldValue("name").toString().substring(2);//blender adds 2-charactes as a name prefix - } - +/** + * 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. + * @return the name of the structure read from the ID field or null + */ + public String getName() { + Object fieldValue = this.getFieldValue("ID"); + if(fieldValue instanceof Structure) { + Structure id = (Structure)fieldValue; + return id == null ? null : id.getFieldValue("name").toString().substring(2);//blender adds 2-charactes as a name prefix + } + return null; + } + @Override public String toString() { StringBuilder result = new StringBuilder("struct ").append(type).append(" {\n");