com.cloudera.sqoop.lib
Class FieldFormatter

java.lang.Object
  extended by com.cloudera.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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. 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 © 2010 Cloudera, Inc.