Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing generics or deprecated code. Also add the `-Werror` compiler option to ensure that any future warnings will fail the build. Issue: SPR-11064
This commit is contained in:
@@ -38,10 +38,10 @@ public class MemorySafeUndeclaredThrowableStrategy extends DefaultGeneratorStrat
|
||||
};
|
||||
|
||||
|
||||
private Class wrapper;
|
||||
private Class<?> wrapper;
|
||||
|
||||
|
||||
public MemorySafeUndeclaredThrowableStrategy(Class wrapper) {
|
||||
public MemorySafeUndeclaredThrowableStrategy(Class<?> wrapper) {
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class BridgeMethodResolver {
|
||||
*/
|
||||
private static Method findGenericDeclaration(Method bridgeMethod) {
|
||||
// Search parent types for method that has same signature as bridge.
|
||||
Class superclass = bridgeMethod.getDeclaringClass().getSuperclass();
|
||||
Class<?> superclass = bridgeMethod.getDeclaringClass().getSuperclass();
|
||||
while (superclass != null && !Object.class.equals(superclass)) {
|
||||
Method method = searchForMatch(superclass, bridgeMethod);
|
||||
if (method != null && !method.isBridge()) {
|
||||
@@ -150,8 +150,8 @@ public abstract class BridgeMethodResolver {
|
||||
}
|
||||
|
||||
// Search interfaces.
|
||||
Class[] interfaces = ClassUtils.getAllInterfacesForClass(bridgeMethod.getDeclaringClass());
|
||||
for (Class ifc : interfaces) {
|
||||
Class<?>[] interfaces = ClassUtils.getAllInterfacesForClass(bridgeMethod.getDeclaringClass());
|
||||
for (Class<?> ifc : interfaces) {
|
||||
Method method = searchForMatch(ifc, bridgeMethod);
|
||||
if (method != null && !method.isBridge()) {
|
||||
return method;
|
||||
@@ -170,13 +170,13 @@ public abstract class BridgeMethodResolver {
|
||||
private static boolean isResolvedTypeMatch(
|
||||
Method genericMethod, Method candidateMethod, Class<?> declaringClass) {
|
||||
Type[] genericParameters = genericMethod.getGenericParameterTypes();
|
||||
Class[] candidateParameters = candidateMethod.getParameterTypes();
|
||||
Class<?>[] candidateParameters = candidateMethod.getParameterTypes();
|
||||
if (genericParameters.length != candidateParameters.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < candidateParameters.length; i++) {
|
||||
ResolvableType genericParameter = ResolvableType.forMethodParameter(genericMethod, i, declaringClass);
|
||||
Class candidateParameter = candidateParameters[i];
|
||||
Class<?> candidateParameter = candidateParameters[i];
|
||||
if (candidateParameter.isArray()) {
|
||||
// An array type: compare the component type.
|
||||
if (!candidateParameter.getComponentType().equals(genericParameter.getComponentType().resolve(Object.class))) {
|
||||
@@ -196,7 +196,7 @@ public abstract class BridgeMethodResolver {
|
||||
* that of the supplied {@link Method}, then this matching {@link Method} is returned,
|
||||
* otherwise {@code null} is returned.
|
||||
*/
|
||||
private static Method searchForMatch(Class type, Method bridgeMethod) {
|
||||
private static Method searchForMatch(Class<?> type, Method bridgeMethod) {
|
||||
return ReflectionUtils.findMethod(type, bridgeMethod.getName(), bridgeMethod.getParameterTypes());
|
||||
}
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
public abstract class CollectionFactory {
|
||||
|
||||
private static Class navigableSetClass = null;
|
||||
private static Class<?> navigableSetClass = null;
|
||||
|
||||
private static Class navigableMapClass = null;
|
||||
private static Class<?> navigableMapClass = null;
|
||||
|
||||
private static final Set<Class> approximableCollectionTypes = new HashSet<Class>(10);
|
||||
private static final Set<Class<?>> approximableCollectionTypes = new HashSet<Class<?>>(10);
|
||||
|
||||
private static final Set<Class> approximableMapTypes = new HashSet<Class>(6);
|
||||
private static final Set<Class<?>> approximableMapTypes = new HashSet<Class<?>>(6);
|
||||
|
||||
|
||||
static {
|
||||
@@ -105,18 +105,18 @@ public abstract class CollectionFactory {
|
||||
* @see java.util.LinkedHashSet
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection createApproximateCollection(Object collection, int initialCapacity) {
|
||||
public static <E> Collection<E> createApproximateCollection(Object collection, int initialCapacity) {
|
||||
if (collection instanceof LinkedList) {
|
||||
return new LinkedList();
|
||||
return new LinkedList<E>();
|
||||
}
|
||||
else if (collection instanceof List) {
|
||||
return new ArrayList(initialCapacity);
|
||||
return new ArrayList<E>(initialCapacity);
|
||||
}
|
||||
else if (collection instanceof SortedSet) {
|
||||
return new TreeSet(((SortedSet) collection).comparator());
|
||||
return new TreeSet<E>(((SortedSet<E>) collection).comparator());
|
||||
}
|
||||
else {
|
||||
return new LinkedHashSet(initialCapacity);
|
||||
return new LinkedHashSet<E>(initialCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,16 +131,17 @@ public abstract class CollectionFactory {
|
||||
* @see java.util.TreeSet
|
||||
* @see java.util.LinkedHashSet
|
||||
*/
|
||||
public static Collection createCollection(Class<?> collectionType, int initialCapacity) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> Collection<E> createCollection(Class<?> collectionType, int initialCapacity) {
|
||||
if (collectionType.isInterface()) {
|
||||
if (List.class.equals(collectionType)) {
|
||||
return new ArrayList(initialCapacity);
|
||||
return new ArrayList<E>(initialCapacity);
|
||||
}
|
||||
else if (SortedSet.class.equals(collectionType) || collectionType.equals(navigableSetClass)) {
|
||||
return new TreeSet();
|
||||
return new TreeSet<E>();
|
||||
}
|
||||
else if (Set.class.equals(collectionType) || Collection.class.equals(collectionType)) {
|
||||
return new LinkedHashSet(initialCapacity);
|
||||
return new LinkedHashSet<E>(initialCapacity);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unsupported Collection interface: " + collectionType.getName());
|
||||
@@ -151,7 +152,7 @@ public abstract class CollectionFactory {
|
||||
throw new IllegalArgumentException("Unsupported Collection type: " + collectionType.getName());
|
||||
}
|
||||
try {
|
||||
return (Collection) collectionType.newInstance();
|
||||
return (Collection<E>) collectionType.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalArgumentException("Could not instantiate Collection type: " +
|
||||
@@ -181,12 +182,12 @@ public abstract class CollectionFactory {
|
||||
* @see java.util.LinkedHashMap
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map createApproximateMap(Object map, int initialCapacity) {
|
||||
public static <K, V> Map<K, V> createApproximateMap(Object map, int initialCapacity) {
|
||||
if (map instanceof SortedMap) {
|
||||
return new TreeMap(((SortedMap) map).comparator());
|
||||
return new TreeMap<K, V>(((SortedMap<K, V>) map).comparator());
|
||||
}
|
||||
else {
|
||||
return new LinkedHashMap(initialCapacity);
|
||||
return new LinkedHashMap<K, V>(initialCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,13 +200,14 @@ public abstract class CollectionFactory {
|
||||
* @see java.util.TreeMap
|
||||
* @see java.util.LinkedHashMap
|
||||
*/
|
||||
public static Map createMap(Class<?> mapType, int initialCapacity) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <K, V> Map<K, V> createMap(Class<?> mapType, int initialCapacity) {
|
||||
if (mapType.isInterface()) {
|
||||
if (Map.class.equals(mapType)) {
|
||||
return new LinkedHashMap(initialCapacity);
|
||||
return new LinkedHashMap<K, V>(initialCapacity);
|
||||
}
|
||||
else if (SortedMap.class.equals(mapType) || mapType.equals(navigableMapClass)) {
|
||||
return new TreeMap();
|
||||
return new TreeMap<K, V>();
|
||||
}
|
||||
else if (MultiValueMap.class.equals(mapType)) {
|
||||
return new LinkedMultiValueMap();
|
||||
@@ -219,7 +221,7 @@ public abstract class CollectionFactory {
|
||||
throw new IllegalArgumentException("Unsupported Map type: " + mapType.getName());
|
||||
}
|
||||
try {
|
||||
return (Map) mapType.newInstance();
|
||||
return (Map<K, V>) mapType.newInstance();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalArgumentException("Could not instantiate Map type: " +
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
|
||||
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
if (this.classLoader != null) {
|
||||
// Use the specified ClassLoader to resolve local classes.
|
||||
@@ -85,13 +85,13 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
|
||||
protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException {
|
||||
if (!this.acceptProxyClasses) {
|
||||
throw new NotSerializableException("Not allowed to accept serialized proxy classes");
|
||||
}
|
||||
if (this.classLoader != null) {
|
||||
// Use the specified ClassLoader to resolve local proxy classes.
|
||||
Class[] resolvedInterfaces = new Class[interfaces.length];
|
||||
Class<?>[] resolvedInterfaces = new Class<?>[interfaces.length];
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
try {
|
||||
resolvedInterfaces[i] = ClassUtils.forName(interfaces[i], this.classLoader);
|
||||
@@ -113,7 +113,7 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
||||
return super.resolveProxyClass(interfaces);
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
Class[] resolvedInterfaces = new Class[interfaces.length];
|
||||
Class<?>[] resolvedInterfaces = new Class<?>[interfaces.length];
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
resolvedInterfaces[i] = resolveFallbackIfPossible(interfaces[i], ex);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class ConfigurableObjectInputStream extends ObjectInputStream {
|
||||
* @param ex the original exception thrown when attempting to load the class
|
||||
* @return the newly resolved class (never {@code null})
|
||||
*/
|
||||
protected Class resolveFallbackIfPossible(String className, ClassNotFoundException ex)
|
||||
protected Class<?> resolveFallbackIfPossible(String className, ClassNotFoundException ex)
|
||||
throws IOException, ClassNotFoundException{
|
||||
|
||||
throw ex;
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface ControlFlow {
|
||||
* according to the current stack trace.
|
||||
* @param clazz the clazz to look for
|
||||
*/
|
||||
boolean under(Class clazz);
|
||||
boolean under(Class<?> clazz);
|
||||
|
||||
/**
|
||||
* Detect whether we're under the given class and method,
|
||||
@@ -39,7 +39,7 @@ public interface ControlFlow {
|
||||
* @param clazz the clazz to look for
|
||||
* @param methodName the name of the method to look for
|
||||
*/
|
||||
boolean under(Class clazz, String methodName);
|
||||
boolean under(Class<?> clazz, String methodName);
|
||||
|
||||
/**
|
||||
* Detect whether the current stack trace contains the given token.
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class ControlFlowFactory {
|
||||
* Searches for class name match in a StackTraceElement.
|
||||
*/
|
||||
@Override
|
||||
public boolean under(Class clazz) {
|
||||
public boolean under(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
String className = clazz.getName();
|
||||
for (int i = 0; i < stack.length; i++) {
|
||||
@@ -78,7 +78,7 @@ public abstract class ControlFlowFactory {
|
||||
* in a StackTraceElement.
|
||||
*/
|
||||
@Override
|
||||
public boolean under(Class clazz, String methodName) {
|
||||
public boolean under(Class<?> clazz, String methodName) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
Assert.notNull(methodName, "Method name must not be null");
|
||||
String className = clazz.getName();
|
||||
|
||||
@@ -20,7 +20,9 @@ import java.io.Externalizable;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
@@ -43,18 +45,18 @@ public abstract class Conventions {
|
||||
*/
|
||||
private static final String PLURAL_SUFFIX = "List";
|
||||
|
||||
|
||||
/**
|
||||
* Set of interfaces that are supposed to be ignored
|
||||
* when searching for the 'primary' interface of a proxy.
|
||||
*/
|
||||
private static final Set<Class> ignoredInterfaces = new HashSet<Class>();
|
||||
|
||||
private static final Set<Class<?>> IGNORED_INTERFACES;
|
||||
static {
|
||||
ignoredInterfaces.add(Serializable.class);
|
||||
ignoredInterfaces.add(Externalizable.class);
|
||||
ignoredInterfaces.add(Cloneable.class);
|
||||
ignoredInterfaces.add(Comparable.class);
|
||||
IGNORED_INTERFACES = Collections.unmodifiableSet(
|
||||
new HashSet<Class<?>>(Arrays.<Class<?>> asList(
|
||||
Serializable.class,
|
||||
Externalizable.class,
|
||||
Cloneable.class,
|
||||
Comparable.class)));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +77,7 @@ public abstract class Conventions {
|
||||
*/
|
||||
public static String getVariableName(Object value) {
|
||||
Assert.notNull(value, "Value must not be null");
|
||||
Class valueClass;
|
||||
Class<?> valueClass;
|
||||
boolean pluralize = false;
|
||||
|
||||
if (value.getClass().isArray()) {
|
||||
@@ -83,7 +85,7 @@ public abstract class Conventions {
|
||||
pluralize = true;
|
||||
}
|
||||
else if (value instanceof Collection) {
|
||||
Collection collection = (Collection) value;
|
||||
Collection<?> collection = (Collection<?>) value;
|
||||
if (collection.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot generate variable name for an empty Collection");
|
||||
}
|
||||
@@ -107,7 +109,7 @@ public abstract class Conventions {
|
||||
*/
|
||||
public static String getVariableNameForParameter(MethodParameter parameter) {
|
||||
Assert.notNull(parameter, "MethodParameter must not be null");
|
||||
Class valueClass;
|
||||
Class<?> valueClass;
|
||||
boolean pluralize = false;
|
||||
|
||||
if (parameter.getParameterType().isArray()) {
|
||||
@@ -163,7 +165,7 @@ public abstract class Conventions {
|
||||
* @param value the return value (may be {@code null} if not available)
|
||||
* @return the generated variable name
|
||||
*/
|
||||
public static String getVariableNameForReturnType(Method method, Class resolvedType, Object value) {
|
||||
public static String getVariableNameForReturnType(Method method, Class<?> resolvedType, Object value) {
|
||||
Assert.notNull(method, "Method must not be null");
|
||||
|
||||
if (Object.class.equals(resolvedType)) {
|
||||
@@ -173,7 +175,7 @@ public abstract class Conventions {
|
||||
return getVariableName(value);
|
||||
}
|
||||
|
||||
Class valueClass;
|
||||
Class<?> valueClass;
|
||||
boolean pluralize = false;
|
||||
|
||||
if (resolvedType.isArray()) {
|
||||
@@ -187,7 +189,7 @@ public abstract class Conventions {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot generate variable name for non-typed Collection return type and a non-Collection value");
|
||||
}
|
||||
Collection collection = (Collection) value;
|
||||
Collection<?> collection = (Collection<?>) value;
|
||||
if (collection.isEmpty()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot generate variable name for non-typed Collection return type and an empty Collection value");
|
||||
@@ -239,7 +241,7 @@ public abstract class Conventions {
|
||||
* the attribute name '{@code foo}' qualified by {@link Class} '{@code com.myapp.SomeClass}'
|
||||
* would be '{@code com.myapp.SomeClass.foo}'
|
||||
*/
|
||||
public static String getQualifiedAttributeName(Class enclosingClass, String attributeName) {
|
||||
public static String getQualifiedAttributeName(Class<?> enclosingClass, String attributeName) {
|
||||
Assert.notNull(enclosingClass, "'enclosingClass' must not be null");
|
||||
Assert.notNull(attributeName, "'attributeName' must not be null");
|
||||
return enclosingClass.getName() + "." + attributeName;
|
||||
@@ -255,12 +257,12 @@ public abstract class Conventions {
|
||||
* @param value the value to check
|
||||
* @return the class to use for naming a variable
|
||||
*/
|
||||
private static Class getClassForValue(Object value) {
|
||||
Class valueClass = value.getClass();
|
||||
private static Class<?> getClassForValue(Object value) {
|
||||
Class<?> valueClass = value.getClass();
|
||||
if (Proxy.isProxyClass(valueClass)) {
|
||||
Class[] ifcs = valueClass.getInterfaces();
|
||||
for (Class ifc : ifcs) {
|
||||
if (!ignoredInterfaces.contains(ifc)) {
|
||||
Class<?>[] ifcs = valueClass.getInterfaces();
|
||||
for (Class<?> ifc : ifcs) {
|
||||
if (!IGNORED_INTERFACES.contains(ifc)) {
|
||||
return ifc;
|
||||
}
|
||||
}
|
||||
@@ -285,13 +287,13 @@ public abstract class Conventions {
|
||||
* The exact element for which the {@code Class} is retreived will depend
|
||||
* on the concrete {@code Collection} implementation.
|
||||
*/
|
||||
private static Object peekAhead(Collection collection) {
|
||||
Iterator it = collection.iterator();
|
||||
private static <E> E peekAhead(Collection<E> collection) {
|
||||
Iterator<E> it = collection.iterator();
|
||||
if (!it.hasNext()) {
|
||||
throw new IllegalStateException(
|
||||
"Unable to peek ahead in non-empty collection - no element found");
|
||||
}
|
||||
Object value = it.next();
|
||||
E value = it.next();
|
||||
if (value == null) {
|
||||
throw new IllegalStateException(
|
||||
"Unable to peek ahead in non-empty collection - only null element found");
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ExceptionDepthComparator implements Comparator<Class<? extends Thro
|
||||
return (depth1 - depth2);
|
||||
}
|
||||
|
||||
private int getDepth(Class declaredException, Class exceptionToMatch, int depth) {
|
||||
private int getDepth(Class<?> declaredException, Class<?> exceptionToMatch, int depth) {
|
||||
if (declaredException.equals(exceptionToMatch)) {
|
||||
// Found it!
|
||||
return depth;
|
||||
|
||||
@@ -41,6 +41,7 @@ public abstract class GenericCollectionTypeResolver {
|
||||
* @param collectionClass the collection class to introspect
|
||||
* @return the generic type, or {@code null} if none
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Class<?> getCollectionType(Class<? extends Collection> collectionClass) {
|
||||
return ResolvableType.forClass(collectionClass).asCollection().resolveGeneric();
|
||||
}
|
||||
@@ -51,6 +52,7 @@ public abstract class GenericCollectionTypeResolver {
|
||||
* @param mapClass the map class to introspect
|
||||
* @return the generic type, or {@code null} if none
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Class<?> getMapKeyType(Class<? extends Map> mapClass) {
|
||||
return ResolvableType.forClass(mapClass).asMap().resolveGeneric(0);
|
||||
}
|
||||
@@ -61,6 +63,7 @@ public abstract class GenericCollectionTypeResolver {
|
||||
* @param mapClass the map class to introspect
|
||||
* @return the generic type, or {@code null} if none
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Class<?> getMapValueType(Class<? extends Map> mapClass) {
|
||||
return ResolvableType.forClass(mapClass).asMap().resolveGeneric(1);
|
||||
}
|
||||
|
||||
@@ -44,8 +44,9 @@ import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
public abstract class GenericTypeResolver {
|
||||
|
||||
/** Cache from Class to TypeVariable Map */
|
||||
private static final Map<Class, Map<TypeVariable, Type>> typeVariableCache =
|
||||
new ConcurrentReferenceHashMap<Class, Map<TypeVariable,Type>>();
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static final Map<Class<?>, Map<TypeVariable, Type>> typeVariableCache =
|
||||
new ConcurrentReferenceHashMap<Class<?>, Map<TypeVariable, Type>>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -256,6 +257,7 @@ public abstract class GenericTypeResolver {
|
||||
* @deprecated as of Spring 4.0 in favor of {@link ResolvableType}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Class<?> resolveType(Type genericType, Map<TypeVariable, Type> map) {
|
||||
return ResolvableType.forType(genericType, new TypeVariableMapVariableResolver(map)).resolve(Object.class);
|
||||
}
|
||||
@@ -267,6 +269,7 @@ public abstract class GenericTypeResolver {
|
||||
* @deprecated as of Spring 4.0 in favor of {@link ResolvableType}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Map<TypeVariable, Type> getTypeVariableMap(Class<?> clazz) {
|
||||
Map<TypeVariable, Type> typeVariableMap = typeVariableCache.get(clazz);
|
||||
if (typeVariableMap == null) {
|
||||
@@ -277,6 +280,7 @@ public abstract class GenericTypeResolver {
|
||||
return typeVariableMap;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static void buildTypeVariableMap(ResolvableType type, Map<TypeVariable, Type> typeVariableMap) {
|
||||
if (type != ResolvableType.NONE) {
|
||||
if (type.getType() instanceof ParameterizedType) {
|
||||
@@ -302,7 +306,7 @@ public abstract class GenericTypeResolver {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@SuppressWarnings({"serial", "rawtypes"})
|
||||
private static class TypeVariableMapVariableResolver implements ResolvableType.VariableResolver {
|
||||
|
||||
private final Map<TypeVariable, Type> typeVariableMap;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MethodParameter {
|
||||
|
||||
private final Method method;
|
||||
|
||||
private final Constructor constructor;
|
||||
private final Constructor<?> constructor;
|
||||
|
||||
private final int parameterIndex;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class MethodParameter {
|
||||
* @param constructor the Constructor to specify a parameter for
|
||||
* @param parameterIndex the index of the parameter
|
||||
*/
|
||||
public MethodParameter(Constructor constructor, int parameterIndex) {
|
||||
public MethodParameter(Constructor<?> constructor, int parameterIndex) {
|
||||
this(constructor, parameterIndex, 1);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class MethodParameter {
|
||||
* (typically 1; e.g. in case of a List of Lists, 1 would indicate the
|
||||
* nested List, whereas 2 would indicate the element of the nested List)
|
||||
*/
|
||||
public MethodParameter(Constructor constructor, int parameterIndex, int nestingLevel) {
|
||||
public MethodParameter(Constructor<?> constructor, int parameterIndex, int nestingLevel) {
|
||||
Assert.notNull(constructor, "Constructor must not be null");
|
||||
this.constructor = constructor;
|
||||
this.parameterIndex = parameterIndex;
|
||||
@@ -155,7 +155,7 @@ public class MethodParameter {
|
||||
* <p>Note: Either Method or Constructor is available.
|
||||
* @return the Constructor, or {@code null} if none
|
||||
*/
|
||||
public Constructor getConstructor() {
|
||||
public Constructor<?> getConstructor() {
|
||||
return this.constructor;
|
||||
}
|
||||
|
||||
@@ -268,12 +268,12 @@ public class MethodParameter {
|
||||
Type[] args = ((ParameterizedType) type).getActualTypeArguments();
|
||||
Type arg = args[index != null ? index : args.length - 1];
|
||||
if (arg instanceof Class) {
|
||||
return (Class) arg;
|
||||
return (Class<?>) arg;
|
||||
}
|
||||
else if (arg instanceof ParameterizedType) {
|
||||
arg = ((ParameterizedType) arg).getRawType();
|
||||
if (arg instanceof Class) {
|
||||
return (Class) arg;
|
||||
return (Class<?>) arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public class MethodParameter {
|
||||
return new MethodParameter((Method) methodOrConstructor, parameterIndex);
|
||||
}
|
||||
else if (methodOrConstructor instanceof Constructor) {
|
||||
return new MethodParameter((Constructor) methodOrConstructor, parameterIndex);
|
||||
return new MethodParameter((Constructor<?>) methodOrConstructor, parameterIndex);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
|
||||
@@ -109,7 +109,7 @@ public abstract class NestedCheckedException extends Exception {
|
||||
* @param exType the exception type to look for
|
||||
* @return whether there is a nested exception of the specified type
|
||||
*/
|
||||
public boolean contains(Class exType) {
|
||||
public boolean contains(Class<?> exType) {
|
||||
if (exType == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class NestedRuntimeException extends RuntimeException {
|
||||
* @param exType the exception type to look for
|
||||
* @return whether there is a nested exception of the specified type
|
||||
*/
|
||||
public boolean contains(Class exType) {
|
||||
public boolean contains(Class<?> exType) {
|
||||
if (exType == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class OrderComparator implements Comparator<Object> {
|
||||
sort((Object[]) value);
|
||||
}
|
||||
else if (value instanceof List) {
|
||||
sort((List) value);
|
||||
sort((List<?>) value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ public class OverridingClassLoader extends DecoratingClassLoader {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
Class result = null;
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
Class<?> result = null;
|
||||
if (isEligibleForOverriding(name)) {
|
||||
result = loadClassForOverriding(name);
|
||||
}
|
||||
@@ -90,8 +90,8 @@ public class OverridingClassLoader extends DecoratingClassLoader {
|
||||
* @return the Class object, or {@code null} if no class defined for that name
|
||||
* @throws ClassNotFoundException if the class for the given name couldn't be loaded
|
||||
*/
|
||||
protected Class loadClassForOverriding(String name) throws ClassNotFoundException {
|
||||
Class result = findLoadedClass(name);
|
||||
protected Class<?> loadClassForOverriding(String name) throws ClassNotFoundException {
|
||||
Class<?> result = findLoadedClass(name);
|
||||
if (result == null) {
|
||||
byte[] bytes = loadBytesForClass(name);
|
||||
if (bytes != null) {
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class ParameterizedTypeReference<T> {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj || (obj instanceof ParameterizedTypeReference &&
|
||||
this.type.equals(((ParameterizedTypeReference) obj).type)));
|
||||
this.type.equals(((ParameterizedTypeReference<?>) obj).type)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PrioritizedParameterNameDiscoverer implements ParameterNameDiscover
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterNames(Constructor ctor) {
|
||||
public String[] getParameterNames(Constructor<?> ctor) {
|
||||
for (ParameterNameDiscoverer pnd : this.parameterNameDiscoverers) {
|
||||
String[] result = pnd.getParameterNames(ctor);
|
||||
if (result != null) {
|
||||
|
||||
@@ -155,7 +155,7 @@ public final class ResolvableType implements Serializable {
|
||||
if (rawType instanceof ParameterizedType) {
|
||||
rawType = ((ParameterizedType) rawType).getRawType();
|
||||
}
|
||||
return (rawType instanceof Class ? (Class) rawType : null);
|
||||
return (rawType instanceof Class ? (Class<?>) rawType : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1060,11 +1060,11 @@ public final class ResolvableType implements Serializable {
|
||||
@SuppressWarnings("serial")
|
||||
private static class TypeVariablesVariableResolver implements VariableResolver {
|
||||
|
||||
private final TypeVariable[] typeVariables;
|
||||
private final TypeVariable<?>[] typeVariables;
|
||||
|
||||
private final ResolvableType[] generics;
|
||||
|
||||
public TypeVariablesVariableResolver(TypeVariable[] typeVariables, ResolvableType[] generics) {
|
||||
public TypeVariablesVariableResolver(TypeVariable<?>[] typeVariables, ResolvableType[] generics) {
|
||||
Assert.isTrue(typeVariables.length == generics.length, "Mismatched number of generics specified");
|
||||
this.typeVariables = typeVariables;
|
||||
this.generics = generics;
|
||||
|
||||
@@ -38,6 +38,6 @@ public interface SmartClassLoader {
|
||||
* @return whether the class should be expected to appear in a reloaded
|
||||
* version (with a different {@code Class} object) later on
|
||||
*/
|
||||
boolean isClassReloadable(Class clazz);
|
||||
boolean isClassReloadable(Class<?> clazz);
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class AnnotationAwareOrderComparator extends OrderComparator {
|
||||
return ((Ordered) obj).getOrder();
|
||||
}
|
||||
if (obj != null) {
|
||||
Class<?> clazz = (obj instanceof Class ? (Class) obj : obj.getClass());
|
||||
Class<?> clazz = (obj instanceof Class ? (Class<?>) obj : obj.getClass());
|
||||
Order order = AnnotationUtils.findAnnotation(clazz, Order.class);
|
||||
if (order != null) {
|
||||
return order.value();
|
||||
@@ -99,7 +99,7 @@ public class AnnotationAwareOrderComparator extends OrderComparator {
|
||||
sort((Object[]) value);
|
||||
}
|
||||
else if (value instanceof List) {
|
||||
sort((List) value);
|
||||
sort((List<?>) value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ public abstract class AnnotationUtils {
|
||||
*/
|
||||
public static Object getValue(Annotation annotation, String attributeName) {
|
||||
try {
|
||||
Method method = annotation.annotationType().getDeclaredMethod(attributeName, new Class[0]);
|
||||
Method method = annotation.annotationType().getDeclaredMethod(attributeName, new Class<?>[0]);
|
||||
ReflectionUtils.makeAccessible(method);
|
||||
return method.invoke(annotation);
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public abstract class AnnotationUtils {
|
||||
*/
|
||||
public static Object getDefaultValue(Class<? extends Annotation> annotationType, String attributeName) {
|
||||
try {
|
||||
Method method = annotationType.getDeclaredMethod(attributeName, new Class[0]);
|
||||
Method method = annotationType.getDeclaredMethod(attributeName, new Class<?>[0]);
|
||||
return method.getDefaultValue();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
@@ -56,7 +56,6 @@ final class ArrayToCollectionConverter implements ConditionalGenericConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
||||
@@ -56,7 +56,6 @@ final class CollectionToCollectionConverter implements ConditionalGenericConvert
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.ConversionException;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
|
||||
@@ -52,7 +52,6 @@ final class ObjectToCollectionConverter implements ConditionalGenericConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
||||
@@ -56,7 +56,6 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
|
||||
@@ -30,14 +30,14 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ClassRelativeResourceLoader extends DefaultResourceLoader {
|
||||
|
||||
private final Class clazz;
|
||||
private final Class<?> clazz;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new ClassRelativeResourceLoader for the given class.
|
||||
* @param clazz the class to load resources through
|
||||
*/
|
||||
public ClassRelativeResourceLoader(Class clazz) {
|
||||
public ClassRelativeResourceLoader(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
this.clazz = clazz;
|
||||
setClassLoader(clazz.getClassLoader());
|
||||
@@ -55,9 +55,9 @@ public class ClassRelativeResourceLoader extends DefaultResourceLoader {
|
||||
*/
|
||||
private static class ClassRelativeContextResource extends ClassPathResource implements ContextResource {
|
||||
|
||||
private final Class clazz;
|
||||
private final Class<?> clazz;
|
||||
|
||||
public ClassRelativeContextResource(String path, Class clazz) {
|
||||
public ClassRelativeContextResource(String path, Class<?> clazz) {
|
||||
super(path, clazz);
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@@ -175,9 +175,9 @@ public abstract class PropertiesLoaderUtils {
|
||||
clToUse = ClassUtils.getDefaultClassLoader();
|
||||
}
|
||||
Properties props = new Properties();
|
||||
Enumeration urls = clToUse.getResources(resourceName);
|
||||
Enumeration<URL> urls = clToUse.getResources(resourceName);
|
||||
while (urls.hasMoreElements()) {
|
||||
URL url = (URL) urls.nextElement();
|
||||
URL url = urls.nextElement();
|
||||
URLConnection con = url.openConnection();
|
||||
ResourceUtils.useCachesIfNecessary(con);
|
||||
InputStream is = con.getInputStream();
|
||||
|
||||
@@ -57,20 +57,20 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
return "\'" + value + "\'";
|
||||
}
|
||||
else if (value instanceof Class) {
|
||||
return ClassUtils.getShortName((Class) value);
|
||||
return ClassUtils.getShortName((Class<?>) value);
|
||||
}
|
||||
else if (value instanceof Method) {
|
||||
Method method = (Method) value;
|
||||
return method.getName() + "@" + ClassUtils.getShortName(method.getDeclaringClass());
|
||||
}
|
||||
else if (value instanceof Map) {
|
||||
return style((Map) value);
|
||||
return style((Map<?, ?>) value);
|
||||
}
|
||||
else if (value instanceof Map.Entry) {
|
||||
return style((Map.Entry) value);
|
||||
return style((Map.Entry<? ,?>) value);
|
||||
}
|
||||
else if (value instanceof Collection) {
|
||||
return style((Collection) value);
|
||||
return style((Collection<?>) value);
|
||||
}
|
||||
else if (value.getClass().isArray()) {
|
||||
return styleArray(ObjectUtils.toObjectArray(value));
|
||||
@@ -80,11 +80,11 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
}
|
||||
}
|
||||
|
||||
private String style(Map value) {
|
||||
private <K, V> String style(Map<K, V> value) {
|
||||
StringBuilder result = new StringBuilder(value.size() * 8 + 16);
|
||||
result.append(MAP + "[");
|
||||
for (Iterator it = value.entrySet().iterator(); it.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
for (Iterator<Map.Entry<K, V>> it = value.entrySet().iterator(); it.hasNext();) {
|
||||
Map.Entry<K, V> entry = it.next();
|
||||
result.append(style(entry));
|
||||
if (it.hasNext()) {
|
||||
result.append(',').append(' ');
|
||||
@@ -97,14 +97,14 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String style(Map.Entry value) {
|
||||
private String style(Map.Entry<?, ?> value) {
|
||||
return style(value.getKey()) + " -> " + style(value.getValue());
|
||||
}
|
||||
|
||||
private String style(Collection value) {
|
||||
private String style(Collection<?> value) {
|
||||
StringBuilder result = new StringBuilder(value.size() * 8 + 16);
|
||||
result.append(getCollectionTypeString(value)).append('[');
|
||||
for (Iterator i = value.iterator(); i.hasNext();) {
|
||||
for (Iterator<?> i = value.iterator(); i.hasNext();) {
|
||||
result.append(style(i.next()));
|
||||
if (i.hasNext()) {
|
||||
result.append(',').append(' ');
|
||||
@@ -117,7 +117,7 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String getCollectionTypeString(Collection value) {
|
||||
private String getCollectionTypeString(Collection<?> value) {
|
||||
if (value instanceof List) {
|
||||
return LIST;
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class StandardClassMetadata implements ClassMetadata {
|
||||
|
||||
private final Class introspectedClass;
|
||||
private final Class<?> introspectedClass;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new StandardClassMetadata wrapper for the given Class.
|
||||
* @param introspectedClass the Class to introspect
|
||||
*/
|
||||
public StandardClassMetadata(Class introspectedClass) {
|
||||
public StandardClassMetadata(Class<?> introspectedClass) {
|
||||
Assert.notNull(introspectedClass, "Class must not be null");
|
||||
this.introspectedClass = introspectedClass;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class StandardClassMetadata implements ClassMetadata {
|
||||
/**
|
||||
* Return the underlying Class.
|
||||
*/
|
||||
public final Class getIntrospectedClass() {
|
||||
public final Class<?> getIntrospectedClass() {
|
||||
return this.introspectedClass;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class StandardClassMetadata implements ClassMetadata {
|
||||
|
||||
@Override
|
||||
public String getEnclosingClassName() {
|
||||
Class enclosingClass = this.introspectedClass.getEnclosingClass();
|
||||
Class<?> enclosingClass = this.introspectedClass.getEnclosingClass();
|
||||
return (enclosingClass != null ? enclosingClass.getName() : null);
|
||||
}
|
||||
|
||||
@@ -100,13 +100,13 @@ public class StandardClassMetadata implements ClassMetadata {
|
||||
|
||||
@Override
|
||||
public String getSuperClassName() {
|
||||
Class superClass = this.introspectedClass.getSuperclass();
|
||||
Class<?> superClass = this.introspectedClass.getSuperclass();
|
||||
return (superClass != null ? superClass.getName() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getInterfaceNames() {
|
||||
Class[] ifcs = this.introspectedClass.getInterfaces();
|
||||
Class<?>[] ifcs = this.introspectedClass.getInterfaces();
|
||||
String[] ifcNames = new String[ifcs.length];
|
||||
for (int i = 0; i < ifcs.length; i++) {
|
||||
ifcNames[i] = ifcs[i].getName();
|
||||
|
||||
@@ -60,7 +60,7 @@ abstract class AnnotationReadingVisitorUtils {
|
||||
}
|
||||
else if (value instanceof Type[]) {
|
||||
Type[] array = (Type[]) value;
|
||||
Object[] convArray = (classValuesAsString ? new String[array.length] : new Class[array.length]);
|
||||
Object[] convArray = (classValuesAsString ? new String[array.length] : new Class<?>[array.length]);
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
convArray[i] = (classValuesAsString ? array[i].getClassName() :
|
||||
classLoader.loadClass(array[i].getClassName()));
|
||||
|
||||
@@ -26,14 +26,14 @@ package org.springframework.core.type.filter;
|
||||
*/
|
||||
public class AssignableTypeFilter extends AbstractTypeHierarchyTraversingFilter {
|
||||
|
||||
private final Class targetType;
|
||||
private final Class<?> targetType;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new AssignableTypeFilter for the given type.
|
||||
* @param targetType the type to match
|
||||
*/
|
||||
public AssignableTypeFilter(Class targetType) {
|
||||
public AssignableTypeFilter(Class<?> targetType) {
|
||||
super(true, true);
|
||||
this.targetType = targetType;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class AssignableTypeFilter extends AbstractTypeHierarchyTraversingFilter
|
||||
}
|
||||
else if (typeName.startsWith("java.")) {
|
||||
try {
|
||||
Class clazz = getClass().getClassLoader().loadClass(typeName);
|
||||
Class<?> clazz = getClass().getClassLoader().loadClass(typeName);
|
||||
return Boolean.valueOf(this.targetType.isAssignableFrom(clazz));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
|
||||
@@ -263,7 +263,7 @@ public abstract class Assert {
|
||||
* @param message the exception message to use if the assertion fails
|
||||
* @throws IllegalArgumentException if the collection is {@code null} or has no elements
|
||||
*/
|
||||
public static void notEmpty(Collection collection, String message) {
|
||||
public static void notEmpty(Collection<?> collection, String message) {
|
||||
if (CollectionUtils.isEmpty(collection)) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
@@ -276,7 +276,7 @@ public abstract class Assert {
|
||||
* @param collection the collection to check
|
||||
* @throws IllegalArgumentException if the collection is {@code null} or has no elements
|
||||
*/
|
||||
public static void notEmpty(Collection collection) {
|
||||
public static void notEmpty(Collection<?> collection) {
|
||||
notEmpty(collection,
|
||||
"[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
|
||||
}
|
||||
@@ -289,7 +289,7 @@ public abstract class Assert {
|
||||
* @param message the exception message to use if the assertion fails
|
||||
* @throws IllegalArgumentException if the map is {@code null} or has no entries
|
||||
*/
|
||||
public static void notEmpty(Map map, String message) {
|
||||
public static void notEmpty(Map<?, ?> map, String message) {
|
||||
if (CollectionUtils.isEmpty(map)) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public abstract class Assert {
|
||||
* @param map the map to check
|
||||
* @throws IllegalArgumentException if the map is {@code null} or has no entries
|
||||
*/
|
||||
public static void notEmpty(Map map) {
|
||||
public static void notEmpty(Map<?, ?> map) {
|
||||
notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class AutoPopulatingList<E> implements List<E>, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection c) {
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return this.backingList.containsAll(c);
|
||||
}
|
||||
|
||||
|
||||
@@ -894,13 +894,13 @@ public abstract class ClassUtils {
|
||||
return true;
|
||||
}
|
||||
if (lhsType.isPrimitive()) {
|
||||
Class resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType);
|
||||
Class<?> resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType);
|
||||
if (resolvedPrimitive != null && lhsType.equals(resolvedPrimitive)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Class resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType);
|
||||
Class<?> resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType);
|
||||
if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) {
|
||||
return true;
|
||||
}
|
||||
@@ -1002,7 +1002,7 @@ public abstract class ClassUtils {
|
||||
* @return a String of form "[com.foo.Bar, com.foo.Baz]"
|
||||
* @see java.util.AbstractCollection#toString()
|
||||
*/
|
||||
public static String classNamesToString(Class... classes) {
|
||||
public static String classNamesToString(Class<?>... classes) {
|
||||
return classNamesToString(Arrays.asList(classes));
|
||||
}
|
||||
|
||||
@@ -1015,13 +1015,13 @@ public abstract class ClassUtils {
|
||||
* @return a String of form "[com.foo.Bar, com.foo.Baz]"
|
||||
* @see java.util.AbstractCollection#toString()
|
||||
*/
|
||||
public static String classNamesToString(Collection<Class> classes) {
|
||||
public static String classNamesToString(Collection<Class<?>> classes) {
|
||||
if (CollectionUtils.isEmpty(classes)) {
|
||||
return "[]";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
for (Iterator<Class> it = classes.iterator(); it.hasNext(); ) {
|
||||
Class clazz = it.next();
|
||||
for (Iterator<Class<?>> it = classes.iterator(); it.hasNext(); ) {
|
||||
Class<?> clazz = it.next();
|
||||
sb.append(clazz.getName());
|
||||
if (it.hasNext()) {
|
||||
sb.append(", ");
|
||||
@@ -1077,8 +1077,8 @@ public abstract class ClassUtils {
|
||||
* @return all interfaces that the given object implements as array
|
||||
*/
|
||||
public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, ClassLoader classLoader) {
|
||||
Set<Class> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader);
|
||||
return ifcs.toArray(new Class[ifcs.size()]);
|
||||
Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader);
|
||||
return ifcs.toArray(new Class<?>[ifcs.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1087,7 +1087,7 @@ public abstract class ClassUtils {
|
||||
* @param instance the instance to analyze for interfaces
|
||||
* @return all interfaces that the given instance implements as Set
|
||||
*/
|
||||
public static Set<Class> getAllInterfacesAsSet(Object instance) {
|
||||
public static Set<Class<?>> getAllInterfacesAsSet(Object instance) {
|
||||
Assert.notNull(instance, "Instance must not be null");
|
||||
return getAllInterfacesForClassAsSet(instance.getClass());
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ public abstract class ClassUtils {
|
||||
* @param clazz the class to analyze for interfaces
|
||||
* @return all interfaces that the given object implements as Set
|
||||
*/
|
||||
public static Set<Class> getAllInterfacesForClassAsSet(Class clazz) {
|
||||
public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz) {
|
||||
return getAllInterfacesForClassAsSet(clazz, null);
|
||||
}
|
||||
|
||||
@@ -1112,12 +1112,12 @@ public abstract class ClassUtils {
|
||||
* (may be {@code null} when accepting all declared interfaces)
|
||||
* @return all interfaces that the given object implements as Set
|
||||
*/
|
||||
public static Set<Class> getAllInterfacesForClassAsSet(Class clazz, ClassLoader classLoader) {
|
||||
public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, ClassLoader classLoader) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
if (clazz.isInterface() && isVisible(clazz, classLoader)) {
|
||||
return Collections.singleton(clazz);
|
||||
return Collections.<Class<?>>singleton(clazz);
|
||||
}
|
||||
Set<Class> interfaces = new LinkedHashSet<Class>();
|
||||
Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
|
||||
while (clazz != null) {
|
||||
Class<?>[] ifcs = clazz.getInterfaces();
|
||||
for (Class<?> ifc : ifcs) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class CollectionUtils {
|
||||
* @param collection the Collection to check
|
||||
* @return whether the given Collection is empty
|
||||
*/
|
||||
public static boolean isEmpty(Collection collection) {
|
||||
public static boolean isEmpty(Collection<?> collection) {
|
||||
return (collection == null || collection.isEmpty());
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class CollectionUtils {
|
||||
* @param map the Map to check
|
||||
* @return whether the given Map is empty
|
||||
*/
|
||||
public static boolean isEmpty(Map map) {
|
||||
public static boolean isEmpty(Map<?, ?> map) {
|
||||
return (map == null || map.isEmpty());
|
||||
}
|
||||
|
||||
@@ -70,8 +70,9 @@ public abstract class CollectionUtils {
|
||||
* @return the converted List result
|
||||
* @see ObjectUtils#toObjectArray(Object)
|
||||
*/
|
||||
public static List arrayToList(Object source) {
|
||||
return Arrays.asList(ObjectUtils.toObjectArray(source));
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> List<E> arrayToList(Object source) {
|
||||
return (List<E>) Arrays.asList(ObjectUtils.toObjectArray(source));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,13 +81,13 @@ public abstract class CollectionUtils {
|
||||
* @param collection the target Collection to merge the array into
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void mergeArrayIntoCollection(Object array, Collection collection) {
|
||||
public static <E> void mergeArrayIntoCollection(Object array, Collection<E> collection) {
|
||||
if (collection == null) {
|
||||
throw new IllegalArgumentException("Collection must not be null");
|
||||
}
|
||||
Object[] arr = ObjectUtils.toObjectArray(array);
|
||||
for (Object elem : arr) {
|
||||
collection.add(elem);
|
||||
collection.add((E) elem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,19 +100,19 @@ public abstract class CollectionUtils {
|
||||
* @param map the target Map to merge the properties into
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void mergePropertiesIntoMap(Properties props, Map map) {
|
||||
public static <K, V> void mergePropertiesIntoMap(Properties props, Map<K, V> map) {
|
||||
if (map == null) {
|
||||
throw new IllegalArgumentException("Map must not be null");
|
||||
}
|
||||
if (props != null) {
|
||||
for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
|
||||
for (Enumeration<?> en = props.propertyNames(); en.hasMoreElements();) {
|
||||
String key = (String) en.nextElement();
|
||||
Object value = props.getProperty(key);
|
||||
if (value == null) {
|
||||
// Potentially a non-String value...
|
||||
value = props.get(key);
|
||||
}
|
||||
map.put(key, value);
|
||||
map.put((K) key, (V) value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +124,7 @@ public abstract class CollectionUtils {
|
||||
* @param element the element to look for
|
||||
* @return {@code true} if found, {@code false} else
|
||||
*/
|
||||
public static boolean contains(Iterator iterator, Object element) {
|
||||
public static boolean contains(Iterator<?> iterator, Object element) {
|
||||
if (iterator != null) {
|
||||
while (iterator.hasNext()) {
|
||||
Object candidate = iterator.next();
|
||||
@@ -141,7 +142,7 @@ public abstract class CollectionUtils {
|
||||
* @param element the element to look for
|
||||
* @return {@code true} if found, {@code false} else
|
||||
*/
|
||||
public static boolean contains(Enumeration enumeration, Object element) {
|
||||
public static boolean contains(Enumeration<?> enumeration, Object element) {
|
||||
if (enumeration != null) {
|
||||
while (enumeration.hasMoreElements()) {
|
||||
Object candidate = enumeration.nextElement();
|
||||
@@ -161,7 +162,7 @@ public abstract class CollectionUtils {
|
||||
* @param element the element to look for
|
||||
* @return {@code true} if found, {@code false} else
|
||||
*/
|
||||
public static boolean containsInstance(Collection collection, Object element) {
|
||||
public static boolean containsInstance(Collection<?> collection, Object element) {
|
||||
if (collection != null) {
|
||||
for (Object candidate : collection) {
|
||||
if (candidate == element) {
|
||||
@@ -179,7 +180,7 @@ public abstract class CollectionUtils {
|
||||
* @param candidates the candidates to search for
|
||||
* @return whether any of the candidates has been found
|
||||
*/
|
||||
public static boolean containsAny(Collection source, Collection candidates) {
|
||||
public static boolean containsAny(Collection<?> source, Collection<?> candidates) {
|
||||
if (isEmpty(source) || isEmpty(candidates)) {
|
||||
return false;
|
||||
}
|
||||
@@ -200,13 +201,14 @@ public abstract class CollectionUtils {
|
||||
* @param candidates the candidates to search for
|
||||
* @return the first present object, or {@code null} if not found
|
||||
*/
|
||||
public static Object findFirstMatch(Collection source, Collection candidates) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E findFirstMatch(Collection<?> source, Collection<E> candidates) {
|
||||
if (isEmpty(source) || isEmpty(candidates)) {
|
||||
return null;
|
||||
}
|
||||
for (Object candidate : candidates) {
|
||||
if (source.contains(candidate)) {
|
||||
return candidate;
|
||||
return (E) candidate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -265,7 +267,7 @@ public abstract class CollectionUtils {
|
||||
* @return {@code true} if the collection contains a single reference or
|
||||
* multiple references to the same instance, {@code false} else
|
||||
*/
|
||||
public static boolean hasUniqueObject(Collection collection) {
|
||||
public static boolean hasUniqueObject(Collection<?> collection) {
|
||||
if (isEmpty(collection)) {
|
||||
return false;
|
||||
}
|
||||
@@ -289,7 +291,7 @@ public abstract class CollectionUtils {
|
||||
* @return the common element type, or {@code null} if no clear
|
||||
* common type has been found (or the collection was empty)
|
||||
*/
|
||||
public static Class<?> findCommonElementType(Collection collection) {
|
||||
public static Class<?> findCommonElementType(Collection<?> collection) {
|
||||
if (isEmpty(collection)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class MethodInvoker {
|
||||
}
|
||||
|
||||
Object[] arguments = getArguments();
|
||||
Class[] argTypes = new Class[arguments.length];
|
||||
Class<?>[] argTypes = new Class<?>[arguments.length];
|
||||
for (int i = 0; i < arguments.length; ++i) {
|
||||
argTypes[i] = (arguments[i] != null ? arguments[i].getClass() : Object.class);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class MethodInvoker {
|
||||
|
||||
for (Method candidate : candidates) {
|
||||
if (candidate.getName().equals(targetMethod)) {
|
||||
Class[] paramTypes = candidate.getParameterTypes();
|
||||
Class<?>[] paramTypes = candidate.getParameterTypes();
|
||||
if (paramTypes.length == argCount) {
|
||||
int typeDiffWeight = getTypeDifferenceWeight(paramTypes, arguments);
|
||||
if (typeDiffWeight < minTypeDiffWeight) {
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class NumberUtils {
|
||||
* @param number the number we tried to convert
|
||||
* @param targetClass the target class we tried to convert to
|
||||
*/
|
||||
private static void raiseOverflowException(Number number, Class targetClass) {
|
||||
private static void raiseOverflowException(Number number, Class<?> targetClass) {
|
||||
throw new IllegalArgumentException("Could not convert number [" + number + "] of type [" +
|
||||
number.getClass().getName() + "] to target class [" + targetClass.getName() + "]: overflow");
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class ObjectUtils {
|
||||
* @param declaredExceptions the exceptions declared in the throws clause
|
||||
* @return whether the given exception is compatible
|
||||
*/
|
||||
public static boolean isCompatibleWithThrowsClause(Throwable ex, Class[] declaredExceptions) {
|
||||
public static boolean isCompatibleWithThrowsClause(Throwable ex, Class<?>[] declaredExceptions) {
|
||||
if (!isCheckedException(ex)) {
|
||||
return true;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return new Object[0];
|
||||
}
|
||||
Class wrapperType = Array.get(source, 0).getClass();
|
||||
Class<?> wrapperType = Array.get(source, 0).getClass();
|
||||
Object[] newArray = (Object[]) Array.newInstance(wrapperType, length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
newArray[i] = Array.get(source, i);
|
||||
@@ -286,7 +286,7 @@ public abstract class ObjectUtils {
|
||||
|
||||
/**
|
||||
* Return as hash code for the given object; typically the value of
|
||||
* {@code {@link Object#hashCode()}}. If the object is an array,
|
||||
* {@code Object#hashCode()}}. If the object is an array,
|
||||
* this method will delegate to any of the {@code nullSafeHashCode}
|
||||
* methods for arrays in this class. If the object is {@code null},
|
||||
* this method returns 0.
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract class ReflectionUtils {
|
||||
* @return the Method object, or {@code null} if none found
|
||||
*/
|
||||
public static Method findMethod(Class<?> clazz, String name) {
|
||||
return findMethod(clazz, name, new Class[0]);
|
||||
return findMethod(clazz, name, new Class<?>[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ public class WeakReferenceMonitor {
|
||||
private static final ReferenceQueue<Object> handleQueue = new ReferenceQueue<Object>();
|
||||
|
||||
// All tracked entries (WeakReference => ReleaseListener)
|
||||
private static final Map<Reference, ReleaseListener> trackedEntries = new HashMap<Reference, ReleaseListener>();
|
||||
private static final Map<Reference<?>, ReleaseListener> trackedEntries = new HashMap<Reference<?>, ReleaseListener>();
|
||||
|
||||
// Thread polling handleQueue, lazy initialized
|
||||
private static Thread monitoringThread = null;
|
||||
@@ -84,7 +84,7 @@ public class WeakReferenceMonitor {
|
||||
* @param ref reference to tracked handle
|
||||
* @param entry the associated entry
|
||||
*/
|
||||
private static void addEntry(Reference ref, ReleaseListener entry) {
|
||||
private static void addEntry(Reference<?> ref, ReleaseListener entry) {
|
||||
synchronized (WeakReferenceMonitor.class) {
|
||||
// Add entry, the key is given reference.
|
||||
trackedEntries.put(ref, entry);
|
||||
@@ -103,7 +103,7 @@ public class WeakReferenceMonitor {
|
||||
* @param reference the reference that should be removed
|
||||
* @return entry object associated with given reference
|
||||
*/
|
||||
private static ReleaseListener removeEntry(Reference reference) {
|
||||
private static ReleaseListener removeEntry(Reference<?> reference) {
|
||||
synchronized (WeakReferenceMonitor.class) {
|
||||
return trackedEntries.remove(reference);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class WeakReferenceMonitor {
|
||||
// Check if there are any tracked entries left.
|
||||
while (keepMonitoringThreadAlive()) {
|
||||
try {
|
||||
Reference reference = handleQueue.remove();
|
||||
Reference<?> reference = handleQueue.remove();
|
||||
// Stop tracking this reference.
|
||||
ReleaseListener entry = removeEntry(reference);
|
||||
if (entry != null) {
|
||||
|
||||
@@ -37,10 +37,10 @@ import org.springframework.util.Assert;
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.2.2
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@SuppressWarnings({ "serial", "rawtypes" })
|
||||
public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
|
||||
private final List<InvertibleComparator<T>> comparators;
|
||||
private final List<InvertibleComparator> comparators;
|
||||
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
* IllegalStateException is thrown.
|
||||
*/
|
||||
public CompoundComparator() {
|
||||
this.comparators = new ArrayList<InvertibleComparator<T>>();
|
||||
this.comparators = new ArrayList<InvertibleComparator>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public CompoundComparator(Comparator... comparators) {
|
||||
Assert.notNull(comparators, "Comparators must not be null");
|
||||
this.comparators = new ArrayList<InvertibleComparator<T>>(comparators.length);
|
||||
this.comparators = new ArrayList<InvertibleComparator>(comparators.length);
|
||||
for (Comparator comparator : comparators) {
|
||||
this.addComparator(comparator);
|
||||
}
|
||||
@@ -76,12 +76,13 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
* @param comparator the Comparator to add to the end of the chain
|
||||
* @see InvertibleComparator
|
||||
*/
|
||||
public void addComparator(Comparator<T> comparator) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addComparator(Comparator<? extends T> comparator) {
|
||||
if (comparator instanceof InvertibleComparator) {
|
||||
this.comparators.add((InvertibleComparator<T>) comparator);
|
||||
this.comparators.add((InvertibleComparator) comparator);
|
||||
}
|
||||
else {
|
||||
this.comparators.add(new InvertibleComparator<T>(comparator));
|
||||
this.comparators.add(new InvertibleComparator(comparator));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +91,9 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
* @param comparator the Comparator to add to the end of the chain
|
||||
* @param ascending the sort order: ascending (true) or descending (false)
|
||||
*/
|
||||
public void addComparator(Comparator<T> comparator, boolean ascending) {
|
||||
this.comparators.add(new InvertibleComparator<T>(comparator, ascending));
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addComparator(Comparator<? extends T> comparator, boolean ascending) {
|
||||
this.comparators.add(new InvertibleComparator(comparator, ascending));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,12 +104,13 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
* @param comparator the Comparator to place at the given index
|
||||
* @see InvertibleComparator
|
||||
*/
|
||||
public void setComparator(int index, Comparator<T> comparator) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setComparator(int index, Comparator<? extends T> comparator) {
|
||||
if (comparator instanceof InvertibleComparator) {
|
||||
this.comparators.set(index, (InvertibleComparator<T>) comparator);
|
||||
this.comparators.set(index, (InvertibleComparator) comparator);
|
||||
}
|
||||
else {
|
||||
this.comparators.set(index, new InvertibleComparator<T>(comparator));
|
||||
this.comparators.set(index, new InvertibleComparator(comparator));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +129,7 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
* comparator.
|
||||
*/
|
||||
public void invertOrder() {
|
||||
for (InvertibleComparator<T> comparator : this.comparators) {
|
||||
for (InvertibleComparator comparator : this.comparators) {
|
||||
comparator.invertOrder();
|
||||
}
|
||||
}
|
||||
@@ -163,10 +166,11 @@ public class CompoundComparator<T> implements Comparator<T>, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public int compare(T o1, T o2) {
|
||||
Assert.state(this.comparators.size() > 0,
|
||||
"No sort definitions have been added to this CompoundComparator to compare");
|
||||
for (InvertibleComparator<T> comparator : this.comparators) {
|
||||
for (InvertibleComparator comparator : this.comparators) {
|
||||
int result = comparator.compare(o1, o2);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class NullSafeComparator<T> implements Comparator<T> {
|
||||
* @see #NULLS_LOW
|
||||
* @see #NULLS_HIGH
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked"})
|
||||
@SuppressWarnings({ "unchecked", "rawtypes"})
|
||||
private NullSafeComparator(boolean nullsLow) {
|
||||
this.nonNullComparator = new ComparableComparator();
|
||||
this.nullsLow = nullsLow;
|
||||
|
||||
@@ -184,7 +184,7 @@ public abstract class DomUtils {
|
||||
/**
|
||||
* Matches the given node's name and local name against the given desired names.
|
||||
*/
|
||||
private static boolean nodeNameMatch(Node node, Collection desiredNames) {
|
||||
private static boolean nodeNameMatch(Node node, Collection<?> desiredNames) {
|
||||
return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,12 +63,12 @@ public class SimpleNamespaceContext implements NamespaceContext {
|
||||
|
||||
@Override
|
||||
public String getPrefix(String namespaceUri) {
|
||||
List prefixes = getPrefixesInternal(namespaceUri);
|
||||
List<?> prefixes = getPrefixesInternal(namespaceUri);
|
||||
return prefixes.isEmpty() ? null : (String) prefixes.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator getPrefixes(String namespaceUri) {
|
||||
public Iterator<String> getPrefixes(String namespaceUri) {
|
||||
return getPrefixesInternal(namespaceUri).iterator();
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class SimpleNamespaceContext implements NamespaceContext {
|
||||
}
|
||||
else {
|
||||
String namespaceUri = prefixToNamespaceUri.remove(prefix);
|
||||
List prefixes = getPrefixesInternal(namespaceUri);
|
||||
List<String> prefixes = getPrefixesInternal(namespaceUri);
|
||||
prefixes.remove(prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.util.xml;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.Location;
|
||||
@@ -29,11 +30,10 @@ import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import javax.xml.stream.util.XMLEventConsumer;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* SAX {@code ContentHandler} that transforms callback calls to {@code XMLEvent}s
|
||||
* and writes them to a {@code XMLEventConsumer}.
|
||||
@@ -92,15 +92,15 @@ class StaxEventContentHandler extends AbstractStaxContentHandler {
|
||||
protected void startElementInternal(QName name, Attributes atts, SimpleNamespaceContext namespaceContext)
|
||||
throws XMLStreamException {
|
||||
|
||||
List attributes = getAttributes(atts);
|
||||
List namespaces = createNamespaces(namespaceContext);
|
||||
List<Attribute> attributes = getAttributes(atts);
|
||||
List<Namespace> namespaces = createNamespaces(namespaceContext);
|
||||
consumeEvent(this.eventFactory.createStartElement(name, attributes.iterator(),
|
||||
(namespaces != null ? namespaces.iterator() : null)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endElementInternal(QName name, SimpleNamespaceContext namespaceContext) throws XMLStreamException {
|
||||
List namespaces = createNamespaces(namespaceContext);
|
||||
List<Namespace> namespaces = createNamespaces(namespaceContext);
|
||||
consumeEvent(this.eventFactory.createEndElement(name, namespaces != null ? namespaces.iterator() : null));
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ class StaxEventContentHandler extends AbstractStaxContentHandler {
|
||||
if (StringUtils.hasLength(defaultNamespaceUri)) {
|
||||
namespaces.add(this.eventFactory.createNamespace(defaultNamespaceUri));
|
||||
}
|
||||
for (Iterator iterator = namespaceContext.getBoundPrefixes(); iterator.hasNext();) {
|
||||
String prefix = (String) iterator.next();
|
||||
for (Iterator<String> iterator = namespaceContext.getBoundPrefixes(); iterator.hasNext();) {
|
||||
String prefix = iterator.next();
|
||||
String namespaceUri = namespaceContext.getNamespaceURI(prefix);
|
||||
namespaces.add(this.eventFactory.createNamespace(prefix, namespaceUri));
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.springframework.util.xml;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
@@ -38,14 +37,13 @@ import javax.xml.stream.events.StartDocument;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.ext.Locator2;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* SAX {@code XMLReader} that reads from a StAX {@code XMLEventReader}. Consumes {@code XMLEvents} from
|
||||
* an {@code XMLEventReader}, and calls the corresponding methods on the SAX callback interfaces.
|
||||
@@ -58,14 +56,13 @@ import org.springframework.util.StringUtils;
|
||||
* @see #setEntityResolver(org.xml.sax.EntityResolver)
|
||||
* @see #setErrorHandler(org.xml.sax.ErrorHandler)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
class StaxEventXMLReader extends AbstractStaxXMLReader {
|
||||
|
||||
private static final String DEFAULT_XML_VERSION = "1.0";
|
||||
|
||||
private final XMLEventReader reader;
|
||||
|
||||
private final Map<String, String> namespaces = new LinkedHashMap<String, String>();
|
||||
|
||||
private String xmlVersion = DEFAULT_XML_VERSION;
|
||||
|
||||
private String encoding;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.util.xml;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.Location;
|
||||
@@ -38,6 +39,7 @@ import javax.xml.stream.events.XMLEvent;
|
||||
* @since 3.0
|
||||
* @see StaxUtils#createEventStreamReader(javax.xml.stream.XMLEventReader)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
class XMLEventStreamReader extends AbstractXMLStreamReader {
|
||||
|
||||
private XMLEvent event;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.util.xml;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventFactory;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.util.Assert;
|
||||
* @since 3.0.5
|
||||
* @see StaxUtils#createEventStreamWriter(javax.xml.stream.XMLEventWriter, javax.xml.stream.XMLEventFactory)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
class XMLEventStreamWriter implements XMLStreamWriter {
|
||||
|
||||
private static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
Reference in New Issue
Block a user