Genericize some more classes
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@754808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9aa057fea0
commit
950def5b6f
|
@ -256,12 +256,12 @@ public class ClassUtils {
|
||||||
* @return the <code>List</code> of superclasses in order going up from this one
|
* @return the <code>List</code> of superclasses in order going up from this one
|
||||||
* <code>null</code> if null input
|
* <code>null</code> if null input
|
||||||
*/
|
*/
|
||||||
public static List getAllSuperclasses(Class cls) {
|
public static List<Class<?>> getAllSuperclasses(Class<?> cls) {
|
||||||
if (cls == null) {
|
if (cls == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List classes = new ArrayList();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
Class superclass = cls.getSuperclass();
|
Class<?> superclass = cls.getSuperclass();
|
||||||
while (superclass != null) {
|
while (superclass != null) {
|
||||||
classes.add(superclass);
|
classes.add(superclass);
|
||||||
superclass = superclass.getSuperclass();
|
superclass = superclass.getSuperclass();
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.lang;
|
package org.apache.commons.lang;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Thrown to indicate that a block of code has not been implemented.
|
* <p>Thrown to indicate that a block of code has not been implemented.
|
||||||
|
@ -44,6 +42,7 @@ import java.io.PrintWriter;
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
//@Immutable
|
||||||
public class NotImplementedException extends UnsupportedOperationException {
|
public class NotImplementedException extends UnsupportedOperationException {
|
||||||
|
|
||||||
private static final String DEFAULT_MESSAGE = "Code is not implemented";
|
private static final String DEFAULT_MESSAGE = "Code is not implemented";
|
||||||
|
@ -104,7 +103,7 @@ public class NotImplementedException extends UnsupportedOperationException {
|
||||||
* @param clazz
|
* @param clazz
|
||||||
* the <code>Class</code> that has not implemented the method
|
* the <code>Class</code> that has not implemented the method
|
||||||
*/
|
*/
|
||||||
public NotImplementedException(Class clazz) {
|
public NotImplementedException(Class<?> clazz) {
|
||||||
super(clazz == null ? DEFAULT_MESSAGE : DEFAULT_MESSAGE + " in " + clazz);
|
super(clazz == null ? DEFAULT_MESSAGE : DEFAULT_MESSAGE + " in " + clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class ExceptionUtils {
|
||||||
*/
|
*/
|
||||||
public static void addCauseMethodName(String methodName) {
|
public static void addCauseMethodName(String methodName) {
|
||||||
if (StringUtils.isNotEmpty(methodName) && !isCauseMethodName(methodName)) {
|
if (StringUtils.isNotEmpty(methodName) && !isCauseMethodName(methodName)) {
|
||||||
List list = getCauseMethodNameList();
|
List<String> list = getCauseMethodNameList();
|
||||||
if (list.add(methodName)) {
|
if (list.add(methodName)) {
|
||||||
synchronized(CAUSE_METHOD_NAMES) {
|
synchronized(CAUSE_METHOD_NAMES) {
|
||||||
CAUSE_METHOD_NAMES = toArray(list);
|
CAUSE_METHOD_NAMES = toArray(list);
|
||||||
|
@ -140,7 +140,7 @@ public class ExceptionUtils {
|
||||||
*/
|
*/
|
||||||
public static void removeCauseMethodName(String methodName) {
|
public static void removeCauseMethodName(String methodName) {
|
||||||
if (StringUtils.isNotEmpty(methodName)) {
|
if (StringUtils.isNotEmpty(methodName)) {
|
||||||
List list = getCauseMethodNameList();
|
List<String> list = getCauseMethodNameList();
|
||||||
if (list.remove(methodName)) {
|
if (list.remove(methodName)) {
|
||||||
synchronized(CAUSE_METHOD_NAMES) {
|
synchronized(CAUSE_METHOD_NAMES) {
|
||||||
CAUSE_METHOD_NAMES = toArray(list);
|
CAUSE_METHOD_NAMES = toArray(list);
|
||||||
|
@ -212,8 +212,8 @@ public class ExceptionUtils {
|
||||||
* @param list a list to transform.
|
* @param list a list to transform.
|
||||||
* @return the given list as a <code>String[]</code>.
|
* @return the given list as a <code>String[]</code>.
|
||||||
*/
|
*/
|
||||||
private static String[] toArray(List list) {
|
private static String[] toArray(List<String> list) {
|
||||||
return (String[]) list.toArray(new String[list.size()]);
|
return list.toArray(new String[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,9 +221,9 @@ public class ExceptionUtils {
|
||||||
*
|
*
|
||||||
* @return {@link #CAUSE_METHOD_NAMES} as a List.
|
* @return {@link #CAUSE_METHOD_NAMES} as a List.
|
||||||
*/
|
*/
|
||||||
private static ArrayList getCauseMethodNameList() {
|
private static ArrayList<String> getCauseMethodNameList() {
|
||||||
synchronized(CAUSE_METHOD_NAMES) {
|
synchronized(CAUSE_METHOD_NAMES) {
|
||||||
return new ArrayList(Arrays.asList(CAUSE_METHOD_NAMES));
|
return new ArrayList<String>(Arrays.asList(CAUSE_METHOD_NAMES));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ public class ExceptionUtils {
|
||||||
* <code>null</code> if none found or null throwable input
|
* <code>null</code> if none found or null throwable input
|
||||||
*/
|
*/
|
||||||
public static Throwable getRootCause(Throwable throwable) {
|
public static Throwable getRootCause(Throwable throwable) {
|
||||||
List list = getThrowableList(throwable);
|
List<Throwable> list = getThrowableList(throwable);
|
||||||
return (list.size() < 2 ? null : (Throwable)list.get(list.size() - 1));
|
return (list.size() < 2 ? null : (Throwable)list.get(list.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ public class ExceptionUtils {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class cls = throwable.getClass();
|
Class<? extends Throwable> cls = throwable.getClass();
|
||||||
synchronized(CAUSE_METHOD_NAMES) {
|
synchronized(CAUSE_METHOD_NAMES) {
|
||||||
for (int i = 0, isize = CAUSE_METHOD_NAMES.length; i < isize; i++) {
|
for (int i = 0, isize = CAUSE_METHOD_NAMES.length; i < isize; i++) {
|
||||||
try {
|
try {
|
||||||
|
@ -533,8 +533,8 @@ public class ExceptionUtils {
|
||||||
* @return the array of throwables, never null
|
* @return the array of throwables, never null
|
||||||
*/
|
*/
|
||||||
public static Throwable[] getThrowables(Throwable throwable) {
|
public static Throwable[] getThrowables(Throwable throwable) {
|
||||||
List list = getThrowableList(throwable);
|
List<Throwable> list = getThrowableList(throwable);
|
||||||
return (Throwable[]) list.toArray(new Throwable[list.size()]);
|
return list.toArray(new Throwable[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -556,8 +556,8 @@ public class ExceptionUtils {
|
||||||
* @return the list of throwables, never null
|
* @return the list of throwables, never null
|
||||||
* @since Commons Lang 2.2
|
* @since Commons Lang 2.2
|
||||||
*/
|
*/
|
||||||
public static List getThrowableList(Throwable throwable) {
|
public static List<Throwable> getThrowableList(Throwable throwable) {
|
||||||
List list = new ArrayList();
|
List<Throwable> list = new ArrayList<Throwable>();
|
||||||
while (throwable != null && list.contains(throwable) == false) {
|
while (throwable != null && list.contains(throwable) == false) {
|
||||||
list.add(throwable);
|
list.add(throwable);
|
||||||
throwable = ExceptionUtils.getCause(throwable);
|
throwable = ExceptionUtils.getCause(throwable);
|
||||||
|
@ -580,7 +580,7 @@ public class ExceptionUtils {
|
||||||
* @param clazz the class to search for, subclasses do not match, null returns -1
|
* @param clazz the class to search for, subclasses do not match, null returns -1
|
||||||
* @return the index into the throwable chain, -1 if no match or null input
|
* @return the index into the throwable chain, -1 if no match or null input
|
||||||
*/
|
*/
|
||||||
public static int indexOfThrowable(Throwable throwable, Class clazz) {
|
public static int indexOfThrowable(Throwable throwable, Class<?> clazz) {
|
||||||
return indexOf(throwable, clazz, 0, false);
|
return indexOf(throwable, clazz, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ public class ExceptionUtils {
|
||||||
* negative treated as zero, larger than chain size returns -1
|
* negative treated as zero, larger than chain size returns -1
|
||||||
* @return the index into the throwable chain, -1 if no match or null input
|
* @return the index into the throwable chain, -1 if no match or null input
|
||||||
*/
|
*/
|
||||||
public static int indexOfThrowable(Throwable throwable, Class clazz, int fromIndex) {
|
public static int indexOfThrowable(Throwable throwable, Class<?> clazz, int fromIndex) {
|
||||||
return indexOf(throwable, clazz, fromIndex, false);
|
return indexOf(throwable, clazz, fromIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ public class ExceptionUtils {
|
||||||
* @return the index into the throwable chain, -1 if no match or null input
|
* @return the index into the throwable chain, -1 if no match or null input
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static int indexOfType(Throwable throwable, Class type) {
|
public static int indexOfType(Throwable throwable, Class<?> type) {
|
||||||
return indexOf(throwable, type, 0, true);
|
return indexOf(throwable, type, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ public class ExceptionUtils {
|
||||||
* @return the index into the throwable chain, -1 if no match or null input
|
* @return the index into the throwable chain, -1 if no match or null input
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static int indexOfType(Throwable throwable, Class type, int fromIndex) {
|
public static int indexOfType(Throwable throwable, Class<?> type, int fromIndex) {
|
||||||
return indexOf(throwable, type, fromIndex, true);
|
return indexOf(throwable, type, fromIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,7 +662,7 @@ public class ExceptionUtils {
|
||||||
* using references
|
* using references
|
||||||
* @return index of the <code>type</code> within throwables nested withing the specified <code>throwable</code>
|
* @return index of the <code>type</code> within throwables nested withing the specified <code>throwable</code>
|
||||||
*/
|
*/
|
||||||
private static int indexOf(Throwable throwable, Class type, int fromIndex, boolean subclass) {
|
private static int indexOf(Throwable throwable, Class<?> type, int fromIndex, boolean subclass) {
|
||||||
if (throwable == null || type == null) {
|
if (throwable == null || type == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -798,10 +798,10 @@ public class ExceptionUtils {
|
||||||
}
|
}
|
||||||
Throwable throwables[] = getThrowables(throwable);
|
Throwable throwables[] = getThrowables(throwable);
|
||||||
int count = throwables.length;
|
int count = throwables.length;
|
||||||
ArrayList frames = new ArrayList();
|
ArrayList<String> frames = new ArrayList<String>();
|
||||||
List nextTrace = getStackFrameList(throwables[count - 1]);
|
List<String> nextTrace = getStackFrameList(throwables[count - 1]);
|
||||||
for (int i = count; --i >= 0;) {
|
for (int i = count; --i >= 0;) {
|
||||||
List trace = nextTrace;
|
List<String> trace = nextTrace;
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
nextTrace = getStackFrameList(throwables[i - 1]);
|
nextTrace = getStackFrameList(throwables[i - 1]);
|
||||||
removeCommonFrames(trace, nextTrace);
|
removeCommonFrames(trace, nextTrace);
|
||||||
|
@ -815,7 +815,7 @@ public class ExceptionUtils {
|
||||||
frames.add(trace.get(j));
|
frames.add(trace.get(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (String[]) frames.toArray(new String[0]);
|
return frames.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -826,7 +826,7 @@ public class ExceptionUtils {
|
||||||
* @throws IllegalArgumentException if either argument is null
|
* @throws IllegalArgumentException if either argument is null
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public static void removeCommonFrames(List causeFrames, List wrapperFrames) {
|
public static void removeCommonFrames(List<String> causeFrames, List<String> wrapperFrames) {
|
||||||
if (causeFrames == null || wrapperFrames == null) {
|
if (causeFrames == null || wrapperFrames == null) {
|
||||||
throw new IllegalArgumentException("The List must not be null");
|
throw new IllegalArgumentException("The List must not be null");
|
||||||
}
|
}
|
||||||
|
@ -835,8 +835,8 @@ public class ExceptionUtils {
|
||||||
while (causeFrameIndex >= 0 && wrapperFrameIndex >= 0) {
|
while (causeFrameIndex >= 0 && wrapperFrameIndex >= 0) {
|
||||||
// Remove the frame from the cause trace if it is the same
|
// Remove the frame from the cause trace if it is the same
|
||||||
// as in the wrapper trace
|
// as in the wrapper trace
|
||||||
String causeFrame = (String) causeFrames.get(causeFrameIndex);
|
String causeFrame = causeFrames.get(causeFrameIndex);
|
||||||
String wrapperFrame = (String) wrapperFrames.get(wrapperFrameIndex);
|
String wrapperFrame = wrapperFrames.get(wrapperFrameIndex);
|
||||||
if (causeFrame.equals(wrapperFrame)) {
|
if (causeFrame.equals(wrapperFrame)) {
|
||||||
causeFrames.remove(causeFrameIndex);
|
causeFrames.remove(causeFrameIndex);
|
||||||
}
|
}
|
||||||
|
@ -921,7 +921,7 @@ public class ExceptionUtils {
|
||||||
static String[] getStackFrames(String stackTrace) {
|
static String[] getStackFrames(String stackTrace) {
|
||||||
String linebreak = SystemUtils.LINE_SEPARATOR;
|
String linebreak = SystemUtils.LINE_SEPARATOR;
|
||||||
StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
|
StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
|
||||||
List list = new ArrayList();
|
List<String> list = new ArrayList<String>();
|
||||||
while (frames.hasMoreTokens()) {
|
while (frames.hasMoreTokens()) {
|
||||||
list.add(frames.nextToken());
|
list.add(frames.nextToken());
|
||||||
}
|
}
|
||||||
|
@ -940,11 +940,11 @@ public class ExceptionUtils {
|
||||||
* @param t is any throwable
|
* @param t is any throwable
|
||||||
* @return List of stack frames
|
* @return List of stack frames
|
||||||
*/
|
*/
|
||||||
static List getStackFrameList(Throwable t) {
|
static List<String> getStackFrameList(Throwable t) {
|
||||||
String stackTrace = getStackTrace(t);
|
String stackTrace = getStackTrace(t);
|
||||||
String linebreak = SystemUtils.LINE_SEPARATOR;
|
String linebreak = SystemUtils.LINE_SEPARATOR;
|
||||||
StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
|
StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
|
||||||
List list = new ArrayList();
|
List<String> list = new ArrayList<String>();
|
||||||
boolean traceStarted = false;
|
boolean traceStarted = false;
|
||||||
while (frames.hasMoreTokens()) {
|
while (frames.hasMoreTokens()) {
|
||||||
String token = frames.nextToken();
|
String token = frames.nextToken();
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
private static final char QUOTE = '\'';
|
private static final char QUOTE = '\'';
|
||||||
|
|
||||||
private String toPattern;
|
private String toPattern;
|
||||||
private Map registry;
|
private final Map<String, FormatFactory> registry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ExtendedMessageFormat for the default locale.
|
* Create a new ExtendedMessageFormat for the default locale.
|
||||||
|
@ -108,7 +108,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
* @param registry Registry of format factories: Map<String, FormatFactory>
|
* @param registry Registry of format factories: Map<String, FormatFactory>
|
||||||
* @throws IllegalArgumentException in case of a bad pattern.
|
* @throws IllegalArgumentException in case of a bad pattern.
|
||||||
*/
|
*/
|
||||||
public ExtendedMessageFormat(String pattern, Map registry) {
|
public ExtendedMessageFormat(String pattern, Map<String, FormatFactory> registry) {
|
||||||
this(pattern, Locale.getDefault(), registry);
|
this(pattern, Locale.getDefault(), registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
* @param registry Registry of format factories: Map<String, FormatFactory>
|
* @param registry Registry of format factories: Map<String, FormatFactory>
|
||||||
* @throws IllegalArgumentException in case of a bad pattern.
|
* @throws IllegalArgumentException in case of a bad pattern.
|
||||||
*/
|
*/
|
||||||
public ExtendedMessageFormat(String pattern, Locale locale, Map registry) {
|
public ExtendedMessageFormat(String pattern, Locale locale, Map<String, FormatFactory> registry) {
|
||||||
super(DUMMY_PATTERN);
|
super(DUMMY_PATTERN);
|
||||||
setLocale(locale);
|
setLocale(locale);
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
|
@ -147,8 +147,8 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
toPattern = super.toPattern();
|
toPattern = super.toPattern();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList foundFormats = new ArrayList();
|
ArrayList<Format> foundFormats = new ArrayList<Format>();
|
||||||
ArrayList foundDescriptions = new ArrayList();
|
ArrayList<String> foundDescriptions = new ArrayList<String>();
|
||||||
StringBuffer stripCustom = new StringBuffer(pattern.length());
|
StringBuffer stripCustom = new StringBuffer(pattern.length());
|
||||||
|
|
||||||
ParsePosition pos = new ParsePosition(0);
|
ParsePosition pos = new ParsePosition(0);
|
||||||
|
@ -197,8 +197,8 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
// only loop over what we know we have, as MessageFormat on Java 1.3
|
// only loop over what we know we have, as MessageFormat on Java 1.3
|
||||||
// seems to provide an extra format element:
|
// seems to provide an extra format element:
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Iterator it = foundFormats.iterator(); it.hasNext(); i++) {
|
for (Iterator<Format> it = foundFormats.iterator(); it.hasNext(); i++) {
|
||||||
Format f = (Format) it.next();
|
Format f = it.next();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
origFormats[i] = f;
|
origFormats[i] = f;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
name = desc.substring(0, i).trim();
|
name = desc.substring(0, i).trim();
|
||||||
args = desc.substring(i + 1).trim();
|
args = desc.substring(i + 1).trim();
|
||||||
}
|
}
|
||||||
FormatFactory factory = (FormatFactory) registry.get(name);
|
FormatFactory factory = registry.get(name);
|
||||||
if (factory != null) {
|
if (factory != null) {
|
||||||
return factory.getFormat(name, args, getLocale());
|
return factory.getFormat(name, args, getLocale());
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
* @param customPatterns The custom patterns to re-insert, if any
|
* @param customPatterns The custom patterns to re-insert, if any
|
||||||
* @return full pattern
|
* @return full pattern
|
||||||
*/
|
*/
|
||||||
private String insertFormats(String pattern, ArrayList customPatterns) {
|
private String insertFormats(String pattern, ArrayList<String> customPatterns) {
|
||||||
if (!containsElements(customPatterns)) {
|
if (!containsElements(customPatterns)) {
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
fe++;
|
fe++;
|
||||||
sb.append(START_FE).append(
|
sb.append(START_FE).append(
|
||||||
readArgumentIndex(pattern, next(pos)));
|
readArgumentIndex(pattern, next(pos)));
|
||||||
String customPattern = (String) customPatterns.get(fe);
|
String customPattern = customPatterns.get(fe);
|
||||||
if (customPattern != null) {
|
if (customPattern != null) {
|
||||||
sb.append(START_FMT).append(customPattern);
|
sb.append(START_FMT).append(customPattern);
|
||||||
}
|
}
|
||||||
|
@ -467,11 +467,11 @@ public class ExtendedMessageFormat extends MessageFormat {
|
||||||
* @param coll to check
|
* @param coll to check
|
||||||
* @return <code>true</code> if some Object was found, <code>false</code> otherwise.
|
* @return <code>true</code> if some Object was found, <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
private boolean containsElements(Collection coll) {
|
private boolean containsElements(Collection<?> coll) {
|
||||||
if (coll == null || coll.size() == 0) {
|
if (coll == null || coll.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Iterator iter = coll.iterator(); iter.hasNext();) {
|
for (Iterator<?> iter = coll.iterator(); iter.hasNext();) {
|
||||||
if (iter.next() != null) {
|
if (iter.next() != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ import java.util.NoSuchElementException;
|
||||||
* @since 2.2
|
* @since 2.2
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class StrTokenizer implements ListIterator, Cloneable {
|
public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
|
|
||||||
private static final StrTokenizer CSV_TOKENIZER_PROTOTYPE;
|
private static final StrTokenizer CSV_TOKENIZER_PROTOTYPE;
|
||||||
private static final StrTokenizer TSV_TOKENIZER_PROTOTYPE;
|
private static final StrTokenizer TSV_TOKENIZER_PROTOTYPE;
|
||||||
|
@ -529,7 +529,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*
|
*
|
||||||
* @return the next String token
|
* @return the next String token
|
||||||
*/
|
*/
|
||||||
public Object next() {
|
public String next() {
|
||||||
if (hasNext()) {
|
if (hasNext()) {
|
||||||
return tokens[tokenPos++];
|
return tokens[tokenPos++];
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*
|
*
|
||||||
* @return the previous token
|
* @return the previous token
|
||||||
*/
|
*/
|
||||||
public Object previous() {
|
public String previous() {
|
||||||
if (hasPrevious()) {
|
if (hasPrevious()) {
|
||||||
return tokens[--tokenPos];
|
return tokens[--tokenPos];
|
||||||
}
|
}
|
||||||
|
@ -590,7 +590,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @param obj this parameter ignored.
|
* @param obj this parameter ignored.
|
||||||
* @throws UnsupportedOperationException always
|
* @throws UnsupportedOperationException always
|
||||||
*/
|
*/
|
||||||
public void set(Object obj) {
|
public void set(String obj) {
|
||||||
throw new UnsupportedOperationException("set() is unsupported");
|
throw new UnsupportedOperationException("set() is unsupported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @param obj this parameter ignored.
|
* @param obj this parameter ignored.
|
||||||
* @throws UnsupportedOperationException always
|
* @throws UnsupportedOperationException always
|
||||||
*/
|
*/
|
||||||
public void add(Object obj) {
|
public void add(String obj) {
|
||||||
throw new UnsupportedOperationException("add() is unsupported");
|
throw new UnsupportedOperationException("add() is unsupported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,7 +261,7 @@ public class DateUtils {
|
||||||
* @param parsePatterns the date format patterns to use, see SimpleDateFormat, not null
|
* @param parsePatterns the date format patterns to use, see SimpleDateFormat, not null
|
||||||
* @return the parsed date
|
* @return the parsed date
|
||||||
* @throws IllegalArgumentException if the date string or pattern array is null
|
* @throws IllegalArgumentException if the date string or pattern array is null
|
||||||
* @throws ParseException if none of the date patterns were suitable
|
* @throws ParseException if none of the date patterns were suitable (or there were none)
|
||||||
*/
|
*/
|
||||||
public static Date parseDate(String str, String[] parsePatterns) throws ParseException {
|
public static Date parseDate(String str, String[] parsePatterns) throws ParseException {
|
||||||
if (str == null || parsePatterns == null) {
|
if (str == null || parsePatterns == null) {
|
||||||
|
@ -925,7 +925,7 @@ public class DateUtils {
|
||||||
* @throws IllegalArgumentException if the date is <code>null</code>
|
* @throws IllegalArgumentException if the date is <code>null</code>
|
||||||
* @throws IllegalArgumentException if the rangeStyle is invalid
|
* @throws IllegalArgumentException if the rangeStyle is invalid
|
||||||
*/
|
*/
|
||||||
public static Iterator iterator(Date focus, int rangeStyle) {
|
public static Iterator<Calendar> iterator(Date focus, int rangeStyle) {
|
||||||
if (focus == null) {
|
if (focus == null) {
|
||||||
throw new IllegalArgumentException("The date must not be null");
|
throw new IllegalArgumentException("The date must not be null");
|
||||||
}
|
}
|
||||||
|
@ -958,7 +958,7 @@ public class DateUtils {
|
||||||
* @throws IllegalArgumentException if the date is <code>null</code>
|
* @throws IllegalArgumentException if the date is <code>null</code>
|
||||||
* @throws IllegalArgumentException if the rangeStyle is invalid
|
* @throws IllegalArgumentException if the rangeStyle is invalid
|
||||||
*/
|
*/
|
||||||
public static Iterator iterator(Calendar focus, int rangeStyle) {
|
public static Iterator<Calendar> iterator(Calendar focus, int rangeStyle) {
|
||||||
if (focus == null) {
|
if (focus == null) {
|
||||||
throw new IllegalArgumentException("The date must not be null");
|
throw new IllegalArgumentException("The date must not be null");
|
||||||
}
|
}
|
||||||
|
@ -1049,7 +1049,7 @@ public class DateUtils {
|
||||||
* @throws ClassCastException if the object type is
|
* @throws ClassCastException if the object type is
|
||||||
* not a <code>Date</code> or <code>Calendar</code>
|
* not a <code>Date</code> or <code>Calendar</code>
|
||||||
*/
|
*/
|
||||||
public static Iterator iterator(Object focus, int rangeStyle) {
|
public static Iterator<?> iterator(Object focus, int rangeStyle) {
|
||||||
if (focus == null) {
|
if (focus == null) {
|
||||||
throw new IllegalArgumentException("The date must not be null");
|
throw new IllegalArgumentException("The date must not be null");
|
||||||
}
|
}
|
||||||
|
@ -1565,7 +1565,7 @@ public class DateUtils {
|
||||||
/**
|
/**
|
||||||
* <p>Date iterator.</p>
|
* <p>Date iterator.</p>
|
||||||
*/
|
*/
|
||||||
static class DateIterator implements Iterator {
|
static class DateIterator implements Iterator<Calendar> {
|
||||||
private final Calendar endFinal;
|
private final Calendar endFinal;
|
||||||
private final Calendar spot;
|
private final Calendar spot;
|
||||||
|
|
||||||
|
@ -1596,12 +1596,12 @@ public class DateUtils {
|
||||||
*
|
*
|
||||||
* @return Object calendar for the next date
|
* @return Object calendar for the next date
|
||||||
*/
|
*/
|
||||||
public Object next() {
|
public Calendar next() {
|
||||||
if (spot.equals(endFinal)) {
|
if (spot.equals(endFinal)) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
spot.add(Calendar.DATE, 1);
|
spot.add(Calendar.DATE, 1);
|
||||||
return spot.clone();
|
return (Calendar) spot.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -485,11 +485,11 @@ public class DurationFormatUtils {
|
||||||
* Parses a classic date format string into Tokens
|
* Parses a classic date format string into Tokens
|
||||||
*
|
*
|
||||||
* @param format to parse
|
* @param format to parse
|
||||||
* @return Token[] of tokens
|
* @return array of Token[]
|
||||||
*/
|
*/
|
||||||
static Token[] lexx(String format) {
|
static Token[] lexx(String format) {
|
||||||
char[] array = format.toCharArray();
|
char[] array = format.toCharArray();
|
||||||
ArrayList list = new ArrayList(array.length);
|
ArrayList<Token> list = new ArrayList<Token>(array.length);
|
||||||
|
|
||||||
boolean inLiteral = false;
|
boolean inLiteral = false;
|
||||||
StringBuffer buffer = null;
|
StringBuffer buffer = null;
|
||||||
|
@ -498,7 +498,7 @@ public class DurationFormatUtils {
|
||||||
for(int i=0; i<sz; i++) {
|
for(int i=0; i<sz; i++) {
|
||||||
char ch = array[i];
|
char ch = array[i];
|
||||||
if(inLiteral && ch != '\'') {
|
if(inLiteral && ch != '\'') {
|
||||||
buffer.append(ch);
|
buffer.append(ch); // buffer can't be null if inLiteral is true
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object value = null;
|
Object value = null;
|
||||||
|
@ -540,7 +540,7 @@ public class DurationFormatUtils {
|
||||||
buffer = null;
|
buffer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (Token[]) list.toArray( new Token[list.size()] );
|
return list.toArray( new Token[list.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue