forked from phoedos/pmd
Checking in some Java 5 changes - Using the MessageFormatter.format varargs construct
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5024 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -402,7 +402,7 @@ public abstract class AbstractRule extends JavaParserVisitorAdapter implements R
|
||||
*/
|
||||
protected final void addViolation(Object data, SimpleNode node, String embed) {
|
||||
RuleContext ctx = (RuleContext) data;
|
||||
ctx.getReport().addRuleViolation(new RuleViolation(this, ctx, node, MessageFormat.format(getMessage(), new Object[]{embed})));
|
||||
ctx.getReport().addRuleViolation(new RuleViolation(this, ctx, node, MessageFormat.format(getMessage(), embed)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,8 +70,7 @@ public class CommandLineOptions {
|
||||
cpus = Integer.parseInt(args[++i]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException(MessageFormat.format(
|
||||
"cpus parameter must be a whole number, {0} received",
|
||||
(Object[]) new String[] { args[i] }));
|
||||
"cpus parameter must be a whole number, {0} received", args[i]));
|
||||
}
|
||||
} else if (args[i].equals("-targetjdk")) {
|
||||
targetJDK = args[++i];
|
||||
@ -90,8 +89,7 @@ public class CommandLineOptions {
|
||||
minPriority = Integer.parseInt(args[++i]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException(MessageFormat.format(
|
||||
"minimumpriority parameter must be a whole number, {0} received",
|
||||
(Object[]) new String[] { args[i] }));
|
||||
"minimumpriority parameter must be a whole number, {0} received", args[i]));
|
||||
}
|
||||
} else if (args[i].equals("-reportfile")) {
|
||||
reportFile = args[++i];
|
||||
|
@ -216,7 +216,7 @@ public abstract class CommonAbstractRule implements Rule {
|
||||
*/
|
||||
protected final void addViolation(Object data, SimpleNode node, String embed) {
|
||||
RuleContext ctx = (RuleContext) data;
|
||||
ctx.getReport().addRuleViolation(new RuleViolation(this, ctx, node, MessageFormat.format(getMessage(), new Object[]{embed})));
|
||||
ctx.getReport().addRuleViolation(new RuleViolation(this, ctx, node, MessageFormat.format(getMessage(), embed)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -148,10 +148,9 @@ public class DaaRule extends AbstractRule implements Executable {
|
||||
&& !violationAlreadyExists(type, var, startLine, endLine)
|
||||
&& node != null) {
|
||||
final RuleContext ctx = (RuleContext) data;
|
||||
final Object[] params = new Object[] { type, var, startLine, endLine };
|
||||
String msg = type;
|
||||
if (getMessage() != null) {
|
||||
msg = MessageFormat.format(getMessage(), params);
|
||||
msg = MessageFormat.format(getMessage(), type, var, startLine, endLine);
|
||||
}
|
||||
final DaaRuleViolation violation = new DaaRuleViolation(this, ctx, node, type, msg, var, startLine, endLine);
|
||||
ctx.getReport().addRuleViolation(violation);
|
||||
|
@ -228,7 +228,7 @@ public abstract class AbstractJspRule extends JspParserVisitorAdapter implements
|
||||
*/
|
||||
protected final void addViolation(Object data, SimpleNode node, String embed) {
|
||||
RuleContext ctx = (RuleContext) data;
|
||||
ctx.getReport().addRuleViolation(new RuleViolation(this, ctx, node, MessageFormat.format(getMessage(), new Object[]{embed})));
|
||||
ctx.getReport().addRuleViolation(new RuleViolation(this, ctx, node, MessageFormat.format(getMessage(), embed)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,9 +300,9 @@ public class Benchmark {
|
||||
while (buf2.length() <= 50) {
|
||||
buf2.append(' ');
|
||||
}
|
||||
buf2.append(StringUtil.lpad(MessageFormat.format("{0,number,0.000}", new Object[]{new Double(benchmarkResult.getTime()/1000000000.0)}), 8));
|
||||
buf2.append(StringUtil.lpad(MessageFormat.format("{0,number,0.000}", new Double(benchmarkResult.getTime()/1000000000.0)), 8));
|
||||
if (benchmarkResult.getType() <= TYPE_RULE_CHAIN_RULE) {
|
||||
buf2.append(StringUtil.lpad(MessageFormat.format("{0,number,###,###,###,###,###}", new Object[]{new Long(benchmarkResult.getCount())}), 20));
|
||||
buf2.append(StringUtil.lpad(MessageFormat.format("{0,number,###,###,###,###,###}", benchmarkResult.getCount()), 20));
|
||||
}
|
||||
switch (benchmarkResult.getType()) {
|
||||
case TYPE_RULE:
|
||||
|
@ -25,7 +25,7 @@ public class TypeMap {
|
||||
*
|
||||
* @param types Class[]
|
||||
*/
|
||||
public TypeMap(Class[] types) {
|
||||
public TypeMap(Class... types) {
|
||||
this(types.length);
|
||||
add(types);
|
||||
}
|
||||
@ -76,7 +76,7 @@ public class TypeMap {
|
||||
*
|
||||
* @param types Class[]
|
||||
*/
|
||||
public void add(Class[] types) {
|
||||
public void add(Class... types) {
|
||||
for (int i=0; i<types.length; i++) {
|
||||
add(types[i]);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class AttributesSubMenu
|
||||
private SimpleNode node;
|
||||
|
||||
public AttributesSubMenu(ViewerModel model, SimpleNode node) {
|
||||
super(MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), new Object[]{node.toString()}));
|
||||
super(MessageFormat.format(NLS.nls("AST.MENU.ATTRIBUTES"), node.toString()));
|
||||
this.model = model;
|
||||
this.node = node;
|
||||
init();
|
||||
|
@ -27,7 +27,7 @@ public class SimpleNodeSubMenu
|
||||
* @param node menu's owner
|
||||
*/
|
||||
public SimpleNodeSubMenu(ViewerModel model, SimpleNode node) {
|
||||
super(MessageFormat.format(NLS.nls("AST.MENU.NODE.TITLE"), new Object[]{node.toString()}));
|
||||
super(MessageFormat.format(NLS.nls("AST.MENU.NODE.TITLE"), node.toString()));
|
||||
this.model = model;
|
||||
this.node = node;
|
||||
init();
|
||||
|
Reference in New Issue
Block a user