use of lucee.runtime.dump.ClassicHTMLDumpWriter in project Lucee by lucee.
the class XMLConfigWebFactory method loadDumpWriter.
private static void loadDumpWriter(ConfigServerImpl configServer, ConfigImpl config, Document doc) throws ClassException {
boolean hasCS = configServer != null;
Element coll = getChildByName(doc.getDocumentElement(), "dump-writers");
Element[] writers = getChildren(coll, "dump-writer");
Struct sct = new StructImpl();
boolean hasPlain = false;
boolean hasRich = false;
if (hasCS) {
DumpWriterEntry[] entries = configServer.getDumpWritersEntries();
if (entries != null)
for (int i = 0; i < entries.length; i++) {
if (entries[i].getDefaultType() == HTMLDumpWriter.DEFAULT_PLAIN)
hasPlain = true;
if (entries[i].getDefaultType() == HTMLDumpWriter.DEFAULT_RICH)
hasRich = true;
sct.put(entries[i].getName(), entries[i]);
}
}
if (writers != null && writers.length > 0) {
ClassDefinition cd;
String strName;
String strDefault;
Class clazz;
int def = HTMLDumpWriter.DEFAULT_NONE;
for (int i = 0; i < writers.length; i++) {
cd = getClassDefinition(writers[i], "", config.getIdentification());
strName = getAttr(writers[i], "name");
strDefault = getAttr(writers[i], "default");
clazz = cd.getClazz(null);
if (clazz != null && !StringUtil.isEmpty(strName)) {
if (StringUtil.isEmpty(strDefault))
def = HTMLDumpWriter.DEFAULT_NONE;
else if ("browser".equalsIgnoreCase(strDefault))
def = HTMLDumpWriter.DEFAULT_RICH;
else if ("console".equalsIgnoreCase(strDefault))
def = HTMLDumpWriter.DEFAULT_PLAIN;
sct.put(strName, new DumpWriterEntry(def, strName, (DumpWriter) ClassUtil.loadInstance(clazz)));
}
}
} else {
// print.err("yep");
if (!hasRich)
sct.setEL(KeyConstants._html, new DumpWriterEntry(HTMLDumpWriter.DEFAULT_RICH, "html", new HTMLDumpWriter()));
if (!hasPlain)
sct.setEL(KeyConstants._text, new DumpWriterEntry(HTMLDumpWriter.DEFAULT_PLAIN, "text", new TextDumpWriter()));
sct.setEL(KeyConstants._classic, new DumpWriterEntry(HTMLDumpWriter.DEFAULT_NONE, "classic", new ClassicHTMLDumpWriter()));
sct.setEL(KeyConstants._simple, new DumpWriterEntry(HTMLDumpWriter.DEFAULT_NONE, "simple", new SimpleHTMLDumpWriter()));
}
Iterator<Object> it = sct.valueIterator();
java.util.List<DumpWriterEntry> entries = new ArrayList<DumpWriterEntry>();
while (it.hasNext()) {
entries.add((DumpWriterEntry) it.next());
}
config.setDumpWritersEntries(entries.toArray(new DumpWriterEntry[entries.size()]));
}
Aggregations