/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Autogenerated by Thrift Compiler (0.9.1) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package cgl.iotcloud.core.api.thrift; import org.apache.thrift.scheme.IScheme; import org.apache.thrift.scheme.SchemeFactory; import org.apache.thrift.scheme.StandardScheme; import org.apache.thrift.scheme.TupleScheme; import org.apache.thrift.protocol.TTupleProtocol; import org.apache.thrift.protocol.TProtocolException; import org.apache.thrift.EncodingUtils; import org.apache.thrift.TException; import org.apache.thrift.async.AsyncMethodCallback; import org.apache.thrift.server.AbstractNonblockingServer.*; 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; @SuppressWarnings("all") public class TSensorMessage implements org.apache.thrift.TBase<TSensorMessage, TSensorMessage._Fields>, java.io.Serializable, Cloneable, Comparable<TSensorMessage> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSensorMessage"); private static final org.apache.thrift.protocol.TField SENSOR_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("sensorId", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.protocol.TField SITE_FIELD_DESC = new org.apache.thrift.protocol.TField("site", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField BODY_FIELD_DESC = new org.apache.thrift.protocol.TField("body", org.apache.thrift.protocol.TType.STRING, (short)3); private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)4); private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); static { schemes.put(StandardScheme.class, new TSensorMessageStandardSchemeFactory()); schemes.put(TupleScheme.class, new TSensorMessageTupleSchemeFactory()); } public String sensorId; // required public String site; // required public ByteBuffer body; // required public Map<String,String> properties; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum { SENSOR_ID((short)1, "sensorId"), SITE((short)2, "site"), BODY((short)3, "body"), PROPERTIES((short)4, "properties"); 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: // SENSOR_ID return SENSOR_ID; case 2: // SITE return SITE; case 3: // BODY return BODY; case 4: // PROPERTIES return PROPERTIES; 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 private _Fields optionals[] = {_Fields.PROPERTIES}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SENSOR_ID, new org.apache.thrift.meta_data.FieldMetaData("sensorId", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.SITE, new org.apache.thrift.meta_data.FieldMetaData("site", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.BODY, new org.apache.thrift.meta_data.FieldMetaData("body", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSensorMessage.class, metaDataMap); } public TSensorMessage() { } public TSensorMessage( String sensorId, String site, ByteBuffer body) { this(); this.sensorId = sensorId; this.site = site; this.body = body; } /** * Performs a deep copy on <i>other</i>. */ public TSensorMessage(TSensorMessage other) { if (other.isSetSensorId()) { this.sensorId = other.sensorId; } if (other.isSetSite()) { this.site = other.site; } if (other.isSetBody()) { this.body = org.apache.thrift.TBaseHelper.copyBinary(other.body); ; } if (other.isSetProperties()) { Map<String,String> __this__properties = new HashMap<String,String>(other.properties); this.properties = __this__properties; } } public TSensorMessage deepCopy() { return new TSensorMessage(this); } @Override public void clear() { this.sensorId = null; this.site = null; this.body = null; this.properties = null; } public String getSensorId() { return this.sensorId; } public TSensorMessage setSensorId(String sensorId) { this.sensorId = sensorId; return this; } public void unsetSensorId() { this.sensorId = null; } /** Returns true if field sensorId is set (has been assigned a value) and false otherwise */ public boolean isSetSensorId() { return this.sensorId != null; } public void setSensorIdIsSet(boolean value) { if (!value) { this.sensorId = null; } } public String getSite() { return this.site; } public TSensorMessage setSite(String site) { this.site = site; return this; } public void unsetSite() { this.site = null; } /** Returns true if field site is set (has been assigned a value) and false otherwise */ public boolean isSetSite() { return this.site != null; } public void setSiteIsSet(boolean value) { if (!value) { this.site = null; } } public byte[] getBody() { setBody(org.apache.thrift.TBaseHelper.rightSize(body)); return body == null ? null : body.array(); } public ByteBuffer bufferForBody() { return body; } public TSensorMessage setBody(byte[] body) { setBody(body == null ? (ByteBuffer)null : ByteBuffer.wrap(body)); return this; } public TSensorMessage setBody(ByteBuffer body) { this.body = body; return this; } public void unsetBody() { this.body = null; } /** Returns true if field body is set (has been assigned a value) and false otherwise */ public boolean isSetBody() { return this.body != null; } public void setBodyIsSet(boolean value) { if (!value) { this.body = null; } } public int getPropertiesSize() { return (this.properties == null) ? 0 : this.properties.size(); } public void putToProperties(String key, String val) { if (this.properties == null) { this.properties = new HashMap<String,String>(); } this.properties.put(key, val); } public Map<String,String> getProperties() { return this.properties; } public TSensorMessage setProperties(Map<String,String> properties) { this.properties = properties; return this; } public void unsetProperties() { this.properties = null; } /** Returns true if field properties is set (has been assigned a value) and false otherwise */ public boolean isSetProperties() { return this.properties != null; } public void setPropertiesIsSet(boolean value) { if (!value) { this.properties = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case SENSOR_ID: if (value == null) { unsetSensorId(); } else { setSensorId((String)value); } break; case SITE: if (value == null) { unsetSite(); } else { setSite((String)value); } break; case BODY: if (value == null) { unsetBody(); } else { setBody((ByteBuffer)value); } break; case PROPERTIES: if (value == null) { unsetProperties(); } else { setProperties((Map<String,String>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case SENSOR_ID: return getSensorId(); case SITE: return getSite(); case BODY: return getBody(); case PROPERTIES: return getProperties(); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case SENSOR_ID: return isSetSensorId(); case SITE: return isSetSite(); case BODY: return isSetBody(); case PROPERTIES: return isSetProperties(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TSensorMessage) return this.equals((TSensorMessage)that); return false; } public boolean equals(TSensorMessage that) { if (that == null) return false; boolean this_present_sensorId = true && this.isSetSensorId(); boolean that_present_sensorId = true && that.isSetSensorId(); if (this_present_sensorId || that_present_sensorId) { if (!(this_present_sensorId && that_present_sensorId)) return false; if (!this.sensorId.equals(that.sensorId)) return false; } boolean this_present_site = true && this.isSetSite(); boolean that_present_site = true && that.isSetSite(); if (this_present_site || that_present_site) { if (!(this_present_site && that_present_site)) return false; if (!this.site.equals(that.site)) return false; } boolean this_present_body = true && this.isSetBody(); boolean that_present_body = true && that.isSetBody(); if (this_present_body || that_present_body) { if (!(this_present_body && that_present_body)) return false; if (!this.body.equals(that.body)) return false; } boolean this_present_properties = true && this.isSetProperties(); boolean that_present_properties = true && that.isSetProperties(); if (this_present_properties || that_present_properties) { if (!(this_present_properties && that_present_properties)) return false; if (!this.properties.equals(that.properties)) return false; } return true; } @Override public int hashCode() { return 0; } @Override public int compareTo(TSensorMessage other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetSensorId()).compareTo(other.isSetSensorId()); if (lastComparison != 0) { return lastComparison; } if (isSetSensorId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sensorId, other.sensorId); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetSite()).compareTo(other.isSetSite()); if (lastComparison != 0) { return lastComparison; } if (isSetSite()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.site, other.site); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetBody()).compareTo(other.isSetBody()); if (lastComparison != 0) { return lastComparison; } if (isSetBody()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.body, other.body); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetProperties()).compareTo(other.isSetProperties()); if (lastComparison != 0) { return lastComparison; } if (isSetProperties()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, other.properties); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { schemes.get(iprot.getScheme()).getScheme().read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { schemes.get(oprot.getScheme()).getScheme().write(oprot, this); } @Override public String toString() { StringBuilder sb = new StringBuilder("TSensorMessage("); boolean first = true; sb.append("sensorId:"); if (this.sensorId == null) { sb.append("null"); } else { sb.append(this.sensorId); } first = false; if (!first) sb.append(", "); sb.append("site:"); if (this.site == null) { sb.append("null"); } else { sb.append(this.site); } first = false; if (!first) sb.append(", "); sb.append("body:"); if (this.body == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.body, sb); } first = false; if (isSetProperties()) { if (!first) sb.append(", "); sb.append("properties:"); if (this.properties == null) { sb.append("null"); } else { sb.append(this.properties); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class TSensorMessageStandardSchemeFactory implements SchemeFactory { public TSensorMessageStandardScheme getScheme() { return new TSensorMessageStandardScheme(); } } private static class TSensorMessageStandardScheme extends StandardScheme<TSensorMessage> { public void read(org.apache.thrift.protocol.TProtocol iprot, TSensorMessage struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // SENSOR_ID if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.sensorId = iprot.readString(); struct.setSensorIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // SITE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.site = iprot.readString(); struct.setSiteIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // BODY if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.body = iprot.readBinary(); struct.setBodyIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // PROPERTIES if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map54 = iprot.readMapBegin(); struct.properties = new HashMap<String,String>(2*_map54.size); for (int _i55 = 0; _i55 < _map54.size; ++_i55) { String _key56; String _val57; _key56 = iprot.readString(); _val57 = iprot.readString(); struct.properties.put(_key56, _val57); } iprot.readMapEnd(); } struct.setPropertiesIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, TSensorMessage struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.sensorId != null) { oprot.writeFieldBegin(SENSOR_ID_FIELD_DESC); oprot.writeString(struct.sensorId); oprot.writeFieldEnd(); } if (struct.site != null) { oprot.writeFieldBegin(SITE_FIELD_DESC); oprot.writeString(struct.site); oprot.writeFieldEnd(); } if (struct.body != null) { oprot.writeFieldBegin(BODY_FIELD_DESC); oprot.writeBinary(struct.body); oprot.writeFieldEnd(); } if (struct.properties != null) { if (struct.isSetProperties()) { oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.properties.size())); for (Map.Entry<String, String> _iter58 : struct.properties.entrySet()) { oprot.writeString(_iter58.getKey()); oprot.writeString(_iter58.getValue()); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class TSensorMessageTupleSchemeFactory implements SchemeFactory { public TSensorMessageTupleScheme getScheme() { return new TSensorMessageTupleScheme(); } } private static class TSensorMessageTupleScheme extends TupleScheme<TSensorMessage> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, TSensorMessage struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; BitSet optionals = new BitSet(); if (struct.isSetSensorId()) { optionals.set(0); } if (struct.isSetSite()) { optionals.set(1); } if (struct.isSetBody()) { optionals.set(2); } if (struct.isSetProperties()) { optionals.set(3); } oprot.writeBitSet(optionals, 4); if (struct.isSetSensorId()) { oprot.writeString(struct.sensorId); } if (struct.isSetSite()) { oprot.writeString(struct.site); } if (struct.isSetBody()) { oprot.writeBinary(struct.body); } if (struct.isSetProperties()) { { oprot.writeI32(struct.properties.size()); for (Map.Entry<String, String> _iter59 : struct.properties.entrySet()) { oprot.writeString(_iter59.getKey()); oprot.writeString(_iter59.getValue()); } } } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, TSensorMessage struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(4); if (incoming.get(0)) { struct.sensorId = iprot.readString(); struct.setSensorIdIsSet(true); } if (incoming.get(1)) { struct.site = iprot.readString(); struct.setSiteIsSet(true); } if (incoming.get(2)) { struct.body = iprot.readBinary(); struct.setBodyIsSet(true); } if (incoming.get(3)) { { org.apache.thrift.protocol.TMap _map60 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.properties = new HashMap<String,String>(2*_map60.size); for (int _i61 = 0; _i61 < _map60.size; ++_i61) { String _key62; String _val63; _key62 = iprot.readString(); _val63 = iprot.readString(); struct.properties.put(_key62, _val63); } } struct.setPropertiesIsSet(true); } } } }