simpleProp.getOutput().render(value, buf);
delimiter = COMMA_DELIMITER_NEWLINE;
}
}
else {
EventPropertyRendererContext context = rendererOptions.getRendererContext();
context.setStringBuilderAndReset(buf);
for (GetterPair simpleProp : simpleProps)
{
Object value = simpleProp.getGetter().get(theEvent);
writeDelimitedIndentedProp(buf, delimiter, level, simpleProp.getName());
context.setDefaultRenderer(simpleProp.getOutput());
context.setPropertyName(simpleProp.getName());
context.setPropertyValue(value);
rendererOptions.getRenderer().render(context);
delimiter = COMMA_DELIMITER_NEWLINE;
}
}
GetterPair[] indexProps = meta.getIndexProperties();
for (GetterPair indexProp : indexProps)
{
Object value = indexProp.getGetter().get(theEvent);
writeDelimitedIndentedProp(buf, delimiter, level, indexProp.getName());
if (value == null)
{
buf.append("null");
}
else
{
if (!value.getClass().isArray())
{
buf.append("[]");
}
else
{
buf.append('[');
String arrayDelimiter = "";
if (rendererOptions.getRenderer() == null) {
for (int i = 0; i < Array.getLength(value); i++)
{
Object arrayItem = Array.get(value, i);
buf.append(arrayDelimiter);
indexProp.getOutput().render(arrayItem, buf);
arrayDelimiter = ", ";
}
}
else {
EventPropertyRendererContext context = rendererOptions.getRendererContext();
context.setStringBuilderAndReset(buf);
for (int i = 0; i < Array.getLength(value); i++)
{
Object arrayItem = Array.get(value, i);
buf.append(arrayDelimiter);
context.setPropertyName(indexProp.getName());
context.setPropertyValue(arrayItem);
context.setIndexedPropertyIndex(i);
context.setDefaultRenderer(indexProp.getOutput());
rendererOptions.getRenderer().render(context);
arrayDelimiter = ", ";
}
}
buf.append(']');
}
}
delimiter = COMMA_DELIMITER_NEWLINE;
}
GetterPair[] mappedProps = meta.getMappedProperties();
for (GetterPair mappedProp : mappedProps)
{
Object value = mappedProp.getGetter().get(theEvent);
if ((value != null) && (!(value instanceof Map)))
{
log.warn("Property '" + mappedProp.getName() + "' expected to return Map and returned " + value.getClass() + " instead");
continue;
}
writeDelimitedIndentedProp(buf, delimiter, level, mappedProp.getName());
if (value == null)
{
buf.append("null");
buf.append(NEWLINE);
}
else
{
Map<String, Object> map = (Map<String, Object>) value;
if (map.isEmpty())
{
buf.append("{}");
buf.append(NEWLINE);
}
else
{
buf.append('{');
buf.append(NEWLINE);
String localDelimiter = "";
Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
for (;it.hasNext();)
{
Map.Entry<String, Object> entry = it.next();
if (entry.getKey() == null)
{
continue;
}
buf.append(localDelimiter);
ident(buf, level + 1);
buf.append('\"');
buf.append(entry.getKey());
buf.append("\": ");
if (entry.getValue() == null)
{
buf.append("null");
}
else
{
OutputValueRenderer outRenderer = OutputValueRendererFactory.getOutputValueRenderer(entry.getValue().getClass(), rendererOptions);
if (rendererOptions.getRenderer() == null) {
outRenderer.render(entry.getValue(), buf);
}
else {
EventPropertyRendererContext context = rendererOptions.getRendererContext();
context.setStringBuilderAndReset(buf);
context.setPropertyName(mappedProp.getName());
context.setPropertyValue(entry.getValue());
context.setMappedPropertyKey(entry.getKey());
context.setDefaultRenderer(outRenderer);
rendererOptions.getRenderer().render(context);
}
}
localDelimiter = COMMA_DELIMITER_NEWLINE;
}