浏览代码

A method to find property in subproperties added.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7749 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Kae..pl 14 年之前
父节点
当前提交
ccf1242112
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. 30 0
      engine/src/blender/com/jme3/scene/plugins/blender/structures/Properties.java

+ 30 - 0
engine/src/blender/com/jme3/scene/plugins/blender/structures/Properties.java

@@ -196,6 +196,36 @@ public class Properties implements Cloneable, Savable {
 	public Object getValue() {
 		return value;
 	}
+	
+	/**
+	 * This method returns the same as getValue if the current property is of
+	 * other type than IDP_GROUP and its name matches 'propertyName' param. If
+	 * this property is a group property the method tries to find subproperty
+	 * value of the given name. The first found value is returnes os <b>use this
+	 * method wisely</b>. If no property of a given name is foung - <b>null</b>
+	 * is returned.
+	 * 
+	 * @param propertyName
+	 *            the name of the property
+	 * @return found property value or <b>null</b>
+	 */
+	@SuppressWarnings("unchecked")
+	public Object findValue(String propertyName) {
+		if (name.equals(propertyName)) {
+			return value;
+		} else {
+			if (type == IDP_GROUP) {
+				List<Properties> props = (List<Properties>) value;
+				for (Properties p : props) {
+					Object v = p.findValue(propertyName);
+					if (v != null) {
+						return v;
+					}
+				}
+			}
+		}
+		return null;
+	}
 
 	@Override
 	public String toString() {