Java tutorial
/** * Licensed to Cloudera, Inc. under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Cloudera, Inc. 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. */ package com.cloudera.sqoop.lib; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Map; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Writable; import org.apache.hadoop.mapreduce.lib.db.DBWritable; /** * Interface implemented by the classes generated by sqoop's orm.ClassWriter. */ public abstract class SqoopRecord implements Cloneable, DBWritable, FieldMappable, Writable { public SqoopRecord() { } public abstract void parse(CharSequence s) throws RecordParser.ParseError; public abstract void parse(Text s) throws RecordParser.ParseError; public abstract void parse(byte[] s) throws RecordParser.ParseError; public abstract void parse(char[] s) throws RecordParser.ParseError; public abstract void parse(ByteBuffer s) throws RecordParser.ParseError; public abstract void parse(CharBuffer s) throws RecordParser.ParseError; public abstract void loadLargeObjects(LargeObjectLoader objLoader) throws SQLException, IOException, InterruptedException; /** * Inserts the data in this object into the PreparedStatement, starting * at parameter 'offset'. * @return the number of fields written to the statement. */ public abstract int write(PreparedStatement stmt, int offset) throws SQLException; public abstract String toString(DelimiterSet delimiters); @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Returns an integer specifying which API format version the * generated class conforms to. Used by internal APIs for backwards * compatibility. * @return the API version this class was generated against. */ public abstract int getClassFormatVersion(); /** * Use the delegate pattern to allow arbitrary processing of the * fields of this record. * @param processor A delegate that operates on this object. * @throws IOException if the processor encounters an IO error when * operating on this object. * @throws ProcessingException if the FieldMapProcessor encounters * a general processing error when operating on this object. */ public void delegate(FieldMapProcessor processor) throws IOException, ProcessingException { processor.accept(this); } @Override /** * {@inheriDoc} * @throws RuntimeException if used with a record that was generated * before this capability was added (1.1.0). */ public Map<String, Object> getFieldMap() { // Default implementation does not support field iteration. // ClassWriter should provide an overriding version. throw new RuntimeException("Got null field map from record. Regenerate your record class."); } }