This project has retired. For details please refer to its Attic page.
FieldFormatter (Sqoop 1.4.0-incubating API)

org.apache.sqoop.lib
Class FieldFormatter

java.lang.Object
  extended by org.apache.sqoop.lib.FieldFormatter

public final class FieldFormatter
extends java.lang.Object

Static helper class that will help format data with quotes and escape chars.


Method Summary
static java.lang.String escapeAndEnclose(java.lang.String str, DelimiterSet delimiters)
          Takes an input string representing the value of a field, encloses it in enclosing chars, and escapes any occurrences of such characters in the middle.
static java.lang.String hiveStringDropDelims(java.lang.String str, DelimiterSet delimiters)
          only pass fields that are strings when --hive-drop-delims option is on.
static java.lang.String hiveStringReplaceDelims(java.lang.String str, java.lang.String replacement, DelimiterSet delimiters)
          replace hive delimiters with a user-defined string passed to the --hive-delims-replacement option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hiveStringDropDelims

public static java.lang.String hiveStringDropDelims(java.lang.String str,
                                                    DelimiterSet delimiters)
only pass fields that are strings when --hive-drop-delims option is on.

Parameters:
str -
delimiters -
Returns:

hiveStringReplaceDelims

public static java.lang.String hiveStringReplaceDelims(java.lang.String str,
                                                       java.lang.String replacement,
                                                       DelimiterSet delimiters)
replace hive delimiters with a user-defined string passed to the --hive-delims-replacement option.

Parameters:
str -
delimiters -
Returns:

escapeAndEnclose

public static java.lang.String escapeAndEnclose(java.lang.String str,
                                                DelimiterSet delimiters)
Takes an input string representing the value of a field, encloses it in enclosing chars, and escapes any occurrences of such characters in the middle. The escape character itself is also escaped if it appears in the text of the field. If there is no enclosing character, then any delimiters present in the field body are escaped instead. The field is enclosed only if: enclose != '\000', and: encloseRequired is true, or one of the fields-terminated-by or lines-terminated-by characters is present in the string. Escaping is not performed if the escape char is '\000'.

Parameters:
str - - The user's string to escape and enclose
delimiters - - The DelimiterSet to use identifying the escape and enclose semantics. If the specified escape or enclose characters are '\000', those operations are not performed.
Returns:
the escaped, enclosed version of 'str'.


Copyright © 2011 The Apache Software Foundation