OSDN Git Service

A method to find property in subproperties added.
authorKaelthas_Spellsinger@o2.pl <Kaelthas_Spellsinger@o2.pl@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Sun, 26 Jun 2011 19:39:47 +0000 (19:39 +0000)
committerKaelthas_Spellsinger@o2.pl <Kaelthas_Spellsinger@o2.pl@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Sun, 26 Jun 2011 19:39:47 +0000 (19:39 +0000)
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7749 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/blender/com/jme3/scene/plugins/blender/structures/Properties.java

index 02806a9..eb090d7 100644 (file)
@@ -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() {