summaryrefslogtreecommitdiff
path: root/tutorial/examples/print
diff options
context:
space:
mode:
authorKenny Ballou <kballou@devnulllabs.io>2018-11-19 22:59:50 -0700
committerKenny Ballou <kballou@devnulllabs.io>2018-11-19 22:59:50 -0700
commitea3e1b949dcbdc09518f17eee0bcf21d41d76896 (patch)
tree7ec7a7fb4df67815a9b7bb0e4d95d67c4050e2a2 /tutorial/examples/print
downloadopenjava-ea3e1b949dcbdc09518f17eee0bcf21d41d76896.tar.gz
openjava-ea3e1b949dcbdc09518f17eee0bcf21d41d76896.tar.xz
OJ (aka OpenJava) modernization/mirroring
Signed-off-by: Kenny Ballou <kballou@devnulllabs.io>
Diffstat (limited to 'tutorial/examples/print')
-rw-r--r--tutorial/examples/print/MyClass.java30
-rw-r--r--tutorial/examples/print/MyClass.oj21
-rw-r--r--tutorial/examples/print/Printer.java64
-rw-r--r--tutorial/examples/print/Test.java119
-rw-r--r--tutorial/examples/print/Test.oj107
-rw-r--r--tutorial/examples/print/TestPrinter.java99
6 files changed, 440 insertions, 0 deletions
diff --git a/tutorial/examples/print/MyClass.java b/tutorial/examples/print/MyClass.java
new file mode 100644
index 0000000..bbd1481
--- /dev/null
+++ b/tutorial/examples/print/MyClass.java
@@ -0,0 +1,30 @@
+/*
+ * This code was generated by ojc.
+ */
+package examples.print;
+
+
+import openjava.mop.*;
+import openjava.ptree.*;
+
+
+public class MyClass extends OJClass
+{
+
+ public MyClass( Environment outer_env, OJClass declarer, ClassDeclaration ptree )
+ {
+ super( outer_env, declarer, ptree );
+ }
+
+ public MyClass( Class javaclass, MetaInfo minfo )
+ {
+ super( javaclass, minfo );
+ }
+
+ protected void pro()
+ {}
+
+ public void pub()
+ {}
+
+}
diff --git a/tutorial/examples/print/MyClass.oj b/tutorial/examples/print/MyClass.oj
new file mode 100644
index 0000000..0b689ea
--- /dev/null
+++ b/tutorial/examples/print/MyClass.oj
@@ -0,0 +1,21 @@
+package examples.print;
+
+
+import openjava.mop.*;
+import openjava.ptree.*;
+
+
+public class MyClass instantiates TestPrinter extends OJClass
+{
+ public MyClass( Environment outer_env, OJClass declarer,
+ ClassDeclaration ptree ) {
+ super( outer_env, declarer, ptree );
+ }
+
+ public MyClass( Class javaclass, MetaInfo minfo ) {
+ super( javaclass, minfo );
+ }
+
+ protected void pro() {}
+ public void pub() {}
+}
diff --git a/tutorial/examples/print/Printer.java b/tutorial/examples/print/Printer.java
new file mode 100644
index 0000000..4de9203
--- /dev/null
+++ b/tutorial/examples/print/Printer.java
@@ -0,0 +1,64 @@
+/*
+ * Printer.java
+ *
+ * comments here.
+ *
+ * @author Michiaki Tatsubori
+ * @version %VERSION% %DATE%
+ * @see java.lang.Object
+ *
+ * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
+ */
+package examples.print;
+
+import java.lang.Object;
+import openjava.mop.*;
+import openjava.ptree.ClassDeclaration;
+import openjava.syntax.*;
+
+/**
+ * The class <code>Printer</code>
+ * <p>
+ * For example
+ * <pre>
+ * </pre>
+ * <p>
+ *
+ * @author Michiaki Tatsubori
+ * @version 1.0
+ * @since $Id: Printer.java,v 1.2 2003/02/19 02:55:01 tatsubori Exp $
+ * @see java.lang.Object
+ */
+public class Printer extends OJClass {
+ public void translateDefinition() throws MOPException {
+ System.out.println("CONSTRUCTORS");
+ OJConstructor[] c = getConstructors();
+ for (int i = 0; i < c.length; ++i) {
+ System.out.println(c[i].toString());
+ }
+
+ System.out.println("FIELDS");
+ OJField[] f = getAllFields();
+ for (int i = 0; i < f.length; ++i) {
+ System.out.println(f[i].toString());
+ }
+
+ System.out.println("METHODS");
+ OJMethod[] m = getAllMethods();
+ for (int i = 0; i < m.length; ++i) {
+ System.out.println(m[i].toString());
+ }
+ }
+
+ public Printer(
+ Environment outer_env,
+ OJClass declarer,
+ ClassDeclaration ptree) {
+ super(outer_env, declarer, ptree);
+ }
+
+ public Printer(Class javaclass, MetaInfo minfo) {
+ super(javaclass, minfo);
+ }
+
+}
diff --git a/tutorial/examples/print/Test.java b/tutorial/examples/print/Test.java
new file mode 100644
index 0000000..77238e9
--- /dev/null
+++ b/tutorial/examples/print/Test.java
@@ -0,0 +1,119 @@
+/*
+ * This code was generated by ojc.
+ */
+/*
+ * Test.java
+ *
+ * comments here.
+ *
+ * @author Michiaki Tatsubori
+ * @version %VERSION% %DATE%
+ * @see java.lang.Object
+ *
+ * COPYRIGHT 1998 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
+ */
+package examples.print;
+
+import java.awt.Panel;
+import java.util.*;
+import java.io.PrintStream;
+
+/**
+ * The class <code>Test</code>
+ * <p>
+ * For example
+ * <pre>
+ * </pre>
+ * <p>
+ *
+ * @author Michiaki Tatsubori
+ * @version 1.0
+ * @since $Id: Test.java,v 1.2 2003/02/19 02:55:01 tatsubori Exp $
+ * @see java.lang.Object
+ */
+public class Test extends Panel {
+
+ private int iii = 0;
+
+ private Test n = null;
+
+ private String str = "string";
+
+ public Test() {
+ super();
+ }
+
+ /**
+ * @param
+ * @return
+ * @exception
+ * @see java.lang.Object
+ */
+ public static void main(String[] argv) {
+ PrintStream out = System.out;
+ PrintStream error = java.lang.System.err;
+ out.println("Hello" + " " + "World");
+ Test n = new Test();
+ java.lang.System.err.println("done");
+ }
+
+ public void hoge() {
+ Local l = new Local();
+ System.out.println(l.foo);
+ System.out.println(l.bar.str);
+ }
+
+ public Test(String str) {
+ this.str = str;
+ n = null;
+ }
+
+ public int foo(int iii) {
+ switch (iii) {
+ case 0 :
+ return 0;
+
+ case 1 :
+ {
+ String str = null;
+ }
+
+ case 2 :
+ case 3 :
+ case 4 :
+ {
+ String ppp = null;
+ }
+
+ default :
+
+ }
+ return iii;
+ }
+
+ public String toString() {
+ if (n == null) {
+ return str;
+ }
+ return str + n;
+ }
+
+}
+
+class Local {
+
+ String foo = null;
+
+ Local2 bar = new Local2();
+
+ public final String getFoo(Integer i) {
+ return foo;
+ }
+
+}
+
+class Local2 {
+
+ String str = "" + "TEST";
+
+}
diff --git a/tutorial/examples/print/Test.oj b/tutorial/examples/print/Test.oj
new file mode 100644
index 0000000..7b1061a
--- /dev/null
+++ b/tutorial/examples/print/Test.oj
@@ -0,0 +1,107 @@
+/*
+ * Test.java
+ *
+ * comments here.
+ *
+ * @author Michiaki Tatsubori
+ * @version %VERSION% %DATE%
+ * @see java.lang.Object
+ *
+ * COPYRIGHT 1998 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
+ */
+package examples.print;
+
+
+import java.awt.Panel;
+import java.util.*;
+import java.io.PrintStream;
+
+
+/**
+ * The class <code>Test</code>
+ * <p>
+ * For example
+ * <pre>
+ * </pre>
+ * <p>
+ *
+ * @author Michiaki Tatsubori
+ * @version 1.0
+ * @since %SOFTWARE% 1.0
+ * @see java.lang.Object
+ */
+public class Test instantiates Printer
+ extends Panel
+{
+ private int iii = 0;
+
+ private Test n = null;
+
+ private String str = "string";
+
+ public Test() {
+ super();
+ }
+
+ /**
+ * @param
+ * @return
+ * @exception
+ * @see java.lang.Object
+ */
+ public static void main( String[] argv ) {
+ PrintStream out = System.out;
+ PrintStream error = java.lang.System.err;
+ out.println( "Hello" + " " + "World" );
+ Test n = new Test();
+ java.lang.System.err.println( "done" );
+ }
+
+ public void hoge() {
+ Local l = new Local();
+ System.out.println( l.foo );
+ System.out.println( l.bar.str );
+ }
+
+ public Test( String str ) {
+ this.str = str;
+ n = null;
+ }
+
+ public int foo( int iii ) {
+ switch (iii) {
+ case 0:
+ return 0;
+ case 1: {
+ String str = null;
+ }
+ case 2:
+ case 3:
+ case 4: {
+ String ppp = null;
+ }
+ default:
+ }
+ return iii;
+ }
+
+ public String toString() {
+ if (n == null) return str;
+ return str + n;
+ }
+
+}
+
+class Local instantiates Printer
+{
+ String foo = null;
+ Local2 bar = new Local2();
+ public final String getFoo( Integer i ) {
+ return foo;
+ }
+}
+
+class Local2
+{
+ String str = "" + "TEST";
+}
diff --git a/tutorial/examples/print/TestPrinter.java b/tutorial/examples/print/TestPrinter.java
new file mode 100644
index 0000000..bd6d359
--- /dev/null
+++ b/tutorial/examples/print/TestPrinter.java
@@ -0,0 +1,99 @@
+/*
+ * TestPrinter.java
+ *
+ * comments here.
+ *
+ * @author Michiaki Tatsubori
+ * @version %VERSION% %DATE%
+ * @see java.lang.Object
+ *
+ * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
+ */
+package examples.print;
+
+import java.lang.Object;
+import openjava.mop.*;
+import openjava.ptree.ClassDeclaration;
+import openjava.syntax.*;
+
+/**
+ * The class <code>TestPrinter</code>
+ * <p>
+ * For example
+ * <pre>
+ * </pre>
+ * <p>
+ *
+ * @author Michiaki Tatsubori
+ * @version 1.0
+ * @since $Id: TestPrinter.java,v 1.2 2003/02/19 02:55:01 tatsubori Exp $
+ * @see java.lang.Object
+ */
+public class TestPrinter extends OJClass {
+ public void translateDefinition() throws MOPException {
+ OJMethod[] m;
+
+ /*
+ System.out.println( "SELF" );
+ m = getInheritedMethods();
+ for (int i = 0; i < m.length; ++i) {
+ System.out.println( m[i].toString() );
+ }
+ */
+
+ System.out.println("STATEMENTLIST");
+ OJClass clazz = OJClass.forName("openjava.ptree.StatementList");
+
+ m = clazz.getMethods(this);
+ /*
+ for (int i = 0; i < m.length; ++i) {
+ System.out.println( m[i].toString() );
+ }
+ */
+
+ System.out.println("INSERTELEMENTAT");
+ OJMethod method;
+ try {
+ OJClass[] params =
+ new OJClass[] {
+ OJClass.forName("openjava.ptree.Statement"),
+ OJClass.forName("int")};
+ method = clazz.getMethod("insertElementAt", params);
+ m = Toolbox.pickupMethodsByName(m, "insertElementAt");
+ System.out.println("name matches : " + m.length);
+ System.err.println(m[0].toString());
+ OJClass[] mparams = m[0].getParameterTypes();
+ System.err.println("M " + mparams[0] + " " + mparams[1]);
+ System.err.println("P " + params[0] + " " + params[1]);
+ boolean assign0 = mparams[0].isAssignableFrom(params[0]);
+ System.out.println("assignable0 : " + assign0);
+ boolean assign1 = mparams[1].isAssignableFrom(params[1]);
+ System.out.println("assignable1 : " + assign1);
+ System.out.println("equality : " + (mparams[0] == params[0]));
+
+ boolean isa = Toolbox.isAcceptable(mparams, params);
+ System.out.println("acceptable : " + isa);
+ m = Toolbox.pickupAcceptableMethodsByParameterTypes(m, params);
+ System.out.println("param matches : " + m.length);
+ } catch (NoSuchMethodException e) {
+ method = null;
+ }
+ if (method == null) {
+ System.out.println("NOT FOUND");
+ } else {
+ System.out.println(method.toString());
+ }
+ }
+
+ public TestPrinter(
+ Environment outer_env,
+ OJClass declarer,
+ ClassDeclaration ptree) {
+ super(outer_env, declarer, ptree);
+ }
+
+ public TestPrinter(Class javaclass, MetaInfo minfo) {
+ super(javaclass, minfo);
+ }
+
+}