summaryrefslogtreecommitdiff
path: root/tutorial/examples/facemake/FaceProvidedClass.java
diff options
context:
space:
mode:
Diffstat (limited to 'tutorial/examples/facemake/FaceProvidedClass.java')
-rw-r--r--tutorial/examples/facemake/FaceProvidedClass.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/tutorial/examples/facemake/FaceProvidedClass.java b/tutorial/examples/facemake/FaceProvidedClass.java
new file mode 100644
index 0000000..e2d15df
--- /dev/null
+++ b/tutorial/examples/facemake/FaceProvidedClass.java
@@ -0,0 +1,76 @@
+/*
+ * This code was generated by ojc.
+ */
+/*
+ * FaceProvidedClass.oj
+ *
+ * @author Michiaki Tatsubori
+ * @see java.lang.Object
+ *
+ * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
+ */
+package examples.facemake;
+
+
+import openjava.mop.*;
+import openjava.ptree.*;
+import openjava.syntax.*;
+
+
+public class FaceProvidedClass extends OJClass
+{
+
+ /* overrides for translation */
+ public void translateDefinition()
+ throws MOPException
+ {
+ OJMethod[] methods = getMethods();
+ String fname = getName() + "Face";
+ FaceProvidedClass face = createEmptyInterface( fname );
+ OJSystem.addNewClass( face );
+ for (int i = 0; i < methods.length; ++i) {
+ OJMethod fmtd = OJMethod.makePrototype( methods[i] );
+ OJModifier modif = fmtd.getModifiers();
+ if (modif.isStatic()) {
+ continue;
+ }
+ if (isMethodOfObject( methods[i] )) {
+ continue;
+ }
+ fmtd.setModifiers( OJModifier.PUBLIC );
+ face.addMethod( fmtd );
+ }
+ addInterface( face );
+ }
+
+ public static FaceProvidedClass createEmptyInterface( String qname )
+ {
+ String pack = Environment.toPackageName( qname );
+ String sname = Environment.toSimpleName( qname );
+ ClassDeclaration cd = new ClassDeclaration( new ModifierList( ModifierList.PUBLIC ), sname, new TypeName[0], new TypeName[0], new MemberDeclarationList(), false );
+ FileEnvironment env = new FileEnvironment( OJSystem.env, pack, sname );
+ return new FaceProvidedClass( env, null, cd );
+ }
+
+ public static boolean isMethodOfObject( OJMethod m )
+ {
+ try {
+ OJClass clazz = OJSystem.OBJECT;
+ clazz.getMethod( m.getName(), m.getParameterTypes(), clazz );
+ return true;
+ } catch ( NoSuchMemberException ex ) {
+ return false;
+ }
+ }
+
+ public FaceProvidedClass( openjava.mop.Environment oj_param0, openjava.mop.OJClass oj_param1, openjava.ptree.ClassDeclaration oj_param2 )
+ {
+ super( oj_param0, oj_param1, oj_param2 );
+ }
+
+ public FaceProvidedClass( java.lang.Class oj_param0, openjava.mop.MetaInfo oj_param1 )
+ {
+ super( oj_param0, oj_param1 );
+ }
+
+}