1 package definition
1.1 UML mode:
a) definition:
i. 图:
ii. Build code:
Public interface stpackage extends EPACKAGE {
String ename = "st";
String ENS_URI = "http:// ST";
String ENS_PREFIX = "ST";
...
}
1.2 java way:
a) definition:
i. code:
Public interface stpackage {
Public String Ename = "ST";
Public String ENS_URI = "http: // st";
Public String ENS_PREFIX = "ST";
}
Description: The "@Model" tag cannot be taken in the interface statement, and the interface name is ended with "package". Pick up
The mouth can declare the following three fields ename, ENS_URI, ENS_PREFIX.
1.3 XML
a) definition:
i. code:
Targetnamespace = http: // st XMLns: ST = "http: // st"> xsd: schema> Note: The value of nsuri is specified by TargenameSpace. The value of NspRefix is exported by TargetNameSpace. Name is the last paragraph of TargetNameSpace. 2 >! - [i!" -> UML method a) definition: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { ... } b) interface: i. Description: If the class's STEREOTYPE is set to << Interface >>, the EMF will make the generated ECLASS's Interface field True, but in EMF 2.1.0 In the beta, EMF does not recognize this << interface >> type. c) Abstract class: i. 图: ii. Build code: Public Abstract Class TeacherImpl Extends EOBJECTIMPL IMPLEments TEACHER { ... } d) single inherit: i. 图: ii. Build code: Public Class JavaTeacherImpl Extends TeacherImpl Implements JavaTeacher {... } e) inheritance i. 图: ii. Build code: Public Interface JavaTeacher Extends Teacher, Nothing, Java { } Public Class JavaTeacherImpl Extends TeacherImpl Implements JavaTeacher { ... } 2.2 java way: a) definition: i. code: / ** * @Model * / Public interface student {} Description: You need to use the "@Model" tag. b) interface: i. code: / ** * @Model Interface = "TRUE" * * / Public interface teacher {} Note: By declaring the interface property, there will be no TeacherImpl class generated in the generated code. c) Abstract class: i. code: / ** * @Model Abstract = "True" * * / Public interface teacher {} Description: By declaring the Abstract property, TeacherImpl in the generated code will become an abstract class. d) single inherit: i. code: / ** * @Model * * / Public Interface JavaTeacher Extends Teacher {} e) inherit: i. code: / ** * @Model * * / Public Interface JavaTeacher Extends Teacher, Java {} Note: When inheriting, the implementation class of the interface will extends the implementation class of the interface of the first location in Extends. In the above example, JavaTeacherIMPL in the generated code will Extends TeacherImpl. 2.3 XML method: a) definition: i. code: Explanation: The class name is specified by the Name property in ComplexType. b) interface: i. Description: XML does not provide a mechanism for defining the interface. c) Abstract class: i. code: d) single inherit: i. code: xsd: complexType> Description: Realize single inheritance through the expansion mechanism of ComplexType. e) inherit: i. Description: The appropriate multi-inheritance mechanism has not found. 3 attribute definition 3.1 UML method: a) single value attribute: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected static factory string name_edefault = null; protected string name = name_edefault; Public string getname () {...} Public void setname (String newname) {...} ... } b) Multi-value attribute: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected Elist students = null; Public Elist getstudents () {...} ... } c) modify the ECORE attribute value of the property: i. Figure: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected static final string unchangeable_edefault = null; protected string unchangeable = unchangeable_edefault; Protected static final string volatile_edefault = null; Protected static final string unstetable_edefault = null; Protected string unstetable = unsettable_edefault; Protected Boolean UnsetTableSet = false; Public String getunchangeable () {...} Public String getVolatile () { Throw new unsupportedOperationException (); } Public void setvolatile (String newvolatile) { Throw new unsupportedOperationException (); } Public string getunSettable () {...} Public void setunSettable (String newunSettable) {...} Public void unsetunSettable () {...} Public boolean issetunSettable () {...} ... } Description: For the Unchangeable property, I changed his changeable attribute to false, so he will not include a set method in the generated code. For the Volatile property, I set his isvolatile property to True, so the GET () / set () method of English Volatile is implemented as an empty method in the generated code, and an exception is thrown. For the unstetable property, I set his isunSetTable property to TURE, so in addition to the unsettable attribute in the generated code, there is a Boolean quantity unsettableset that is set if the property is set. d) -> Enumeration Type: i. 图: II. Generating Code: Public Final Class Score Extends AbstractEnumerator { Public static final int good = 0; Public static final int big = 1; ... } 3.2 java way: a) single value attribute: i. code: / ** * @Model * / Public interface teacher { / ** * @Model * * / Public string getname (); } Description: When defining properties, you must have a "@Model" tag, and the method name must comply with getxyz (), or Isxyz () form. b) Multi-value attribute: i. code: / ** * @Model * / Public interface teacher { / ** * @Model type = "string" * * / Public List GetStudents (); } c) The ecore value of the properties: i. code: Public interface teacher extends eobject { / ** * @Model changeable = "false" * / Public String getunchangeable (); / ** * @Model volatile = "True" * / Public String getVolatile (); / ** * @Model unstetable = "true" * / Public string getunSettable (); } d) -> Enumeration Type: i. code: / ** * @Model * / Public final clas score { / ** * @Model * / Public static final int good = 0; / ** * @Model * / Public static final int big = 1; } Note: Enumeration Types need to be defined as a Final Class type, and enumerate values are specified by Static Final Int within the class. 3.3 XML method: a) single value attribute: i. code: xsd: sequence> xsd: complexType> b) Multi-value attribute: i. code: Maxoccurs = "unbounded" /> xsd: sequence> xsd: complexType> c) The ecore value of the properties: i. Description: SCHEMA does not provide a way to modify the ECORE value. d) -> Enumeration Type: i. code: xsd: SimpleType> 4 Quote Definition 4.1 UML method: a) one-way reference: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected student student = NULL; Public student getstudent () {...} Public void setstudent (student newstudent) {...} ... } b) two-way reference: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected student student = NULL; Public student getstudent () {...} Public void setstudent (student newstudent) {...} ... } Public Class StudentImpl Extends EOBJECTIMPL IMPLEments Student { protected teacher teacher = null; Public teacher getteacher () {...} Public void setteacher (teacher newteacher) {...} ... } c) multi-value reference: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected Elist student = null; Public Elist getstudent () {...} ... } d) contains the reference: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected Elist student = null; Public Elist getstudent () {...} } Note: When using the included object, since the object being referenced, the object being referenced will be saved inside the same resource, so it is possible to use EOBJECTCONTAINMENTELIST to save the reference to Student inside the TEACher. If it is a general reference, consider using eobjectResolvingeList. e) modify the reference ECORE value: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { protected nonproxy nonproxy = null; protected nonchange nonchange = null; protected unset unset = null; Protected Boolean Unsetset = false; Public nonproxy getnonproxy () { Return Nonproxy; } Public void setnonproxy (nonproxy newnonproxy) {...} Public volatile getVolatile () {...} Public void setVolatile (Volatile newvolatile) { Throw new unsupportedOperationException (); Public nonchange getnonchange () {...} Public unset getunset () {...} Public void setunset (unset newunset) {...} Public void unsetunset () {...} Public boolean issetunset () {...} ... } Note: When the referenced ResolveProxy value is set to FALSE, the generated GET method will make a proxy explanation step, while only simply returns the reference value. When the referenced Unchangeable value is set to TRUE, the generated code will not contain the set method. When the referenced Volatile value is set to TRUE, only the empty method body will only be included in the generated code. When the referenced unstetable is set to TRUE, in addition to generating a reference value, the amount of Boolean used to determine if the reference has been set. f) map reference: i. 图: Note: The STUDENTTABLE's STEREOTYPE must be MaPENTRY, she must contain a key attribute, and must have a reference to Value. ii. Build code: Public Class TableImpl Extends EOBJECTIMPL IMPLEments BASICEMAP.Entry { protected static final int key_edefault = 0; Protected int key = key_edefault; Protected student value = null; Public Object getKey () {...} Public void setKey (Object Key) {...} Public Object getValue () {...} Public Object SetValue (Object Value) {...} ... } Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { protected emap table = null; Public emap gettable () {...} ... } Note: The EMAP in ECORE is not inherited from java.util.map, she inherited Elist, so she only has a column rather than two values. For each value in the EMAP, it is an ECLASS inherited from Java.util.map $ Entry, and the ECLASS contains the key and value properties. Due to this structure of EMAP, we cannot use single-values to reference Table, but must use multiple values, this is equivalent to: / ** * @Model type = "Table" * / Elis T getTable (); Key: Value Key: Value Key: ValueKey: Value ... Key Value Key Key ... Key Value Value ... Value Java.util.map EMAP 4.2 java way: a) one-way reference: i. code: / ** * @Model * / Public interface teacher { / ** * @Model * / Public student getstudent (); } / ** * @Model * / Public interface student {} b) two-way reference: i. code: / ** * @Model * / Public interface teacher { / ** * @Model * / Public student getstudent (); } / ** * @Model * / Public interface student { / ** * @Model * * / Public teacher getteacher (); } c) multi-value reference: i. code: / ** * @Model * / Public interface teacher { / ** * @Model Type = "student" * / Public List GetStudent (); } d) contains the reference: i. code: / ** * @Model * / Public interface teacher extends eobject { / ** * @Model type = "student" containment = "true" * / Public elist getstudent (); } e) Modify the reference ECORE value: i. Code: / ** * @Model * / Public interface teacher extends eobject { / ** * @Model resolveproxies = "false" * / Public nonproxy getnonproxy (); / ** * @Model volatile = "True" * / Public volatile getVolitile (); / ** * @Model changeable = "false" * / Public Nonchange Getnonchange (); / ** * @Model unstetable = "true" * / Public unset getunset (); } f) map reference: i. code: / ** * @Model * / Public interface teacher extends eobject { / ** * @Model keytype = "int" valueetype = "student" * * / Public emap gettable (); } 4.3 XML method: a) one-way reference: i. code: xsd: sequence> xsd: complexType> xsd: complexType> b) two-way reference: i. code: xsd: sequence> xsd: complexType> xsd: sequence> xsd: complexType> c) multi-value reference: i. code: Minoccurs = "0" maxoccurs = "unbounded" /> xsd: sequence> xsd: complexType> d) contains the reference: i. Description: Through complexType, in addition to the type of elements, the value of Containment is True. e) modify the reference ECORE value: i. Description: Schema does not provide a mechanism for modifying the reference ECORE value. f) map reference: i. Description: SCHEMA does not provide mechanisms for defining the MAP reference. 5 Data Type Definition 5.1 UML method: a) definition: i. Photo: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Protected static factory date born_edefault = null; Protected Date Born = born_edefault; Public Date getBorn () {...} Public void setBorn (Date newborn) {...} ... } 5.2 java way: a) definition: i. code: Public interface stpackage { / ** * @Model instanceclass = "java.util.date" * * / EDATYPE GETNEWDATE (); } / ** * @Model * / Public interface teacher extends eobject { / ** * @Model * / Public NewDate getBorn (); } Note: When declaring a new type using Java, you need to add type definitions in the package declaration. 5.3 XML method: a) definition: i. code: xsd: SimpleType> xsd: sequence> xsd: complexType> 6 method definition 6.1 UML method: a) definition: i. 图: ii. Build code: Public Class Teacherimpl Extends EOBJECTIMPL IMPLEments TEACHER { Public void dosomething (string par) { Throw new unsupportedOperationException (); } } 6.2 java way: a) definition: i. code: / ** * @Model * / Public interface teacher { / ** * @Model * / Public void Dosomething (String Par); } 6.3 XML method: a) definition: i. Description: Schema cannot define actions.