Property p = (Property) child;
List<String> propertyNames = c.getPropertyNames();
Collections.sort(propertyNames);
index = propertyNames.indexOf(p.getName());
} else if (parent instanceof SingleValuedProperty) {
SingleValuedProperty p = (SingleValuedProperty) parent;
Value v = (Value) child;
if (p.getValue() != null && p.getValue().equals(v.getObject())) {
index = 0;
}
} else if (parent instanceof ListProperty) {
ListProperty p = (ListProperty) parent;
Value v = (Value) child;
for (int i = 0; i < p.getNumValues() && index == -1; i++) {
if (p.getValue(i) != null && p.getValue(i).equals(v.getObject())) {
index = i;
}
}
} else if (parent instanceof NamedValueProperty) {
NamedValueProperty p = (NamedValueProperty) parent;
String name = ((Value) child).getName();
for (int i = 0; i < p.getValueNames().size() && index == -1; i++) {
if (p.getValueNames().get(i).equals(name)) {
index = i;
}
}
}
} catch (StructuralException e) {