Hi, I have a problem getting the correct string representation of an Eclipse Term since I upgraded to the version 5.3 of Eclipse. In Version 5.2, eclipse_to_java_formatted.readTerm().toString() provided the correct string representation, for example "foo (X, a).". In Version 5.3, you will get an object containing the Eclipse-classes, for instance "class com.parctechnologies.eclipse.CompoundTermImpl" with a functor, the arity and so on. Trying to create the "nicer" string out of the Object, I wrote the function "getString" that you can find at the end of this mail. It works fine, but it doesn't recognize any variables, because they were represented as "null" and hence have no "toString" method. Simply printing "X" for "null" will result in problems, because foo(X, Y) will be printed as foo(X, X). Is there another way to translate variables to its original name? Or better: is there a build in function in the Java Interface to get the string representation from an Eclipse Term, and I just didn't see it? Thank you for any hint, Roland Wenzel --- public String getString(Object EclipseTerm) { String result = ""; LinkedList LinkList; int i; if (EclipseTerm == null) { return ""; } if (EclipseTerm.getClass().toString().equals("class com.parctechnologies.eclipse.CompoundTermImpl")) { result = ((CompoundTerm)EclipseTerm).functor(); if (((CompoundTerm)EclipseTerm).arity() >= 1) { result = result + "("; for (i=1; i <= ((CompoundTerm)EclipseTerm).arity(); i++) { result = result + getString(((CompoundTerm)EclipseTerm).arg(i)); if (i < ((CompoundTerm)EclipseTerm).arity()) { result = result + ", "; } } result = result + ")"; } } else if (EclipseTerm.getClass().toString().equals("class com.parctechnologies.eclipse.Atom")) { result = result + ((Atom)EclipseTerm).functor().toString(); } else if (EclipseTerm.getClass().toString().equals("class java.util.LinkedList")) { result = result + "["; LinkList = (LinkedList)EclipseTerm; while (!LinkList.isEmpty()) { result = result + getString(LinkList.getFirst()); LinkList.removeFirst(); if (!LinkList.isEmpty()) { result = result + ", "; } } result = result + "]"; } else { result = result + EclipseTerm.toString(); } return result; }Received on Thu Dec 13 16:28:43 2001
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:12 PM GMT GMT