Remove unnecessary cast

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@1557985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Louis Boudart 2014-01-14 09:02:20 +00:00
parent 02ae34d1d3
commit 6f8302fed2
27 changed files with 60 additions and 68 deletions

View File

@ -198,7 +198,7 @@ public final class IvyPatternHelper {
sb = new StringBuffer();
}
String var = m.group(1);
String val = (String) variables.getVariable(var);
String val = variables.getVariable(var);
if (val != null) {
int index = substituting.indexOf(var);
if (index != -1) {
@ -385,7 +385,7 @@ public final class IvyPatternHelper {
StringBuffer sb = new StringBuffer();
while (m.find()) {
String var = m.group(1);
String val = (String) params.getVariable(var);
String val = params.getVariable(var);
if (val != null) {
int index = substituting.indexOf(var);
if (index != -1) {

View File

@ -43,7 +43,7 @@ public class EventManager implements TransferListener {
public void removeIvyListener(IvyListener listener) {
listeners.remove(IvyListener.class, listener);
IvyListener[] listeners = (IvyListener[]) this.listeners.getListeners(IvyListener.class);
IvyListener[] listeners = this.listeners.getListeners(IvyListener.class);
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] instanceof FilteredIvyListener) {
if (listener.equals(((FilteredIvyListener) listeners[i]).getIvyListener())) {

View File

@ -220,7 +220,7 @@ public class ConfigurationResolveReport {
downloaded.add(node);
}
}
return (IvyNode[]) downloaded.toArray(new IvyNode[downloaded.size()]);
return downloaded.toArray(new IvyNode[downloaded.size()]);
}
public ArtifactDownloadReport[] getDownloadReports(ModuleRevisionId mrid) {
@ -353,7 +353,7 @@ public class ConfigurationResolveReport {
Collection<ArtifactDownloadReport> adrs = new ArrayList<ArtifactDownloadReport>(
Arrays.asList(allFailedReports));
for (Iterator<ArtifactDownloadReport> iterator = adrs.iterator(); iterator.hasNext();) {
ArtifactDownloadReport adr = (ArtifactDownloadReport) iterator.next();
ArtifactDownloadReport adr = iterator.next();
if (adr.getArtifact().getExtraAttribute("ivy:merged") != null) {
iterator.remove();

View File

@ -340,7 +340,7 @@ public class ResolveReport {
for (int i = 0; i < allConfs.length; i++) {
gatherExtendingConfs(extendingConfs, allConfs[i], extended);
}
return (String[]) extendingConfs.toArray(new String[extendingConfs.size()]);
return extendingConfs.toArray(new String[extendingConfs.size()]);
}
private boolean gatherExtendingConfs(Set<String> extendingConfs, String conf, String extended) {

View File

@ -698,7 +698,7 @@ public class IvyNode implements Comparable {
}
private Collection findPath(ModuleId from, IvyNode node, List path) {
IvyNode parent = (IvyNode) node.getDirectCallerFor(from);
IvyNode parent = node.getDirectCallerFor(from);
if (parent == null) {
throw new IllegalArgumentException("no path from " + from + " to " + getId() + " found");
}

View File

@ -73,8 +73,7 @@ public class IvyNodeCallers {
if (prevDepConfs != null) {
Set newDepConfs = new HashSet(Arrays.asList(prevDepConfs));
newDepConfs.addAll(Arrays.asList(dependencyConfs));
confs.put(callerConf,
(String[]) newDepConfs.toArray(new String[newDepConfs.size()]));
confs.put(callerConf, newDepConfs.toArray(new String[newDepConfs.size()]));
} else {
confs.put(callerConf, dependencyConfs);
}

View File

@ -1492,7 +1492,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
*/
private void validateAll(Collection values) {
for (Iterator iterator = values.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
Object object = iterator.next();
if (object instanceof Validatable) {
((Validatable) object).validate();
}

View File

@ -283,7 +283,7 @@ public class XmlSettingsParser extends DefaultHandler {
private void versionMatchersStarted(String qName, Map attributes) {
anyConfiguratorStarted(qName);
if ("true".equals((String) attributes.get("usedefaults"))) {
if ("true".equals(attributes.get("usedefaults"))) {
ivy.configureDefaultVersionMatcher();
}
}
@ -390,7 +390,7 @@ public class XmlSettingsParser extends DefaultHandler {
}
private void includeStarted(Map attributes) throws IOException, ParseException {
final IvyVariableContainer variables = (IvyVariableContainer) ivy.getVariableContainer();
final IvyVariableContainer variables = ivy.getVariableContainer();
ivy.setVariableContainer(new IvyVariableContainerWrapper(variables));
try {
String propFilePath = (String) attributes.get("file");

View File

@ -117,8 +117,7 @@ class ModuleInSort {
loopElements.add(stackEl);
}
elemOfLoop.add(this.module.getModuleRevisionId());
ModuleRevisionId[] mrids = (ModuleRevisionId[]) elemOfLoop
.toArray(new ModuleRevisionId[elemOfLoop.size()]);
ModuleRevisionId[] mrids = elemOfLoop.toArray(new ModuleRevisionId[elemOfLoop.size()]);
depStrategy.handleCircularDependency(mrids);
return true;
} else {

View File

@ -83,7 +83,7 @@ public class SortEngine {
(int) (list.size() * adjustFactor + nulls.size()));
// attempt to adjust the size to avoid too much list resizing
for (int i = 0; i < list.size(); i++) {
ModuleDescriptor md = (ModuleDescriptor) list.get(i);
ModuleDescriptor md = list.get(i);
List<IvyNode> n = dependenciesMap.get(md);
ret.addAll(n);
}

View File

@ -54,7 +54,7 @@ public class ExecutionEnvironmentProfileProvider {
}
public ExecutionEnvironmentProfile getProfile(String profile) {
return (ExecutionEnvironmentProfile) profileList.get(profile);
return profileList.get(profile);
}
public static Map<String, ExecutionEnvironmentProfile> loadDefaultProfileList()
@ -93,8 +93,7 @@ public class ExecutionEnvironmentProfileProvider {
// load the package for the extended profile
String extendedProfileName = props.getProperty(name + ".extends");
if (extendedProfileName != null) {
ExecutionEnvironmentProfile extendedProfile = (ExecutionEnvironmentProfile) profiles
.get(extendedProfileName);
ExecutionEnvironmentProfile extendedProfile = profiles.get(extendedProfileName);
if (extendedProfile == null) {
// not loaded yet, so load it now
extendedProfile = loadProfile(props, profiles, extendedProfileName);

View File

@ -91,22 +91,22 @@ public class ManifestHeaderElement {
String string = "";
Iterator<String> itValues = values.iterator();
while (itValues.hasNext()) {
string = string.concat((String) itValues.next());
string = string.concat(itValues.next());
if (itValues.hasNext()) {
string = string.concat(";");
}
}
for (Entry<String, String> directive : directives.entrySet()) {
string = string.concat(";");
string = string.concat((String) directive.getKey());
string = string.concat(directive.getKey());
string = string.concat(":=");
string = string.concat((String) directive.getValue());
string = string.concat(directive.getValue());
}
for (Entry<String, String> attribute : attributes.entrySet()) {
string = string.concat(";");
string = string.concat((String) attribute.getKey());
string = string.concat(attribute.getKey());
string = string.concat("=");
string = string.concat((String) attribute.getValue());
string = string.concat(attribute.getValue());
}
return string;
}

View File

@ -160,7 +160,7 @@ public class ManifestParser {
ManifestHeaderValue exportElements = new ManifestHeaderValue(
mainAttributes.getValue(EXPORT_PACKAGE));
for (ManifestHeaderElement exportElement : exportElements.getElements()) {
String vExport = (String) exportElement.getAttributes().get(ATTR_VERSION);
String vExport = exportElement.getAttributes().get(ATTR_VERSION);
Version v = null;
try {
v = versionOf(vExport);
@ -171,7 +171,7 @@ public class ManifestParser {
for (String name : exportElement.getValues()) {
ExportPackage export = new ExportPackage(name, v);
String uses = (String) exportElement.getDirectives().get(ATTR_USE);
String uses = exportElement.getDirectives().get(ATTR_USE);
if (uses != null) {
String[] split = uses.trim().split(",");
for (int i = 0; i < split.length; i++) {
@ -190,11 +190,11 @@ public class ManifestParser {
bundleInfo.setSource(true);
ManifestHeaderValue eclipseSourceBundleValue = new ManifestHeaderValue(
eclipseSourceBundle);
ManifestHeaderElement element = (ManifestHeaderElement) eclipseSourceBundleValue
.getElements().iterator().next();
String symbolicNameTarget = (String) element.getValues().iterator().next();
ManifestHeaderElement element = eclipseSourceBundleValue.getElements().iterator()
.next();
String symbolicNameTarget = element.getValues().iterator().next();
bundleInfo.setSymbolicNameTarget(symbolicNameTarget);
String v = (String) element.getAttributes().get(ATTR_VERSION);
String v = element.getAttributes().get(ATTR_VERSION);
if (v != null) {
bundleInfo.setVersionTarget(new Version(v));
}
@ -233,7 +233,7 @@ public class ManifestParser {
String headerName, String type) throws ParseException {
ManifestHeaderValue elements = new ManifestHeaderValue(mainAttributes.getValue(headerName));
for (ManifestHeaderElement element : elements.getElements()) {
String attVersion = (String) element.getAttributes().get(ATTR_VERSION);
String attVersion = element.getAttributes().get(ATTR_VERSION);
Version version = null;
try {
version = versionOf(attVersion);

View File

@ -174,8 +174,7 @@ public class OBRXMLParser {
RequirementAdapter.adapt(bundleInfo, child.requirement);
} catch (UnsupportedFilterException e) {
throw new SAXParseException("Unsupported requirement filter: "
+ ((RequireHandler) child).filter + " (" + e.getMessage() + ")",
getLocator());
+ child.filter + " (" + e.getMessage() + ")", getLocator());
} catch (ParseException e) {
throw new SAXParseException(
"Error in the requirement filter on the bundle: " + e.getMessage(),

View File

@ -447,7 +447,7 @@ public class P2MetadataParser implements XMLInputParser {
addChild(new ProvidedHandler(), new ChildElementHandler<ProvidedHandler>() {
public void childHanlded(ProvidedHandler child) {
if (child.namespace.equals("org.eclipse.equinox.p2.eclipse.type")) {
eclipseType = ((ProvidedHandler) child).name;
eclipseType = child.name;
} else {
String type = namespace2Type(child.namespace);
if (type == null) {
@ -521,12 +521,11 @@ public class P2MetadataParser implements XMLInputParser {
public void childHanlded(RequiredHandler child) {
String name = child.name;
VersionRange range = child.range;
String type = namespace2Type(((RequiredHandler) child).namespace);
String type = namespace2Type(child.namespace);
if (type == null) {
if (logLevel >= Message.MSG_DEBUG) {
Message.debug("Unsupported required capability "
+ ((RequiredHandler) child).namespace + " " + name + " "
+ range);
Message.debug("Unsupported required capability " + child.namespace
+ " " + name + " " + range);
}
} else {
String resolution = child.optional ? "optional" : null;

View File

@ -389,7 +389,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
Iterator<ModuleDescriptor> itModules = entry.getValue().iterator();
boolean moduleMatchRev = false;
while (!moduleMatchRev && itModules.hasNext()) {
ModuleDescriptor md = (ModuleDescriptor) itModules.next();
ModuleDescriptor md = itModules.next();
moduleMatchRev = rev.equals(md.getRevision());
}
if (moduleMatchRev) {
@ -404,7 +404,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
public Map[] listTokenValues(String[] tokens, Map criteria) {
Set<String> tokenSet = new HashSet<String>(Arrays.asList(tokens));
Set<Map<String, String>> listTokenValues = listTokenValues(tokenSet, criteria);
return (Map[]) listTokenValues.toArray(new Map[listTokenValues.size()]);
return listTokenValues.toArray(new Map[listTokenValues.size()]);
}
private Set<Map<String, String>> listTokenValues(Set<String> tokens,

View File

@ -99,7 +99,7 @@ public class FSManifestIterable extends AbstractFSManifestIterable<File> {
}
protected InputStream getInputStream(File f) throws FileNotFoundException {
return new FileInputStream((File) f);
return new FileInputStream(f);
}
protected List<File> listBundleFiles(File dir) {

View File

@ -46,7 +46,7 @@ public class RelativeURLRepository extends URLRepository {
public Resource getResource(String source) throws IOException {
source = encode(source);
Resource res = (Resource) resourcesCache.get(source);
Resource res = resourcesCache.get(source);
if (res == null) {
URI uri;
try {

View File

@ -46,7 +46,7 @@ public class RepositoryManifestIterable extends AbstractFSManifestIterable<Strin
}
protected URI buildBundleURI(String location) throws IOException {
Resource resource = repo.getResource((String) location);
Resource resource = repo.getResource(location);
// We have a resource to transform into an URI, let's use some heuristics
try {
return new URI(resource.getName());
@ -56,15 +56,15 @@ public class RepositoryManifestIterable extends AbstractFSManifestIterable<Strin
}
protected InputStream getInputStream(String f) throws IOException {
return repo.getResource((String) f).openStream();
return repo.getResource(f).openStream();
}
protected List<String> listBundleFiles(String dir) throws IOException {
return asList(ResolverHelper.listAll(repo, (String) dir));
return asList(ResolverHelper.listAll(repo, dir));
}
protected List<String> listDirs(String dir) throws IOException {
return asList(ResolverHelper.listAll(repo, (String) dir));
return asList(ResolverHelper.listAll(repo, dir));
}
private List<String> asList(String[] array) {

View File

@ -214,7 +214,7 @@ public class DelegatingHandler extends DefaultHandler implements DTDHandler, Con
return;
}
// time now to delegate for a new element
delegate = (DelegatingHandler) saxHandlerMapping.get(localName);
delegate = saxHandlerMapping.get(localName);
if (delegate != null) {
skipOnError(new SkipOnErrorCallback() {
public void call() throws SAXException {

View File

@ -77,6 +77,6 @@ public class ParseUtil {
list.add(sb.toString().trim());
}
return (String[]) list.toArray(new String[list.size()]);
return list.toArray(new String[list.size()]);
}
}

View File

@ -120,8 +120,7 @@ public class XmlReportParser {
if (skip) {
return;
}
MetadataArtifactDownloadReport madr = (MetadataArtifactDownloadReport) metadataReports
.get(mrid);
MetadataArtifactDownloadReport madr = metadataReports.get(mrid);
if (madr != null) {
madr.setDownloadStatus(DownloadStatus.fromString(attributes
.getValue("status")));
@ -172,7 +171,7 @@ public class XmlReportParser {
if (skip) {
return;
}
ArtifactDownloadReport aReport = (ArtifactDownloadReport) revisionArtifacts
ArtifactDownloadReport aReport = revisionArtifacts
.get(revisionArtifacts.size() - 1);
if (ArtifactOrigin.isUnknown(attributes.getValue("location"))) {
@ -299,22 +298,21 @@ public class XmlReportParser {
}
public Artifact[] getArtifacts() {
return (Artifact[]) parser.getArtifacts().toArray(
new Artifact[parser.getArtifacts().size()]);
return parser.getArtifacts().toArray(new Artifact[parser.getArtifacts().size()]);
}
public ArtifactDownloadReport[] getArtifactReports() {
return (ArtifactDownloadReport[]) parser.getArtifactReports().toArray(
return parser.getArtifactReports().toArray(
new ArtifactDownloadReport[parser.getArtifactReports().size()]);
}
public ModuleRevisionId[] getDependencyRevisionIds() {
return (ModuleRevisionId[]) parser.getModuleRevisionIds().toArray(
return parser.getModuleRevisionIds().toArray(
new ModuleRevisionId[parser.getModuleRevisionIds().size()]);
}
public ModuleRevisionId[] getRealDependencyRevisionIds() {
return (ModuleRevisionId[]) parser.getRealModuleRevisionIds().toArray(
return parser.getRealModuleRevisionIds().toArray(
new ModuleRevisionId[parser.getRealModuleRevisionIds().size()]);
}

View File

@ -154,9 +154,9 @@ public final class ChecksumHelper {
ch = (byte) (ch >>> 4); // shift the bits down
ch = (byte) (ch & 0x0F); // must do this is high order bit is on!
out.append(CHARS[(int) ch]); // convert the nibble to a String Character
out.append(CHARS[ch]); // convert the nibble to a String Character
ch = (byte) (in[i] & 0x0F); // Strip off low nibble
out.append(CHARS[(int) ch]); // convert the nibble to a String Character
out.append(CHARS[ch]); // convert the nibble to a String Character
}
// CheckStyle:MagicNumber ON

View File

@ -72,7 +72,7 @@ public final class FilterHelper {
}
Collection ret = new ArrayList(col);
for (Iterator iter = ret.iterator(); iter.hasNext();) {
Object element = (Object) iter.next();
Object element = iter.next();
if (!filter.accept(element)) {
iter.remove();
}

View File

@ -373,8 +373,8 @@ public class HttpClientHandler extends AbstractURLHandler {
throws CredentialsNotAvailableException {
String realm = scheme.getRealm();
org.apache.ivy.util.Credentials c = (org.apache.ivy.util.Credentials) CredentialsStore.INSTANCE
.getCredentials(realm, host);
org.apache.ivy.util.Credentials c = CredentialsStore.INSTANCE.getCredentials(realm,
host);
if (c != null) {
return createCredentials(c.getUserName(), c.getPasswd());
}

View File

@ -49,13 +49,13 @@ public class IvyTaskTest extends TestCase {
settings.getDefaultCache());
// The next test doesn't always works on windows (mix C: and c: drive)
assertEquals(new File("test/repositories/ivysettings.xml").getAbsolutePath().toUpperCase(),
new File((String) settings.getVariables().getVariable("ivy.settings.file"))
.getAbsolutePath().toUpperCase());
new File(settings.getVariables().getVariable("ivy.settings.file")).getAbsolutePath()
.toUpperCase());
assertEquals(new File("test/repositories/ivysettings.xml").toURI().toURL().toExternalForm()
.toUpperCase(),
((String) settings.getVariables().getVariable("ivy.settings.url")).toUpperCase());
assertEquals(new File("test/repositories").getAbsolutePath().toUpperCase(),
((String) settings.getVariables().getVariable("ivy.settings.dir")).toUpperCase());
.toUpperCase(), settings.getVariables().getVariable("ivy.settings.url")
.toUpperCase());
assertEquals(new File("test/repositories").getAbsolutePath().toUpperCase(), settings
.getVariables().getVariable("ivy.settings.dir").toUpperCase());
assertEquals("myvalue", settings.getVariables().getVariable("myproperty"));
}

View File

@ -84,8 +84,7 @@ public class UpdateSiteLoaderTest extends TestCase {
// check that the url of the artifact is correctly resolved
String path = new File("test/test-p2/ivyde-repo/").toURI().toURL().toExternalForm();
ModuleDescriptor md = ((ModuleDescriptorWrapper) site.getModules().next())
.getModuleDescriptor();
ModuleDescriptor md = site.getModules().next().getModuleDescriptor();
assertTrue(md.getAllArtifacts()[0].getUrl().toExternalForm().startsWith(path));
}
}