Small fix to name fetching from structure.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7601 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
Kae..pl
2011-06-12 23:01:19 +00:00
parent 10efb37490
commit f914018dc5
@@ -241,15 +241,19 @@ public class Structure implements Cloneable {
return oldMemoryAddress; return oldMemoryAddress;
} }
/** /**
* This method returns the name of the structure. If the structure has an ID field then the name is returned. * 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. * Otherwise the name does not exists and the method returns null.
* @return the name of the structure read from the ID field or null * @return the name of the structure read from the ID field or null
*/ */
public String getName() { public String getName() {
Structure id = (Structure) this.getFieldValue("ID"); Object fieldValue = this.getFieldValue("ID");
return id == null ? null : id.getFieldValue("name").toString().substring(2);//blender adds 2-charactes as a name prefix 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 @Override
public String toString() { public String toString() {