[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [emf-dev] searching the object by id
|
Martin,
If you use an XPath processor you can use the predicate capabilities on a
search. It works well.
Russell J. Nile
Martin Zdila <zdila@xxxxxxxx>
To: emf-dev@xxxxxxxxxxx
Sent by: emf-dev-admin@xxxxxxxxxxx cc: l.fasianok@xxxxxxxxxxxxxxx
Subject: [emf-dev] searching the object by id
Wednesday January 14, 2004 05:49 AM
Please respond to emf-dev
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
_______________________________________________
emf-dev mailing list
emf-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/emf-dev