KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > sdo > util > BasicESequence


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: BasicESequence.java,v 1.4 2005/06/08 06:24:25 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.sdo.util;
18
19 import org.eclipse.emf.ecore.EStructuralFeature;
20 import org.eclipse.emf.ecore.sdo.EProperty;
21 import org.eclipse.emf.ecore.util.FeatureMap;
22 import org.eclipse.emf.ecore.util.FeatureMapUtil;
23
24 import commonj.sdo.Property;
25
26 /**
27  * Delegates to a feature map
28  */

29 public class BasicESequence implements ESequence
30 {
31   protected FeatureMap.Internal featureMap;
32
33   public BasicESequence(FeatureMap.Internal featureMap)
34   {
35     this.featureMap = featureMap;
36   }
37
38   public FeatureMap featureMap()
39   {
40     return featureMap;
41   }
42
43   public int size()
44   {
45     return featureMap.size();
46   }
47
48   public Property getProperty(int index)
49   {
50     return SDOUtil.adaptProperty(featureMap.getEStructuralFeature(index));
51   }
52   
53   public Object JavaDoc getValue(int index)
54   {
55     return featureMap.getValue(index);
56   }
57   
58   public Object JavaDoc setValue(int index, Object JavaDoc value)
59   {
60     return featureMap.setValue(index, value);
61   }
62
63   protected EStructuralFeature getEStructuralFeature(String JavaDoc propertyName)
64   {
65     return featureMap.getEObject().eClass().getEStructuralFeature(propertyName);
66   }
67
68   protected EStructuralFeature getEStructuralFeature(int propertyIndex)
69   {
70     return featureMap.getEObject().eClass().getEStructuralFeature(propertyIndex);
71   }
72
73   public boolean add(String JavaDoc propertyName, Object JavaDoc value)
74   {
75     return featureMap.add(getEStructuralFeature(propertyName), value);
76   }
77
78   public boolean add(int propertyIndex, Object JavaDoc value)
79   {
80     return featureMap.add(getEStructuralFeature(propertyIndex), value);
81   }
82
83   public boolean add(Property property, Object JavaDoc value)
84   {
85     return featureMap.add(((EProperty)property).getEStructuralFeature(), value);
86   }
87
88   public void add(int index, String JavaDoc propertyName, Object JavaDoc value)
89   {
90     featureMap.add(index, getEStructuralFeature(propertyName), value);
91   }
92
93   public void add(int index, int propertyIndex, Object JavaDoc value)
94   {
95     featureMap.add(index, getEStructuralFeature(propertyIndex), value);
96   }
97
98   public void add(int index, Property property, Object JavaDoc value)
99   {
100     featureMap.add(index, ((EProperty)property).getEStructuralFeature(), value);
101   }
102
103   public void add(String JavaDoc text)
104   {
105     FeatureMapUtil.addText(featureMap, text);
106   }
107
108   public void add(int index, String JavaDoc text)
109   {
110     FeatureMapUtil.addText(featureMap, index, text);
111   }
112  
113   public void remove(int index)
114   {
115     featureMap.remove(index);
116   }
117
118   public void move(int toIndex, int fromIndex)
119   {
120     featureMap.move(toIndex, fromIndex);
121   }
122
123   public String JavaDoc toString()
124   {
125     return featureMap.toString();
126   }
127 }
128
Popular Tags