本文整理汇总了Java中com.espertech.esper.client.util.EventPropertyRendererContext类的典型用法代码示例。如果您正苦于以下问题:Java EventPropertyRendererContext类的具体用法?Java EventPropertyRendererContext怎么用?Java EventPropertyRendererContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventPropertyRendererContext类属于com.espertech.esper.client.util包,在下文中一共展示了EventPropertyRendererContext类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public void render(EventPropertyRendererContext context) {
if (context.getPropertyName().equals("someProperties")) {
Object[] value = (Object[]) context.getPropertyValue();
StringBuilder builder = context.getStringBuilder();
if (context.isJsonFormatted()) {
context.getStringBuilder().append("\"");
}
String delimiter = "";
for (int i = 0; i < value.length; i++) {
builder.append(delimiter);
builder.append("index#");
builder.append(Integer.toString(i));
builder.append("=");
builder.append(value[i]);
delimiter = ";";
}
if (context.isJsonFormatted()) {
context.getStringBuilder().append("\"");
}
} else {
context.getDefaultRenderer().render(context.getPropertyValue(), context.getStringBuilder());
}
contexts.add(context.copy());
}
示例2: renderAttributes
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
private void renderAttributes(EventBean theEvent, StringBuilder buf, RendererMeta meta) {
String delimiter = " ";
GetterPair[] simpleProps = meta.getSimpleProperties();
for (GetterPair simpleProp : simpleProps) {
Object value = simpleProp.getGetter().get(theEvent);
if (value == null) {
continue;
}
buf.append(delimiter);
buf.append(simpleProp.getName());
buf.append("=\"");
if (rendererMetaOptions.getRenderer() == null) {
simpleProp.getOutput().render(value, buf);
} else {
EventPropertyRendererContext context = rendererMetaOptions.getRendererContext();
context.setStringBuilderAndReset(buf);
context.setPropertyName(simpleProp.getName());
context.setPropertyValue(value);
context.setDefaultRenderer(simpleProp.getOutput());
rendererMetaOptions.getRenderer().render(context);
}
buf.append('"');
}
}
示例3: runAssertionPropertyCustomRenderer
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
private void runAssertionPropertyCustomRenderer(EPServiceProvider epService) {
epService.getEPAdministrator().getConfiguration().addEventType(MyRendererEvent.class);
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from MyRendererEvent");
epService.getEPRuntime().sendEvent(new MyRendererEvent("id1", new Object[][]{{1, "x"}, {2, "y"}}));
MyRenderer.getContexts().clear();
JSONRenderingOptions jsonOptions = new JSONRenderingOptions();
jsonOptions.setRenderer(new MyRenderer());
String json = epService.getEPRuntime().getEventRenderer().renderJSON("MyEvent", stmt.iterator().next(), jsonOptions);
assertEquals(4, MyRenderer.getContexts().size());
List<EventPropertyRendererContext> contexts = MyRenderer.getContexts();
EventPropertyRendererContext context = contexts.get(2);
assertNotNull(context.getDefaultRenderer());
assertEquals(1, (int) context.getIndexedPropertyIndex());
assertEquals(MyRendererEvent.class.getSimpleName(), context.getEventType().getName());
assertEquals("someProperties", context.getPropertyName());
String expectedJson = "{ \"MyEvent\": { \"id\": \"id1\", \"someProperties\": [\"index#0=1;index#1=x\", \"index#0=2;index#1=y\"], \"mappedProperty\": { \"key\": \"value\" } } }";
assertEquals(removeNewline(expectedJson), removeNewline(json));
MyRenderer.getContexts().clear();
XMLRenderingOptions xmlOptions = new XMLRenderingOptions();
xmlOptions.setRenderer(new MyRenderer());
String xmlOne = epService.getEPRuntime().getEventRenderer().renderXML("MyEvent", stmt.iterator().next(), xmlOptions);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <MyEvent> <id>id1</id> <someProperties>index#0=1;index#1=x</someProperties> <someProperties>index#0=2;index#1=y</someProperties> <mappedProperty> <key>value</key> </mappedProperty> </MyEvent>";
assertEquals(4, MyRenderer.getContexts().size());
assertEquals(removeNewline(expected), removeNewline(xmlOne));
stmt.destroy();
}
示例4: RendererMetaOptions
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
/**
* Ctor.
* @param preventLooping true to prevent looping
* @param xmlOutput true for XML output
*/
public RendererMetaOptions(boolean preventLooping, boolean xmlOutput, EventPropertyRenderer renderer, EventPropertyRendererContext rendererContext) {
this.preventLooping = preventLooping;
this.xmlOutput = xmlOutput;
this.renderer = renderer;
this.rendererContext = rendererContext;
}
示例5: renderAttributes
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
private void renderAttributes(EventBean theEvent, StringBuilder buf, RendererMeta meta)
{
String delimiter = " ";
GetterPair[] simpleProps = meta.getSimpleProperties();
for (GetterPair simpleProp : simpleProps)
{
Object value = simpleProp.getGetter().get(theEvent);
if (value == null)
{
continue;
}
buf.append(delimiter);
buf.append(simpleProp.getName());
buf.append("=\"");
if (rendererMetaOptions.getRenderer() == null) {
simpleProp.getOutput().render(value, buf);
}
else {
EventPropertyRendererContext context = rendererMetaOptions.getRendererContext();
context.setStringBuilderAndReset(buf);
context.setPropertyName(simpleProp.getName());
context.setPropertyValue(value);
context.setDefaultRenderer(simpleProp.getOutput());
rendererMetaOptions.getRenderer().render(context);
}
buf.append('"');
}
}
示例6: testPropertyCustomRenderer
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public void testPropertyCustomRenderer() {
epService.getEPAdministrator().getConfiguration().addEventType(MyRendererEvent.class);
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from MyRendererEvent");
epService.getEPRuntime().sendEvent(new MyRendererEvent("id1", new Object[][] {{1, "x"}, {2, "y"}}));
MyRenderer.getContexts().clear();
JSONRenderingOptions jsonOptions = new JSONRenderingOptions();
jsonOptions.setRenderer(new MyRenderer());
String json = epService.getEPRuntime().getEventRenderer().renderJSON("MyEvent", stmt.iterator().next(), jsonOptions);
assertEquals(4, MyRenderer.getContexts().size());
List<EventPropertyRendererContext> contexts = MyRenderer.getContexts();
EventPropertyRendererContext context = contexts.get(2);
assertNotNull(context.getDefaultRenderer());
assertEquals(1, (int) context.getIndexedPropertyIndex());
assertEquals(MyRendererEvent.class.getSimpleName(), context.getEventType().getName());
assertEquals("someProperties", context.getPropertyName());
String expectedJson = "{ \"MyEvent\": { \"id\": \"id1\", \"someProperties\": [\"index#0=1;index#1=x\", \"index#0=2;index#1=y\"], \"mappedProperty\": { \"key\": \"value\" } } }";
assertEquals(removeNewline(expectedJson), removeNewline(json));
MyRenderer.getContexts().clear();
XMLRenderingOptions xmlOptions = new XMLRenderingOptions();
xmlOptions.setRenderer(new MyRenderer());
String xmlOne = epService.getEPRuntime().getEventRenderer().renderXML("MyEvent", stmt.iterator().next(), xmlOptions);
String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <MyEvent> <id>id1</id> <someProperties>index#0=1;index#1=x</someProperties> <someProperties>index#0=2;index#1=y</someProperties> <mappedProperty> <key>value<key> </mappedProperty> </MyEvent>";
assertEquals(4, MyRenderer.getContexts().size());
assertEquals(removeNewline(expected), removeNewline(xmlOne));
}
示例7: render
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public void render(EventPropertyRendererContext context) {
if (context.getPropertyName().equals("someProperties")) {
Object[] value = (Object[]) context.getPropertyValue();
StringBuilder builder = context.getStringBuilder();
if (context.isJsonFormatted()) {
context.getStringBuilder().append("\"");
}
String delimiter = "";
for (int i = 0; i < value.length; i++) {
builder.append(delimiter);
builder.append("index#");
builder.append(Integer.toString(i));
builder.append("=");
builder.append(value[i]);
delimiter = ";";
}
if (context.isJsonFormatted()) {
context.getStringBuilder().append("\"");
}
}
else {
context.getDefaultRenderer().render(context.getPropertyValue(), context.getStringBuilder());
}
contexts.add(context.copy());
}
示例8: getContexts
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public static List<EventPropertyRendererContext> getContexts() {
return contexts;
}
示例9: setContexts
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public static void setContexts(List<EventPropertyRendererContext> contexts) {
MyRenderer.contexts = contexts;
}
示例10: getRendererContext
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public EventPropertyRendererContext getRendererContext() {
return rendererContext;
}
示例11: RendererMetaOptions
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
/**
* Ctor.
*
* @param preventLooping true to prevent looping
* @param xmlOutput true for XML output
* @param rendererContext context
* @param renderer renderer
*/
public RendererMetaOptions(boolean preventLooping, boolean xmlOutput, EventPropertyRenderer renderer, EventPropertyRendererContext rendererContext) {
this.preventLooping = preventLooping;
this.xmlOutput = xmlOutput;
this.renderer = renderer;
this.rendererContext = rendererContext;
}
示例12: render
import com.espertech.esper.client.util.EventPropertyRendererContext; //导入依赖的package包/类
public void render(EventPropertyRendererContext context) {
}