/// <dt><code>sequence</code></dt>
/// <dd>Sequence of name of attributes to return</dd>
/// </dl>
public static final Any newInstance(anvil.script.Context context, Any[] parameters)
{
SearchControls controls = new SearchControls();
int n = parameters.length;
for(int i=0; i<n; i++) {
Any property = parameters[i];
if (property.isMap()) {
AnyMap map = property.toMap();
String key = map.getLeft().toString();
if (key.equalsIgnoreCase("scope")) {
controls.setSearchScope(map.getRight().toInt());
} else if (key.equalsIgnoreCase("countlimit")) {
controls.setCountLimit(map.getRight().toInt());
} else if (key.equalsIgnoreCase("timelimit")) {
controls.setTimeLimit(map.getRight().toInt());
} else if (key.equalsIgnoreCase("attributes")) {
Any right = map.getRight();
if (right.isNull()) {
controls.setReturningAttributes(null);
} else {
String[] attributes = AnyUtils.toStringArray(right);
controls.setReturningAttributes(attributes);
}
} else if (key.equalsIgnoreCase("returnobject")) {
controls.setReturningObjFlag(map.getRight().toBoolean());
} else if (key.equalsIgnoreCase("dereflinks")) {
controls.setDerefLinkFlag(map.getRight().toBoolean());
} else {
throw context.BadParameter("Invalid attribute: '"+key+"'");
}
} else if (property.isString()) {
String key = property.toString();
if (key.equalsIgnoreCase("returnobject")) {
controls.setReturningObjFlag(true);
} else if (key.equalsIgnoreCase("dereflinks")) {
controls.setDerefLinkFlag(true);
} else {
throw context.BadParameter("Invalid attribute: '"+key+"'");
}
} else if (property.isSequence() || property.isArray()) {
String[] attributes = AnyUtils.toStringArray(property);
controls.setReturningAttributes(attributes);
} else {
throw context.BadParameter("Invalid property: '"+property+"'");
}