Author: xavier
Date: Thu Jan 3 01:03:58 2008
New Revision: 608384
URL: http://svn.apache.org/viewvc?rev=608384&view=rev
Log:
clean code: apply patch from Markus M. May (IVY-511)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/example/configurations/multi-projects/myapp/src/myapp/Main.java
ant/ivy/core/trunk/src/example/multi-project/projects/find/src/find/Main.java
ant/ivy/core/trunk/src/example/multi-project/projects/version/src/version/Version.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/BasicResource.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
ant/ivy/core/trunk/src/java/org/apache/ivy/util/HostUtil.java
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Jan 3 01:03:58 2008
@@ -35,6 +35,7 @@
Antoine Levy-Lambert
William Lyvers
Jan Materne
+ Markus M. May
Stephen Nesbitt
Joshua Nichols
Bernard Niset
@@ -71,6 +72,8 @@
- FIX: Maven test scope includes all runtime dependencies (IVY-682)
- TASK: Remove cache attribute on Ant tasks (IVY-685)
+
+- Improvement in coding conventions (IVY-511) (with contribution from Markus
M. May)
2.0.0-beta1
=====================================
Modified:
ant/ivy/core/trunk/src/example/configurations/multi-projects/myapp/src/myapp/Main.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/example/configurations/multi-projects/myapp/src/myapp/Main.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/example/configurations/multi-projects/myapp/src/myapp/Main.java
(original)
+++
ant/ivy/core/trunk/src/example/configurations/multi-projects/myapp/src/myapp/Main.java
Thu Jan 3 01:03:58 2008
@@ -24,10 +24,10 @@
public class Main {
public static void main(String[] args) {
- String toFilter[] = new String[]{"one", "two", "tree", "four"};
+ String[] toFilter = new String[]{"one", "two", "tree", "four"};
IFilter filter = FilterProvider.getFilter();
System.out.println("Filtering with:"+filter.getClass());
- String filtered[] = filter.filter(toFilter, "t");
+ String[] filtered = filter.filter(toFilter, "t");
System.out.println("Result :"+Arrays.asList(filtered));
}
}
Modified:
ant/ivy/core/trunk/src/example/multi-project/projects/find/src/find/Main.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/example/multi-project/projects/find/src/find/Main.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/example/multi-project/projects/find/src/find/Main.java
(original)
+++
ant/ivy/core/trunk/src/example/multi-project/projects/find/src/find/Main.java
Thu Jan 3 01:03:58 2008
@@ -32,14 +32,14 @@
public class Main {
private static Options getOptions() {
- Option dir = OptionBuilder.withArgName( "dir" )
+ Option dir = OptionBuilder.withArgName("dir")
.hasArg()
- .withDescription( "list files in given dir" )
- .create( "dir" );
- Option name = OptionBuilder.withArgName( "name" )
+ .withDescription("list files in given dir")
+ .create("dir");
+ Option name = OptionBuilder.withArgName("name")
.hasArg()
- .withDescription( "list files with given name" )
- .create( "name" );
+ .withDescription("list files with given name")
+ .create("name");
Options options = new Options();
options.addOption(dir);
@@ -49,26 +49,26 @@
}
public static void main(String[] args) throws Exception {
- Options options = getOptions();
- try {
+ Options options = getOptions();
+ try {
- CommandLineParser parser = new GnuParser();
-
- CommandLine line = parser.parse( options, args );
- File dir = new File(line.getOptionValue("dir", "."));
- String name = line.getOptionValue("name", "jar");
- Collection files = FindFile.find(dir, name);
- System.out.println("listing files in "+dir+" containing "+name);
- for (Iterator it = files.iterator(); it.hasNext(); ) {
- System.out.println("\t"+it.next()+"\n");
- }
- } catch( ParseException exp ) {
- // oops, something went wrong
- System.err.println( "Parsing failed. Reason: " + exp.getMessage() );
-
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "find", options );
- }
+ CommandLineParser parser = new GnuParser();
+
+ CommandLine line = parser.parse(options, args);
+ File dir = new File(line.getOptionValue("dir", "."));
+ String name = line.getOptionValue("name", "jar");
+ Collection files = FindFile.find(dir, name);
+ System.out.println("listing files in " + dir + " containing " +
name);
+ for (Iterator it = files.iterator(); it.hasNext();) {
+ System.out.println("\t" + it.next() + "\n");
+ }
+ } catch(ParseException exp) {
+ // oops, something went wrong
+ System.err.println("Parsing failed. Reason: " + exp.getMessage());
+
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("find", options);
+ }
}
}
Modified:
ant/ivy/core/trunk/src/example/multi-project/projects/version/src/version/Version.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/example/multi-project/projects/version/src/version/Version.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/example/multi-project/projects/version/src/version/Version.java
(original)
+++
ant/ivy/core/trunk/src/example/multi-project/projects/version/src/version/Version.java
Thu Jan 3 01:03:58 2008
@@ -23,24 +23,24 @@
import java.util.HashMap;
public class Version {
- static {
- versions = new HashMap();
- register("version");
- }
+ static {
+ versions = new HashMap();
+ register("version");
+ }
- private static Map versions;
+ private static Map versions;
- public static void register(String module) {
- try {
- InputStream moduleVersion =
Version.class.getResourceAsStream("/"+module+".properties");
- Properties props = new Properties();
- props.load(moduleVersion);
- String version = (String)props.get("version");
- versions.put(module, version);
- System.out.println("--- using "+module+" v"+version);
- } catch (Exception ex) {
- System.err.println("an error occured while registering "+module+":
"+ex.getMessage());
- ex.printStackTrace();
+ public static void register(String module) {
+ try {
+ InputStream moduleVersion =
Version.class.getResourceAsStream("/"+module+".properties");
+ Properties props = new Properties();
+ props.load(moduleVersion);
+ String version = (String)props.get("version");
+ versions.put(module, version);
+ System.out.println("--- using "+module+" v"+version);
+ } catch (Exception ex) {
+ System.err.println("an error occured while registering "+module+":
"+ex.getMessage());
+ ex.printStackTrace();
+ }
}
- }
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/BasicResource.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/BasicResource.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/BasicResource.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/BasicResource.java
Thu Jan 3 01:03:58 2008
@@ -21,23 +21,23 @@
import java.io.InputStream;
public class BasicResource implements Resource {
- private boolean _local;
+ private boolean local;
- private String _name;
+ private String name;
- private long _lastModified;
+ private long lastModified;
- private long _contentLength;
+ private long contentLength;
- private boolean _exists;
+ private boolean exists;
public BasicResource(String name, boolean exists, long contentLength, long
lastModified,
boolean local) {
- _name = name;
- _exists = exists;
- _contentLength = contentLength;
- _lastModified = lastModified;
- _local = local;
+ this.name = name;
+ this.exists = exists;
+ this.contentLength = contentLength;
+ this.lastModified = lastModified;
+ this.local = local;
}
public Resource clone(String cloneName) {
@@ -45,23 +45,23 @@
}
public boolean exists() {
- return _exists;
+ return this.exists;
}
public long getContentLength() {
- return _contentLength;
+ return this.contentLength;
}
public long getLastModified() {
- return _lastModified;
+ return this.lastModified;
}
public String getName() {
- return _name;
+ return this.name;
}
public boolean isLocal() {
- return _local;
+ return this.local;
}
public InputStream openStream() throws IOException {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
Thu Jan 3 01:03:58 2008
@@ -120,7 +120,7 @@
String srcName = index == -1 ? source : source.substring(index +
1);
final File to = destDir == null ? new File(srcName) : new
File(destDir, srcName);
- final IOException ex[] = new IOException[1];
+ final IOException[] ex = new IOException[1];
Thread get = new IvyThread() {
public void run() {
initContext();
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/HostUtil.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/HostUtil.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/HostUtil.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/HostUtil.java Thu Jan 3
01:03:58 2008
@@ -20,7 +20,22 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
+/**
+ * This class contains basic helper methods for the Host.
+ *
+ */
public class HostUtil {
+ /**
+ * This default constructor is to hide this class from initialization
through other classes.
+ */
+ private HostUtil() {}
+
+ /**
+ * This method returns the name of the current Host, if this name cannot
be determined,
+ * localhost will be returned.
+ *
+ * @return The name of the current "local" Host.
+ */
public static String getLocalHostName() {
try {
return InetAddress.getLocalHost().getHostName();
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java?rev=608384&r1=608383&r2=608384&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/BasicURLHandler.java
Thu Jan 3 01:03:58 2008
@@ -32,7 +32,7 @@
import org.apache.ivy.util.Message;
/**
- *
+ *
*/
public class BasicURLHandler extends AbstractURLHandler {