The Eclipse Modeling Framework 

by Frank Budinsky



Listing One



public interface PurchaseOrder {

  String getShipTo();

  void setShipTo(String value);

  String getBillTo();

  void setBillTo(String value);

  List getItems(); // List of Item

}



public interface Item {

  String getProductName();

  void setProductName(String value);

  int getQuantity();

  void setQuantity(int value);

  float getPrice();

  void setPrice(float value);

}



Listing Two



<xsd:complexType name="PurchaseOrder">

 <xsd:sequence>

  <xsd:element name="shipTo" type="xsd:string"/>

  <xsd:element name="billTo" type="xsd:string"/>

  <xsd:element name="items"  type="PO:Item" 

               minOccurs="0" maxOccurs="unbounded"/>

 </xsd:sequence>

</xsd:complexType>



<xsd:complexType name="Item">

 <xsd:sequence>

  <xsd:element name="productName" type="xsd:string"/>

  <xsd:element name="quantity" type="xsd:int"/>

  <xsd:element name="price" type="xsd:float"/>

 </xsd:sequence>

</xsd:complexType>





Listing Three



public String getShipTo() {

  return shipTo;

}



Listing Four



public void setShipTo(String newShipTo) {

  String oldShipTo = shipTo;

  shipTo = newShipTo;

  if (eNotificationRequired())

    eNotify(new ENotificationImpl(this, Notification.SET,

                       POPackage.PURCHASE_ORDER__SHIP_TO, oldShipTo, shipTo));

}





Listing Five



public interface PurchaseOrder {

  /** @model opposite="previous" */

  PurchaseOrder getNext();



  /** @model opposite="next" */

  PurchaseOrder getPrevious();

  ...

}



Listing Six



public void setNext(PurchaseOrder newNext) {

  if (newNext != next) {

    NotificationChain msgs = null;

    if (next != null)

      msgs = ((InternalEObject)next).eInverseRemove(this,

        POPackage.PURCHASE_ORDER__PREVIOUS, PurchaseOrder.class, msgs);

    if (newNext != null)

      msgs = ((InternalEObject)newNext).eInverseAdd(this,

        POPackage.PURCHASE_ORDER__PREVIOUS, PurchaseOrder.class, msgs);

    msgs = basicSetNext(newNext, msgs);

    if (msgs != null) msgs.dispatch();

  }

  else if (eNotificationRequired())

    eNotify(new ENotificationImpl(this, Notification.SET,

     POPackage.PURCHASE_ORDER__NEXT, newNext, newNext)); // touch notification

}









2



