// A behavior file for misc util adpative methods. Most of these routines // traverse down into an object to retrieve a name of some sort. PrimaryExpression{ // The first identifier should be the object name in the format of o.a() // Where o.a is the name and () are arguments. String getObjName() through {PrimaryPrefix,PName} to Name { (@ String name; @) before Name (@ name = host.getFirstId(); @) return (@ name @) } } // Ends PrimaryExpression // The name can be a simple name (foo) or a more complex name (java.lang.io) Name { (@ String convertToString() { boolean firstOne = true; Enumeration enum = this.elements(); StringBuffer next = new StringBuffer(); if (false) System.out.println("** Starting name conversion with: " + this.get_first().get_it().get_ident().toString()); if (false) System.out.println("** The enum has " + this.size() + " elements") ; while (enum.hasMoreElements()) { if (!firstOne) { next.append("." +((Identifier) enum.nextElement()).get_ident().toString()); } else { next.append(((Identifier) enum.nextElement()).get_ident().toString()); firstOne = false; } } if (false) System.out.println("**Name conversion returning: " + next); return next.toString(); } @) // THis must return the object name when the Name is o.a(). If the name is // just bar(), the object is returned to be null. If the string is // this.bar() it should also return null. If the name is this.o.bar() then it // should return o. String getFirstId() to Identifier { (@ String beginning; boolean first = true; boolean another=false; String result;@) before Identifier (@ if (first) { beginning = new String(host.get_ident().toString()); if (beginning != "this") first = false; } else another = true; if (another) result = beginning; @) return String (@ result @) } } // Ends Name Type { String getName() to Name { (@ String name; @) before Name (@ name = host.convertToString(); @) return (@ name @) } } // End Type VariableDeclarators { Vector getObjNames() to Identifier{ (@ Vector names = new Vector(); Ident i; @) before Identifier (@ i = host.get_ident(); if (false) System.out.println("At obj: "+i.toString()); names.addElement(i.toString()); @) return (@ names @) } } // End VariableDeclarators LocalVariableDeclaration { String getObjName() via VariableDeclaratorId to Identifier{ (@ String name; @) before Identifier (@ name = new String(host.get_ident().toString()); if (false) System.out.println("At obj: "+name); @) return (@ name @) } } //End LocalVariableDeclaration VariableDeclaratorId { String getObjName() to Identifier{ (@ String name; @) before Identifier (@ name = new String(host.get_ident().toString()); if (false) System.out.println("At obj: "+name); @) return (@ name @) } } //End VariableDeclaratorId MethodDeclaration{ String getMethodName() through {MethodDeclarator} bypassing {FormalParameter} to-stop Identifier { (@ String name; @) before Identifier (@ name = new String(host.get_ident().toString()); if (false) System.out.println("At method: "+name); @) return (@ name @) } } // End MethodDeclaration