/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Collections; import java.util.BitSet; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.facebook.thrift.*; import com.facebook.thrift.annotations.*; import com.facebook.thrift.async.*; import com.facebook.thrift.meta_data.*; import com.facebook.thrift.server.*; import com.facebook.thrift.transport.*; import com.facebook.thrift.protocol.*; @SuppressWarnings({ "unused", "serial" }) public class FooBarBazService { public interface Iface { public void foo() throws TException; public void bar() throws TException; public void baz() throws TException; } public interface AsyncIface { public void foo(AsyncMethodCallback resultHandler) throws TException; public void bar(AsyncMethodCallback resultHandler) throws TException; public void baz(AsyncMethodCallback resultHandler) throws TException; } public static class Client extends EventHandlerBase implements Iface, TClientIf { public Client(TProtocol prot) { this(prot, prot); } public Client(TProtocol iprot, TProtocol oprot) { iprot_ = iprot; oprot_ = oprot; } protected TProtocol iprot_; protected TProtocol oprot_; protected int seqid_; @Override public TProtocol getInputProtocol() { return this.iprot_; } @Override public TProtocol getOutputProtocol() { return this.oprot_; } public void foo() throws TException { ContextStack ctx = getContextStack("FooBarBazService.foo", null); this.setContextStack(ctx); send_foo(); recv_foo(); } public void send_foo() throws TException { ContextStack ctx = this.getContextStack(); super.preWrite(ctx, "FooBarBazService.foo", null); oprot_.writeMessageBegin(new TMessage("foo", TMessageType.CALL, seqid_)); foo_args args = new foo_args(); args.write(oprot_); oprot_.writeMessageEnd(); oprot_.getTransport().flush(); super.postWrite(ctx, "FooBarBazService.foo", args); return; } public void recv_foo() throws TException { ContextStack ctx = super.getContextStack(); long bytes; TMessageType mtype; super.preRead(ctx, "FooBarBazService.foo"); TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { TApplicationException x = TApplicationException.read(iprot_); iprot_.readMessageEnd(); throw x; } foo_result result = foo_result.deserialize(iprot_); iprot_.readMessageEnd(); super.postRead(ctx, "FooBarBazService.foo", result); return; } public void bar() throws TException { ContextStack ctx = getContextStack("FooBarBazService.bar", null); this.setContextStack(ctx); send_bar(); recv_bar(); } public void send_bar() throws TException { ContextStack ctx = this.getContextStack(); super.preWrite(ctx, "FooBarBazService.bar", null); oprot_.writeMessageBegin(new TMessage("bar", TMessageType.CALL, seqid_)); bar_args args = new bar_args(); args.write(oprot_); oprot_.writeMessageEnd(); oprot_.getTransport().flush(); super.postWrite(ctx, "FooBarBazService.bar", args); return; } public void recv_bar() throws TException { ContextStack ctx = super.getContextStack(); long bytes; TMessageType mtype; super.preRead(ctx, "FooBarBazService.bar"); TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { TApplicationException x = TApplicationException.read(iprot_); iprot_.readMessageEnd(); throw x; } bar_result result = bar_result.deserialize(iprot_); iprot_.readMessageEnd(); super.postRead(ctx, "FooBarBazService.bar", result); return; } public void baz() throws TException { ContextStack ctx = getContextStack("FooBarBazService.baz", null); this.setContextStack(ctx); send_baz(); recv_baz(); } public void send_baz() throws TException { ContextStack ctx = this.getContextStack(); super.preWrite(ctx, "FooBarBazService.baz", null); oprot_.writeMessageBegin(new TMessage("baz", TMessageType.CALL, seqid_)); baz_args args = new baz_args(); args.write(oprot_); oprot_.writeMessageEnd(); oprot_.getTransport().flush(); super.postWrite(ctx, "FooBarBazService.baz", args); return; } public void recv_baz() throws TException { ContextStack ctx = super.getContextStack(); long bytes; TMessageType mtype; super.preRead(ctx, "FooBarBazService.baz"); TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { TApplicationException x = TApplicationException.read(iprot_); iprot_.readMessageEnd(); throw x; } baz_result result = baz_result.deserialize(iprot_); iprot_.readMessageEnd(); super.postRead(ctx, "FooBarBazService.baz", result); return; } } public static class AsyncClient extends TAsyncClient implements AsyncIface { public static class Factory implements TAsyncClientFactory { private TAsyncClientManager clientManager; private TProtocolFactory protocolFactory; public Factory(TAsyncClientManager clientManager, TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager clientManager, TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void foo(AsyncMethodCallback resultHandler82) throws TException { checkReady(); foo_call method_call = new foo_call(resultHandler82, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class foo_call extends TAsyncMethodCall { public foo_call(AsyncMethodCallback resultHandler83, TAsyncClient client79, TProtocolFactory protocolFactory80, TNonblockingTransport transport81) throws TException { super(client79, protocolFactory80, transport81, resultHandler83, false); } public void write_args(TProtocol prot) throws TException { prot.writeMessageBegin(new TMessage("foo", TMessageType.CALL, 0)); foo_args args = new foo_args(); args.write(prot); prot.writeMessageEnd(); } public void getResult() throws TException { if (getState() != State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array()); TProtocol prot = super.client.getProtocolFactory().getProtocol(memoryTransport); (new Client(prot)).recv_foo(); } } public void bar(AsyncMethodCallback resultHandler87) throws TException { checkReady(); bar_call method_call = new bar_call(resultHandler87, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class bar_call extends TAsyncMethodCall { public bar_call(AsyncMethodCallback resultHandler88, TAsyncClient client84, TProtocolFactory protocolFactory85, TNonblockingTransport transport86) throws TException { super(client84, protocolFactory85, transport86, resultHandler88, false); } public void write_args(TProtocol prot) throws TException { prot.writeMessageBegin(new TMessage("bar", TMessageType.CALL, 0)); bar_args args = new bar_args(); args.write(prot); prot.writeMessageEnd(); } public void getResult() throws TException { if (getState() != State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array()); TProtocol prot = super.client.getProtocolFactory().getProtocol(memoryTransport); (new Client(prot)).recv_bar(); } } public void baz(AsyncMethodCallback resultHandler92) throws TException { checkReady(); baz_call method_call = new baz_call(resultHandler92, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class baz_call extends TAsyncMethodCall { public baz_call(AsyncMethodCallback resultHandler93, TAsyncClient client89, TProtocolFactory protocolFactory90, TNonblockingTransport transport91) throws TException { super(client89, protocolFactory90, transport91, resultHandler93, false); } public void write_args(TProtocol prot) throws TException { prot.writeMessageBegin(new TMessage("baz", TMessageType.CALL, 0)); baz_args args = new baz_args(); args.write(prot); prot.writeMessageEnd(); } public void getResult() throws TException { if (getState() != State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array()); TProtocol prot = super.client.getProtocolFactory().getProtocol(memoryTransport); (new Client(prot)).recv_baz(); } } } public static class Processor implements TProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName()); public Processor(Iface iface) { iface_ = iface; event_handler_ = new TProcessorEventHandler(); // Empty handler processMap_.put("foo", new foo()); processMap_.put("bar", new bar()); processMap_.put("baz", new baz()); } protected static interface ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException; } public void setEventHandler(TProcessorEventHandler handler) { this.event_handler_ = handler; } private Iface iface_; protected TProcessorEventHandler event_handler_; protected final HashMap processMap_ = new HashMap(); public boolean process(TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException { TMessage msg = iprot.readMessageBegin(); ProcessFunction fn = processMap_.get(msg.name); if (fn == null) { TProtocolUtil.skip(iprot, TType.STRUCT); iprot.readMessageEnd(); TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'"); oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return true; } fn.process(msg.seqid, iprot, oprot, server_ctx); return true; } private class foo implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException { Object handler_ctx = event_handler_.getContext("FooBarBazService.foo", server_ctx); foo_args args = new foo_args(); event_handler_.preRead(handler_ctx, "FooBarBazService.foo"); args.read(iprot); iprot.readMessageEnd(); event_handler_.postRead(handler_ctx, "FooBarBazService.foo", args); foo_result result = new foo_result(); iface_.foo(); event_handler_.preWrite(handler_ctx, "FooBarBazService.foo", result); oprot.writeMessageBegin(new TMessage("foo", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); event_handler_.postWrite(handler_ctx, "FooBarBazService.foo", result); } } private class bar implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException { Object handler_ctx = event_handler_.getContext("FooBarBazService.bar", server_ctx); bar_args args = new bar_args(); event_handler_.preRead(handler_ctx, "FooBarBazService.bar"); args.read(iprot); iprot.readMessageEnd(); event_handler_.postRead(handler_ctx, "FooBarBazService.bar", args); bar_result result = new bar_result(); iface_.bar(); event_handler_.preWrite(handler_ctx, "FooBarBazService.bar", result); oprot.writeMessageBegin(new TMessage("bar", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); event_handler_.postWrite(handler_ctx, "FooBarBazService.bar", result); } } private class baz implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot, TConnectionContext server_ctx) throws TException { Object handler_ctx = event_handler_.getContext("FooBarBazService.baz", server_ctx); baz_args args = new baz_args(); event_handler_.preRead(handler_ctx, "FooBarBazService.baz"); args.read(iprot); iprot.readMessageEnd(); event_handler_.postRead(handler_ctx, "FooBarBazService.baz", args); baz_result result = new baz_result(); iface_.baz(); event_handler_.preWrite(handler_ctx, "FooBarBazService.baz", result); oprot.writeMessageBegin(new TMessage("baz", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); event_handler_.postWrite(handler_ctx, "FooBarBazService.baz", result); } } } public static class foo_args implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("foo_args"); public foo_args() { } /** * Performs a deep copy on other. */ public foo_args(foo_args other) { } public foo_args deepCopy() { return new foo_args(this); } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof foo_args)) return false; foo_args that = (foo_args)_that; return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {}); } // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. public void read(TProtocol iprot) throws TException { throw new TException("unimplemented in android immutable structure"); } public static foo_args deserialize(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); foo_args _that; _that = new foo_args( ); _that.validate(); return _that; } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { return TBaseHelper.toStringHelper(this, indent, prettyPrint); } public void validate() throws TException { // check for required fields } } public static class foo_result implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("foo_result"); public foo_result() { } /** * Performs a deep copy on other. */ public foo_result(foo_result other) { } public foo_result deepCopy() { return new foo_result(this); } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof foo_result)) return false; foo_result that = (foo_result)_that; return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {}); } // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. public void read(TProtocol iprot) throws TException { throw new TException("unimplemented in android immutable structure"); } public static foo_result deserialize(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); foo_result _that; _that = new foo_result( ); _that.validate(); return _that; } public void write(TProtocol oprot) throws TException { oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { return TBaseHelper.toStringHelper(this, indent, prettyPrint); } public void validate() throws TException { // check for required fields } } public static class bar_args implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("bar_args"); public bar_args() { } /** * Performs a deep copy on other. */ public bar_args(bar_args other) { } public bar_args deepCopy() { return new bar_args(this); } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof bar_args)) return false; bar_args that = (bar_args)_that; return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {}); } // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. public void read(TProtocol iprot) throws TException { throw new TException("unimplemented in android immutable structure"); } public static bar_args deserialize(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); bar_args _that; _that = new bar_args( ); _that.validate(); return _that; } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { return TBaseHelper.toStringHelper(this, indent, prettyPrint); } public void validate() throws TException { // check for required fields } } public static class bar_result implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("bar_result"); public bar_result() { } /** * Performs a deep copy on other. */ public bar_result(bar_result other) { } public bar_result deepCopy() { return new bar_result(this); } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof bar_result)) return false; bar_result that = (bar_result)_that; return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {}); } // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. public void read(TProtocol iprot) throws TException { throw new TException("unimplemented in android immutable structure"); } public static bar_result deserialize(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); bar_result _that; _that = new bar_result( ); _that.validate(); return _that; } public void write(TProtocol oprot) throws TException { oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { return TBaseHelper.toStringHelper(this, indent, prettyPrint); } public void validate() throws TException { // check for required fields } } public static class baz_args implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("baz_args"); public baz_args() { } /** * Performs a deep copy on other. */ public baz_args(baz_args other) { } public baz_args deepCopy() { return new baz_args(this); } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof baz_args)) return false; baz_args that = (baz_args)_that; return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {}); } // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. public void read(TProtocol iprot) throws TException { throw new TException("unimplemented in android immutable structure"); } public static baz_args deserialize(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); baz_args _that; _that = new baz_args( ); _that.validate(); return _that; } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { return TBaseHelper.toStringHelper(this, indent, prettyPrint); } public void validate() throws TException { // check for required fields } } public static class baz_result implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("baz_result"); public baz_result() { } /** * Performs a deep copy on other. */ public baz_result(baz_result other) { } public baz_result deepCopy() { return new baz_result(this); } @Override public boolean equals(Object _that) { if (_that == null) return false; if (this == _that) return true; if (!(_that instanceof baz_result)) return false; baz_result that = (baz_result)_that; return true; } @Override public int hashCode() { return Arrays.deepHashCode(new Object[] {}); } // This is required to satisfy the TBase interface, but can't be implemented on immutable struture. public void read(TProtocol iprot) throws TException { throw new TException("unimplemented in android immutable structure"); } public static baz_result deserialize(TProtocol iprot) throws TException { TField __field; iprot.readStructBegin(); while (true) { __field = iprot.readFieldBegin(); if (__field.type == TType.STOP) { break; } switch (__field.id) { default: TProtocolUtil.skip(iprot, __field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); baz_result _that; _that = new baz_result( ); _that.validate(); return _that; } public void write(TProtocol oprot) throws TException { oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { return toString(1, true); } @Override public String toString(int indent, boolean prettyPrint) { return TBaseHelper.toStringHelper(this, indent, prettyPrint); } public void validate() throws TException { // check for required fields } } }