use of net.sourceforge.htmlunit.corejs.javascript.Delegator in project htmlunit by HtmlUnit.
the class Console method dir.
/**
* Implementation of console {@code dir} function. This method does not enter recursively
* in the passed object, nor prints the details of objects or functions.
* @param o the object to be printed
*/
@JsxFunction
public void dir(final Object o) {
if (o instanceof ScriptableObject) {
final ScriptableObject obj = (ScriptableObject) o;
final Object[] ids = obj.getIds();
if (ids != null && ids.length > 0) {
final StringBuilder sb = new StringBuilder();
for (final Object id : ids) {
final Object value = obj.get(id);
if (value instanceof Delegator) {
sb.append(id).append(": ").append(((Delegator) value).getClassName()).append('\n');
} else if (value instanceof HtmlUnitScriptable) {
sb.append(id).append(": ").append(((HtmlUnitScriptable) value).getClassName()).append('\n');
} else if (value instanceof BaseFunction) {
sb.append(id).append(": function ").append(((BaseFunction) value).getFunctionName()).append("()\n");
} else {
sb.append(id).append(": ").append(value).append('\n');
}
}
getWebConsole().info(sb.toString());
}
}
}
Aggregations