[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[emf-dev] searching the object by id
|
Hello
I am using EMF for serialization / deserialization of data holding
objects into / from a XML file.
Suppose, I have a XML file:
<project>
<someItem id='345' value='a' />
<someItem id='666' value='b' />
<someItem id='12' value='c' />
</project>
I am possile to get the correct SomeItem object:
Project project = (Project) resource.getContents().get(0);
Iterator iter = project.iterator();
while (iter.hasNext()) {
SomeItem item = (SomeItem) iter.next();
if (item.getId().equals("666")) {
System.out.println("Found: value = " + item.getValue());
break;
}
}
My answer is: it is possible to find value of that item if I know the
id directly - something like this?:
Project project = (Project) resource.getContents().get(0);
SomeItem item = project.getItemById("666");
...
I al looking for a method like getItemById - can EMF generate one for
me - if yes, then how can I achieve this?
Has an id some special meaning or is it jus a normal attribute? I am
expecting that the id attribute has to be unique, of course.
Or is there (somewhere) some another method which helps me in to find that item?
--
Thanks in advance
Martin Zdila
Developer
EpiSoftware Slovakia Ltd.
Prazska 4, 040 11 Kosice
cellular: +421 908 363 848
phone: +421 55 643 9954
fax: +421 55 643 9954
mailto:m.zdila@xxxxxxxxxxxxxxx
http://www.episoftware.com