Search in sources :

Example 1 with DumpProperties

use of lucee.runtime.dump.DumpProperties 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;
}
Also used : DumpTable(lucee.runtime.dump.DumpTable) RefBoolean(lucee.commons.lang.types.RefBoolean) SimpleDumpData(lucee.runtime.dump.SimpleDumpData) DumpProperties(lucee.runtime.dump.DumpProperties) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl) SimpleDumpData(lucee.runtime.dump.SimpleDumpData) DumpData(lucee.runtime.dump.DumpData) Struct(lucee.runtime.type.Struct)

Example 2 with DumpProperties

use of lucee.runtime.dump.DumpProperties in project Lucee by lucee.

the class Dump method call.

public static String call(PageContext pc, Object object, String label, boolean expand, double maxLevel, String show, String hide, String output, String format, double keys, boolean metainfo, boolean showUDFs) throws PageException {
    if (show != null && "all".equalsIgnoreCase(show.trim()))
        show = null;
    if (hide != null && "all".equalsIgnoreCase(hide.trim()))
        hide = null;
    // PageContext pcc = pc;
    try {
        // output
        int defType = DumpWriter.DEFAULT_RICH;
        int outputType = OUTPUT_TYPE_NONE;
        Resource outputRes = null;
        if (!StringUtil.isEmpty(output, true)) {
            output = output.trim();
            if ("browser".equalsIgnoreCase(output)) {
                outputType = OUTPUT_TYPE_BROWSER;
                defType = DumpWriter.DEFAULT_RICH;
            } else if ("console".equalsIgnoreCase(output)) {
                outputType = OUTPUT_TYPE_CONSOLE;
                defType = DumpWriter.DEFAULT_PLAIN;
            } else {
                outputType = OUTPUT_TYPE_RESOURCE;
                defType = DumpWriter.DEFAULT_RICH;
                outputRes = ResourceUtil.toResourceNotExisting(pc, output);
            }
        }
        // format
        DumpWriter writer = pc.getConfig().getDumpWriter(format, defType);
        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(1,new SimpleDumpData(getContext()));
            table.appendRow(0, dd);
            dd = table;
        }
        // formatType==FORMAT_TYPE_TEXT
        boolean isText = "text".equalsIgnoreCase(format);
        if (OUTPUT_TYPE_BROWSER == outputType || outputType == OUTPUT_TYPE_NONE) {
            if (isText)
                pc.forceWrite("<pre>");
            pc.forceWrite(writer.toString(pc, dd, expand));
            if (isText)
                pc.forceWrite("</pre>");
        } else if (OUTPUT_TYPE_CONSOLE == outputType)
            System.out.println(writer.toString(pc, dd, expand));
        else if (OUTPUT_TYPE_RESOURCE == outputType)
            IOUtil.write(outputRes, writer.toString(pc, dd, expand) + "\n************************************************************************************\n", ((PageContextImpl) pc).getResourceCharset(), true);
    } catch (IOException e) {
        throw Caster.toPageException(e);
    }
    return "";
}
Also used : DumpTable(lucee.runtime.dump.DumpTable) DumpWriter(lucee.runtime.dump.DumpWriter) SimpleDumpData(lucee.runtime.dump.SimpleDumpData) Resource(lucee.commons.io.res.Resource) DumpProperties(lucee.runtime.dump.DumpProperties) PageContextImpl(lucee.runtime.PageContextImpl) IOException(java.io.IOException) DumpData(lucee.runtime.dump.DumpData) SimpleDumpData(lucee.runtime.dump.SimpleDumpData)

Aggregations

DumpData (lucee.runtime.dump.DumpData)2 DumpProperties (lucee.runtime.dump.DumpProperties)2 DumpTable (lucee.runtime.dump.DumpTable)2 SimpleDumpData (lucee.runtime.dump.SimpleDumpData)2 IOException (java.io.IOException)1 Resource (lucee.commons.io.res.Resource)1 RefBoolean (lucee.commons.lang.types.RefBoolean)1 RefBooleanImpl (lucee.commons.lang.types.RefBooleanImpl)1 PageContextImpl (lucee.runtime.PageContextImpl)1 DumpWriter (lucee.runtime.dump.DumpWriter)1 Struct (lucee.runtime.type.Struct)1