/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package com.flaptor.indextank.rpc;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
@SuppressWarnings("all") public class Suggestor {
public interface Iface {
public List<String> complete(String partial_query, String field) throws TException;
}
public interface AsyncIface {
public void complete(String partial_query, String field, AsyncMethodCallback<AsyncClient.complete_call> resultHandler) throws TException;
}
public static class Client implements TServiceClient, Iface {
public static class Factory implements TServiceClientFactory<Client> {
public Factory() {}
public Client getClient(TProtocol prot) {
return new Client(prot);
}
public Client getClient(TProtocol iprot, TProtocol oprot) {
return new Client(iprot, oprot);
}
}
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_;
public TProtocol getInputProtocol()
{
return this.iprot_;
}
public TProtocol getOutputProtocol()
{
return this.oprot_;
}
public List<String> complete(String partial_query, String field) throws TException
{
send_complete(partial_query, field);
return recv_complete();
}
public void send_complete(String partial_query, String field) throws TException
{
oprot_.writeMessageBegin(new TMessage("complete", TMessageType.CALL, ++seqid_));
complete_args args = new complete_args();
args.set_partial_query(partial_query);
args.set_field(field);
args.write(oprot_);
oprot_.writeMessageEnd();
oprot_.getTransport().flush();
}
public List<String> recv_complete() throws TException
{
TMessage msg = iprot_.readMessageBegin();
if (msg.type == TMessageType.EXCEPTION) {
TApplicationException x = TApplicationException.read(iprot_);
iprot_.readMessageEnd();
throw x;
}
if (msg.seqid != seqid_) {
throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, "complete failed: out of sequence response");
}
complete_result result = new complete_result();
result.read(iprot_);
iprot_.readMessageEnd();
if (result.is_set_success()) {
return result.success;
}
throw new TApplicationException(TApplicationException.MISSING_RESULT, "complete failed: unknown result");
}
}
public static class AsyncClient extends TAsyncClient implements AsyncIface {
public static class Factory implements TAsyncClientFactory<AsyncClient> {
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 complete(String partial_query, String field, AsyncMethodCallback<complete_call> resultHandler) throws TException {
checkReady();
complete_call method_call = new complete_call(partial_query, field, resultHandler, this, protocolFactory, transport);
manager.call(method_call);
}
public static class complete_call extends TAsyncMethodCall {
private String partial_query;
private String field;
public complete_call(String partial_query, String field, AsyncMethodCallback<complete_call> resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException {
super(client, protocolFactory, transport, resultHandler, false);
this.partial_query = partial_query;
this.field = field;
}
public void write_args(TProtocol prot) throws TException {
prot.writeMessageBegin(new TMessage("complete", TMessageType.CALL, 0));
complete_args args = new complete_args();
args.set_partial_query(partial_query);
args.set_field(field);
args.write(prot);
prot.writeMessageEnd();
}
public List<String> getResult() throws TException {
if (getState() != State.RESPONSE_READ) {
throw new IllegalStateException("Method call not finished!");
}
TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array());
TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
return (new Client(prot)).recv_complete();
}
}
}
public static class Processor implements TProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
public Processor(Iface iface)
{
iface_ = iface;
processMap_.put("complete", new complete());
}
protected static interface ProcessFunction {
public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;
}
private Iface iface_;
protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>();
public boolean process(TProtocol iprot, TProtocol oprot) 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);
return true;
}
private class complete implements ProcessFunction {
public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
{
complete_args args = new complete_args();
try {
args.read(iprot);
} catch (TProtocolException e) {
iprot.readMessageEnd();
TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());
oprot.writeMessageBegin(new TMessage("complete", TMessageType.EXCEPTION, seqid));
x.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
return;
}
iprot.readMessageEnd();
complete_result result = new complete_result();
result.success = iface_.complete(args.partial_query, args.field);
oprot.writeMessageBegin(new TMessage("complete", TMessageType.REPLY, seqid));
result.write(oprot);
oprot.writeMessageEnd();
oprot.getTransport().flush();
}
}
}
public static class complete_args implements TBase<complete_args, complete_args._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("complete_args");
private static final TField PARTIAL_QUERY_FIELD_DESC = new TField("partial_query", TType.STRING, (short)1);
private static final TField FIELD_FIELD_DESC = new TField("field", TType.STRING, (short)2);
private String partial_query;
private String field;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
PARTIAL_QUERY((short)1, "partial_query"),
FIELD((short)2, "field");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // PARTIAL_QUERY
return PARTIAL_QUERY;
case 2: // FIELD
return FIELD;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.PARTIAL_QUERY, new FieldMetaData("partial_query", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
tmpMap.put(_Fields.FIELD, new FieldMetaData("field", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(complete_args.class, metaDataMap);
}
public complete_args() {
this.field = "";
}
public complete_args(
String partial_query,
String field)
{
this();
this.partial_query = partial_query;
this.field = field;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public complete_args(complete_args other) {
if (other.is_set_partial_query()) {
this.partial_query = other.partial_query;
}
if (other.is_set_field()) {
this.field = other.field;
}
}
public complete_args deepCopy() {
return new complete_args(this);
}
@Override
public void clear() {
this.partial_query = null;
this.field = "";
}
public String get_partial_query() {
return this.partial_query;
}
public complete_args set_partial_query(String partial_query) {
this.partial_query = partial_query;
return this;
}
public void unset_partial_query() {
this.partial_query = null;
}
/** Returns true if field partial_query is set (has been asigned a value) and false otherwise */
public boolean is_set_partial_query() {
return this.partial_query != null;
}
public void set_partial_query_isSet(boolean value) {
if (!value) {
this.partial_query = null;
}
}
public String get_field() {
return this.field;
}
public complete_args set_field(String field) {
this.field = field;
return this;
}
public void unset_field() {
this.field = null;
}
/** Returns true if field field is set (has been asigned a value) and false otherwise */
public boolean is_set_field() {
return this.field != null;
}
public void set_field_isSet(boolean value) {
if (!value) {
this.field = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case PARTIAL_QUERY:
if (value == null) {
unset_partial_query();
} else {
set_partial_query((String)value);
}
break;
case FIELD:
if (value == null) {
unset_field();
} else {
set_field((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case PARTIAL_QUERY:
return get_partial_query();
case FIELD:
return get_field();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case PARTIAL_QUERY:
return is_set_partial_query();
case FIELD:
return is_set_field();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof complete_args)
return this.equals((complete_args)that);
return false;
}
public boolean equals(complete_args that) {
if (that == null)
return false;
boolean this_present_partial_query = true && this.is_set_partial_query();
boolean that_present_partial_query = true && that.is_set_partial_query();
if (this_present_partial_query || that_present_partial_query) {
if (!(this_present_partial_query && that_present_partial_query))
return false;
if (!this.partial_query.equals(that.partial_query))
return false;
}
boolean this_present_field = true && this.is_set_field();
boolean that_present_field = true && that.is_set_field();
if (this_present_field || that_present_field) {
if (!(this_present_field && that_present_field))
return false;
if (!this.field.equals(that.field))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(complete_args other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
complete_args typedOther = (complete_args)other;
lastComparison = Boolean.valueOf(is_set_partial_query()).compareTo(typedOther.is_set_partial_query());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_partial_query()) {
lastComparison = TBaseHelper.compareTo(this.partial_query, typedOther.partial_query);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(is_set_field()).compareTo(typedOther.is_set_field());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_field()) {
lastComparison = TBaseHelper.compareTo(this.field, typedOther.field);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 1: // PARTIAL_QUERY
if (field.type == TType.STRING) {
this.partial_query = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // FIELD
if (field.type == TType.STRING) {
this.field = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.partial_query != null) {
oprot.writeFieldBegin(PARTIAL_QUERY_FIELD_DESC);
oprot.writeString(this.partial_query);
oprot.writeFieldEnd();
}
if (this.field != null) {
oprot.writeFieldBegin(FIELD_FIELD_DESC);
oprot.writeString(this.field);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("complete_args(");
boolean first = true;
sb.append("partial_query:");
if (this.partial_query == null) {
sb.append("null");
} else {
sb.append(this.partial_query);
}
first = false;
if (!first) sb.append(", ");
sb.append("field:");
if (this.field == null) {
sb.append("null");
} else {
sb.append(this.field);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}
public static class complete_result implements TBase<complete_result, complete_result._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("complete_result");
private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
private List<String> success;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
SUCCESS((short)0, "success");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 0: // SUCCESS
return SUCCESS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, FieldMetaData> metaDataMap;
static {
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT,
new ListMetaData(TType.LIST,
new FieldValueMetaData(TType.STRING))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(complete_result.class, metaDataMap);
}
public complete_result() {
}
public complete_result(
List<String> success)
{
this();
this.success = success;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public complete_result(complete_result other) {
if (other.is_set_success()) {
List<String> __this__success = new ArrayList<String>();
for (String other_element : other.success) {
__this__success.add(other_element);
}
this.success = __this__success;
}
}
public complete_result deepCopy() {
return new complete_result(this);
}
@Override
public void clear() {
this.success = null;
}
public int get_success_size() {
return (this.success == null) ? 0 : this.success.size();
}
public java.util.Iterator<String> get_success_iterator() {
return (this.success == null) ? null : this.success.iterator();
}
public void add_to_success(String elem) {
if (this.success == null) {
this.success = new ArrayList<String>();
}
this.success.add(elem);
}
public List<String> get_success() {
return this.success;
}
public complete_result set_success(List<String> success) {
this.success = success;
return this;
}
public void unset_success() {
this.success = null;
}
/** Returns true if field success is set (has been asigned a value) and false otherwise */
public boolean is_set_success() {
return this.success != null;
}
public void set_success_isSet(boolean value) {
if (!value) {
this.success = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SUCCESS:
if (value == null) {
unset_success();
} else {
set_success((List<String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SUCCESS:
return get_success();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SUCCESS:
return is_set_success();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof complete_result)
return this.equals((complete_result)that);
return false;
}
public boolean equals(complete_result that) {
if (that == null)
return false;
boolean this_present_success = true && this.is_set_success();
boolean that_present_success = true && that.is_set_success();
if (this_present_success || that_present_success) {
if (!(this_present_success && that_present_success))
return false;
if (!this.success.equals(that.success))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(complete_result other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
complete_result typedOther = (complete_result)other;
lastComparison = Boolean.valueOf(is_set_success()).compareTo(typedOther.is_set_success());
if (lastComparison != 0) {
return lastComparison;
}
if (is_set_success()) {
lastComparison = TBaseHelper.compareTo(this.success, typedOther.success);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 0: // SUCCESS
if (field.type == TType.LIST) {
{
TList _list141 = iprot.readListBegin();
this.success = new ArrayList<String>(_list141.size);
for (int _i142 = 0; _i142 < _list141.size; ++_i142)
{
String _elem143;
_elem143 = iprot.readString();
this.success.add(_elem143);
}
iprot.readListEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
validate();
}
public void write(TProtocol oprot) throws TException {
oprot.writeStructBegin(STRUCT_DESC);
if (this.is_set_success()) {
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.STRING, this.success.size()));
for (String _iter144 : this.success)
{
oprot.writeString(_iter144);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("complete_result(");
boolean first = true;
sb.append("success:");
if (this.success == null) {
sb.append("null");
} else {
sb.append(this.success);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}
}