// -*- java -*-
// $Id: JavaTemplate.txt,v 1.11 2003/05/11 06:25:15 stephens Exp $
[% MACRO isa BLOCK %]
/**
* @return true if receiver is a [% cls.package %]
.
* Other receivers will return false.
* Trace: [% cls.package %]
*/
public boolean isa[% cls.name_ %]()
[% UNLESS target_cls.isaInterface %]
{ return true; }
[% ELSE %];[% END %]
[% IF cls.name_q_ != cls.name_ %]
/**
* @return true if receiver is a [% cls.package %]
.
* Other receivers will return false.
* This is the fully qualified version of the isa[% cls.name_ %]
method.
* Trace: [% cls.package %]
*/
public boolean isa[% cls.name_q_ %]()
[% UNLESS target_cls.isaInterface %]
{ return true; }
[% ELSE %];[% END %]
[% END %]
[% END %]
[% MACRO other BLOCK %]
[% FOREACH other = end.opposite %]
[% NEXT UNLESS other.isNavigable %]
if ( __old != null ) __old.remove[% other.Name %](this);
if ( __val != null ) __val.add[% other.Name %](this);
[% END %]
[% END %]
[% MACRO iterate BLOCK %]
[% IF type == 'java.util.Vector' %]
for ( java.util.Enumeration __[% x %] = [% col %].elements();
__[% x %].hasMoreElements();
) {
[% elem_type %] [% x %] = ([% elem_type %]) __[% x %].nextElement();
[% ELSE %]
for ( int __[% x %] = -1;
++ __[% x %] < [% col %].length;
) {
[% elem_type %] [% x %] = ([% elem_type %]) [% col %][__[% x %]];
[% END %]
[% END %]
[% MACRO iterate_end BLOCK %]
}
[% END %]
[% MACRO contains BLOCK %]
[% IF type == 'java.util.Vector' %]
([% col %] != null && [% col %].contains([% x %]))
[% ELSE %]
false /* IMPLEMENT */
[% END %]
[% END %]
[% MACRO add BLOCK %]
[% IF type == 'java.util.Vector' %]
if ( [% col %] == null ) {
[% col %] = new [% type %]();
}
[% col %].add([% x %])
[% ELSE %]
/* IMPLEMENT */;
[% END %]
[% END %]
[% MACRO remove BLOCK %]
[% IF type == 'java.util.Vector' %]
if ( [% col %] != null ) [% col %].remove([% x %])
[% ELSE %]
/* IMPLEMENT */;
[% END %]
[% END %]
[% MACRO clear BLOCK %]
[% IF type == 'java.util.Vector' %]
[% col %] = null;
[% ELSE %]
[% col %] = null;
[% END %]
[% END %]
[% MACRO java_modifiers BLOCK %]
[% SWITCH attr.visibility %]
[% CASE public %][% DEFAULT attr.java_visibility = 'public' %]
[% CASE private %][% DEFAULT attr.java_visibility = 'private' %]
[% CASE protected %][% DEFAULT attr.java_visibility = 'protected' %]
[% CASE package %][% DEFAULT attr.java_visibility = 'public' %]
[% END %]
[% UNLESS attr.instance %]
[% DEFAULT attr.java_static = 'static' %]
[% END %]
[% SET attr.java_modifiers = "${attr.java_visibliity} ${attr.java_static}" %]
[% SET attr.java_modifiers_accessor = "public ${attr.java_static}" %]
[% END %]
// Template 2.09: CASE stmts are regexs!!
// type='some.java.type[]' causes Perl regex to freek the f**k out!
[% MACRO box BLOCK %]
[% SWITCH type.replace('[(\[\])]', '\\$1') %]
[% CASE 'boolean' %]
[% SET expr = "new java.lang.Boolean((boolean) ($expr))" %]
[% CASE 'byte' %]
[% SET expr = "new java.lang.Byte((byte) ($expr))" %]
[% CASE 'char' %]
[% SET expr = "new java.lang.Char((char) ($expr))" %]
[% CASE 'short' %]
[% SET expr = "new java.lang.Short((short) ($expr))" %]
[% CASE 'int' %]
[% SET expr = "new java.lang.Integer((int) ($expr))" %]
[% CASE 'long' %]
[% SET expr = "new java.lang.Long((long) ($expr))" %]
[% CASE 'float' %]
[% SET expr = "new java.lang.Float((float) ($expr))" %]
[% CASE 'double' %]
[% SET expr = "new java.lang.Double((double) ($expr))" %]
[% END %]
[% expr %]
[% END %]
[% MACRO unbox BLOCK %]
[% SWITCH type.replace('[(\[\])]', '\\$1') %]
[% CASE 'boolean' %]
[% SET expr = "((java.lang.Boolean) ($expr)).booleanValue()" %]
[% CASE 'byte' %]
[% SET expr = "((java.lang.Byte) ($expr)).byteValue()" %]
[% CASE 'char' %]
[% SET expr = "((java.lang.Char) ($expr)).charValue()" %]
[% CASE 'short' %]
[% SET expr = "((java.lang.Short) ($expr)).shortValue()" %]
[% CASE 'int' %]
[% SET expr = "((java.lang.Integer) ($expr)).intValue()" %]
[% CASE 'long' %]
[% SET expr = "((java.lang.Long) ($expr)).longValue()" %]
[% CASE 'float' %]
[% SET expr = "((java.lang.Float) ($expr)).floatValue()" %]
[% CASE 'double' %]
[% SET expr = "((java.lang.Double) ($expr)).doubleValue()" %]
[% CASE %]
[% SET expr = "(($type) ($expr))" %]
[% END %]
[% expr %]
[% END %]
//-// FILE BEGIN [%model_package_dir%]/__Model.java
// -*- java -*-
// DO NOT EDIT - This file is generated by UML2CODE.
// From template: $Id: JavaTemplate.txt,v 1.11 2003/05/11 06:25:15 stephens Exp $
package [%model_package%];
// import [%model_package%].__Factory;
public class __Model
{
private final static java.lang.String[] factory_map = {
[% FOREACH x = factory_map %]
"[% x %]",
[% END %]
};
/**
* Returns an array ref that maps all UML Model names to Java package names.
* Also includes short name to fully-qualified name mappings.
*/
public java.lang.String [] factory_map() { return factory_map; }
private java.lang.Object model;
/**
* Returns the UML meta-model Model object for this Model.
*/
public java.lang.Object model()
{
/* IMPLEMENT */
return null;
}
/**
* The cached factory.
*/
private [% model_package %].__Factory factory;
/**
* Returns a factory for this Model.
*/
public [% model_package %].__Factory factory()
{
if ( factory == null ) {
factory = new [% model_package %].__Factory(factory_map());
}
return factory;
}
/**
* Use create() method.
*/
private __Model()
{
}
private static __Model instance = null;
public static __Model create()
{
if ( instance == null ) {
instance = new __Model();
}
return instance;
}
}
/// Keep these comments at end of file: ks.perl@kurtstephens.com 2003/04/06 ///
/// Local Variables: ///
/// mode:java ///
/// java-indent-level:2 ///
/// java-continued-statement-offset:0 ///
/// java-brace-offset:0 ///
/// java-label-offset:0 ///
/// End: ///
//-// FILE END [% model_package_dir %]/__Model.java
//-// FILE BEGIN [%model_package_dir%]/__Factory.java
// -*- java -*-
// DO NOT EDIT - This file is generated by UML2CODE.
// From template: $Id: JavaTemplate.txt,v 1.11 2003/05/11 06:25:15 stephens Exp $
package [%model_package%];
public class __Factory
{
private java.util.Map map;
private __Factory() { }
public __Factory(java.lang.String[] __map)
{
map = new java.util.HashMap(__map.length / 2);
for ( int i = 0; i < __map.length; ++ i ) {
map.put(__map[i], __map[i + 1]);
}
}
public java.lang.String className(java.lang.String name)
{
return (java.lang.String) map.get(name);
}
public java.lang.Object create(java.lang.String name, java.lang.String [] inits)
throws java.lang.Throwable
{
try {
// Get the implementation clsName.
java.lang.String clsName = className(name);
// Get the Java Class object.
java.lang.Class cls = java.lang.Class.forName(clsName);
// Create a new instance.
java.lang.Object instance = cls.newInstance();
// IMPLEMENT: Call appropriate initializers.
// Return new instance.
return instance;
} catch ( Throwable e ) {
throw new Throwable(e);
}
}
}
/// Keep these comments at end of file: ks.perl@kurtstephens.com 2003/04/06 ///
/// Local Variables: ///
/// mode:java ///
/// java-indent-level:2 ///
/// java-continued-statement-offset:0 ///
/// java-brace-offset:0 ///
/// java-label-offset:0 ///
/// End: ///
//-// FILE END [% model_package_dir %]/__Factory.java
[% FOREACH cls = classifier %]
// Initialize the Classifier.
[% IF cls.primitive || cls.construct %]
[% DEFAULT cls.primitive_type = 'java.lang.Object' %]
[% ELSIF cls.isaEnumeration() %]
[% DEFAULT cls.primitive_type = 'java.lang.String' %]
[% DEFAULT cls.validate_type = '__literal.containsKey(x)' %]
[% ELSE %]
[% DEFAULT cls.primitive_type = 'java.lang.Object' %]
[% END %]
[% DEFAULT cls.construct_type = cls.primitive_type %]
[% DEFAULT cls.validate_type_type = cls.construct_type %]
[% DEFAULT cls.validate_type = 'true /* IMPLEMENT */' %]
// Initialize the Attributes.
[% FOREACH attr = cls.attribute %]
[% IF attr.instance %]
[% SET attr.loc = "this.${attr.name}" %]
[% ELSE %]
[% SET attr.loc = "${cls.name}.${attr.name}" %]
[% END %]
[% java_modifiers(attr=attr) %]
[% SET attr.typecheck = "${attr.type}.__typecheck(__val, \"${cls.package}.${attr.name}\")" %]
[% SET attr.typecheck = "/* IMPLEMENT: typecheck on __val */" %]
[% IF attr.multi_single %]
[% SET attr.type_multi = attr.type_impl %]
[% SET attr.type_multi_impl = attr.type_impl %]
[% ELSE %]
[% SET attr.type_multi = "${attr.type_impl}[]" %]
[% SET attr.type_multi_impl = 'java.util.Vector' %]
[% END %]
[% IF attr._trace %]
[% SET attr._trace_comm = "${attr.name} <> --> ${attr._trace}\n" %]
[% END %]
[% END %]
// Initialize AssociationEnds
[% FOREACH cls_end = cls.association %]
[% IF cls_end._trace %]
[% SET cls_end._trace_comm = "${cls_end.name} <> --> ${cls_end._trace}" %]
[% END %]
[% FOREACH end = cls_end.opposite %]
[% NEXT UNLESS end.isNavigable %]
[% NEXT IF end.phantom_obj %]
[% java_modifiers(attr=end) %]
[% IF end.instance %]
[% SET end.loc = "this.${end.name}" %]
[% ELSE %]
[% SET end.loc = "${end.name}" %]
[% END %]
[% SET end.typecheck = "${end.type}.__typecheck(__val, \"${cls.package}.${end.name}\")" %]
[% SET end.typecheck = "/* IMPLEMENT: typecheck on __val */" %]
[% IF end.multi_single %]
[% SET end.type_multi = end.type_impl %]
[% SET end.type_multi_impl = end.type_impl %]
[% ELSE %]
[% SET end.type_multi = "${end.type_impl}[]" %]
[% SET end.type_multi_impl = 'java.util.Vector' %]
[% END %]
[% IF end._trace %]
[% SET end._trace_comm = "${end.name} <> --> ${end._trace}" %]
[% END %]
[% END %]
[% END %]
//-// FILE BEGIN [% cls.implementation_file %]
// -*- java -*-
// DO NOT EDIT - This file is generated by UML2CODE.
// From template: $Id: JavaTemplate.txt,v 1.11 2003/05/11 06:25:15 stephens Exp $
package [% cls.namespace.package %];
/////////////////////////////////////////////////////////////////
// Dependencies
//
[% FOREACH dep = cls.dependency %]
[% IF dep.obj.isaPackage() %]
import [% dep.package %].*;
[% ELSE %]
import [% dep.package %];
[% END %]
[% END %]
[% SWITCH cls.visibility %]
[% CASE public %]
public
[% CASE private %]
[% CASE protected %]
[% CASE package %]
[% END %]
[% IF cls.isaInterface %]interface[% ELSE %]class[% END %] [% cls.name_ %]
[% IF cls.generalizations %]
// Generalization
extends
[% FOREACH super = cls.generalization %]
[% super.package %][%- ", " UNLESS loop.last %]
[% END %]
[% END %]
[% IF cls.abstractions %]
// Abstraction
implements
[% FOREACH super = cls.abstraction %]
[% super.package %][%- ", " UNLESS loop.last %]
[% END %]
[% END %]
{
/////////////////////////////////////////////////////////////////
// Instantiation
//
[% IF cls.primitive || cls.construct %]
/**
* Constructs new [% cls.package %] value.
*/
public static [% cls.primitive_type %] create([% cls.construct_type %] x)
throws java.lang.Throwable
{
[% cls.primitive_type %] result;
__typecheck(x, "[% cls.package %].create");
result =
[% IF cls.construct %]
[% cls.construct %]
[% ELSE %]
x
[% END %]
;
return result;
}
[% ELSIF cls.isaEnumeration %]
[% UNLESS cls.isaInterface %]
private static java.util.Map __literal;
private [% cls.primitive_type %] __name;
/**
* Private initializer.
*/
private [% cls.name %] ( [% cls.primitive_type %] name )
{
__name = name;
if ( __literal == null ) {
__literal = new java.util.HashMap();
}
__literal.put(__name, this);
}
[% END %]
/**
* Returns the name of the EnumerationLiteral.
*/
public java.lang.String toString()
[% UNLESS cls.isaInterface %]
{ return __name; }
[% ELSE %];[% END %]
[% UNLESS cls.isaInterface %]
/**
* Constructs new [% cls.package %] literal value.
* can be one of the following:
* [% FOREACH literal = cls.literal %]"[% literal.name %]"
[% END %]
*/
public static final [% cls.name %] create([% cls.construct_type %] x)
throws java.lang.Throwable
{
__typecheck(x, "[% cls.package %].create");
return ([% cls.name %]) __literal.get((java.lang.Object) x);
}
[% END %]
/////////////////////////////////////////////////////////////////
// EnumerationLiterals
//
[% UNLESS cls.isaInterface %]
[% FOREACH literal = cls.literal %]
public final static [% cls.name %] [% literal.NAME %] = new [% cls.name %]("[% literal.name %]");
[% END %]
[% END %]
[% ELSE %]
[% UNLESS cls.isaInterface %]
/**
* Use static create() method.
*/
public [% cls.name_ %] ()
{
}
/**
* Create new instance.
*/
public static [% cls.name_ %] create[% cls.name_ %]()
{
return new [% cls.name_ %]();
}
/**
* Create new instance from initializer name => value pairs.
*/
public static [% cls.name_ %] create[% cls.name_ %](java.lang.Object [] inits)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% cls.name_ %] instance = create[% cls.name_ %]();
for ( int i = 0; i < inits.length; i ++ ) {
java.lang.String name = (java.lang.String) inits[i ++];
if ( false ) {
}
[% FOREACH attr = cls.attribute %]
else if ( name.equals("[% attr.name %]") ) {
instance.set[% attr.Name %]([% unbox(type=attr.type_multi, expr='inits[i]') %]);
}
[% END %]
[% FOREACH cls_end = cls.association %]
[% FOREACH end = cls_end.opposite %]
[% NEXT UNLESS end.isNavigable %]
[% NEXT IF end.phantom_obj %]
else if ( name.equals("[% end.name %]") ) {
instance.set[% end.Name %]([% unbox(type=end.type_multi, expr='inits[i]') %]);
}
[% END %]
[% END %]
else {
throw new java.lang.Throwable("Unknown init: '" + name + "'");
}
}
return instance;
}
[% ELSE %];[% END %]
[% END %]
[% END %]
/////////////////////////////////////////////////////////////////
// Validation
//
[% UNLESS cls.isaInterface %]
/**
* @return true if x is a valid value of [%cls.package%]
.
*/
public static boolean __validate_type([% cls.validate_type_type %] x)
{
return [% cls.validate_type %];
}
[% ELSE %];[% END %]
[% UNLESS cls.isaInterface %]
/**
* Throws with msg
if [%cls.package%].__validate_type(x)
is false.
*/
public static void __typecheck([% cls.validate_type_type %] x, java.lang.String msg)
throws java.lang.Throwable
{
if ( ! __validate_type(x) ) {
throw new java.lang.Exception("typecheck: " + msg + ": type '[%cls.package%]': value '" + x + "'");
}
}
[% END %]
[% isa(target_cls=cls, cls=cls) %]
[% FOREACH a = cls.abstraction %]
[% isa(target_cls=cls, cls=a) %]
[% END %]
/////////////////////////////////////////////////////////////////
// Introspection
//
[% UNLESS cls.isaInterface %]
/**
* The UML Model name ("[% cls.name_q %]"
) for this Classifier.
*/
public final static java.lang.String __MODEL_NAME = "[% cls.name_q %]";
[% END %]
/**
* @return the UML Model name ("[% cls.name_q %]"
) for this Classifier.
*/
public java.lang.String __model_name()
[% UNLESS cls.isaInterface %]
{ return __MODEL_NAME; }
[% ELSE %];[% END %]
[% UNLESS cls.isaInterface %]
/**
* @return the UML Model object for an object or package of
* this Classifier.
*/
public static [% model_package %].__Model __MODEL()
[% UNLESS cls.isaInterface %]
{ return [% model_package %].__Model.create(); }
[% ELSE %];[% END %]
[% END %]
/**
* @return the UML Model object for an object or package of
* this Classifier.
*/
public [% model_package %].__Model __model()
[% UNLESS cls.isaInterface %]
{ return [% model_package %].__Model.create(); }
[% ELSE %];[% END %]
[% IF cls.attributes %]
/////////////////////////////////////////////////////////////////
// Attributes
//
[% FOREACH attr = cls.attribute %]
[% UNLESS cls.isaInterface %]
/**
* Attribute [% attr.name %];
* id = [% attr.id %];
* type = [% attr.type %];
* multiplicity = [% attr.multi %];
* [% attr._trace_comm %];
*/
[% attr.java_modifiers %][% attr.type_multi_impl %] [% attr.name %][% IF attr.initialValue_defined %] = [% attr.initialValue %][% END %];
[% END %]
[% IF attr.multi_single %]
/**
* @return the value of Attribute [% attr.name %].
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] [% attr.type_impl %] get[% attr.Name %]()
[% UNLESS cls.isaInterface %]
{
return [% attr.loc %];
}
[% ELSE %];[% END %]
/**
* Sets the value of Attribute [% attr.name %].
* val
must be of type [% attr.type_multi %]
.
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void set[% attr.Name %]([% attr.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% attr.typecheck %];
[% attr.loc %] = __val;
}
[% ELSE %];[% END %]
[% ELSE %]
/**
* @return the values of Attribute [% attr.name %].
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] [%attr.type_multi%] get[% attr.Name %]()
[% UNLESS cls.isaInterface %]
{
return ([%attr.type_multi%]) ([% attr.loc %].toArray());
}
[% ELSE %];[% END %]
/**
* Sets the values of Attribute [% attr.name %].
* The elements of __col
must be of type [% attr.type %]
.
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void set[% attr.Name %] ([%attr.type_multi%] __col)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
clear[% attr.Name %]();
add[% attr.Name %](__col);
}
[% ELSE %];[% END %]
/**
* Sets the values of Attribute [% attr.name %].
* The elements of __col
must be of type [% attr.type %]
.
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void set[% attr.Name %] ([%attr.type_impl%] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
clear[% attr.Name %]();
add[% attr.Name %](__val);
}
[% ELSE %];[% END %]
/**
* Adds the values of Attribute [% attr.name %].
* The elements of val
must be of type [% attr.type %]
.
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void add[% attr.Name %] ([%attr.type_multi%] __col)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% iterate(col='__col', type=attr.type_multi, elem_type=attr.type_impl, x='__val') %]
[% attr.typecheck %];
[% add(col=attr.loc, type=attr.type_multi_impl, elem_type=attr.type_impl, x='__val') %];
[% iterate_end() %]
}
[% ELSE %];[% END %]
/**
* Adds __val
to Attribute [% attr.name %]
* __val
must of type [% end.type %]
.
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void add[% attr.Name %]([% attr.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% attr.type_impl %][] __temp = new [% attr.type_impl %][1];
__temp[0] = __val;
add[% attr.Name %](__temp);
}
[% ELSE %];[% END %]
/**
* Removes values from Attribute [% attr.name %].
* The elements of @al
must be of type [% attr.type %]
.
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void remove[% attr.Name %] ([%attr.type_multi%] __col)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% iterate(col='__col', type=attr.type_multi, elem_type=attr.type_impl, x='__val') %]
[% attr.typecheck %];
[% remove(col=attr.loc, type=attr.type_multi_impl, elem_type=attr.type_impl, x='__val') %];
[% iterate_end() %]
}
[% ELSE %];[% END %]
/**
* Removes all values from Attribute [% attr.name %].
* [% attr._trace_comm %]
*/
[% attr.java_modifiers_accessor %] void clear[% attr.Name %]()
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% clear(col=attr.loc, type=attr.type_multi_impl) %];
}
[% ELSE %];[% END %]
[% END %]
[% END %]
[% END %]
[% IF cls.associations %]
/////////////////////////////////////////////////////////////////
// Association
//
[% FOREACH cls_end = cls.association %]
[% FOREACH end = cls_end.opposite %]
[% NEXT UNLESS end.isNavigable %]
[% NEXT IF end.phantom_obj %]
/**
* AssociationEnd [% cls_end.name %] --- [% end.name %];
* [% cls_end.name %].id = [% cls_end.id %];
* [% end.name %].id = [% end.id %];
* [% end.name %].type = [% end.type %];
* [% end.name %].multiplicity = [% end.multi %];
* [% cls_end._trace_comm %];
* [% end._trace_comm %];
*/
[% UNLESS cls.isaInterface %]
private [% end.java_static %][% end.type_multi_impl %] [% end.name %];
[% END %]
[% IF end.multi_single %]
/**
* @return the AssociationEnd value of type [% end.type %]
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %][% end.type_impl %] get[% end.Name %]()
[% UNLESS cls.isaInterface %]
{
return [% end.loc %];
}
[% ELSE %];[% END %]
/**
* Sets the AssociationEnd value.
* __val
must of of type [% end.type %]
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void set[% end.Name %]([% end.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %] __old;
if ( (__old = [% end.loc %]) != __val ) { // Recursion lock
[% end.typecheck %];
[% end.loc %] = __val; // Recursion lock
// Remove and add associations with other ends.
[% other(end=end) %]
}
}
[% ELSE %];[% END %]
/**
* Adds the AssociationEnd value.
* val
must of of type [% end.type %]
.
* Throws if a value already exists.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void add[% end.Name %]([% end.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %] __old;
if ( (__old = [% end.loc %]) != __val ) { // Recursion lock
[% end.typecheck %];
if ( __old != null ) {
throw new java.lang.Exception("[% cls.package %]::[% end_name %]: too many");
}
[% end.loc %] = __val; // Recursion lock
// Remove and add associations with other ends.
[% other(end=end) %]
}
}
[% ELSE %];[% END %]
/**
* Removes the Association to $val
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void remove[% end.Name %]([% end.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %] __old;
if ( (__old = [% end.loc %]) == __val ) { // Recursion lock
[% end.loc %] = null; // Recursion lock
// Remove and add associations with other ends.
[% other(end=end) %]
}
}
[% ELSE %];[% END %]
/**
* Clears the Association.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void clear[% end.Name %]()
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %] __old;
if ( (__old = [% end.loc %]) != null ) { // Recursion lock
[% end.type_multi %] __val = [% end.loc %] = null; // Recursion lock
// Remove and add associations with other ends.
[% other(end=end) %]
}
}
[% ELSE %];[% END %]
[% ELSE %]
/**
* @return the AssociationEnd value.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] [% end.type_multi %] get[% end.Name %]()
[% UNLESS cls.isaInterface %]
{
return ([% end.type_multi %]) ([% end.loc %].toArray());
}
[% ELSE %];[% END %]
/**
* Sets the AssociationEnd value.
* Elements of @val
must of of type [% end.type %]
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void set[% end.Name %]([% end.type_multi %] __col)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
clear[% end.Name %]();
add[% end.Name %](__col);
}
[% ELSE %];[% END %]
/**
* Adds the AssociationEnd values
* Elements of __col
must of of type [% end.type %]
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void add[% end.Name %]([% end.type_multi %] __col)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type %] __old = null; // Place holder for other MACRO.
[% iterate(col='__col', type=end.type_multi, elem_type=end.type_impl, x='__val') %]
// Recursion lock check.
if ( ! [% contains(col=end.loc, type=end.type_multi_impl, elem_type=end.type_impl, x='__val') %] ) {
[% end.typecheck %];
// Recursion locked.
[% add(col=end.loc, type=end.type_multi_impl, x='__val') %];
// Remove and add associations with other ends.
[% other(end=end) %]
}
[% iterate_end() %]
}
[% ELSE %];[% END %]
/**
* Adds Association with __val
.
* __val
must of type [% end.type %]
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void add[% end.Name %]([% end.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %][] __temp = new [% end.type_impl %][1];
__temp[0] = __val;
add[% end.Name %](__temp);
}
[% ELSE %];[% END %]
/**
* Removes the Association with __col
values.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void remove[% end.Name %]([% end.type_multi %] __col)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %] __val = null; // place holder for other MACRO.
[% iterate(col='__col', type=end.type_multi, elem_type=end.type, x='__old') %]
// Recursion lock check.
if ( [% contains(col=end.loc, type=end.type_multi_impl, elem_type=end.type_impl, x='__old') %] ) {
[% end.typecheck %];
// Recursion locked.
[% remove(col=end.loc, type=end.type_multi_impl, x='__old') %];
// Remove and add associations with other ends.
[% other(end=end) %]
}
[% iterate_end() %]
}
[% ELSE %];[% END %]
/**
* Removes the Association with __val
.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void remove[% end.Name %]([% end.type_impl %] __val)
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_impl %][] __temp = new [% end.type_impl %][1];
__temp[0] = __val;
remove[% end.Name %](__temp);
}
[% ELSE %];[% END %]
/**
* Removes all Associations.
* [% end._trace_comm %]
*/
[% end.java_modifiers_accessor %] void clear[% end.Name %]()
throws java.lang.Throwable
[% UNLESS cls.isaInterface %]
{
[% end.type_multi_impl %] __oldcol = [% end.loc %];
// Recursion lock.
[% clear(col=end.loc, type=end.type_multi_impl) %]
[% end.type %] __val = null; // place holder for other MACRO.
// Recursion lock check.
[% iterate(col='__oldcol', type=end.type_multi_impl, elem_type=end.type_impl, x='__old') %]
[% other(end=end) %];
[% iterate_end() %];
}
[% ELSE %];[% END %]
[% END %]
[% END %]
[% END %]
[% END %]
} // End of [% cls.name %]
///////////////////////////////////////////////////////////////////////////#
/// Keep these comments at end of file: ks.perl@kurtstephens.com 2003/04/06 ///
/// Local Variables: ///
/// mode:java ///
/// java-indent-level:2 ///
/// java-continued-statement-offset:0 ///
/// java-brace-offset:0 ///
/// java-label-offset:0 ///
/// End: ///
//-// FILE END [% cls.implementation_file %]
[% END %]
///////////////////////////////////////////////////////////////////////////#
/// Keep these comments at end of file: ks.perl@kurtstephens.com 2003/04/06 ///
/// Local Variables: ///
/// mode:java ///
/// java-indent-level:2 ///
/// java-continued-statement-offset:0 ///
/// java-brace-offset:0 ///
/// java-label-offset:0 ///
/// End: ///