提交 a858d565 编写于 作者: M malenkov

4922835: DOC: Statement javadoc should indicate that target and methodName cannot be null

Reviewed-by: peterz
上级 3694a07c
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -51,12 +51,19 @@ public class Expression extends Statement {
private Object value = unbound;
/**
* Creates a new <code>Statement</code> object with a <code>target</code>,
* <code>methodName</code> and <code>arguments</code> as per the parameters.
* Creates a new {@link Expression} object
* for the specified target object to invoke the method
* specified by the name and by the array of arguments.
* <p>
* The {@code target} and the {@code methodName} values should not be {@code null}.
* Otherwise an attempt to execute this {@code Expression}
* will result in a {@code NullPointerException}.
* If the {@code arguments} value is {@code null},
* an empty array is used as the value of the {@code arguments} property.
*
* @param target The target of this expression.
* @param methodName The methodName of this expression.
* @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
* @param target the target object of this expression
* @param methodName the name of the method to invoke on the specified target
* @param arguments the array of arguments to invoke the specified method
*
* @see #getValue
*/
......@@ -66,16 +73,23 @@ public class Expression extends Statement {
}
/**
* Creates a new <code>Expression</code> object for a method
* that returns a result. The result will never be calculated
* however, since this constructor uses the <code>value</code>
* parameter to set the value property by calling the
* <code>setValue</code> method.
* Creates a new {@link Expression} object with the specified value
* for the specified target object to invoke the method
* specified by the name and by the array of arguments.
* The {@code value} value is used as the value of the {@code value} property,
* so the {@link #getValue} method will return it
* without executing this {@code Expression}.
* <p>
* The {@code target} and the {@code methodName} values should not be {@code null}.
* Otherwise an attempt to execute this {@code Expression}
* will result in a {@code NullPointerException}.
* If the {@code arguments} value is {@code null},
* an empty array is used as the value of the {@code arguments} property.
*
* @param value The value of this expression.
* @param target The target of this expression.
* @param methodName The methodName of this expression.
* @param arguments The arguments of this expression. If <code>null</code> then an empty array will be used.
* @param value the value of this expression
* @param target the target object of this expression
* @param methodName the name of the method to invoke on the specified target
* @param arguments the array of arguments to invoke the specified method
*
* @see #setValue
*/
......
/*
* Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -69,13 +69,19 @@ public class Statement {
ClassLoader loader;
/**
* Creates a new <code>Statement</code> object with a <code>target</code>,
* <code>methodName</code> and <code>arguments</code> as per the parameters.
*
* @param target The target of this statement.
* @param methodName The methodName of this statement.
* @param arguments The arguments of this statement. If <code>null</code> then an empty array will be used.
* Creates a new {@link Statement} object
* for the specified target object to invoke the method
* specified by the name and by the array of arguments.
* <p>
* The {@code target} and the {@code methodName} values should not be {@code null}.
* Otherwise an attempt to execute this {@code Expression}
* will result in a {@code NullPointerException}.
* If the {@code arguments} value is {@code null},
* an empty array is used as the value of the {@code arguments} property.
*
* @param target the target object of this statement
* @param methodName the name of the method to invoke on the specified target
* @param arguments the array of arguments to invoke the specified method
*/
@ConstructorProperties({"target", "methodName", "arguments"})
public Statement(Object target, String methodName, Object[] arguments) {
......@@ -85,27 +91,36 @@ public class Statement {
}
/**
* Returns the target of this statement.
* Returns the target object of this statement.
* If this method returns {@code null},
* the {@link #execute} method
* throws a {@code NullPointerException}.
*
* @return The target of this statement.
* @return the target object of this statement
*/
public Object getTarget() {
return target;
}
/**
* Returns the name of the method.
* Returns the name of the method to invoke.
* If this method returns {@code null},
* the {@link #execute} method
* throws a {@code NullPointerException}.
*
* @return The name of the method.
* @return the name of the method
*/
public String getMethodName() {
return methodName;
}
/**
* Returns the arguments of this statement.
* Returns the arguments for the method to invoke.
* The number of arguments and their types
* must match the method being called.
* {@code null} can be used as a synonym of an empty array.
*
* @return the arguments of this statement.
* @return the array of arguments
*/
public Object[] getArguments() {
return arguments;
......@@ -154,6 +169,9 @@ public class Statement {
}
Object[] arguments = getArguments();
if (arguments == null) {
arguments = emptyArray;
}
// Class.forName() won't load classes outside
// of core from a class inside core. Special
// case this method.
......@@ -285,7 +303,9 @@ public class Statement {
Object target = getTarget();
String methodName = getMethodName();
Object[] arguments = getArguments();
if (arguments == null) {
arguments = emptyArray;
}
StringBuffer result = new StringBuffer(instanceName(target) + "." + methodName + "(");
int n = arguments.length;
for(int i = 0; i < n; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册