Browse Source

big refactoring

refactoring
aclement 16 years ago
parent
commit
b15a77c892

+ 0
- 116
util/src/org/aspectj/util/CharOperation.java View File

@@ -1,116 +0,0 @@
/********************************************************************
* Copyright (c) 2006 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version
*******************************************************************/
package org.aspectj.util;


/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*
*/
public class CharOperation {
/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final char[] subarray(char[] array, int start, int end) {
if (end == -1)
end = array.length;
if (start > end)
return null;
if (start < 0)
return null;
if (end > array.length)
return null;

char[] result = new char[end - start];
System.arraycopy(array, start, result, 0, end - start);
return result;
}
/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final int lastIndexOf(char toBeFound, char[] array) {
for (int i = array.length; --i >= 0;)
if (toBeFound == array[i])
return i;
return -1;
}
/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final boolean contains(char character, char[] array) {
for (int i = array.length; --i >= 0;)
if (array[i] == character)
return true;
return false;
}

/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final int indexOf(char toBeFound, char[] array) {
for (int i = 0; i < array.length; i++)
if (toBeFound == array[i])
return i;
return -1;
}
/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final char[] concat(char[] first, char[] second) {
if (first == null)
return second;
if (second == null)
return first;

int length1 = first.length;
int length2 = second.length;
char[] result = new char[length1 + length2];
System.arraycopy(first, 0, result, 0, length1);
System.arraycopy(second, 0, result, length1, length2);
return result;
}
/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final boolean equals(char[] first, char[] second) {
if (first == second)
return true;
if (first == null || second == null)
return false;
if (first.length != second.length)
return false;

for (int i = first.length; --i >= 0;)
if (first[i] != second[i])
return false;
return true;
}
/**
* Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation
*/
public static final void replace(
char[] array,
char toBeReplaced,
char replacementChar) {
if (toBeReplaced != replacementChar) {
for (int i = 0, max = array.length; i < max; i++) {
if (array[i] == toBeReplaced)
array[i] = replacementChar;
}
}
}
}

+ 0
- 60
util/src/org/aspectj/util/CollectionUtil.java View File

@@ -1,60 +0,0 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/


package org.aspectj.util;


import java.util.*;

public class CollectionUtil {
public static final String[] NO_STRINGS = new String[0];
public static List getListInMap(Map map, Object key) {
List list = (List)map.get(key);
if (list == null) {
list = new ArrayList();
map.put(key, list);
}
return list;
}

public static SortedSet getSortedSetInMap(Map map, Object key) {
SortedSet list = (SortedSet)map.get(key);
if (list == null) {
list = new TreeSet();
map.put(key, list);
}
return list;
}

public static Set getSetInMap(Map map, Object key) {
Set list = (Set)map.get(key);
if (list == null) {
list = new HashSet();
map.put(key, list);
}
return list;
}

public static Map getMapInMap(Map map, Object key) {
Map list = (Map)map.get(key);
if (list == null) {
list = new HashMap();
map.put(key, list);
}
return list;
}
}

+ 0
- 311
util/src/org/aspectj/util/ConfigParser.java View File

@@ -1,311 +0,0 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/



package org.aspectj.util;

import java.util.*;
import java.io.*;

public class ConfigParser {
Location location;
protected File relativeDirectory = null;
protected List files = new LinkedList();
private boolean fileParsed = false;
protected static String CONFIG_MSG = "build config error: ";
public List getFiles() { return files; }

public void parseCommandLine(String[] argsArray) throws ParseException {
location = new CommandLineLocation();
LinkedList args = new LinkedList();
for (int i = 0; i < argsArray.length; i++) {
args.add(new Arg(argsArray[i], location));
}
parseArgs(args);
}

public void parseConfigFile(File configFile) throws ParseException {
if (fileParsed == true) {
throw new ParseException(CONFIG_MSG + "The file has already been parsed.", null);
} else {
parseConfigFileHelper(configFile);
}
}

/**
* @throws ParseException if the config file has already been prased.
*/
private void parseConfigFileHelper(File configFile) {
if (!configFile.exists()) {
showError("file does not exist: " + configFile.getPath());
return;
}

LinkedList args = new LinkedList();
int lineNum = 0;

try {
BufferedReader stream =
new BufferedReader(new FileReader(configFile));
String line = null;
while ( (line = stream.readLine()) != null) {
lineNum += 1;
line = stripWhitespaceAndComments(line);
if (line.length() == 0) continue;
args.add(new Arg(line, new SourceLocation(configFile, lineNum)));
}
stream.close();
} catch (IOException e) {
location = new SourceLocation(configFile, lineNum);
showError("error reading config file: " + e.toString());
}
File oldRelativeDirectory = relativeDirectory; // for nested arg files;
relativeDirectory = configFile.getParentFile();
parseArgs(args);
relativeDirectory = oldRelativeDirectory;
fileParsed = true;
}

File getCurrentDir() {
return location.getDirectory();
}

String stripSingleLineComment(String s, String commentString) {
int commentStart = s.indexOf(commentString);
if (commentStart == -1) return s;
else return s.substring(0, commentStart);
}

String stripWhitespaceAndComments(String s) {
s = stripSingleLineComment(s, "//");
s = stripSingleLineComment(s, "#");
s = s.trim();
if (s.startsWith("\"") && s.endsWith("\"")) {
s = s.substring(1, s.length()-1);
}
return s;
}


/** ??? We would like to call a showNonFatalError method here
* to show all errors in config files before aborting the compilation
*/
protected void addFile(File sourceFile) {
if (!sourceFile.isFile()) {
showError("source file does not exist: " + sourceFile.getPath());
}
files.add(sourceFile);
}

void addFileOrPattern(File sourceFile) {
if (sourceFile.getName().equals("*.java")) {
addFiles(sourceFile.getParentFile(), new FileFilter() {
public boolean accept(File f) {
return f != null && f.getName().endsWith(".java");
}});
} else if (sourceFile.getName().equals("*.aj")) {
addFiles(sourceFile.getParentFile(), new FileFilter() {
public boolean accept(File f) {
return f != null && f.getName().endsWith(".aj");
}});
} else {
addFile(sourceFile);
}
}

void addFiles(File dir, FileFilter filter) {
if (dir == null) dir = new File(System.getProperty("user.dir"));
if (!dir.isDirectory()) {
showError("can't find " + dir.getPath());
} else {

File[] files = dir.listFiles(filter);
if (files.length == 0) {
showWarning("no matching files found in: " + dir);
}

for (int i = 0; i < files.length; i++) {
addFile(files[i]);
}
}
}

protected void parseOption(String arg, LinkedList args) {
showWarning("unrecognized option: " + arg);
}

protected void showWarning(String message) {
if (location != null) {
message += " at " + location.toString();
}
System.err.println(CONFIG_MSG + message);
}

protected void showError(String message) {
throw new ParseException(CONFIG_MSG + message, location);
}

void parseArgs(LinkedList args) {
while (args.size() > 0) parseOneArg(args);
}

protected Arg removeArg(LinkedList args) {
if (args.size() == 0) {
showError("value missing");
return null;
} else {
return (Arg)args.removeFirst();
}
}

protected String removeStringArg(LinkedList args) {
Arg arg = removeArg(args);
if (arg == null) return null;
return arg.getValue();
}

boolean isSourceFileName(String s) {
if (s.endsWith(".java")) return true;
if (s.endsWith(".aj")) return true;
if (s.endsWith(".ajava")) {
showWarning(".ajava is deprecated, replace with .aj or .java: " + s);
return true;
}
return false;
}

void parseOneArg(LinkedList args) {
Arg arg = removeArg(args);
String v = arg.getValue();
location = arg.getLocation();
if (v.startsWith("@")) {
parseImportedConfigFile(v.substring(1));
} else if (v.equals("-argfile")) {
parseConfigFileHelper(makeFile(removeArg(args).getValue()));
} else if (isSourceFileName(v)) {
addFileOrPattern(makeFile(v));
} else {
parseOption(arg.getValue(), args);
}
}

protected void parseImportedConfigFile(String relativeFilePath) {
parseConfigFileHelper(makeFile(relativeFilePath));
}

public File makeFile(String name) {
if (relativeDirectory != null) {
return makeFile(relativeDirectory,name);
} else {
return makeFile(getCurrentDir(), name);
}
}

private File makeFile(File dir, String name) {
name = name.replace('/', File.separatorChar);
File ret = new File(name);
boolean isAbsolute = ret.isAbsolute()
|| (ret.exists() && ret.getPath().startsWith(File.separator));
if (!isAbsolute && (dir != null)) {
ret = new File(dir, name);
}
try {
ret = ret.getCanonicalFile();
} catch (IOException ioEx) {
// proceed without canonicalization
// so nothing to do here
}
return ret;
}


protected static class Arg {
private Location location;
private String value;
public Arg(String value, Location location) {
this.value = value;
this.location = location;
}
public void setValue(String value) {
this.value = value;
}

public void setLocation(Location location) {
this.location = location;
}
public String getValue() { return value; }
public Location getLocation() { return location; }
}
static abstract class Location {
public abstract File getFile();
public abstract File getDirectory();
public abstract int getLine();
public abstract String toString();
}

static class SourceLocation extends Location {
private int line;
private File file;
public SourceLocation(File file, int line) {
this.line = line;
this.file = file;
}

public File getFile() { return file; }
public File getDirectory() { return file.getParentFile(); }
public int getLine() { return line; }

public String toString() {
return file.getPath()+":"+line;
}
}
static class CommandLineLocation extends Location {
public File getFile() {
return new File(System.getProperty("user.dir"));
}
public File getDirectory() {
return new File(System.getProperty("user.dir"));
}
public int getLine() { return -1; }
public String toString() {
return "command-line";
}
}

public static class ParseException extends RuntimeException {
private Location location;

public ParseException(String message, Location location) {
super(message);
this.location = location;
}

public int getLine() {
if (location == null) return -1;
return location.getLine();
}
public File getFile() {
if (location == null) return null;
return location.getFile();
}
}
}

+ 1
- 0
util/src/org/aspectj/util/FileUtil.java View File

@@ -1188,6 +1188,7 @@ public class FileUtil {
* @return List of String of the form file:line for each found entry
* (never null, might be empty)
*/
// OPTIMIZE only used by tests? move it out
public static List lineSeek(String sought, List sources, boolean listAll,
PrintStream errorSink) {
if (LangUtil.isEmpty(sought) || LangUtil.isEmpty(sources)) {

+ 6
- 4
util/src/org/aspectj/util/LangUtil.java View File

@@ -16,10 +16,6 @@ package org.aspectj.util;

//import java.awt.event.InvocationEvent;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.security.PrivilegedActionException;
@@ -40,6 +36,9 @@ import java.util.StringTokenizer;
*
*/
public class LangUtil {

public static final String[] NO_STRINGS = new String[0];
/** map from String version to String class implemented in that version or later */
private static final Map VM_CLASSES;

@@ -90,6 +89,7 @@ public class LangUtil {
private static boolean is13VMOrGreater = true;
private static boolean is14VMOrGreater = true;
private static boolean is15VMOrGreater = false;
private static boolean is16VMOrGreater = false;
static {
String vm = System.getProperty("java.version"); // JLS 20.18.7
@@ -99,12 +99,14 @@ public class LangUtil {
is14VMOrGreater = false;
} else if (vm.startsWith("1.5") || vm.startsWith("1.6")) {
is15VMOrGreater = true;
is16VMOrGreater = true;
}
}
public static boolean is13VMOrGreater() { return is13VMOrGreater;}
public static boolean is14VMOrGreater() { return is14VMOrGreater;}
public static boolean is15VMOrGreater() { return is15VMOrGreater;}
public static boolean is16VMOrGreater() { return is16VMOrGreater;}
/**
* Shorthand for "if null, throw IllegalArgumentException"

+ 0
- 213
util/src/org/aspectj/util/NameConvertor.java View File

@@ -1,213 +0,0 @@
/********************************************************************
* Copyright (c) 2006 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version
*******************************************************************/
package org.aspectj.util;

public class NameConvertor {

private static final char BOOLEAN = 'Z';
private static final char BYTE = 'B';
private static final char CHAR = 'C';
private static final char DOUBLE = 'D';
private static final char FLOAT = 'F';
private static final char INT = 'I';
private static final char LONG = 'J';
private static final char SHORT = 'S';
private static final char ARRAY = '[';
private static final char RESOLVED = 'L';
private static final char UNRESOLVED = 'Q';
public static final char PARAMETERIZED = 'P';
private static final char[] BOOLEAN_NAME = new char[]{'b','o','o','l','e','a','n'};
private static final char[] BYTE_NAME = new char[]{'b','y','t','e'};
private static final char[] CHAR_NAME = new char[]{'c','h','a','r'};
private static final char[] DOUBLE_NAME = new char[]{'d','o','u','b','l','e'};
private static final char[] FLOAT_NAME = new char[]{'f','l','o','a','t'};
private static final char[] INT_NAME = new char[]{'i','n','t'};
private static final char[] LONG_NAME = new char[]{'l','o','n','g'};
private static final char[] SHORT_NAME = new char[]{'s','h','o','r','t'};

private static final char[] SQUARE_BRACKETS = new char[]{'[',']'};
private static final char[] GREATER_THAN = new char[]{'>'};
private static final char[] LESS_THAN = new char[]{'<'};
private static final char[] COMMA = new char[]{','};
private static final char[] BACKSLASH_LESSTHAN = new char[]{'\\','<'};
private static final char[] SEMICOLON = new char[]{';'};
/**
* Creates a readable name from the given char array, for example,
* given 'I' returns 'int'. Moreover, given
* 'Ljava/lang/String;<Ljava/lang/String;>' returns
* 'java.lang.String<java.lang.String>'
*/
public static char[] convertFromSignature(char[] c) {
int lt = CharOperation.indexOf('<',c);
int sc = CharOperation.indexOf(';',c);
int gt = CharOperation.indexOf('>',c);
int smallest = 0;
if (lt == -1 && sc == -1 && gt == -1) {
// we have something like 'Ljava/lang/String' or 'I'
return getFullyQualifiedTypeName(c);
} else if (lt != -1 && (sc == -1 || lt <= sc) && (gt == -1 || lt <= gt)) {
// we have something like 'Ljava/lang/String<I'
smallest = lt;
} else if (sc != -1 && (lt == -1 || sc <= lt) && (gt == -1 || sc <= gt)) {
// we have something like 'Ljava/lang/String;I'
smallest = sc;
} else {
// we have something like '>;'
smallest = gt;
}
char[] first = CharOperation.subarray(c,0,smallest);
char[] second = CharOperation.subarray(c,smallest+1,c.length);
if (smallest == 0 && first.length == 0 && c[0] == '>') {
// c = {'>',';'} therefore we just want to return '>' to
// close the generic signature
return GREATER_THAN;
} else if (first.length == 1 && second.length == 0) {
return first;
} else if (second.length == 0 || (second.length == 1 && second[0] == ';')){
// we've reached the end of the array, therefore only care about
// the first part
return convertFromSignature(first);
} else if (smallest == lt) {
// if c = 'Ljava/lang/String;<I' then first = 'Ljava/Lang/String;' and
// second = 'I'. Want to end up with 'Ljava.lang.String<I' and so add
// the '<' back.
char[] inclLT = CharOperation.concat(convertFromSignature(first),LESS_THAN);
return CharOperation.concat(inclLT,convertFromSignature(second));
} else if (smallest == gt) {
char[] inclLT = CharOperation.concat(convertFromSignature(first),GREATER_THAN);
return CharOperation.concat(inclLT,convertFromSignature(second));
} else if (second.length != 2) {
// if c = 'Ljava/lang/Sting;LMyClass' then first = 'Ljava/lang/String'
// and second = 'LMyClass'. Want to end up with 'java.lang.String,MyClass
// so want to add a ','. However, only want to do this if we're in the
// middle of a '<...>'
char[] inclComma = CharOperation.concat(convertFromSignature(first),COMMA);
return CharOperation.concat(inclComma,convertFromSignature(second));
}
return CharOperation.concat(convertFromSignature(first),convertFromSignature(second));
}
/**
* Given a char array, returns the type name for this. For example
* 'I' returns 'int', 'Ljava/lang/String' returns 'java.lang.String' and
* '[Ljava/lang/String' returns 'java.lang.String[]'
*
* NOTE: Doesn't go any deaper so given 'Ljava/lang/String;<Ljava/lang/String;>'
* it would return 'java.lang.String;<Ljava.lang.String;>', however, only called
* with something like 'Ljava/lang/String'
*/
private static char[] getFullyQualifiedTypeName(char[] c) {
if (c.length == 0) {
return c;
}
if (c[0] == BOOLEAN) {
return BOOLEAN_NAME;
} else if (c[0] == BYTE) {
return BYTE_NAME;
} else if (c[0] == CHAR) {
return CHAR_NAME;
} else if (c[0] == DOUBLE) {
return DOUBLE_NAME;
} else if (c[0] == FLOAT) {
return FLOAT_NAME;
} else if (c[0] == INT) {
return INT_NAME;
} else if (c[0] == LONG) {
return LONG_NAME;
} else if (c[0] == SHORT) {
return SHORT_NAME;
} else if (c[0] == ARRAY) {
return CharOperation.concat(
getFullyQualifiedTypeName(CharOperation.subarray(c,1,c.length)),
SQUARE_BRACKETS);
} else {
char[] type = CharOperation.subarray(c,1,c.length);
CharOperation.replace(type,'/','.');
return type;
}
}
/**
* Given 'Ppkg/MyGenericClass<Ljava/lang/String;Ljava/lang/Integer;>;'
* will return 'QMyGenericClass<QString;QInteger;>;'
*/
public static char[] createShortName(char[] c) {
int lt = CharOperation.indexOf('<',c);
int sc = CharOperation.indexOf(';',c);
int gt = CharOperation.indexOf('>',c);
int smallest = 0;
if (lt == -1 && sc == -1 && gt == -1) {
// we have something like 'Ljava/lang/String' or 'I'
return getTypeName(c);
} else if (lt != -1 && (sc == -1 || lt <= sc) && (gt == -1 || lt <= gt)) {
// we have something like 'Ljava/lang/String<I'
smallest = lt;
} else if (sc != -1 && (lt == -1 || sc <= lt) && (gt == -1 || sc <= gt)) {
// we have something like 'Ljava/lang/String;I'
smallest = sc;
} else {
// we have something like '>;'
smallest = gt;
}
char[] first = CharOperation.subarray(c,0,smallest);
char[] second = CharOperation.subarray(c,smallest+1,c.length);
if (smallest == 0 && first.length == 0 && c[0] == '>') {
// c = {'>',';'} therefore we just want to return c to
// close the generic signature
return c;
} else if (first.length == 1 && second.length == 0) {
return first;
} else if (second.length == 0 || (second.length == 1 && second[0] == ';')){
// we've reached the end of the array, therefore only care about
// the first part
return createShortName(first);
} else if (smallest == lt) {
// if c = 'Ljava/lang/String;<I' then first = 'Ljava/Lang/String;' and
// second = 'I'. Want to end up with 'LString<I' and so add
// the '<' back.
char[] inclLT = CharOperation.concat(createShortName(first),BACKSLASH_LESSTHAN);
return CharOperation.concat(inclLT,createShortName(second));
} else if (smallest == gt) {
char[] inclLT = CharOperation.concat(createShortName(first),GREATER_THAN);
return CharOperation.concat(inclLT,createShortName(second));
} else {
// if c = 'Ljava/lang/Sting;LMyClass;' then first = 'Ljava/lang/String'
// and second = 'LMyClass;'. Want to end up with 'QString;QMyClass;
// so add the ';' back
char[] firstTypeParam = CharOperation.concat(createShortName(first),SEMICOLON);
return CharOperation.concat(firstTypeParam,createShortName(second));
}
}

/**
* Given 'Qjava/lang/String;' returns 'QString;'
*/
public static char[] getTypeName(char[] name) {
int i = CharOperation.lastIndexOf('/',name);
if (i != -1) {
if (name[0] == RESOLVED || name[0] == PARAMETERIZED) {
return CharOperation.concat(new char[]{UNRESOLVED},
CharOperation.subarray(name,i+1,name.length));
} else {
return CharOperation.concat(new char[]{name[0]},
CharOperation.subarray(name,i+1,name.length));
}
}
return name;
}
}

+ 0
- 39
util/src/org/aspectj/util/NonLocalExit.java View File

@@ -1,39 +0,0 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/


package org.aspectj.util;

/**
* Throw this when a non-local exit is required (suggested for tests only).
*/
public class NonLocalExit extends RuntimeException {

public static final int SUCCEESS = 0;
public static final int FAULURE = 1;

private int exitCode;

public NonLocalExit(int exitCode) {
this();
this.exitCode = exitCode;
}

public NonLocalExit() {
super();
}

public int getExitCode() {
return exitCode;
}

}

+ 0
- 101
util/src/org/aspectj/util/StreamPrintWriter.java View File

@@ -1,101 +0,0 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/

package org.aspectj.util;

import java.io.*;

/**
* Used for writing converting text written to an output stream into
* a string. Deprecated - use StringWriter:
* <pre>
* StringWriter sw = new StringWriter();
* PrintWriter pw = new PrintWriter(sw, true);
* ... write to pw
* String result = sw.getBuffer().toString();
* </pre>
* @deprecated use StringWriter to construct PrintWriter
* @author Mik Kersten
*/
public class StreamPrintWriter extends PrintWriter {
private String contents = "";

public StreamPrintWriter(Writer out) {
super(out);
}

public String getContents() {
return contents;
}

public void flushBuffer() {
contents = "";
super.flush();
}

public void print(char x) {
contents += x + "\n";
}

public void print(char[] x) {
contents += new String( x );
}

public void print(int x) {
contents += x;
}

public void print(String x) {
contents += x;
}

public void println(char x) {
contents += x + "\n";
}

public void println(char[] x) {
contents += new String( x ) + "\n";
}

public void println(int x) {
contents += x + "\n";
}

public void println(String x) {
contents += x + "\n";
}

public void write( byte[] x ) {
contents += new String( x );
}

public void write( byte[] x, int i1, int i2 ) {
StringWriter writer = new StringWriter();
String s = new String( x );
writer.write( s.toCharArray(), i1, i2 );
contents += writer.getBuffer().toString();
}

public void write( int c ) {
contents += c;
}

public void write( String s ) {
contents += s;
}

public void write( String s, int i1, int i2 ) {
contents += s;
}
}

+ 0
- 83
util/testsrc/org/aspectj/util/NameConvertorTest.java View File

@@ -1,83 +0,0 @@
/********************************************************************
* Copyright (c) 2006 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
* Helen Hawkins - initial version
*******************************************************************/
package org.aspectj.util;

import junit.framework.TestCase;

public class NameConvertorTest extends TestCase {

public void testBoolean() {
checkConversion("Z","boolean");
}
public void testByte() {
checkConversion("B","byte");
}
public void testChar() {
checkConversion("C","char");
}
public void testDouble() {
checkConversion("D","double");
}
public void testFloat() {
checkConversion("F","float");
}
public void testInt() {
checkConversion("I","int");
}
public void testLong() {
checkConversion("J","long");
}
public void testShort() {
checkConversion("S","short");
}
public void testString() {
checkConversion("Ljava/lang/String;","java.lang.String");
}

public void testType() {
checkConversion("LMyClass;","MyClass");
}

public void testListPameterizedWithString() {
checkConversion("Pjava/util/List<Ljava/lang/String;>;",
"java.util.List<java.lang.String>");
}
public void testClassParameterizedWithStringAndType() {
checkConversion("PMyGenericClass<Ljava/lang/String;LMyClass;>;",
"MyGenericClass<java.lang.String,MyClass>");
}
public void testStringArray() {
checkConversion("[Ljava/lang/String;","java.lang.String[]");
}
public void testTwoDimensionalStringArray() {
checkConversion("[[Ljava/lang/String;","java.lang.String[][]");
}
public void testIntArray() {
checkConversion("[I","int[]");
}

private void checkConversion(String signature, String expected) {
char[] c = NameConvertor.convertFromSignature(signature.toCharArray());
assertTrue("converting " + signature + ", expected " + expected + "," +
"but found " + String.valueOf(c),
CharOperation.equals(c,expected.toCharArray()));
}

}

+ 0
- 1
util/testsrc/org/aspectj/util/UtilTests.java View File

@@ -23,7 +23,6 @@ public class UtilTests extends TestCase {
//$JUnit-BEGIN$
suite.addTestSuite(FileUtilTest.class);
suite.addTestSuite(LangUtilTest.class);
suite.addTestSuite(NameConvertorTest.class);
//$JUnit-END$
return suite;
}

Loading…
Cancel
Save