TT.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // ORM class for TT
  2. // WARNING: This class is AUTO-GENERATED. Modify at your own risk.
  3. import org.apache.hadoop.io.BytesWritable;
  4. import org.apache.hadoop.io.Text;
  5. import org.apache.hadoop.io.Writable;
  6. import org.apache.hadoop.mapred.lib.db.DBWritable;
  7. import com.cloudera.sqoop.lib.JdbcWritableBridge;
  8. import com.cloudera.sqoop.lib.DelimiterSet;
  9. import com.cloudera.sqoop.lib.FieldFormatter;
  10. import com.cloudera.sqoop.lib.RecordParser;
  11. import com.cloudera.sqoop.lib.BooleanParser;
  12. import com.cloudera.sqoop.lib.BlobRef;
  13. import com.cloudera.sqoop.lib.ClobRef;
  14. import com.cloudera.sqoop.lib.LargeObjectLoader;
  15. import com.cloudera.sqoop.lib.SqoopRecord;
  16. import java.sql.PreparedStatement;
  17. import java.sql.ResultSet;
  18. import java.sql.SQLException;
  19. import java.io.DataInput;
  20. import java.io.DataOutput;
  21. import java.io.IOException;
  22. import java.nio.ByteBuffer;
  23. import java.nio.CharBuffer;
  24. import java.sql.Date;
  25. import java.sql.Time;
  26. import java.sql.Timestamp;
  27. import java.util.Arrays;
  28. import java.util.Iterator;
  29. import java.util.List;
  30. import java.util.Map;
  31. import java.util.TreeMap;
  32. public class TT extends SqoopRecord implements DBWritable, Writable {
  33. private final int PROTOCOL_VERSION = 3;
  34. public int getClassFormatVersion() { return PROTOCOL_VERSION; }
  35. protected ResultSet __cur_result_set;
  36. private Integer I;
  37. public Integer get_I() {
  38. return I;
  39. }
  40. public void set_I(Integer I) {
  41. this.I = I;
  42. }
  43. public TT with_I(Integer I) {
  44. this.I = I;
  45. return this;
  46. }
  47. private String S;
  48. public String get_S() {
  49. return S;
  50. }
  51. public void set_S(String S) {
  52. this.S = S;
  53. }
  54. public TT with_S(String S) {
  55. this.S = S;
  56. return this;
  57. }
  58. public boolean equals(Object o) {
  59. if (this == o) {
  60. return true;
  61. }
  62. if (!(o instanceof TT)) {
  63. return false;
  64. }
  65. TT that = (TT) o;
  66. boolean equal = true;
  67. equal = equal && (this.I == null ? that.I == null : this.I.equals(that.I));
  68. equal = equal && (this.S == null ? that.S == null : this.S.equals(that.S));
  69. return equal;
  70. }
  71. public void readFields(ResultSet __dbResults) throws SQLException {
  72. this.__cur_result_set = __dbResults;
  73. this.I = JdbcWritableBridge.readInteger(1, __dbResults);
  74. this.S = JdbcWritableBridge.readString(2, __dbResults);
  75. }
  76. public void loadLargeObjects(LargeObjectLoader __loader)
  77. throws SQLException, IOException, InterruptedException {
  78. }
  79. public void write(PreparedStatement __dbStmt) throws SQLException {
  80. write(__dbStmt, 0);
  81. }
  82. public int write(PreparedStatement __dbStmt, int __off) throws SQLException {
  83. JdbcWritableBridge.writeInteger(I, 1 + __off, 4, __dbStmt);
  84. JdbcWritableBridge.writeString(S, 2 + __off, 12, __dbStmt);
  85. return 2;
  86. }
  87. public void readFields(DataInput __dataIn) throws IOException {
  88. if (__dataIn.readBoolean()) {
  89. this.I = null;
  90. } else {
  91. this.I = Integer.valueOf(__dataIn.readInt());
  92. }
  93. if (__dataIn.readBoolean()) {
  94. this.S = null;
  95. } else {
  96. this.S = Text.readString(__dataIn);
  97. }
  98. }
  99. public void write(DataOutput __dataOut) throws IOException {
  100. if (null == this.I) {
  101. __dataOut.writeBoolean(true);
  102. } else {
  103. __dataOut.writeBoolean(false);
  104. __dataOut.writeInt(this.I);
  105. }
  106. if (null == this.S) {
  107. __dataOut.writeBoolean(true);
  108. } else {
  109. __dataOut.writeBoolean(false);
  110. Text.writeString(__dataOut, S);
  111. }
  112. }
  113. private final DelimiterSet __outputDelimiters = new DelimiterSet((char) 44, (char) 10, (char) 0, (char) 0, false);
  114. public String toString() {
  115. return toString(__outputDelimiters, true);
  116. }
  117. public String toString(DelimiterSet delimiters) {
  118. return toString(delimiters, true);
  119. }
  120. public String toString(boolean useRecordDelim) {
  121. return toString(__outputDelimiters, useRecordDelim);
  122. }
  123. public String toString(DelimiterSet delimiters, boolean useRecordDelim) {
  124. StringBuilder __sb = new StringBuilder();
  125. char fieldDelim = delimiters.getFieldsTerminatedBy();
  126. __sb.append(FieldFormatter.escapeAndEnclose(I==null?"null":"" + I, delimiters));
  127. __sb.append(fieldDelim);
  128. __sb.append(FieldFormatter.escapeAndEnclose(S==null?"null":S, delimiters));
  129. if (useRecordDelim) {
  130. __sb.append(delimiters.getLinesTerminatedBy());
  131. }
  132. return __sb.toString();
  133. }
  134. private final DelimiterSet __inputDelimiters = new DelimiterSet((char) 44, (char) 10, (char) 0, (char) 0, false);
  135. private RecordParser __parser;
  136. public void parse(Text __record) throws RecordParser.ParseError {
  137. if (null == this.__parser) {
  138. this.__parser = new RecordParser(__inputDelimiters);
  139. }
  140. List<String> __fields = this.__parser.parseRecord(__record);
  141. __loadFromFields(__fields);
  142. }
  143. public void parse(CharSequence __record) throws RecordParser.ParseError {
  144. if (null == this.__parser) {
  145. this.__parser = new RecordParser(__inputDelimiters);
  146. }
  147. List<String> __fields = this.__parser.parseRecord(__record);
  148. __loadFromFields(__fields);
  149. }
  150. public void parse(byte [] __record) throws RecordParser.ParseError {
  151. if (null == this.__parser) {
  152. this.__parser = new RecordParser(__inputDelimiters);
  153. }
  154. List<String> __fields = this.__parser.parseRecord(__record);
  155. __loadFromFields(__fields);
  156. }
  157. public void parse(char [] __record) throws RecordParser.ParseError {
  158. if (null == this.__parser) {
  159. this.__parser = new RecordParser(__inputDelimiters);
  160. }
  161. List<String> __fields = this.__parser.parseRecord(__record);
  162. __loadFromFields(__fields);
  163. }
  164. public void parse(ByteBuffer __record) throws RecordParser.ParseError {
  165. if (null == this.__parser) {
  166. this.__parser = new RecordParser(__inputDelimiters);
  167. }
  168. List<String> __fields = this.__parser.parseRecord(__record);
  169. __loadFromFields(__fields);
  170. }
  171. public void parse(CharBuffer __record) throws RecordParser.ParseError {
  172. if (null == this.__parser) {
  173. this.__parser = new RecordParser(__inputDelimiters);
  174. }
  175. List<String> __fields = this.__parser.parseRecord(__record);
  176. __loadFromFields(__fields);
  177. }
  178. private void __loadFromFields(List<String> fields) {
  179. Iterator<String> __it = fields.listIterator();
  180. String __cur_str;
  181. __cur_str = __it.next();
  182. if (__cur_str.equals("null") || __cur_str.length() == 0) { this.I = null; } else {
  183. this.I = Integer.valueOf(__cur_str);
  184. }
  185. __cur_str = __it.next();
  186. if (__cur_str.equals("null")) { this.S = null; } else {
  187. this.S = __cur_str;
  188. }
  189. }
  190. public Object clone() throws CloneNotSupportedException {
  191. TT o = (TT) super.clone();
  192. return o;
  193. }
  194. public Map<String, Object> getFieldMap() {
  195. Map<String, Object> __sqoop$field_map = new TreeMap<String, Object>();
  196. __sqoop$field_map.put("I", this.I);
  197. __sqoop$field_map.put("S", this.S);
  198. return __sqoop$field_map;
  199. }
  200. public void setField(String __fieldName, Object __fieldVal) {
  201. if ("I".equals(__fieldName)) {
  202. this.I = (Integer) __fieldVal;
  203. }
  204. else if ("S".equals(__fieldName)) {
  205. this.S = (String) __fieldVal;
  206. }
  207. else {
  208. throw new RuntimeException("No such field: " + __fieldName);
  209. }
  210. }
  211. }