com.espertech.esper.avro.util.support.SupportAvroUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esper-avro Show documentation
Show all versions of esper-avro Show documentation
Complex event processing and event series analysis component
The newest version!
/*
***************************************************************************************
* Copyright (C) 2006 EsperTech, Inc. All rights reserved. *
* http://www.espertech.com/esper *
* http://www.espertech.com *
* ---------------------------------------------------------------------------------- *
* The software in this package is published under the terms of the GPL license *
* a copy of which has been included with this distribution in the license.txt file. *
***************************************************************************************
*/
package com.espertech.esper.avro.util.support;
import com.espertech.esper.avro.core.AvroEventType;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.EventType;
import com.espertech.esper.core.support.SupportEventAdapterService;
import com.espertech.esper.event.EventTypeMetadata;
import com.espertech.esper.event.avro.AvroSchemaEventType;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.io.*;
import java.io.*;
import java.util.HashSet;
import java.util.Set;
public class SupportAvroUtil {
public static String avroToJson(EventBean theEvent) {
Schema schema = (Schema) ((AvroSchemaEventType) theEvent.getEventType()).getSchema();
GenericData.Record record = (GenericData.Record) theEvent.getUnderlying();
return avroToJson(schema, record);
}
public static String avroToJson(Schema schema, GenericData.Record datum) {
DatumWriter