From 6352c4ac1c23080a7d0a9b214272a89ac11d3ab7 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Sat, 26 Jan 2008 14:22:48 +0000 Subject: [PATCH] checkstyle git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@615452 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/FixCRLF.java | 19 ++++++++++----- .../taskdefs/optional/testing/Funtest.java | 4 +++- .../ant/taskdefs/optional/unix/Symlink.java | 2 +- .../resources/AbstractClasspathResource.java | 23 +++++++++++++------ .../types/resources/JavaConstantResource.java | 23 +++++++++++-------- .../ant/types/resources/JavaResource.java | 14 +++++------ .../org/apache/tools/ant/util/FileUtils.java | 18 +++++++-------- 7 files changed, 62 insertions(+), 41 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index 8b95ddfa9..f110e4b54 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -86,7 +86,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { private static final String FIXCRLF_ERROR = " error: "; /** error string for using srcdir and file */ public static final String ERROR_FILE_AND_SRCDIR - =FIXCRLF_ERROR+"srcdir and file are mutually exclusive"; + = FIXCRLF_ERROR + "srcdir and file are mutually exclusive"; private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); @@ -314,20 +314,27 @@ public class FixCRLF extends MatchingTask implements ChainableReader { srcDir = file.getParentFile(); } if (srcDir == null) { - throw new BuildException(FIXCRLF_ERROR +"srcdir attribute must be set!"); + throw new BuildException( + FIXCRLF_ERROR + "srcdir attribute must be set!"); } if (!srcDir.exists()) { - throw new BuildException(FIXCRLF_ERROR +"srcdir does not exist: '"+srcDir+"'"); + throw new BuildException( + FIXCRLF_ERROR + "srcdir does not exist: '" + srcDir + "'"); } if (!srcDir.isDirectory()) { - throw new BuildException(FIXCRLF_ERROR +"srcdir is not a directory: '"+srcDir+"'"); + throw new BuildException( + FIXCRLF_ERROR + "srcdir is not a directory: '" + srcDir + "'"); } if (destDir != null) { if (!destDir.exists()) { - throw new BuildException(FIXCRLF_ERROR +"destdir does not exist: '" + destDir + "'"); + throw new BuildException( + FIXCRLF_ERROR + "destdir does not exist: '" + + destDir + "'"); } if (!destDir.isDirectory()) { - throw new BuildException(FIXCRLF_ERROR +"destdir is not a directory: '" + destDir + "'"); + throw new BuildException( + FIXCRLF_ERROR + "destdir is not a directory: '" + + destDir + "'"); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java b/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java index 9421cc8b3..c0fa13565 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/testing/Funtest.java @@ -165,7 +165,9 @@ public class Funtest extends Task { /** {@value} */ public static final String SKIPPING_TESTS = "Condition failed -skipping tests"; + /** Application exception */ public static final String APPLICATION_EXCEPTION = "Application Exception"; + /** Teardown exception */ public static final String TEARDOWN_EXCEPTION = "Teardown Exception"; /** @@ -533,7 +535,7 @@ public class Funtest extends Task { * @param thrown what was thrown */ protected void ignoringThrowable(String type, Throwable thrown) { - log(type + ": "+ thrown.toString(), + log(type + ": " + thrown.toString(), thrown, Project.MSG_WARN); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java index d594f7bc1..9cd296746 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java @@ -502,7 +502,7 @@ public class Symlink extends DispatchTask { try { Execute.runCommand(this, cmd); } catch (BuildException failedToExecute) { - if(failonerror) { + if (failonerror) { throw failedToExecute; } else { //log at the info level, and keep going. diff --git a/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java b/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java index e2a944eca..79f9eb4b7 100644 --- a/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java +++ b/src/main/org/apache/tools/ant/types/resources/AbstractClasspathResource.java @@ -1,9 +1,10 @@ /* - * Copyright 2007 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -33,8 +34,8 @@ import java.io.IOException; */ public abstract class AbstractClasspathResource extends Resource { - protected Path classpath; - protected Reference loader; + private Path classpath; + private Reference loader; /** * Set the classpath to use when looking up a resource. @@ -80,6 +81,14 @@ public abstract class AbstractClasspathResource extends Resource { ? ((JavaResource) getCheckedRef()).getClasspath() : classpath; } + /** + * Get the loader. + * @return the loader. + */ + public Reference getLoader() { + return loader; + } + /** * Use the reference to locate the loader. If the loader is not * found, taskdef will use the specified classpath and register it diff --git a/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java b/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java index 57f8dfa93..6a22073ee 100644 --- a/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java +++ b/src/main/org/apache/tools/ant/types/resources/JavaConstantResource.java @@ -1,9 +1,10 @@ /* - * Copyright 2008 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -47,14 +48,18 @@ public class JavaConstantResource extends AbstractClasspathResource { String classname = constant.substring(0, index); String fieldname = constant.substring(index + 1, constant.length()); try { - clazz = cl!=null?Class.forName(classname,true,cl):Class.forName(classname); + clazz = + cl != null + ? Class.forName(classname, true, cl) + : Class.forName(classname); Field field = clazz.getField(fieldname); - String value=field.get(null).toString(); + String value = field.get(null).toString(); return new ByteArrayInputStream(value.getBytes("UTF-8")); } catch (ClassNotFoundException e) { - throw new IOException("Class not found:"+ classname); + throw new IOException("Class not found:" + classname); } catch (NoSuchFieldException e) { - throw new IOException("Field not found:" + fieldname+ " in "+classname); + throw new IOException( + "Field not found:" + fieldname + " in " + classname); } catch (IllegalAccessException e) { throw new IOException("Illegal access to :" + fieldname + " in " + classname); } catch (NullPointerException npe) { diff --git a/src/main/org/apache/tools/ant/types/resources/JavaResource.java b/src/main/org/apache/tools/ant/types/resources/JavaResource.java index 45b7bb070..13fd88be8 100644 --- a/src/main/org/apache/tools/ant/types/resources/JavaResource.java +++ b/src/main/org/apache/tools/ant/types/resources/JavaResource.java @@ -20,10 +20,7 @@ package org.apache.tools.ant.types.resources; import java.io.IOException; import java.io.InputStream; -import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.Reference; /** * A Resource representation of something loadable via a Java classloader. @@ -46,7 +43,7 @@ public class JavaResource extends AbstractClasspathResource { */ public JavaResource(String name, Path path) { setName(name); - classpath = path; + setClasspath(path); } /** @@ -76,14 +73,15 @@ public class JavaResource extends AbstractClasspathResource { if (!getName().equals(otherjr.getName())) { return getName().compareTo(otherjr.getName()); } - if (loader != otherjr.loader) { - if (loader == null) { + if (getLoader() != otherjr.getLoader()) { + if (getLoader() == null) { return -1; } - if (otherjr.loader == null) { + if (otherjr.getLoader() == null) { return 1; } - return loader.getRefId().compareTo(otherjr.loader.getRefId()); + return getLoader().getRefId() + .compareTo(otherjr.getLoader().getRefId()); } Path p = getClasspath(); Path op = otherjr.getClasspath(); diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java index 539adf37e..a5f696987 100644 --- a/src/main/org/apache/tools/ant/util/FileUtils.java +++ b/src/main/org/apache/tools/ant/util/FileUtils.java @@ -786,7 +786,7 @@ public class FileUtils { /** * Create a File object for a temporary file in a given directory. Without * actually creating the file. - * + * *

* The file denoted by the returned abstract pathname did not exist before * this method was invoked, any subsequent invocation of this method will @@ -795,7 +795,7 @@ public class FileUtils { *

* The filename is prefixNNNNNsuffix where NNNN is a random number. *

- * + * * @param prefix * prefix before the random number. * @param suffix @@ -803,8 +803,8 @@ public class FileUtils { * @param parentDir * Directory to create the temporary file in; java.io.tmpdir used * if not specified. - * - * @deprecated since ant 1.7.1 use createTempFile(String, String, File, + * + * @deprecated since ant 1.7.1 use createTempFile(String, String, File, * boolean, boolean) instead. * @return a File reference to the new, nonexistent temporary file. */ @@ -836,7 +836,7 @@ public class FileUtils { public File createTempFile(String prefix, String suffix, File parentDir, boolean deleteOnExit, boolean createFile) { File result = null; - String parent = (parentDir == null) + String parent = (parentDir == null) ? System.getProperty("java.io.tmpdir") : parentDir.getPath(); @@ -866,7 +866,7 @@ public class FileUtils { /** * Create a File object for a temporary file in a given directory. Without * actually creating the file. - * + * *

* The file denoted by the returned abstract pathname did not exist before * this method was invoked, any subsequent invocation of this method will @@ -875,7 +875,7 @@ public class FileUtils { *

* The filename is prefixNNNNNsuffix where NNNN is a random number. *

- * + * * @param prefix * prefix before the random number. * @param suffix @@ -885,8 +885,8 @@ public class FileUtils { * if not specified. * @param deleteOnExit * whether to set the tempfile for deletion on normal VM exit. - * - * @deprecated since ant 1.7.1 use createTempFile(String, String, File, + * + * @deprecated since ant 1.7.1 use createTempFile(String, String, File, * boolean, boolean) instead. * @return a File reference to the new, nonexistent temporary file. */