summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-09-11 12:58:34 (EDT)
committer pelder2006-09-11 12:58:34 (EDT)
commit053b221f4c0921b298913eda2e900712440de24b (patch)
tree46c338db049e8ed748e5a1536eb1d0caa0009310
parent5e907e34fc3248890fcf71043014a8c7c69155ca (diff)
downloadorg.eclipse.jet-053b221f4c0921b298913eda2e900712440de24b.zip
org.eclipse.jet-053b221f4c0921b298913eda2e900712440de24b.tar.gz
org.eclipse.jet-053b221f4c0921b298913eda2e900712440de24b.tar.bz2
[156895] Handle simple elements that recur.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EMFEAttrAsElementWrapper.java53
1 files changed, 47 insertions, 6 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EMFEAttrAsElementWrapper.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EMFEAttrAsElementWrapper.java
index f63a55c..ad76635 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EMFEAttrAsElementWrapper.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/xpath/inspectors/EMFEAttrAsElementWrapper.java
@@ -17,6 +17,9 @@
package org.eclipse.jet.internal.xpath.inspectors;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
@@ -28,18 +31,56 @@ public class EMFEAttrAsElementWrapper
{
private final Setting setting;
+ private final int index;
public EMFEAttrAsElementWrapper(Setting setting)
{
+ this(setting, -1);
+ }
+
+ public EMFEAttrAsElementWrapper(Setting setting, int index)
+ {
this.setting = setting;
- // TODO Auto-generated constructor stub
+ this.index = index;
+ }
+
+ public final Object getValue()
+ {
+
+ final Object object = setting.get(true);
+ if(setting.getEStructuralFeature().isMany()) {
+ EList list = (EList)object;
+ return 0 <= index && index < list.size() ? list.get(index) : null;
+ }
+ else
+ {
+ return object;
+ }
+ }
+
+ public final EStructuralFeature getFeature()
+ {
+ return setting.getEStructuralFeature();
+ }
+
+ public final EObject getEObject()
+ {
+ return setting.getEObject();
}
- /**
- * @return Returns the setting.
- */
- public final Setting getSetting()
+ public void remove()
{
- return setting;
+ if(setting.getEStructuralFeature().isMany())
+ {
+ EList list = (EList)setting.get(true);
+ if(index >= 0 && index < list.size())
+ {
+ list.remove(index);
+ }
+ }
+ else
+ {
+ setting.unset();
+ }
}
}