summaryrefslogtreecommitdiff
path: root/tutorial/examples/copy/CopiedClass.oj
blob: 7799f5952b7ff0b78c3a97b4e628c53cc458b028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * CopiedClass.oj
 *
 * @author   Michiaki Tatsubori
 * @see      java.lang.Object
 *
 * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
 */
package examples.copy;


import openjava.mop.*;
import openjava.ptree.*;
import openjava.syntax.*;
import openjava.ptree.util.TypeNameQualifier;


public class CopiedClass instantiates Metaclass extends OJClass
{
    /* overrides for translation */
    public convenient void translateDefinition() throws MOPException {
    String newqname = getName() + "Shadow";
    OJClass shadow = makeCopy( newqname );
    /***
    ClassDeclaration org = getSourceCode();
    ClassDeclaration copy = (ClassDeclaration) org.makeRecursiveCopy();
    String pack = Environment.toPackageName( newqname );
    String sname = Environment.toSimpleName( newqname );
    copy.setName( sname );
    copy.accept( new TypeNameQualifier( getEnvironment(), sname ) );
    FileEnvironment env = new FileEnvironment( OJSystem.env, pack, sname );
    OJClass shadow = new OJClass( env, null, copy );
    ***/
    OJSystem.addNewClass( shadow );
    }

}