我想從一個Java程序獲得的EReference的價值是否有可能通過名稱獲得EReference的價值?
我使用這個庫:https://github.com/tesis-dynaware/graph-editor
這裏是生成一個XMI文件的例子:
<?xml version="1.0" encoding="ASCII"?>
<graph:GModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:graph="http://de.tesis.dynaware.grapheditor.model/1.0">
<nodes type="tree-node" x="1217.0" y="556.0">
<connectors type="tree-output" connections="//@connections.0 //@connections.1" connectionDetachedOnDrag="false"/>
</nodes>
<nodes type="tree-node" x="1020.0" y="756.0">
<connectors type="tree-input" connections="//@connections.0"/>
<connectors type="tree-output" connectionDetachedOnDrag="false"/>
</nodes>
<nodes type="tree-node" x="1260.0" y="775.0">
<connectors type="tree-input" connections="//@connections.1"/>
<connectors type="tree-output" connectionDetachedOnDrag="false"/>
</nodes>
<connections type="tree-connection" source="//@nodes.0/@connectors.0" target="//@nodes.1/@connectors.0"/>
<connections type="tree-connection" source="//@nodes.0/@connectors.0" target="//@nodes.2/@connectors.0"/>
</graph:GModel>
什麼,我要的是獲取EReference源的值,我必須得到的例子:/@nodes.0/@connectors.0
我試了下面的代碼
GModel gModel=model;
EList<GConnection> connections=gModel.getConnections();
for(GConnection connection : connections)
{
GConnector source=connection.getSource();
System.out.println(" valeur source =" +source);
}
,但我得到下面的結果:
valeur [email protected]1dd34be(ID:空,類型:樹輸出中,x:0.0,Y :0.0,connectionDetachedOnDrag:false)
我不完全理解你想要完成的事情。 '/ @ nodes.0/@ connectors.0'是對樹中第一個節點Object中第一個連接器Object的交叉引用,因此'source'引用應該正確地檢索它....或者你想實際上檢索字符串值'/ @ nodes.0/@ connectors.0'?你能更具體一點嗎? –