You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jl...@apache.org on 2014/01/14 09:27:43 UTC
svn commit: r1557968 [16/26] - in /ant/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver/
src...
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java Tue Jan 14 08:27:37 2014
@@ -46,8 +46,8 @@ public class JarJarDependencyAnalyser im
for (int i = 0; i < modules.length; i++) {
jarModulesMap.put(modules[i].getJar().getAbsolutePath(), modules[i]);
- DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(modules[i]
- .getMrid(), new Date(modules[i].getJar().lastModified()));
+ DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(
+ modules[i].getMrid(), new Date(modules[i].getJar().lastModified()));
mds.put(modules[i].getMrid(), md);
jarjarCmd.append("\"").append(modules[i].getJar().getAbsolutePath()).append("\"");
if (i + 1 < modules.length) {
@@ -73,8 +73,8 @@ public class JarJarDependencyAnalyser im
DefaultModuleDescriptor md = (DefaultModuleDescriptor) mds.get(module.getMrid());
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, dependency
- .getMrid(), false, false, true);
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
+ dependency.getMrid(), false, false, true);
dd.addDependencyConfiguration(ModuleDescriptor.DEFAULT_CONFIGURATION,
ModuleDescriptor.DEFAULT_CONFIGURATION);
md.addDependency(dd);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/RepositoryAnalyser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/RepositoryAnalyser.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/RepositoryAnalyser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/RepositoryAnalyser.java Tue Jan 14 08:27:37 2014
@@ -32,8 +32,10 @@ public class RepositoryAnalyser {
ModuleDescriptor[] mds = depAnalyser.analyze(finder.findJarModules());
Message.info("found " + mds.length + " modules");
for (int i = 0; i < mds.length; i++) {
- File ivyFile = new File(IvyPatternHelper.substitute(pattern, DefaultArtifact
- .newIvyArtifact(mds[i].getModuleRevisionId(), mds[i].getPublicationDate())));
+ File ivyFile = new File(IvyPatternHelper.substitute(
+ pattern,
+ DefaultArtifact.newIvyArtifact(mds[i].getModuleRevisionId(),
+ mds[i].getPublicationDate())));
try {
Message.info("generating " + ivyFile);
XmlModuleDescriptorWriter.write(mds[i], ivyFile);
@@ -45,8 +47,8 @@ public class RepositoryAnalyser {
public static void main(String[] args) {
if (args.length != 2) {
- System.out.println(
- "usage: ivyanalyser path/to/jarjar.jar absolute-ivy-repository-pattern");
+ System.out
+ .println("usage: ivyanalyser path/to/jarjar.jar absolute-ivy-repository-pattern");
return;
}
String jarjarLocation = args[0];
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/AbstractMessageLogger.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/AbstractMessageLogger.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/AbstractMessageLogger.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/AbstractMessageLogger.java Tue Jan 14 08:27:37 2014
@@ -31,44 +31,55 @@ public abstract class AbstractMessageLog
private List errors = new ArrayList();
private boolean showProgress = true;
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#debug(java.lang.String)
*/
public void debug(String msg) {
log(msg, Message.MSG_DEBUG);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#verbose(java.lang.String)
*/
public void verbose(String msg) {
log(msg, Message.MSG_VERBOSE);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#deprecated(java.lang.String)
*/
public void deprecated(String msg) {
log("DEPRECATED: " + msg, Message.MSG_WARN);
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#info(java.lang.String)
*/
public void info(String msg) {
log(msg, Message.MSG_INFO);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#info(java.lang.String)
*/
public void rawinfo(String msg) {
rawlog(msg, Message.MSG_INFO);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#warn(java.lang.String)
*/
public void warn(String msg) {
@@ -77,7 +88,9 @@ public abstract class AbstractMessageLog
getWarns().add(msg);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#error(java.lang.String)
*/
public void error(String msg) {
@@ -88,14 +101,18 @@ public abstract class AbstractMessageLog
getErrors().add(msg);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#getProblems()
*/
public List getProblems() {
return problems;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#sumupProblems()
*/
public void sumupProblems() {
@@ -117,7 +134,9 @@ public abstract class AbstractMessageLog
return warns;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#progress()
*/
public void progress() {
@@ -126,15 +145,18 @@ public abstract class AbstractMessageLog
}
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#endProgress()
*/
public void endProgress() {
endProgress("");
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#endProgress(java.lang.String)
*/
public void endProgress(String msg) {
@@ -143,15 +165,18 @@ public abstract class AbstractMessageLog
}
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#isShowProgress()
*/
public boolean isShowProgress() {
return showProgress;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ivy.util.MessageLogger#setShowProgress(boolean)
*/
public void setShowProgress(boolean progress) {
@@ -162,9 +187,12 @@ public abstract class AbstractMessageLog
* Indicates a progression for a long running task
*/
protected abstract void doProgress();
+
/**
* Indicates the end of a long running task
- * @param msg the message associated with long running task end.
+ *
+ * @param msg
+ * the message associated with long running task end.
*/
protected abstract void doEndProgress(String msg);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/Checks.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/Checks.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/Checks.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/Checks.java Tue Jan 14 08:27:37 2014
@@ -25,7 +25,7 @@ import java.io.File;
public final class Checks {
private Checks() {
}
-
+
/**
* Checks that an object is not null, and throw an exception if the object is null.
*
@@ -49,7 +49,7 @@ public final class Checks {
}
return FileUtil.normalize(f.getPath());
}
-
+
public static File checkAbsolute(String path, String fileName) {
checkNotNull(path, fileName);
File f = new File(path);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/ChecksumHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/ChecksumHelper.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/ChecksumHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/ChecksumHelper.java Tue Jan 14 08:27:37 2014
@@ -32,6 +32,7 @@ import java.util.Map;
public final class ChecksumHelper {
private static final int BUFFER_SIZE = 2048;
+
private static Map algorithms = new HashMap();
static {
algorithms.put("md5", "MD5");
@@ -52,8 +53,9 @@ public final class ChecksumHelper {
* if an IO problem occur whle reading files or if the checksum is not compliant
*/
public static void check(File dest, File checksumFile, String algorithm) throws IOException {
- String csFileContent = FileUtil.readEntirely(
- new BufferedReader(new FileReader(checksumFile))).trim().toLowerCase(Locale.US);
+ String csFileContent = FileUtil
+ .readEntirely(new BufferedReader(new FileReader(checksumFile))).trim()
+ .toLowerCase(Locale.US);
String expected;
if (csFileContent.indexOf(' ') > -1
&& (csFileContent.startsWith("md") || csFileContent.startsWith("sha"))) {
@@ -63,7 +65,7 @@ public final class ChecksumHelper {
int spaceIndex = csFileContent.indexOf(' ');
if (spaceIndex != -1) {
expected = csFileContent.substring(0, spaceIndex);
-
+
// IVY-1155: support some strange formats like this one:
// http://repo2.maven.org/maven2/org/apache/pdfbox/fontbox/0.8.0-incubator/fontbox-0.8.0-incubator.jar.md5
if (expected.endsWith(":")) {
@@ -80,7 +82,7 @@ public final class ChecksumHelper {
expected = csFileContent;
}
}
-
+
String computed = computeAsString(dest, algorithm).trim().toLowerCase(Locale.US);
if (!expected.equals(computed)) {
throw new IOException("invalid " + algorithm + ": expected=" + expected + " computed="
@@ -113,7 +115,7 @@ public final class ChecksumHelper {
public static boolean isKnownAlgorithm(String algorithm) {
return algorithms.containsKey(algorithm);
}
-
+
private static MessageDigest getMessageDigest(String algorithm) {
String mdAlgorithm = (String) algorithms.get(algorithm);
if (mdAlgorithm == null) {
@@ -127,8 +129,8 @@ public final class ChecksumHelper {
}
// byte to hex string converter
- private static final char[] CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'a', 'b', 'c', 'd', 'e', 'f'};
+ private static final char[] CHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a',
+ 'b', 'c', 'd', 'e', 'f'};
/**
* Convert a byte[] array to readable string format. This makes the "hex" readable!
@@ -146,7 +148,7 @@ public final class ChecksumHelper {
StringBuffer out = new StringBuffer(in.length * 2);
- //CheckStyle:MagicNumber OFF
+ // CheckStyle:MagicNumber OFF
for (int i = 0; i < in.length; i++) {
ch = (byte) (in[i] & 0xF0); // Strip off high nibble
ch = (byte) (ch >>> 4); // shift the bits down
@@ -156,7 +158,7 @@ public final class ChecksumHelper {
ch = (byte) (in[i] & 0x0F); // Strip off low nibble
out.append(CHARS[(int) ch]); // convert the nibble to a String Character
}
- //CheckStyle:MagicNumber ON
+ // CheckStyle:MagicNumber ON
return out.toString();
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/ConfigurationUtils.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/ConfigurationUtils.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/ConfigurationUtils.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/ConfigurationUtils.java Tue Jan 14 08:27:37 2014
@@ -43,12 +43,12 @@ public final class ConfigurationUtils {
*
* The supported wildcards are:
* <ul>
- * <li><b><tt>*</tt> :</b> all configurations</li>
- * <li><b><tt>*(public)</tt> :</b> all public configurations</li>
- * <li><b><tt>*(private)</tt> :</b> all private configurations</li>
+ * <li><b><tt>*</tt> :</b> all configurations</li>
+ * <li><b><tt>*(public)</tt> :</b> all public configurations</li>
+ * <li><b><tt>*(private)</tt> :</b> all private configurations</li>
* </ul>
- * If the given array of configurations is <code>null</code>, all configurations
- * from the given module descriptor are returned, including if this array is empty.
+ * If the given array of configurations is <code>null</code>, all configurations from the given
+ * module descriptor are returned, including if this array is empty.
*
* @param confs
* the configurations, can contain wildcards
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java Tue Jan 14 08:27:37 2014
@@ -33,25 +33,26 @@ import java.util.Stack;
import org.apache.ivy.core.IvyPatternHelper;
/**
- * Ant 1.6.1 like Configurator
+ * Ant 1.6.1 like Configurator
* <p>
- * This configurator is used to configure elements (initialised with
- * setRoot) using the behaviour defined by ant for its tasks.
+ * This configurator is used to configure elements (initialised with setRoot) using the behaviour
+ * defined by ant for its tasks.
* <p>
- * Example (based on <a
- * href="http://ant.apache.org/manual/develop.html#writingowntask">Ant Example</a>):
+ * Example (based on <a href="http://ant.apache.org/manual/develop.html#writingowntask">Ant
+ * Example</a>):
+ *
* <pre>
- * Configurator conf = new Configurator();
- * conf.typeDef("buildpath", "Sample$BuildPath");
- * conf.typeDef("xinterface", "Sample$XInterface");
- * Sample.MyFileSelector mfs = new Sample.MyFileSelector();
- * conf.setRoot(mfs);
- * conf.startCreateChild("buildpath");
- * conf.setAttribute("path", ".");
- * conf.setAttribute("url", "abc");
- * conf.startCreateChild("xinterface");
- * conf.setAttribute("count", "4");
- * conf.endCreateChild(); // xinterface
+ * Configurator conf = new Configurator();
+ * conf.typeDef("buildpath", "Sample$BuildPath");
+ * conf.typeDef("xinterface", "Sample$XInterface");
+ * Sample.MyFileSelector mfs = new Sample.MyFileSelector();
+ * conf.setRoot(mfs);
+ * conf.startCreateChild("buildpath");
+ * conf.setAttribute("path", ".");
+ * conf.setAttribute("url", "abc");
+ * conf.startCreateChild("xinterface");
+ * conf.setAttribute("count", "4");
+ * conf.endCreateChild(); // xinterface
* conf.endCreateChild(); // buildpath
* </pre>
*/
@@ -162,7 +163,7 @@ public class Configurator {
children.add(child);
return child;
}
-
+
public MacroRecord recordChild(String name, Object object) {
MacroRecord child = recordChild(name);
child.object = object;
@@ -327,8 +328,7 @@ public class Configurator {
}
addCreateMethod(name, m);
} else if (m.getName().startsWith("addConfigured")
- && m.getParameterTypes().length == 1
- && Void.TYPE.equals(m.getReturnType())) {
+ && m.getParameterTypes().length == 1 && Void.TYPE.equals(m.getReturnType())) {
String name = StringUtils.uncapitalize(m.getName().substring(
"addConfigured".length()));
if (name.length() == 0) {
@@ -337,8 +337,7 @@ public class Configurator {
addAddConfiguredMethod(name, m);
} else if (m.getName().startsWith("add")
&& !m.getName().startsWith("addConfigured")
- && m.getParameterTypes().length == 1
- && Void.TYPE.equals(m.getReturnType())) {
+ && m.getParameterTypes().length == 1 && Void.TYPE.equals(m.getReturnType())) {
String name = StringUtils.uncapitalize(m.getName().substring("add".length()));
if (name.length() == 0) {
addAddMethod(m);
@@ -378,7 +377,7 @@ public class Configurator {
public void addSetMethod(String name, Method m) {
Method current = (Method) setMethods.get(name);
if (current != null && current.getParameterTypes()[0] == String.class) {
- // setter methods with String attribute take precedence
+ // setter methods with String attribute take precedence
return;
}
setMethods.put(name, m);
@@ -430,7 +429,7 @@ public class Configurator {
return objName;
}
}
-
+
private FileResolver fileResolver = FileResolver.DEFAULT;
private Map typedefs = new HashMap();
@@ -619,7 +618,7 @@ public class Configurator {
if (od.getObject() instanceof Map) {
((Map) od.getObject()).put(attributeName, value);
return;
- }
+ }
throw new IllegalArgumentException("no set method found for " + attributeName + " on "
+ od.getObject().getClass());
}
@@ -641,8 +640,8 @@ public class Configurator {
} else if (paramClass.equals(Class.class)) {
convertedValue = Class.forName(value);
} else if (paramClass.equals(File.class)) {
- convertedValue = fileResolver.resolveFile(
- value, od.getObjectName() + "." + attributeName);
+ convertedValue = fileResolver.resolveFile(value, od.getObjectName() + "."
+ + attributeName);
} else {
convertedValue = paramClass.getConstructor(new Class[] {String.class}).newInstance(
new Object[] {value});
@@ -670,8 +669,8 @@ public class Configurator {
}
ObjectDescriptor od = (ObjectDescriptor) objectStack.peek();
try {
- od.getObject().getClass().getMethod("addText", new Class[] {String.class}).invoke(
- od.getObject(), new Object[] {text});
+ od.getObject().getClass().getMethod("addText", new Class[] {String.class})
+ .invoke(od.getObject(), new Object[] {text});
} catch (Exception ex) {
IllegalArgumentException iae = new IllegalArgumentException(
"impossible to add text on " + od.getObject().getClass());
@@ -712,8 +711,8 @@ public class Configurator {
} catch (Exception ex) {
IllegalArgumentException iae = new IllegalArgumentException(
"impossible to add configured child for " + name + " on "
- + parentOD.getObject().getClass()
- + ": " + StringUtils.getErrorMessage(ex));
+ + parentOD.getObject().getClass() + ": "
+ + StringUtils.getErrorMessage(ex));
iae.initCause(ex);
throw iae;
}
@@ -753,11 +752,11 @@ public class Configurator {
public Class getTypeDef(String name) {
return (Class) typedefs.get(name);
}
-
+
public FileResolver getFileResolver() {
return fileResolver;
}
-
+
public void setFileResolver(FileResolver fileResolver) {
Checks.checkNotNull(fileResolver, "fileResolver");
this.fileResolver = fileResolver;
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/ContextualSAXHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/ContextualSAXHandler.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/ContextualSAXHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/ContextualSAXHandler.java Tue Jan 14 08:27:37 2014
@@ -27,7 +27,7 @@ import org.xml.sax.helpers.DefaultHandle
public class ContextualSAXHandler extends DefaultHandler {
private Stack contextStack = new Stack();
-
+
private StringBuffer buffer = new StringBuffer();
public void characters(char[] ch, int start, int length) throws SAXException {
@@ -45,7 +45,6 @@ public class ContextualSAXHandler extend
buffer.setLength(0);
}
-
protected String getContext() {
StringBuffer buf = new StringBuffer();
for (Iterator iter = contextStack.iterator(); iter.hasNext();) {
@@ -57,7 +56,7 @@ public class ContextualSAXHandler extend
}
return buf.toString();
}
-
+
protected String getText() {
return buffer.toString();
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/DateUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/DateUtil.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/DateUtil.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/DateUtil.java Tue Jan 14 08:27:37 2014
@@ -22,18 +22,18 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtil {
-
+
private DateUtil() {
- //Utility class
+ // Utility class
}
-
+
public static final String DATE_FORMAT_PATTERN = "yyyyMMddHHmmss";
-
+
public static String format(Date date) {
SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_PATTERN);
return format.format(date);
}
-
+
public static Date parse(String date) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_PATTERN);
return format.parse(date);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileResolver.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileResolver.java Tue Jan 14 08:27:37 2014
@@ -25,7 +25,7 @@ public interface FileResolver {
return new File(path);
}
};
-
+
/**
* Return the canonical form of a path, or raise an {@link IllegalArgumentException} if the path
* is not valid for this {@link FileResolver}.
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/FileUtil.java Tue Jan 14 08:27:37 2014
@@ -44,11 +44,11 @@ import org.apache.ivy.util.url.URLHandle
* Utility class used to deal with file related operations, like copy, full reading, symlink, ...
*/
public final class FileUtil {
-
+
private FileUtil() {
- //Utility class
+ // Utility class
}
-
+
// according to tests by users, 64kB seems to be a good value for the buffer used during copy
// further improvements could be obtained using NIO API
private static final int BUFFER_SIZE = 64 * 1024;
@@ -57,7 +57,8 @@ public final class FileUtil {
private static final Pattern ALLOWED_PATH_PATTERN = Pattern.compile("[\\w-./\\\\:~ %\\(\\)]+");
- public static void symlinkInMass(Map/* <File, File> */destToSrcMap, boolean overwrite) throws IOException {
+ public static void symlinkInMass(Map/* <File, File> */destToSrcMap, boolean overwrite)
+ throws IOException {
// This pattern could be more forgiving if somebody wanted it to be...
// ...but this should satisfy 99+% of all needs, without letting unsafe operations be done.
@@ -70,7 +71,7 @@ public final class FileUtil {
Iterator keyItr = destToSrcMap.entrySet().iterator();
while (keyItr.hasNext()) {
- Entry/*<File, File>*/ entry = (Entry) keyItr.next();
+ Entry/* <File, File> */entry = (Entry) keyItr.next();
File destFile = (File) entry.getKey();
File srcFile = (File) entry.getValue();
if (!ALLOWED_PATH_PATTERN.matcher(srcFile.getAbsolutePath()).matches()) {
@@ -83,7 +84,8 @@ public final class FileUtil {
}
// Add to our buffer of commands
- sb.append("ln -s -f \"" + srcFile.getAbsolutePath() + "\" \"" + destFile.getAbsolutePath() + "\";");
+ sb.append("ln -s -f \"" + srcFile.getAbsolutePath() + "\" \""
+ + destFile.getAbsolutePath() + "\";");
if (keyItr.hasNext()) {
sb.append("\n");
}
@@ -144,16 +146,16 @@ public final class FileUtil {
throw new IOException("error symlinking " + src + " to " + dest + ":\n" + error);
}
-
+
// check if the creation of the symbolic link was successful
if (!dest.exists()) {
throw new IOException("error symlinking: " + dest + " doesn't exists");
}
-
+
// check if the result is a true symbolic link
if (dest.getAbsolutePath().equals(dest.getCanonicalPath())) {
dest.delete(); // just make sure we do delete the invalid symlink!
- throw new IOException("error symlinking: " + dest + " isn't a symlink");
+ throw new IOException("error symlinking: " + dest + " isn't a symlink");
}
} catch (IOException e) {
Message.verbose("symlink failed; falling back to copy", e);
@@ -171,7 +173,8 @@ public final class FileUtil {
if (src.isDirectory()) {
if (dest.exists()) {
if (!dest.isDirectory()) {
- throw new IOException("impossible to copy: destination is not a directory: " + dest);
+ throw new IOException("impossible to copy: destination is not a directory: "
+ + dest);
}
} else {
dest.mkdirs();
@@ -279,13 +282,13 @@ public final class FileUtil {
copy(src, new FileOutputStream(dest), l);
}
- public static void copy(InputStream src, OutputStream dest, CopyProgressListener l)
+ public static void copy(InputStream src, OutputStream dest, CopyProgressListener l)
throws IOException {
copy(src, dest, l, true);
}
-
- public static void copy(InputStream src, OutputStream dest, CopyProgressListener l, boolean autoClose)
- throws IOException {
+
+ public static void copy(InputStream src, OutputStream dest, CopyProgressListener l,
+ boolean autoClose) throws IOException {
CopyProgressEvent evt = null;
if (l != null) {
evt = new CopyProgressEvent();
@@ -387,7 +390,7 @@ public final class FileUtil {
public static String readEntirely(File f) throws IOException {
return readEntirely(new FileInputStream(f));
}
-
+
/**
* Reads the entire content of the {@link InputStream} and returns it as a String.
* <p>
@@ -468,11 +471,12 @@ public final class FileUtil {
* Returns a collection of all Files being contained in the given directory, recursively,
* including directories.
*
- * @param dir The directory from which all files, including files in subdirectory)
- * are extracted.
- * @param ignore a Collection of filenames which must be excluded from listing
- * @return A collectoin containing all the files of the given directory and it's
- * subdirectories.
+ * @param dir
+ * The directory from which all files, including files in subdirectory) are
+ * extracted.
+ * @param ignore
+ * a Collection of filenames which must be excluded from listing
+ * @return A collectoin containing all the files of the given directory and it's subdirectories.
*/
public static Collection listAll(File dir, Collection ignore) {
return listAll(dir, new ArrayList(), ignore);
@@ -482,7 +486,7 @@ public final class FileUtil {
if (ignore.contains(file.getName())) {
return list;
}
-
+
if (file.exists()) {
list.add(file);
}
@@ -500,81 +504,86 @@ public final class FileUtil {
if (!result.isAbsolute()) {
result = new File(file, filename);
}
-
+
return normalize(result.getPath());
}
-
- //////////////////////////////////////////////
+
+ // ////////////////////////////////////////////
// The following code comes from Ant FileUtils
- //////////////////////////////////////////////
-
- /**
- * "Normalize" the given absolute path.
- *
- * <p>This includes:
- * <ul>
- * <li>Uppercase the drive letter if there is one.</li>
- * <li>Remove redundant slashes after the drive spec.</li>
- * <li>Resolve all ./, .\, ../ and ..\ sequences.</li>
- * <li>DOS style paths that start with a drive letter will have
- * \ as the separator.</li>
- * </ul>
- * Unlike {@link File#getCanonicalPath()} this method
- * specifically does not resolve symbolic links.
- *
- * @param path the path to be normalized.
- * @return the normalized version of the path.
- *
- * @throws java.lang.NullPointerException if path is null.
- */
+ // ////////////////////////////////////////////
+
+ /**
+ * "Normalize" the given absolute path.
+ *
+ * <p>
+ * This includes:
+ * <ul>
+ * <li>Uppercase the drive letter if there is one.</li>
+ * <li>Remove redundant slashes after the drive spec.</li>
+ * <li>Resolve all ./, .\, ../ and ..\ sequences.</li>
+ * <li>DOS style paths that start with a drive letter will have \ as the separator.</li>
+ * </ul>
+ * Unlike {@link File#getCanonicalPath()} this method specifically does not resolve symbolic
+ * links.
+ *
+ * @param path
+ * the path to be normalized.
+ * @return the normalized version of the path.
+ *
+ * @throws java.lang.NullPointerException
+ * if path is null.
+ */
public static File normalize(final String path) {
- Stack s = new Stack();
- String[] dissect = dissect(path);
- s.push(dissect[0]);
-
- StringTokenizer tok = new StringTokenizer(dissect[1], File.separator);
- while (tok.hasMoreTokens()) {
- String thisToken = tok.nextToken();
- if (".".equals(thisToken)) {
- continue;
- }
- if ("..".equals(thisToken)) {
- if (s.size() < 2) {
- // Cannot resolve it, so skip it.
- return new File(path);
- }
- s.pop();
- } else { // plain component
- s.push(thisToken);
- }
- }
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < s.size(); i++) {
- if (i > 1) {
- // not before the filesystem root and not after it, since root
- // already contains one
- sb.append(File.separatorChar);
- }
- sb.append(s.elementAt(i));
- }
- return new File(sb.toString());
- }
-
+ Stack s = new Stack();
+ String[] dissect = dissect(path);
+ s.push(dissect[0]);
+
+ StringTokenizer tok = new StringTokenizer(dissect[1], File.separator);
+ while (tok.hasMoreTokens()) {
+ String thisToken = tok.nextToken();
+ if (".".equals(thisToken)) {
+ continue;
+ }
+ if ("..".equals(thisToken)) {
+ if (s.size() < 2) {
+ // Cannot resolve it, so skip it.
+ return new File(path);
+ }
+ s.pop();
+ } else { // plain component
+ s.push(thisToken);
+ }
+ }
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < s.size(); i++) {
+ if (i > 1) {
+ // not before the filesystem root and not after it, since root
+ // already contains one
+ sb.append(File.separatorChar);
+ }
+ sb.append(s.elementAt(i));
+ }
+ return new File(sb.toString());
+ }
+
/**
* Dissect the specified absolute path.
- * @param path the path to dissect.
+ *
+ * @param path
+ * the path to dissect.
* @return String[] {root, remaining path}.
- * @throws java.lang.NullPointerException if path is null.
+ * @throws java.lang.NullPointerException
+ * if path is null.
* @since Ant 1.7
*/
private static String[] dissect(String path) {
char sep = File.separatorChar;
path = path.replace('/', sep).replace('\\', sep);
-// // make sure we are dealing with an absolute path
-// if (!isAbsolutePath(path)) {
-// throw new BuildException(path + " is not an absolute path");
-// }
+ // // make sure we are dealing with an absolute path
+ // if (!isAbsolutePath(path)) {
+ // throw new BuildException(path + " is not an absolute path");
+ // }
String root = null;
int colon = path.indexOf(':');
if (colon > 0) { // && (ON_DOS || ON_NETWARE)) {
@@ -583,7 +592,7 @@ public final class FileUtil {
root = path.substring(0, next);
char[] ca = path.toCharArray();
root += sep;
- //remove the initial separator; the root has it.
+ // remove the initial separator; the root has it.
next = (ca[next] == sep) ? next + 1 : next;
StringBuffer sbPath = new StringBuffer();
@@ -628,5 +637,4 @@ public final class FileUtil {
return l;
}
-
}
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=1557968&r1=1557967&r2=1557968&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 Tue Jan 14 08:27:37 2014
@@ -21,22 +21,22 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
/**
- * This class contains basic helper methods for the Host.
+ * This class contains basic helper methods for the Host.
*
*/
public final class HostUtil {
-
+
private static String localHostName = null;
-
+
/**
* 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.
+ * localhost will be returned.
*
* @return The name of the current "local" Host.
*/
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/MemoryUtil.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/MemoryUtil.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/MemoryUtil.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/MemoryUtil.java Tue Jan 14 08:27:37 2014
@@ -22,8 +22,9 @@ package org.apache.ivy.util;
*/
public final class MemoryUtil {
private static final int SAMPLING_SIZE = 100;
+
private static final int SLEEP_TIME = 100;
-
+
private MemoryUtil() {
}
@@ -82,7 +83,7 @@ public final class MemoryUtil {
Message.debug(e);
}
}
-
+
public static void main(String[] args) throws ClassNotFoundException {
System.out.println(sizeOf(Class.forName(args[0])));
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java Tue Jan 14 08:27:37 2014
@@ -79,8 +79,8 @@ public final class Message {
public static void showInfo() {
if (!showedInfo) {
- info(":: Apache Ivy " + Ivy.getIvyVersion() + " - "
- + Ivy.getIvyDate() + " :: " + Ivy.getIvyHomeURL() + " ::");
+ info(":: Apache Ivy " + Ivy.getIvyVersion() + " - " + Ivy.getIvyDate() + " :: "
+ + Ivy.getIvyHomeURL() + " ::");
showedInfo = true;
}
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLogger.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLogger.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLogger.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLogger.java Tue Jan 14 08:27:37 2014
@@ -25,13 +25,12 @@ import java.util.List;
* Where the messages are logged is depending on the implementation.
* </p>
* <p>
- * This interface provides both level specific methods ({@link #info(String)},
- * {@link #warn(String)}, ...) and generic methods ({@link #log(String, int)},
- * {@link #rawlog(String, int)}). Note that calling level specific methods is usually not
- * equivalent to calling the generic method with the corresponding level. Indeed, for warn and error
- * level, the implementation will actually log the message at a lower level (usually
- * {@link Message#MSG_VERBOSE}) and log the message at the actual level only when
- * {@link #sumupProblems()} is called.
+ * This interface provides both level specific methods ({@link #info(String)}, {@link #warn(String)}
+ * , ...) and generic methods ({@link #log(String, int)}, {@link #rawlog(String, int)}). Note that
+ * calling level specific methods is usually not equivalent to calling the generic method with the
+ * corresponding level. Indeed, for warn and error level, the implementation will actually log the
+ * message at a lower level (usually {@link Message#MSG_VERBOSE}) and log the message at the actual
+ * level only when {@link #sumupProblems()} is called.
* </p>
*
* @see Message
@@ -54,6 +53,7 @@ public interface MessageLogger {
* @see Message#MSG_ERROR
*/
public abstract void log(String msg, int level);
+
/**
* Same as {@link #log(String, int)}, but without adding any contextual information to the
* message.
@@ -68,7 +68,7 @@ public interface MessageLogger {
public abstract void debug(String msg);
public abstract void verbose(String msg);
-
+
public abstract void deprecated(String msg);
public abstract void info(String msg);
@@ -80,13 +80,16 @@ public interface MessageLogger {
public abstract void error(String msg);
public abstract List<String> getProblems();
+
public abstract List<String> getWarns();
+
public abstract List<String> getErrors();
/**
* Clears the list of problems, warns and errors.
*/
public abstract void clearProblems();
+
/**
* Sumup all problems encountered so far, and clear them.
*/
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/MessageLoggerEngine.java Tue Jan 14 08:27:37 2014
@@ -34,8 +34,8 @@ import java.util.Stack;
* </p>
*/
public class MessageLoggerEngine implements MessageLogger {
- private final ThreadLocal/*<Stack<MessageLogger>>*/ loggerStacks = new ThreadLocal();
-
+ private final ThreadLocal/* <Stack<MessageLogger>> */loggerStacks = new ThreadLocal();
+
private MessageLogger defaultLogger = null;
private List problems = new ArrayList();
@@ -43,7 +43,7 @@ public class MessageLoggerEngine impleme
private List warns = new ArrayList();
private List errors = new ArrayList();
-
+
private Stack getLoggerStack() {
Stack stack = (Stack) loggerStacks.get();
if (stack == null) {
@@ -52,21 +52,20 @@ public class MessageLoggerEngine impleme
}
return stack;
}
-
+
public MessageLoggerEngine() {
}
/**
* Sets the logger used when the stack is empty.
*
- * @param defaultLogger the logger to use when the stack is empty.
+ * @param defaultLogger
+ * the logger to use when the stack is empty.
*/
public void setDefaultLogger(MessageLogger defaultLogger) {
this.defaultLogger = defaultLogger;
}
-
-
/**
* Push a logger on the stack.
*
@@ -77,7 +76,7 @@ public class MessageLoggerEngine impleme
Checks.checkNotNull(logger, "logger");
getLoggerStack().push(logger);
}
-
+
/**
* Pops a logger from the logger stack.
* <p>
@@ -92,6 +91,7 @@ public class MessageLoggerEngine impleme
/**
* Returns the current logger, or the default one if there is no logger in the stack
+ *
* @return the current logger, or the default one if there is no logger in the stack
*/
public MessageLogger peekLogger() {
@@ -113,7 +113,7 @@ public class MessageLoggerEngine impleme
problems.add("WARN: " + msg);
warns.add(msg);
}
-
+
public void error(String msg) {
peekLogger().error(msg);
problems.add("\tERROR: " + msg);
@@ -136,7 +136,7 @@ public class MessageLoggerEngine impleme
MessageLoggerHelper.sumupProblems(this);
clearProblems();
}
-
+
public void clearProblems() {
getDefaultLogger().clearProblems();
for (Iterator iter = getLoggerStack().iterator(); iter.hasNext();) {
@@ -156,18 +156,18 @@ public class MessageLoggerEngine impleme
l.setShowProgress(progress);
}
}
-
+
public boolean isShowProgress() {
// testing the default logger is enough, all loggers should be in sync
return getDefaultLogger().isShowProgress();
}
// delegation methods
-
+
public void debug(String msg) {
peekLogger().debug(msg);
}
-
+
public void deprecated(String msg) {
peekLogger().deprecated(msg);
}
@@ -204,5 +204,4 @@ public class MessageLoggerEngine impleme
peekLogger().verbose(msg);
}
-
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/StringUtils.java Tue Jan 14 08:27:37 2014
@@ -27,11 +27,11 @@ import java.util.Locale;
* to have such a dependency for only one feature
*/
public final class StringUtils {
-
+
private StringUtils() {
- //Utility class
+ // Utility class
}
-
+
public static String uncapitalize(String string) {
if (string == null || string.length() == 0) {
return string;
@@ -41,7 +41,7 @@ public final class StringUtils {
}
return string.substring(0, 1).toLowerCase(Locale.US) + string.substring(1);
}
-
+
/**
* Returns the error message associated with the given Throwable. The error message returned
* will try to be as precise as possible, handling cases where e.getMessage() is not meaningful,
@@ -65,7 +65,7 @@ public final class StringUtils {
}
return errMsg;
}
-
+
/**
* Returns the exception stack trace as a String.
*
@@ -84,16 +84,19 @@ public final class StringUtils {
}
/**
- * Joins the given object array in one string, each separated by the given separator.
+ * Joins the given object array in one string, each separated by the given separator.
*
* Example:
+ *
* <pre>
* join(new String[] {"one", "two", "three"}, ", ") -> "one, two, three"
* </pre>
*
- * @param objs The array of objects (<code>toString()</code> is used).
- * @param sep The separator to use.
- * @return The concatinated string.
+ * @param objs
+ * The array of objects (<code>toString()</code> is used).
+ * @param sep
+ * The separator to use.
+ * @return The concatinated string.
*/
public static String join(Object[] objs, String sep) {
StringBuffer buf = new StringBuffer();
@@ -155,7 +158,7 @@ public final class StringUtils {
*
* @param str
* the encrypted string to decrypt
- * @return The decrypted string.
+ * @return The decrypted string.
*/
public static final String decrypt(String str) {
if (str == null) {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java Tue Jan 14 08:27:37 2014
@@ -41,17 +41,13 @@ import org.xml.sax.helpers.DefaultHandle
public abstract class XMLHelper {
- static final String JAXP_SCHEMA_LANGUAGE
- = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+ static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
- static final String JAXP_SCHEMA_SOURCE
- = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+ static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
- static final String XERCES_LOAD_EXTERNAL_DTD
- = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+ static final String XERCES_LOAD_EXTERNAL_DTD = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
- static final String XML_NAMESPACE_PREFIXES
- = "http://xml.org/sax/features/namespace-prefixes";
+ static final String XML_NAMESPACE_PREFIXES = "http://xml.org/sax/features/namespace-prefixes";
static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
@@ -59,8 +55,8 @@ public abstract class XMLHelper {
private static Boolean canDisableExternalDtds = null;
- private static SAXParser newSAXParser(URL schema, InputStream schemaStream,
- boolean loadExternalDtds) throws ParserConfigurationException, SAXException {
+ private static SAXParser newSAXParser(URL schema, InputStream schemaStream,
+ boolean loadExternalDtds) throws ParserConfigurationException, SAXException {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
parserFactory.setValidating(canUseSchemaValidation && (schema != null));
@@ -68,7 +64,7 @@ public abstract class XMLHelper {
parserFactory.setFeature(XERCES_LOAD_EXTERNAL_DTD, false);
}
SAXParser parser = parserFactory.newSAXParser();
-
+
if (canUseSchemaValidation && (schema != null)) {
try {
parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
@@ -81,24 +77,23 @@ public abstract class XMLHelper {
parser = parserFactory.newSAXParser();
}
}
-
+
parser.getXMLReader().setFeature(XML_NAMESPACE_PREFIXES, true);
return parser;
}
private static boolean canDisableExternalDtds(SAXParserFactory parserFactory) {
- if (canDisableExternalDtds == null) {
- try {
- parserFactory.getFeature(XERCES_LOAD_EXTERNAL_DTD);
- canDisableExternalDtds = Boolean.TRUE;
- } catch (Exception ex) {
- canDisableExternalDtds = Boolean.FALSE;
- }
- }
- return canDisableExternalDtds.booleanValue();
+ if (canDisableExternalDtds == null) {
+ try {
+ parserFactory.getFeature(XERCES_LOAD_EXTERNAL_DTD);
+ canDisableExternalDtds = Boolean.TRUE;
+ } catch (Exception ex) {
+ canDisableExternalDtds = Boolean.FALSE;
+ }
+ }
+ return canDisableExternalDtds.booleanValue();
}
-
/**
* Convert an URL to a valid systemId according to RFC 2396.
*/
@@ -119,8 +114,7 @@ public abstract class XMLHelper {
parse(xmlURL, schema, handler, null);
}
- public static void parse(
- URL xmlURL, URL schema, DefaultHandler handler, LexicalHandler lHandler)
+ public static void parse(URL xmlURL, URL schema, DefaultHandler handler, LexicalHandler lHandler)
throws SAXException, IOException, ParserConfigurationException {
InputStream xmlStream = URLHandlerRegistry.getDefault().openStream(xmlURL);
try {
@@ -136,21 +130,19 @@ public abstract class XMLHelper {
}
}
- public static void parse(
- InputStream xmlStream, URL schema, DefaultHandler handler, LexicalHandler lHandler)
- throws SAXException, IOException, ParserConfigurationException {
+ public static void parse(InputStream xmlStream, URL schema, DefaultHandler handler,
+ LexicalHandler lHandler) throws SAXException, IOException, ParserConfigurationException {
parse(new InputSource(xmlStream), schema, handler, lHandler);
}
-
- public static void parse(
- InputSource xmlStream, URL schema, DefaultHandler handler, LexicalHandler lHandler)
- throws SAXException, IOException, ParserConfigurationException {
+
+ public static void parse(InputSource xmlStream, URL schema, DefaultHandler handler,
+ LexicalHandler lHandler) throws SAXException, IOException, ParserConfigurationException {
parse(xmlStream, schema, handler, lHandler, true);
}
- public static void parse(
- InputSource xmlStream, URL schema, DefaultHandler handler, LexicalHandler lHandler,
- boolean loadExternalDtds) throws SAXException, IOException, ParserConfigurationException {
+ public static void parse(InputSource xmlStream, URL schema, DefaultHandler handler,
+ LexicalHandler lHandler, boolean loadExternalDtds) throws SAXException, IOException,
+ ParserConfigurationException {
InputStream schemaStream = null;
try {
if (schema != null) {
@@ -183,26 +175,26 @@ public abstract class XMLHelper {
public static boolean canUseSchemaValidation() {
return canUseSchemaValidation;
}
-
+
/**
- * Escapes invalid XML characters in the given character data using XML entities.
- * For the moment, only the following characters are being escaped: (<), (&), (')
- * and (").
+ * Escapes invalid XML characters in the given character data using XML entities. For the
+ * moment, only the following characters are being escaped: (<), (&), (') and (").
*
- * Remark: we don't escape the (>) character to keep the readability of the
- * configuration mapping! The XML spec only requires that the (&) and (<)
- * characters are being escaped inside character data.
+ * Remark: we don't escape the (>) character to keep the readability of the configuration
+ * mapping! The XML spec only requires that the (&) and (<) characters are being escaped inside
+ * character data.
*
- * @param text the character data to escape
+ * @param text
+ * the character data to escape
* @return the escaped character data
*/
public static String escape(String text) {
if (text == null) {
return null;
}
-
+
StringBuffer result = new StringBuffer(text.length());
-
+
char[] chars = text.toCharArray();
for (int i = 0; i < chars.length; i++) {
switch (chars[i]) {
@@ -222,11 +214,10 @@ public abstract class XMLHelper {
result.append(chars[i]);
}
}
-
+
return result.toString();
}
-
public static Document parseToDom(InputSource source, EntityResolver entityResolver)
throws IOException, SAXException {
DocumentBuilder docBuilder = getDocBuilder(entityResolver);
@@ -244,10 +235,9 @@ public abstract class XMLHelper {
return docBuilder;
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
- }
+ }
}
-
private XMLHelper() {
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLine.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLine.java Tue Jan 14 08:27:37 2014
@@ -21,13 +21,14 @@ import java.util.HashMap;
import java.util.Map;
public class CommandLine {
- private Map/*<String, String[]>*/ optionValues = new HashMap();
+ private Map/* <String, String[]> */optionValues = new HashMap();
+
private String[] leftOverArgs;
-
+
void addOptionValues(String option, String[] values) {
optionValues.put(option, values);
}
-
+
void setLeftOverArgs(String[] args) {
leftOverArgs = args;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLineParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLineParser.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLineParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/CommandLineParser.java Tue Jan 14 08:27:37 2014
@@ -31,10 +31,13 @@ import org.apache.ivy.util.StringUtils;
public class CommandLineParser {
private static final int MIN_DESC_WIDTH = 40;
+
private static final int MAX_SPEC_WIDTH = 30;
- private Map/*<String, Option>*/ options = new LinkedHashMap();
- private Map/*<String, List<Option>>*/ categories = new LinkedHashMap();
-
+
+ private Map/* <String, Option> */options = new LinkedHashMap();
+
+ private Map/* <String, List<Option>> */categories = new LinkedHashMap();
+
public CommandLineParser() {
}
@@ -42,19 +45,18 @@ public class CommandLineParser {
categories.put(category, new ArrayList());
return this;
}
-
+
public CommandLineParser addOption(Option option) {
options.put(option.getName(), option);
if (!categories.isEmpty()) {
- ((List) categories.values().toArray()[categories.values().size() - 1])
- .add(option);
+ ((List) categories.values().toArray()[categories.values().size() - 1]).add(option);
}
return this;
}
-
+
public CommandLine parse(String[] args) throws ParseException {
CommandLine line = new CommandLine();
-
+
int index = args.length;
ListIterator iterator = Arrays.asList(args).listIterator();
while (iterator.hasNext()) {
@@ -69,14 +71,14 @@ public class CommandLineParser {
index = iterator.previousIndex();
break;
}
-
+
Option option = (Option) options.get(arg.substring(1));
if (option == null) {
throw new ParseException("Unrecognized option: " + arg);
}
line.addOptionValues(arg.substring(1), option.parse(iterator));
}
-
+
// left over args
String[] leftOverArgs = new String[args.length - index];
System.arraycopy(args, index, leftOverArgs, 0, leftOverArgs.length);
@@ -94,8 +96,7 @@ public class CommandLineParser {
if (option.isDeprecated() && !showDeprecated) {
continue;
}
- specWidth = Math.min(MAX_SPEC_WIDTH,
- Math.max(specWidth, option.getSpec().length()));
+ specWidth = Math.min(MAX_SPEC_WIDTH, Math.max(specWidth, option.getSpec().length()));
}
// print options help
@@ -103,7 +104,7 @@ public class CommandLineParser {
Entry entry = (Entry) iterator.next();
String category = (String) entry.getKey();
pw.println("==== " + category);
- List/*<Option>*/ options = (List) entry.getValue();
+ List/* <Option> */options = (List) entry.getValue();
for (Iterator it = options.iterator(); it.hasNext();) {
Option option = (Option) it.next();
if (option.isDeprecated() && !showDeprecated) {
@@ -114,10 +115,10 @@ public class CommandLineParser {
pw.print(" " + spec);
int specLength = spec.length() + 1;
pw.print(StringUtils.repeat(" ", specWidth - specLength));
-
+
// print description
- StringBuffer desc = new StringBuffer(
- (option.isDeprecated() ? "DEPRECATED: " : "") + option.getDescription());
+ StringBuffer desc = new StringBuffer((option.isDeprecated() ? "DEPRECATED: " : "")
+ + option.getDescription());
int count = Math.min(desc.length(), width - Math.max(specLength, specWidth));
// see if we have enough space to start on the same line as the spec
if (count > MIN_DESC_WIDTH || desc.length() + specLength < width) {
@@ -125,7 +126,7 @@ public class CommandLineParser {
desc.delete(0, count);
}
pw.println();
-
+
// print remaining description
while (desc.length() > 0) {
pw.print(StringUtils.repeat(" ", specWidth));
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/Option.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/Option.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/Option.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/Option.java Tue Jan 14 08:27:37 2014
@@ -23,14 +23,19 @@ import java.util.ListIterator;
public class Option {
private String name;
+
private String[] args;
+
private String description;
+
private boolean required;
+
private boolean countArgs;
+
private boolean deprecated;
-
- Option(String name, String[] args, String description,
- boolean required, boolean countArgs, boolean deprecated) {
+
+ Option(String name, String[] args, String description, boolean required, boolean countArgs,
+ boolean deprecated) {
this.name = name;
this.args = args;
this.description = description;
@@ -45,18 +50,23 @@ public class Option {
public String getName() {
return name;
}
+
public String[] getArgs() {
return args;
}
+
public String getDescription() {
return description;
}
+
public boolean isRequired() {
return required;
}
+
public boolean isCountArgs() {
return countArgs;
}
+
public boolean isDeprecated() {
return deprecated;
}
@@ -92,8 +102,8 @@ public class Option {
if (i == 0) {
throw new ParseException("no argument for: " + name);
} else {
- throw new ParseException("missing argument for: " + name
- + ". Expected: " + getArgsSpec());
+ throw new ParseException("missing argument for: " + name + ". Expected: "
+ + getArgsSpec());
}
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/OptionBuilder.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/OptionBuilder.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/OptionBuilder.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/cli/OptionBuilder.java Tue Jan 14 08:27:37 2014
@@ -22,31 +22,36 @@ import java.util.List;
public class OptionBuilder {
private String name;
- private List/*<String>*/ args = new ArrayList();
+
+ private List/* <String> */args = new ArrayList();
+
private String description = "";
+
private boolean required = false;
+
private boolean countArgs = true;
+
private boolean deprecated = false;
-
+
public OptionBuilder(String name) {
this.name = name;
}
-
+
public OptionBuilder required(boolean required) {
this.required = required;
return this;
}
-
+
public OptionBuilder description(String description) {
this.description = description;
return this;
}
-
+
public OptionBuilder arg(String argName) {
this.args.add(argName);
return this;
}
-
+
public OptionBuilder countArgs(boolean countArgs) {
this.countArgs = countArgs;
return this;
@@ -56,10 +61,9 @@ public class OptionBuilder {
this.deprecated = true;
return this;
}
-
+
public Option create() {
- return new Option(
- name, (String[]) args.toArray(new String[args.size()]),
- description, required, countArgs, deprecated);
+ return new Option(name, (String[]) args.toArray(new String[args.size()]), description,
+ required, countArgs, deprecated);
}
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/DefaultExtendableItem.java Tue Jan 14 08:27:37 2014
@@ -35,5 +35,4 @@ public class DefaultExtendableItem exten
super.setExtraAttribute(attName, attValue);
}
-
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItem.java Tue Jan 14 08:27:37 2014
@@ -30,7 +30,6 @@ public interface ExtendableItem {
*/
String getAttribute(String attName);
-
/**
* Gets the value of an extra attribute Can be used only to access the value of an extra
* attribute, not a standard one (like organisation, revision)
@@ -51,7 +50,6 @@ public interface ExtendableItem {
*/
Map getAttributes();
-
/**
* Returns a Map of all extra attributes of this extendable item. The Map keys are
* <b>unqualified</b> attribute names as Strings, and values are corresponding attribute values
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/ExtendableItemHelper.java Tue Jan 14 08:27:37 2014
@@ -49,8 +49,8 @@ public final class ExtendableItemHelper
* the XML attributes names which are not extra but Ivy core ones
* @return
*/
- public static Map getExtraAttributes(
- ParserSettings settings, Attributes attributes, String[] ignoredAttNames) {
+ public static Map getExtraAttributes(ParserSettings settings, Attributes attributes,
+ String[] ignoredAttNames) {
Map ret = new HashMap();
Collection ignored = Arrays.asList(ignoredAttNames);
for (int i = 0; i < attributes.getLength(); i++) {
@@ -61,8 +61,8 @@ public final class ExtendableItemHelper
return ret;
}
- public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item,
- Attributes attributes, String[] ignoredAttNames) {
+ public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item,
+ Attributes attributes, String[] ignoredAttNames) {
Map att = getExtraAttributes(settings, attributes, ignoredAttNames);
for (Iterator iter = att.keySet().iterator(); iter.hasNext();) {
String attName = (String) iter.next();
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/extendable/UnmodifiableExtendableItem.java Tue Jan 14 08:27:37 2014
@@ -30,8 +30,8 @@ public class UnmodifiableExtendableItem
private final Map extraAttributes = new HashMap();
- private final Map unmodifiableExtraAttributesView =
- Collections.unmodifiableMap(extraAttributes);
+ private final Map unmodifiableExtraAttributesView = Collections
+ .unmodifiableMap(extraAttributes);
/*
* this is the only place where extra attributes are stored in qualified form. In all other maps
@@ -39,8 +39,8 @@ public class UnmodifiableExtendableItem
*/
private final Map qualifiedExtraAttributes = new HashMap();
- private final Map unmodifiableQualifiedExtraAttributesView =
- Collections.unmodifiableMap(qualifiedExtraAttributes);
+ private final Map unmodifiableQualifiedExtraAttributesView = Collections
+ .unmodifiableMap(qualifiedExtraAttributes);
public UnmodifiableExtendableItem(Map stdAttributes, Map extraAttributes) {
if (stdAttributes != null) {
@@ -66,10 +66,9 @@ public class UnmodifiableExtendableItem
return v;
}
-
protected void setExtraAttribute(String attName, String attValue) {
qualifiedExtraAttributes.put(attName, attValue);
-
+
// unqualify att name if required
int index = attName.indexOf(':');
if (index != -1) {
@@ -87,11 +86,10 @@ public class UnmodifiableExtendableItem
return unmodifiableAttributesView;
}
-
public Map getExtraAttributes() {
return unmodifiableExtraAttributesView;
}
-
+
public Map getQualifiedExtraAttributes() {
return unmodifiableQualifiedExtraAttributesView;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/filter/FilterHelper.java Tue Jan 14 08:27:37 2014
@@ -25,7 +25,7 @@ import java.util.List;
public final class FilterHelper {
private FilterHelper() {
}
-
+
public static final Filter NO_FILTER = NoFilter.INSTANCE;
public static Filter getArtifactTypeFilter(String types) {
@@ -35,12 +35,12 @@ public final class FilterHelper {
String[] t = types.split(",");
return getArtifactTypeFilter(t);
}
-
+
public static Filter getArtifactTypeFilter(String[] types) {
if (types == null || types.length == 0) {
return NO_FILTER;
}
- List acceptedTypes = new ArrayList(types.length);
+ List acceptedTypes = new ArrayList(types.length);
for (int i = 0; i < types.length; i++) {
String current = types[i].trim();
if ("*".equals(current)) {
@@ -55,14 +55,16 @@ public final class FilterHelper {
* Returns a new collection containing only the items from the given collectoin, which are
* accepted by the filter.
*
- * @param col The collection to filter.
- * @param filter The filter to use.
- * @return A new collection instance containing the only the instance accepted by the filter.
- *
+ * @param col
+ * The collection to filter.
+ * @param filter
+ * The filter to use.
+ * @return A new collection instance containing the only the instance accepted by the filter.
+ *
* <br />
- * Comment: We could have used
- * <a href="http://jakarta.apache.org/commons/collections/">Commons-Collections</a>
- * facility for this. If we accepted to add dependencies on third party jars.
+ * Comment: We could have used <a
+ * href="http://jakarta.apache.org/commons/collections/">Commons-Collections</a>
+ * facility for this. If we accepted to add dependencies on third party jars.
*/
public static Collection filter(Collection col, Filter filter) {
if (filter == null) {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/AbstractURLHandler.java Tue Jan 14 08:27:37 2014
@@ -32,7 +32,7 @@ import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
public abstract class AbstractURLHandler implements URLHandler {
-
+
private static final Pattern ESCAPE_PATTERN = Pattern.compile("%25([0-9a-fA-F][0-9a-fA-F])");
// the request method to use. TODO: don't use a static here
@@ -62,8 +62,8 @@ public abstract class AbstractURLHandler
return getURLInfo(url, timeout).getLastModified();
}
- protected void validatePutStatusCode(
- URL dest, int statusCode, String statusMessage) throws IOException {
+ protected void validatePutStatusCode(URL dest, int statusCode, String statusMessage)
+ throws IOException {
switch (statusCode) {
case HttpURLConnection.HTTP_OK:
/* intentional fallthrough */
@@ -76,59 +76,59 @@ public abstract class AbstractURLHandler
case HttpURLConnection.HTTP_UNAUTHORIZED:
/* intentional fallthrough */
case HttpURLConnection.HTTP_FORBIDDEN:
- throw new IOException("Access to URL " + dest + " was refused by the server"
- + (statusMessage == null ? "" : ": " + statusMessage));
+ throw new IOException("Access to URL " + dest + " was refused by the server"
+ + (statusMessage == null ? "" : ": " + statusMessage));
default:
- throw new IOException("PUT operation to URL " + dest + " failed with status code "
- + statusCode + (statusMessage == null ? "" : ": " + statusMessage));
+ throw new IOException("PUT operation to URL " + dest + " failed with status code "
+ + statusCode + (statusMessage == null ? "" : ": " + statusMessage));
}
}
-
+
public void setRequestMethod(int requestMethod) {
AbstractURLHandler.requestMethod = requestMethod;
}
-
+
public int getRequestMethod() {
return requestMethod;
}
-
+
protected String normalizeToString(URL url) throws IOException {
if (!"http".equals(url.getProtocol()) && !"https".equals(url.getProtocol())) {
return url.toExternalForm();
}
-
+
try {
- URI uri = new URI(url.getProtocol(), url.getAuthority(),
- url.getPath(), url.getQuery(), url.getRef());
-
+ URI uri = new URI(url.getProtocol(), url.getAuthority(), url.getPath(), url.getQuery(),
+ url.getRef());
+
// it is possible that the original url was already (partial) escaped,
// so we must unescape all '%' followed by 2 hexadecimals...
String uriString = uri.normalize().toASCIIString();
-
+
// manually escape the '+' character
uriString = uriString.replaceAll("\\+", "%2B");
-
+
return ESCAPE_PATTERN.matcher(uriString).replaceAll("%$1");
} catch (URISyntaxException e) {
- IOException ioe = new MalformedURLException("Couldn't convert '"
- + url.toString() + "' to a valid URI");
- ioe.initCause(e);
+ IOException ioe = new MalformedURLException("Couldn't convert '" + url.toString()
+ + "' to a valid URI");
+ ioe.initCause(e);
throw ioe;
}
}
-
+
protected URL normalizeToURL(URL url) throws IOException {
if (!"http".equals(url.getProtocol()) && !"https".equals(url.getProtocol())) {
return url;
}
-
+
return new URL(normalizeToString(url));
}
-
- protected InputStream getDecodingInputStream(String encoding, InputStream in)
+
+ protected InputStream getDecodingInputStream(String encoding, InputStream in)
throws IOException {
InputStream result = null;
-
+
if ("gzip".equals(encoding) || "x-gzip".equals(encoding)) {
result = new GZIPInputStream(in);
} else if ("deflate".equals(encoding)) {
@@ -141,12 +141,12 @@ public abstract class AbstractURLHandler
byte[] bytes = new byte[100];
int nbBytes = bStream.read(bytes);
bStream.reset();
-
+
Inflater inflater = new Inflater();
inflater.setInput(bytes, 0, nbBytes);
try {
inflater.inflate(new byte[1000]);
-
+
// no error decompressing the first 100 bytes, so we
// assume the "zlib"-variant was used.
result = new InflaterInputStream(bStream);
@@ -160,7 +160,7 @@ public abstract class AbstractURLHandler
} else {
result = in;
}
-
+
return result;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/ApacheURLLister.java Tue Jan 14 08:27:37 2014
@@ -127,7 +127,7 @@ public class ApacheURLLister {
}
text = text.trim();
-
+
// handle complete URL listings
if (href.startsWith("http:") || href.startsWith("https:")) {
try {
@@ -147,7 +147,7 @@ public class ApacheURLLister {
// we are only interested in sub-URLs, not parent URLs, so skip this one
continue;
}
-
+
// absolute href: convert to relative one
if (href.startsWith("/")) {
int slashIndex = href.substring(0, href.length() - 1).lastIndexOf('/');
@@ -174,8 +174,10 @@ public class ApacheURLLister {
} else {
// text is not truncated, so it must match the url after stripping optional
// trailing slashes
- String strippedHref = href.endsWith("/") ? href.substring(0, href.length() - 1) : href;
- String strippedText = text.endsWith("/") ? text.substring(0, text.length() - 1) : text;
+ String strippedHref = href.endsWith("/") ? href.substring(0, href.length() - 1)
+ : href;
+ String strippedText = text.endsWith("/") ? text.substring(0, text.length() - 1)
+ : text;
if (!strippedHref.equalsIgnoreCase(strippedText)) {
continue;
}
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=1557968&r1=1557967&r2=1557968&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 Tue Jan 14 08:27:37 2014
@@ -45,7 +45,7 @@ public class BasicURLHandler extends Abs
static final int SC_OK = 200;
static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
-
+
private HttpStatus() {
}
}
@@ -59,7 +59,7 @@ public class BasicURLHandler extends Abs
if ("http".equals(url.getProtocol()) || "https".equals(url.getProtocol())) {
IvyAuthenticator.install();
}
-
+
URLConnection con = null;
try {
url = normalizeToURL(url);
@@ -72,7 +72,8 @@ public class BasicURLHandler extends Abs
}
if (checkStatusCode(url, httpCon)) {
String bodyCharset = getCharSetFromContentType(con.getContentType());
- return new URLInfo(true, httpCon.getContentLength(), con.getLastModified(), bodyCharset);
+ return new URLInfo(true, httpCon.getContentLength(), con.getLastModified(),
+ bodyCharset);
}
} else {
int contentLength = con.getContentLength();
@@ -87,7 +88,7 @@ public class BasicURLHandler extends Abs
} catch (UnknownHostException e) {
Message.warn("Host " + e.getMessage() + " not found. url=" + url);
Message.info("You probably access the destination server through "
- + "a proxy server that is not well configured.");
+ + "a proxy server that is not well configured.");
} catch (IOException e) {
Message.error("Server access error at url " + url, e);
} finally {
@@ -131,12 +132,12 @@ public class BasicURLHandler extends Abs
if (status == HttpStatus.SC_OK) {
return true;
}
-
+
// IVY-1328: some servers return a 204 on a HEAD request
if ("HEAD".equals(con.getRequestMethod()) && (status == 204)) {
return true;
}
-
+
Message.debug("HTTP response status: " + status + " url=" + url);
if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
Message.warn("Your proxy requires authentication.");
@@ -163,13 +164,12 @@ public class BasicURLHandler extends Abs
if (conn instanceof HttpURLConnection) {
HttpURLConnection httpCon = (HttpURLConnection) conn;
if (!checkStatusCode(url, httpCon)) {
- throw new IOException(
- "The HTTP response code for " + url + " did not indicate a success."
- + " See log for more detail.");
+ throw new IOException("The HTTP response code for " + url
+ + " did not indicate a success." + " See log for more detail.");
}
}
InputStream inStream = getDecodingInputStream(conn.getContentEncoding(),
- conn.getInputStream());
+ conn.getInputStream());
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
@@ -182,7 +182,7 @@ public class BasicURLHandler extends Abs
disconnect(conn);
}
}
-
+
public void download(URL src, File dest, CopyProgressListener l) throws IOException {
// Install the IvyAuthenticator
if ("http".equals(src.getProtocol()) || "https".equals(src.getProtocol())) {
@@ -198,15 +198,14 @@ public class BasicURLHandler extends Abs
if (srcConn instanceof HttpURLConnection) {
HttpURLConnection httpCon = (HttpURLConnection) srcConn;
if (!checkStatusCode(src, httpCon)) {
- throw new IOException(
- "The HTTP response code for " + src + " did not indicate a success."
- + " See log for more detail.");
+ throw new IOException("The HTTP response code for " + src
+ + " did not indicate a success." + " See log for more detail.");
}
}
// do the download
InputStream inStream = getDecodingInputStream(srcConn.getContentEncoding(),
- srcConn.getInputStream());
+ srcConn.getInputStream());
FileUtil.copy(inStream, dest, l);
// check content length only if content was not encoded
@@ -219,7 +218,7 @@ public class BasicURLHandler extends Abs
+ ". Please retry.");
}
}
-
+
// update modification date
long lastModified = srcConn.getLastModified();
if (lastModified > 0) {
@@ -276,7 +275,7 @@ public class BasicURLHandler extends Abs
// so may results in idle TCP connections.[/quote]
readResponseBody((HttpURLConnection) con);
}
-
+
((HttpURLConnection) con).disconnect();
} else if (con != null) {
try {
@@ -287,17 +286,17 @@ public class BasicURLHandler extends Abs
}
}
- /**
- * Read and ignore the response body.
+ /**
+ * Read and ignore the response body.
*/
private void readResponseBody(HttpURLConnection conn) {
byte[] buffer = new byte[BUFFER_SIZE];
-
+
InputStream inStream = null;
try {
inStream = conn.getInputStream();
while (inStream.read(buffer) > 0) {
- //Skip content
+ // Skip content
}
} catch (IOException e) {
// ignore
@@ -310,18 +309,18 @@ public class BasicURLHandler extends Abs
}
}
}
-
+
InputStream errStream = conn.getErrorStream();
if (errStream != null) {
try {
while (errStream.read(buffer) > 0) {
- //Skip content
+ // Skip content
}
} catch (IOException e) {
// ignore
} finally {
try {
- errStream.close();
+ errStream.close();
} catch (IOException e) {
// ignore
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/url/CredentialsStore.java Tue Jan 14 08:27:37 2014
@@ -33,6 +33,7 @@ public final class CredentialsStore {
* A Map of Credentials objects keyed by the 'key' of the Credentials.
*/
private static final Map KEYRING = new HashMap();
+
private static final Set SECURED_HOSTS = new HashSet();
public static final CredentialsStore INSTANCE = new CredentialsStore();
@@ -55,7 +56,7 @@ public final class CredentialsStore {
Message.debug("try to get credentials for: " + key);
return (Credentials) KEYRING.get(key);
}
-
+
public boolean hasCredentials(String host) {
return SECURED_HOSTS.contains(host);
}