logo back up home forward   further reading more topics »

XES - Programmers Guide - nodeClass

for information about XES schema see these pages.

ClassDef

The ClassDef node is used to define a class or interface.

It is also used to instatiate a class. (see issues below)

A ClassDef can occur in a package node or inside another class (inner class) or anywhere where a class can be instantiated.

Attributes used

Child Elements

If this class extends another class or implements interfaces then these should be defined in nameList node or nodes. If there are any nameList nodes then they should be before any other child nodes (apart possibly from comment nodes)

Other possible child elements of classDef are:

Issues

How should class instantiation be handled? For instance:
myClass c=new myClass();

Should this be coded in XES by using a 'classDef' or a 'call' node? The argument for using 'classDef' is that the same node type is used to define and use the class, the argument for using a call node is that it involves calling the constuctor so it has arguments similar to a method call.

I think it is best to use a 'classDef' to instantiate a class because this allows anonymous inner classes - where a class is defined and instantiated at the same point in the program. This makes the handling of class to be similar to variable in that they are both used to define and initialise the quantity.

However the 'call' node is still used for explicit constructor invocation such as this() or super()

Note array instantiation such as:

new int[1];

or

new myArray[4];

is handled by array node and not classDef node.

Another Issue

Can the 'classDef' which instantiates a class be linked to the 'classDef' which defines the class in a more direct way than using its name? Perhaps the instantiating node could have an XPath field or somthing like that, this would allow the definition to be found more quickly. In an object oriented program the definition may only be found at runtime, but perhaps we could link to the base class or at least to something to speed up finding the class defintion.

Schema entry

<xs:complexType name="classType">
<xs:sequence>
<xs:element name="method" type="methodType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="classDef" type="classType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="variable" type="variableType"/>
<xs:element name="tags" type="tagList"/>
<xs:element name="meta" type="xs:string"/>
<xs:element name="comment" type="commentType"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="implements" type="xs:string"/>
<xs:attribute name="extends" type="xs:string"/>
<xs:attribute name="public" type="xs:boolean"/>
<xs:attribute name="private" type="xs:boolean"/>
<xs:attribute name="protected" type="xs:boolean"/>
<xs:attribute name="static" type="xs:boolean"/>
<xs:attribute name="abstract" type="xs:boolean"/>
<xs:attribute name="interface" type="xs:boolean"/>
</xs:complexType>

Possible Improvements

 

Examples of usage

usage java example XES example
class definition class myClass {
}
<class def="true" name="myClass"/>
class instantiation myClass c=new myClass();

<variable name="c" type="myClass">
<assign operator="=">
<variable>
<class name="myClass" new="true"/>
</variable>
</assign>
</variable>

class instantiation with parameters for constructor myClass c=new myClass(int a,double b); <variable name="c" type="myClass">
<assign operator="=">
<variable>
<class name="myClass" new="true">
<variable name="a"/>
<constant intConst="2"/>
</class>
</variable>
</assign>
</variable>
public modifier public class myClass {
}
<class def="true" name="myClass" public="true"/>
protected modifier protected class myClass {
}
<class def="true" name="myClass" protected="true"/>
private modifier private class myClass {
}
<class def="true" name="myClass" private="true"/>
abstract modifier abstract class myClass {
}
<class abstract="true" def="true" name="myClass"/>
static modifier static class myClass {
}
<classDef name="myClass" static="true"/>
final modifier final class myClass {
}
<classDef final="true" name="myClass"/>
synchronized modifier synchronized class myClass {
}
<class def="true" name="myClass" synchronized="true"/>
native modifier native class myClass {
}
<class def="true" name="myClass" native="true"/>
extending a class class myClass extends baseClass{
}

<class def="true" name="myClass">
<nameList elementName="extends" type="baseClass"/>
</class>

implementing an interface class myClass implements baseInterface{
}
<class def="true" name="myClass">
<nameList elementName="implements" type="baseInterface,baseInterface2"/>
</class>
extend and implement class myClass extends baseClass implements baseInterface{} <class def="true" name="myClass">
<nameList elementName="extends" type="baseClass"/>
<nameList elementName="implements" type="baseInterface"/>
</class>
defining an interface interface myInterface{
}
<class def="true" interface="true" name="myInterface"/>
nested classes (inner class) class myClass {
class nestedClass {
}
}
<class def="true" name="myClass">
<class def="true" name="nestedClass"/>
</class>
anonymous inner classes class myClass {
void myOuterMethod() {
new myAnonymousClass() {
public void myInnerMethod(){
}
};
}
<class def="true" name="myClass">
<method name="myOuterMethod" type="void">
<parameterList/>
<variable>
<class def="true" name="myAnonymousClass" new="true">
<method name="myInnerMethod" public="true" type="void">
<parameterList/>
</method>
</class>
</variable>
</method>
</class>
     

Mapping to other languages

Modifiers

XES java C# C++
  public public  
  protected protected  
  private private  
  abstract abstract  
  static    
  final    
  strictfp    
    new  
    internal  
    sealed  
    unsafe  
  interface    
  native,synchronized,transient,volatile    

metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Processing XML with Java: A Guide to SAX, DOM, JDOM, JAXP, and TrAX

Other Java books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover JBuilder - There is also a free version of Jbuilder at borland website . However its licence conditions are quite restrictive so you may prefer another java IDE.

Can this page be improved?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

for xml encoding: http://sourceforge.net/projects/xes/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.