use of lucee.runtime.dump.DumpData in project Lucee by lucee.
the class ComponentImpl method thisScope.
static DumpTable thisScope(ComponentImpl ci, PageContext pc, int maxlevel, DumpProperties dp, int access) {
DumpTable table = new DumpTable("#ffffff", "#cccccc", "#000000");
DumpTable[] accesses = new DumpTable[4];
accesses[Component.ACCESS_REMOTE] = new DumpTable("#ccffcc", "#ffffff", "#000000");
accesses[Component.ACCESS_REMOTE].setTitle("remote");
accesses[Component.ACCESS_PUBLIC] = new DumpTable("#ffcc99", "#ffffcc", "#000000");
accesses[Component.ACCESS_PUBLIC].setTitle("public");
accesses[Component.ACCESS_PACKAGE] = new DumpTable("#ff9966", "#ffcc99", "#000000");
accesses[Component.ACCESS_PACKAGE].setTitle("package");
accesses[Component.ACCESS_PRIVATE] = new DumpTable("#ff6633", "#ff9966", "#000000");
accesses[Component.ACCESS_PRIVATE].setTitle("private");
maxlevel--;
ComponentSpecificAccess cw = new ComponentSpecificAccess(Component.ACCESS_PRIVATE, ci);
Collection.Key[] keys = cw.keys();
List<DumpRow>[] drAccess = new List[4];
for (int i = 0; i < drAccess.length; i++) // ACCESS_REMOTE=0, ACCESS_PUBLIC=1, ACCESS_PACKAGE=2, ACCESS_PRIVATE=3
drAccess[i] = new ArrayList();
Collection.Key key;
for (int i = 0; i < keys.length; i++) {
key = keys[i];
List<DumpRow> box = drAccess[ci.getAccess(key)];
Object o = cw.get(key, null);
if (o == ci)
o = "[this]";
if (DumpUtil.keyValid(dp, maxlevel, key)) {
String memberName = (o instanceof UDF) ? ((UDF) o).getFunctionName() : key.getString();
box.add(new DumpRow(1, new SimpleDumpData(memberName), DumpUtil.toDumpData(o, pc, maxlevel, dp)));
}
}
List<DumpRow> dumpRows;
for (int i = 0; i < drAccess.length; i++) {
dumpRows = drAccess[i];
if (!dumpRows.isEmpty()) {
Collections.sort(dumpRows, new Comparator<DumpRow>() {
@Override
public int compare(DumpRow o1, DumpRow o2) {
DumpData[] rowItems1 = o1.getItems();
DumpData[] rowItems2 = o2.getItems();
if (rowItems1.length >= 0 && rowItems2.length > 0 && rowItems1[0] instanceof SimpleDumpData && rowItems2[0] instanceof SimpleDumpData)
return String.CASE_INSENSITIVE_ORDER.compare(rowItems1[0].toString(), rowItems2[0].toString());
return 0;
}
});
DumpTable dtAccess = accesses[i];
dtAccess.setWidth("100%");
for (DumpRow dr : dumpRows) dtAccess.appendRow(dr);
table.appendRow(0, dtAccess);
}
}
// properties
if (ci.top.properties.persistent || ci.top.properties.accessors) {
Property[] properties = ci.getProperties(false, true, false, false);
DumpTable prop = new DumpTable("#99cc99", "#ccffcc", "#000000");
prop.setTitle("Properties");
prop.setWidth("100%");
Property p;
Object child;
for (int i = 0; i < properties.length; i++) {
p = properties[i];
child = ci.scope.get(KeyImpl.init(p.getName()), null);
DumpData dd;
if (child instanceof Component) {
DumpTable t = new DumpTable("component", "#99cc99", "#ffffff", "#000000");
t.appendRow(1, new SimpleDumpData(((Component) child).getPageSource().getDialect() == CFMLEngine.DIALECT_CFML ? "Component" : "Class"), new SimpleDumpData(((Component) child).getCallName()));
dd = t;
} else {
dd = DumpUtil.toDumpData(child, pc, maxlevel - 1, dp);
}
prop.appendRow(1, new SimpleDumpData(p.getName()), dd);
}
if (access >= ACCESS_PUBLIC && !prop.isEmpty()) {
table.appendRow(0, prop);
}
}
return table;
}
use of lucee.runtime.dump.DumpData in project Lucee by lucee.
the class UDFUtil method toDumpData.
public static DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp, UDF udf, short type) {
if (!dp.getShowUDFs()) {
if (TYPE_UDF == type)
return new SimpleDumpData("<UDF>");
if (TYPE_BIF == type)
return new SimpleDumpData("<BIF>");
if (TYPE_CLOSURE == type)
return new SimpleDumpData("<Closure>");
if (TYPE_LAMBDA == type)
return new SimpleDumpData("<Lambda>");
}
// arguments
FunctionArgument[] args = udf.getFunctionArguments();
DumpTable atts;
if (TYPE_UDF == type)
atts = new DumpTable("udf", "#ca5095", "#e9accc", "#000000");
else if (TYPE_CLOSURE == type)
atts = new DumpTable("udf", "#9cb770", "#c7e1ba", "#000000");
else if (TYPE_BIF == type)
atts = new DumpTable("udf", "#e1c039", "#f1e2a3", "#000000");
else
atts = new DumpTable("udf", "#f3d5bd", "#f6e4cc", "#000000");
atts.appendRow(new DumpRow(63, new DumpData[] { new SimpleDumpData("label"), new SimpleDumpData("name"), new SimpleDumpData("required"), new SimpleDumpData("type"), new SimpleDumpData("default"), new SimpleDumpData("hint") }));
for (int i = 0; i < args.length; i++) {
FunctionArgument arg = args[i];
DumpData def;
try {
Object oa = udf.getDefaultValue(pageContext, i, null);
if (oa == null)
oa = "null";
def = new SimpleDumpData(Caster.toString(oa));
} catch (PageException e) {
def = new SimpleDumpData("");
}
atts.appendRow(new DumpRow(0, new DumpData[] { new SimpleDumpData(arg.getDisplayName()), new SimpleDumpData(arg.getName().getString()), new SimpleDumpData(arg.isRequired()), new SimpleDumpData(arg.getTypeAsString()), def, new SimpleDumpData(arg.getHint()) }));
// atts.setRow(0,arg.getHint());
}
DumpTable func;
String label = udf.getDisplayName();
if (TYPE_CLOSURE == type) {
func = new DumpTable("#9cb770", "#c7e1ba", "#000000");
func.setTitle(StringUtil.isEmpty(label) ? "Closure" : "Closure " + label);
} else if (TYPE_UDF == type) {
func = new DumpTable("#ca5095", "#e9accc", "#000000");
String f = "Function ";
try {
f = StringUtil.ucFirst(ComponentUtil.toStringAccess(udf.getAccess()).toLowerCase()) + " " + f;
} catch (ApplicationException e) {
}
f += udf.getFunctionName();
if (udf instanceof UDFGSProperty)
f += " (generated)";
func.setTitle(f);
} else if (TYPE_BIF == type) {
String f = "Build in Function " + (!StringUtil.isEmpty(label) ? label : udf.getFunctionName());
func = new DumpTable("#e1c039", "#f1e2a3", "#000000");
func.setTitle(f);
} else {
func = new DumpTable("#f3d5bd", "#f6e4cc", "#000000");
func.setTitle(StringUtil.isEmpty(label) ? "Lambda" : "Lambda " + label);
}
// Source
String src = udf.getSource();
if (!StringUtil.isEmpty(src))
func.setComment("source:" + src);
String hint = udf.getHint();
String desc = udf.getDescription();
if (!StringUtil.isEmpty(desc))
addComment(func, desc);
if (!StringUtil.isEmpty(hint))
addComment(func, hint);
if (Component.MODIFIER_NONE != udf.getModifier())
func.appendRow(1, new SimpleDumpData("modifier"), new SimpleDumpData(ComponentUtil.toModifier(udf.getModifier(), "")));
func.appendRow(1, new SimpleDumpData("arguments"), atts);
func.appendRow(1, new SimpleDumpData("return type"), new SimpleDumpData(udf.getReturnTypeAsString()));
return func;
}
use of lucee.runtime.dump.DumpData in project Lucee by lucee.
the class DumpStruct method call.
public static Struct call(PageContext pc, Object object, double maxLevel, String show, String hide, double keys, boolean metainfo, boolean showUDFs, String label) {
if (show != null && "all".equalsIgnoreCase(show.trim()))
show = null;
if (hide != null && "all".equalsIgnoreCase(hide.trim()))
hide = null;
Set<String> setShow = (show != null) ? ListUtil.listToSet(show.toLowerCase(), ",", true) : null;
Set<String> setHide = (hide != null) ? ListUtil.listToSet(hide.toLowerCase(), ",", true) : null;
DumpProperties properties = new DumpProperties((int) maxLevel, setShow, setHide, (int) keys, metainfo, showUDFs);
DumpData dd = DumpUtil.toDumpData(object, pc, (int) maxLevel, properties);
if (!StringUtil.isEmpty(label)) {
DumpTable table = new DumpTable("#ffffff", "#cccccc", "#000000");
table.appendRow(1, new SimpleDumpData(label));
table.appendRow(0, dd);
dd = table;
}
RefBoolean hasReference = new RefBooleanImpl(false);
Struct sct = toStruct(dd, object, hasReference);
sct.setEL("hasReference", hasReference.toBoolean());
addMetaData(sct, object);
return sct;
}
use of lucee.runtime.dump.DumpData in project Lucee by lucee.
the class Image method toDumpData.
@Override
public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
DumpData dd = _info().toDumpData(pageContext, maxlevel, dp);
if (dd instanceof DumpTable) {
DumpTable dt = ((DumpTable) dd);
dt.setTitle("Struct (Image)");
try {
dt.setComment("<img style=\"margin:5px\" src=\"data:image/png;base64," + getBase64String("png") + "\">");
} catch (PageException e) {
}
}
return dd;
}
use of lucee.runtime.dump.DumpData in project Lucee by lucee.
the class QueryUtil method toDumpData.
public static DumpData toDumpData(Query query, PageContext pageContext, int maxlevel, DumpProperties dp) {
maxlevel--;
Collection.Key[] keys = CollectionUtil.keys(query);
DumpData[] heads = new DumpData[keys.length + 1];
// int tmp=1;
heads[0] = new SimpleDumpData("");
for (int i = 0; i < keys.length; i++) {
heads[i + 1] = new SimpleDumpData(keys[i].getString());
}
StringBuilder comment = new StringBuilder();
// table.appendRow(1, new SimpleDumpData("SQL"), new SimpleDumpData(sql.toString()));
String template = query.getTemplate();
if (!StringUtil.isEmpty(template))
comment.append("Template: ").append(template).append("\n");
// table.appendRow(1, new SimpleDumpData("Template"), new SimpleDumpData(template));
// in Query dump maxlevel is used as Top
int top = dp.getMaxlevel();
comment.append("Execution Time: ").append(Caster.toString(FormatUtil.formatNSAsMSDouble(query.getExecutionTime()))).append(" ms \n");
comment.append("Record Count: ").append(Caster.toString(query.getRecordcount()));
if (query.getRecordcount() > top)
comment.append(" (showing top ").append(Caster.toString(top)).append(")");
comment.append("\n");
comment.append("Cached: ").append(query.isCached() ? "Yes\n" : "No\n");
if (query.isCached() && query instanceof Query) {
comment.append("Cache Type: ").append(query.getCacheType()).append("\n");
}
comment.append("Lazy: ").append(query instanceof SimpleQuery ? "Yes\n" : "No\n");
SQL sql = query.getSql();
if (sql != null)
comment.append("SQL: ").append("\n").append(StringUtil.suppressWhiteSpace(sql.toString().trim())).append("\n");
// table.appendRow(1, new SimpleDumpData("Execution Time (ms)"), new SimpleDumpData(exeTime));
// table.appendRow(1, new SimpleDumpData("recordcount"), new SimpleDumpData(getRecordcount()));
// table.appendRow(1, new SimpleDumpData("cached"), new SimpleDumpData(isCached()?"Yes":"No"));
DumpTable recs = new DumpTable("query", "#cc99cc", "#ffccff", "#000000");
recs.setTitle("Query");
if (dp.getMetainfo())
recs.setComment(comment.toString());
recs.appendRow(new DumpRow(-1, heads));
// body
DumpData[] items;
int recordcount = query.getRecordcount();
int columncount = query.getColumnNames().length;
for (int i = 0; i < recordcount; i++) {
items = new DumpData[columncount + 1];
items[0] = new SimpleDumpData(i + 1);
for (int y = 0; y < keys.length; y++) {
try {
Object o = query.getAt(keys[y], i + 1);
if (o instanceof String)
items[y + 1] = new SimpleDumpData(o.toString());
else if (o instanceof Number)
items[y + 1] = new SimpleDumpData(Caster.toString(((Number) o)));
else if (o instanceof Boolean)
items[y + 1] = new SimpleDumpData(((Boolean) o).booleanValue());
else if (o instanceof Date)
items[y + 1] = new SimpleDumpData(Caster.toString(o));
else if (o instanceof Clob)
items[y + 1] = new SimpleDumpData(Caster.toString(o));
else
items[y + 1] = DumpUtil.toDumpData(o, pageContext, maxlevel, dp);
} catch (PageException e) {
items[y + 1] = new SimpleDumpData("[empty]");
}
}
recs.appendRow(new DumpRow(1, items));
if (i == top - 1)
break;
}
if (!dp.getMetainfo())
return recs;
// table.appendRow(1, new SimpleDumpData("result"), recs);
return recs;
}
Aggregations