GenericSignature.ClassSignature classSig = new GenericSignature.ClassSignature();
// FormalTypeParameters-opt
if (maybeEat("<")) {
- List formalTypeParametersList = new ArrayList();
+ List<FormalTypeParameter> formalTypeParametersList = new ArrayList<FormalTypeParameter>();
do {
formalTypeParametersList.add(parseFormalTypeParameter());
} while (!maybeEat(">"));
formalTypeParametersList.toArray(classSig.formalTypeParameters);
}
classSig.superclassSignature = parseClassTypeSignature();
- List superIntSigs = new ArrayList();
+ List<ClassTypeSignature> superIntSigs = new ArrayList<ClassTypeSignature>();
while (tokenIndex < tokenStream.length) {
superIntSigs.add(parseClassTypeSignature());
}
TypeSignature returnType = null;
// FormalTypeParameters-opt
if (maybeEat("<")) {
- List formalTypeParametersList = new ArrayList();
+ List<FormalTypeParameter> formalTypeParametersList = new ArrayList<FormalTypeParameter>();
do {
formalTypeParametersList.add(parseFormalTypeParameter());
} while (!maybeEat(">"));
}
// Parameters
eat("(");
- List paramList = new ArrayList();
+ List<TypeSignature> paramList = new ArrayList<TypeSignature>();
while (!maybeEat(")")) {
FieldTypeSignature fsig = parseFieldTypeSignature(true);
if (fsig != null) {
if (returnType == null)
returnType = new GenericSignature.BaseTypeSignature(eatIdentifier());
// throws
- List throwsList = new ArrayList();
+ List<FieldTypeSignature> throwsList = new ArrayList<FieldTypeSignature>();
while (maybeEat("^")) {
FieldTypeSignature fsig = parseFieldTypeSignature(false);
throwsList.add(fsig);
ftp.classBound = new ClassTypeSignature("Ljava/lang/Object;", "Ljava/lang/Object");
}
// Optional InterfaceBounds
- List optionalBounds = new ArrayList();
+ List<FieldTypeSignature> optionalBounds = new ArrayList<FieldTypeSignature>();
while (maybeEat(":")) {
optionalBounds.add(parseFieldTypeSignature(false));
}
if (maybeEat(".")) {
// outer type completed
outerType = new SimpleClassTypeSignature(identifier);
- List nestedTypeList = new ArrayList();
+ List<SimpleClassTypeSignature> nestedTypeList = new ArrayList<SimpleClassTypeSignature>();
do {
ret.append(".");
SimpleClassTypeSignature sig = parseSimpleClassTypeSignature();
ret.append(">");
outerType = new SimpleClassTypeSignature(identifier, tArgs);
// now parse possible nesteds...
- List nestedTypeList = new ArrayList();
+ List<SimpleClassTypeSignature> nestedTypeList = new ArrayList<SimpleClassTypeSignature>();
while (maybeEat(".")) {
ret.append(".");
SimpleClassTypeSignature sig = parseSimpleClassTypeSignature();
private TypeArgument[] maybeParseTypeArguments() {
if (maybeEat("<")) {
- List typeArgs = new ArrayList();
+ List<TypeArgument> typeArgs = new ArrayList<TypeArgument>();
do {
TypeArgument arg = parseTypeArgument();
typeArgs.add(arg);
public String[] tokenize(String signatureString) {
char[] chars = signatureString.toCharArray();
int index = 0;
- List tokens = new ArrayList();
+ List<String> tokens = new ArrayList<String>();
StringBuffer identifier = new StringBuffer();
boolean inParens = false;
boolean inArray = false;
* @param c the Class to check - use null to ignore type check
* @throws IllegalArgumentException "null {name}" if o is null
*/
- public static final void throwIaxIfNotAssignable(final Object ra[], final Class c, final String name) {
+ public static final void throwIaxIfNotAssignable(final Object ra[], final Class<?> c, final String name) {
throwIaxIfNull(ra, name);
String label = (null == name ? "input" : name);
for (int i = 0; i < ra.length; i++) {
String m = " null " + label + "[" + i + "]";
throw new IllegalArgumentException(m);
} else if (null != c) {
- Class actualClass = ra[i].getClass();
+ Class<?> actualClass = ra[i].getClass();
if (!c.isAssignableFrom(actualClass)) {
String message = label + " not assignable to " + c.getName();
throw new IllegalArgumentException(message);
*
* @throws IllegalArgumentException "null {name}" if o is null
*/
- public static final void throwIaxIfNotAssignable(final Object o, final Class c, final String name) {
+ public static final void throwIaxIfNotAssignable(final Object o, final Class<?> c, final String name) {
throwIaxIfNull(o, name);
if (null != c) {
- Class actualClass = o.getClass();
+ Class<?> actualClass = o.getClass();
if (!c.isAssignableFrom(actualClass)) {
String message = name + " not assignable to " + c.getName();
throw new IllegalArgumentException(message);
}
/** @return ((null == collection) || (0 == collection.size())) */
- public static boolean isEmpty(Collection collection) {
+ public static boolean isEmpty(Collection<?> collection) {
return ((null == collection) || (0 == collection.size()));
}
* @param input <code>String</code> to split.
* @return List of String of elements.
*/
- public static List commaSplit(String input) {
+ public static List<String> commaSplit(String input) {
return anySplit(input, ",");
}
return new String[0];
}
StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator);
- ArrayList result = new ArrayList(st.countTokens());
+ ArrayList<String> result = new ArrayList<String>(st.countTokens());
while (st.hasMoreTokens()) {
String entry = st.nextToken();
if (!LangUtil.isEmpty(entry)) {
* @param delim <code>String</code> separators for input.
* @return List of String of elements.
*/
- public static List anySplit(String input, String delim) {
+ public static List<String> anySplit(String input, String delim) {
if (null == input) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- ArrayList result = new ArrayList();
+ ArrayList<String> result = new ArrayList<String>();
if (LangUtil.isEmpty(delim) || (-1 == input.indexOf(delim))) {
result.add(input.trim());
*
* @param text <code>String</code> to split.
*/
- public static List strings(String text) {
+ public static List<String> strings(String text) {
if (LangUtil.isEmpty(text)) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- List strings = new ArrayList();
+ List<String> strings = new ArrayList<String>();
StringTokenizer tok = new StringTokenizer(text);
while (tok.hasMoreTokens()) {
strings.add(tok.nextToken());
}
/** @return a non-null unmodifiable List */
- public static List safeList(List list) {
- return (null == list ? Collections.EMPTY_LIST : Collections.unmodifiableList(list));
+ public static <T> List<T> safeList(List<T> list) {
+ return (null == list ? Collections.<T>emptyList() : Collections.unmodifiableList(list));
}
// /**
* @throws IllegalArgumentException if either is null
*/
public static Object[] safeCopy(Object[] source, Object[] sink) {
- final Class sinkType = (null == sink ? Object.class : sink.getClass().getComponentType());
+ final Class<?> sinkType = (null == sink ? Object.class : sink.getClass().getComponentType());
final int sourceLength = (null == source ? 0 : source.length);
final int sinkLength = (null == sink ? 0 : sink.length);
final int resultSize;
- ArrayList result = null;
+ ArrayList<Object> result = null;
if (0 == sourceLength) {
resultSize = 0;
} else {
- result = new ArrayList(sourceLength);
+ result = new ArrayList<Object>(sourceLength);
for (int i = 0; i < sourceLength; i++) {
if ((null != source[i]) && (sinkType.isAssignableFrom(source[i].getClass()))) {
result.add(source[i]);
/**
* @return a String with the unqualified class name of the class (or "null")
*/
- public static String unqualifiedClassName(Class c) {
+ public static String unqualifiedClassName(Class<?> c) {
if (null == c) {
return "null";
}
if (null == checker || (null == stack) || (0 == stack.length())) {
return;
}
- final LinkedList lines = new LinkedList();
+ final LinkedList<String> lines = new LinkedList<String>();
StringTokenizer st = new StringTokenizer(stack.toString(), "\n\r");
while (st.hasMoreTokens() && (0 < --maxLines)) {
lines.add(st.nextToken());
* @param array the Object[] to convert (may be null)
* @return the List corresponding to array (never null)
*/
- public static List arrayAsList(Object[] array) {
+ public static List<Object> arrayAsList(Object[] array) {
if ((null == array) || (1 > array.length)) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- ArrayList list = new ArrayList();
+ ArrayList<Object> list = new ArrayList<Object>();
list.addAll(Arrays.asList(array));
return list;
}
*/
public static ProcessController makeProcess(ProcessController controller, String classpath, String mainClass, String[] args) {
File java = LangUtil.getJavaExecutable();
- ArrayList cmd = new ArrayList();
+ ArrayList<String> cmd = new ArrayList<String>();
cmd.add(java.getAbsolutePath());
cmd.add("-classpath");
cmd.add(classpath);
LangUtil.throwIaxIfNull(java, "java");
LangUtil.throwIaxIfNull(mainClass, "mainClass");
LangUtil.throwIaxIfNull(args, "args");
- ArrayList cmd = new ArrayList();
+ ArrayList<String> cmd = new ArrayList<String>();
cmd.add(java.getAbsolutePath());
cmd.add("-classpath");
cmd.add(classpath);
public class UtilClassLoader extends URLClassLoader {
/** seek classes in dirs first */
- List /*File*/ dirs;
+ List<File> dirs;
/** save URL[] only for toString */
private URL[] urlsForDebugString;
super(urls);
LangUtil.throwIaxIfNotAssignable(dirs, File.class, "dirs");
this.urlsForDebugString = urls;
- ArrayList dcopy = new ArrayList();
+ ArrayList<File> dcopy = new ArrayList<File>();
if (!LangUtil.isEmpty(dirs)) {
dcopy.addAll(Arrays.asList(dirs));
return ClassLoader.getSystemResourceAsStream(name);
}
- public synchronized Class loadClass(String name, boolean resolve)
+ public synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException {
// search the cache, our dirs (if maybe test),
// the system, the superclass (URL[]),
// and our dirs again (if not maybe test)
ClassNotFoundException thrown = null;
- Class result = findLoadedClass(name);
+ Class<?> result = findLoadedClass(name);
if (null != result) {
resolve = false;
} else {
/** @return null if class not found or byte[] of class otherwise */
private byte[] readClass(String className) throws ClassNotFoundException {
final String fileName = className.replace('.', '/')+".class";
- for (Iterator iter = dirs.iterator(); iter.hasNext();) {
- File file = new File((File) iter.next(), fileName);
+ for (Iterator<File> iter = dirs.iterator(); iter.hasNext();) {
+ File file = new File(iter.next(), fileName);
if (file.canRead()) {
return getClassData(file);
}