提交 bb28d198 编写于 作者: J Juergen Hoeller

Polishing

上级 e0fd54b8
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -193,27 +193,30 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
/** The default name of the property representing non-option arguments: {@value} */
public static final String DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME = "nonOptionArgs";
private String nonOptionArgsPropertyName = DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME;
/**
* Create a new {@code CommandLinePropertySource} having the default name {@value
* #COMMAND_LINE_PROPERTY_SOURCE_NAME} and backed by the given source object.
* Create a new {@code CommandLinePropertySource} having the default name
* {@value #COMMAND_LINE_PROPERTY_SOURCE_NAME} and backed by the given source object.
*/
public CommandLinePropertySource(T source) {
super(COMMAND_LINE_PROPERTY_SOURCE_NAME, source);
}
/**
* Create a new {@link CommandLinePropertySource} having the given name and backed by
* the given source object.
* Create a new {@link CommandLinePropertySource} having the given name
* and backed by the given source object.
*/
public CommandLinePropertySource(String name, T source) {
super(name, source);
}
/**
* Specify the name of the special "non-option arguments" property. The default is
* {@value #DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME}.
* Specify the name of the special "non-option arguments" property.
* The default is {@value #DEFAULT_NON_OPTION_ARGS_PROPERTY_NAME}.
*/
public void setNonOptionArgsPropertyName(String nonOptionArgsPropertyName) {
this.nonOptionArgsPropertyName = nonOptionArgsPropertyName;
......@@ -265,6 +268,7 @@ public abstract class CommandLinePropertySource<T> extends EnumerablePropertySou
}
}
/**
* Return whether the set of option arguments parsed from the command line contains
* an option with the given name.
......
......@@ -44,10 +44,11 @@ import org.springframework.util.Assert;
*
* See {@link CommandLinePropertySource} for complete general usage examples.
*
* <p>Requires JOpt version 3.0 or higher. Tested against JOpt up until 4.6.
* <p>Requires JOpt version 4.3 or higher. Tested against JOpt up until 4.6.
*
* @author Chris Beams
* @author Juergen Hoeller
* @author Dave Syer
* @since 3.1
* @see CommandLinePropertySource
* @see joptsimple.OptionParser
......@@ -82,11 +83,11 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource<Opt
@Override
public String[] getPropertyNames() {
List<String> names = new ArrayList<String>();
for (OptionSpec<?> spec : source.specs()) {
for (OptionSpec<?> spec : this.source.specs()) {
List<String> aliases = new ArrayList<String>(spec.options());
if (!aliases.isEmpty()) {
// Only the longest name is used for enumerating
names.add(aliases.get(aliases.size()-1));
names.add(aliases.get(aliases.size() - 1));
}
}
return names.toArray(new String[names.size()]);
......
......@@ -55,6 +55,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
private int timeToLive;
/**
* Provide a URL path to help identify the target request for this FlashMap.
* The path may be absolute (e.g. /application/resource) or relative to the
......@@ -69,7 +70,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
* Return the target URL path or {@code null}.
*/
public String getTargetRequestPath() {
return targetRequestPath;
return this.targetRequestPath;
}
/**
......@@ -121,7 +122,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
*/
public boolean isExpired() {
if (this.expirationStartTime != 0) {
return (System.currentTimeMillis() - this.expirationStartTime) > this.timeToLive * 1000;
return (System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000);
}
else {
return false;
......@@ -135,8 +136,8 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
*/
@Override
public int compareTo(FlashMap other) {
int thisUrlPath = (this.targetRequestPath != null) ? 1 : 0;
int otherUrlPath = (other.targetRequestPath != null) ? 1 : 0;
int thisUrlPath = (this.targetRequestPath != null ? 1 : 0);
int otherUrlPath = (other.targetRequestPath != null ? 1 : 0);
if (thisUrlPath != otherUrlPath) {
return otherUrlPath - thisUrlPath;
}
......@@ -148,7 +149,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[Attributes=").append(super.toString());
sb.append("FlashMap [attributes=").append(super.toString());
sb.append(", targetRequestPath=").append(this.targetRequestPath);
sb.append(", targetRequestParams=").append(this.targetRequestParams).append("]");
return sb.toString();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册