Package org.apache.sqoop.lib
Class DelimiterSet
- java.lang.Object
-
- org.apache.sqoop.lib.DelimiterSet
-
- All Implemented Interfaces:
java.lang.Cloneable
public class DelimiterSet extends java.lang.Object implements java.lang.CloneableEncapsulates a set of delimiters used to encode a record.
-
-
Field Summary
Fields Modifier and Type Field Description static DelimiterSetDEFAULT_DELIMITERSstatic DelimiterSetHIVE_DELIMITERSstatic java.lang.StringINPUT_ENCLOSE_REQUIRED_KEYstatic java.lang.StringINPUT_ENCLOSED_BY_KEYstatic java.lang.StringINPUT_ESCAPED_BY_KEYstatic java.lang.StringINPUT_FIELD_DELIM_KEYCreate the input variations for export instead of overloading them.static java.lang.StringINPUT_RECORD_DELIM_KEYstatic DelimiterSetMYSQL_DELIMITERSstatic charNULL_CHARstatic java.lang.StringOUTPUT_ENCLOSE_REQUIRED_KEYstatic java.lang.StringOUTPUT_ENCLOSED_BY_KEYstatic java.lang.StringOUTPUT_ESCAPED_BY_KEYstatic java.lang.StringOUTPUT_FIELD_DELIM_KEYstatic java.lang.StringOUTPUT_RECORD_DELIM_KEY
-
Constructor Summary
Constructors Constructor Description DelimiterSet()Create a delimiter set with the default delimiters (comma for fields, newline for records).DelimiterSet(char field, char record, char enclose, char escape, boolean isEncloseRequired)Create a delimiter set with the specified delimiters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()DelimiterSetcopy()Identical to clone() but does not throw spurious exceptions.booleanequals(java.lang.Object other)java.lang.StringformatConstructor()Format this set of delimiters as a call to the constructor for this object, that would generate identical delimiters.chargetEnclosedBy()chargetEscapedBy()chargetFieldsTerminatedBy()chargetLinesTerminatedBy()inthashCode()booleanisEncloseRequired()voidsetEnclosedBy(char e)Sets the enclosed-by character.voidsetEncloseRequired(boolean required)Set whether the enclosed-by character must be applied to all fields, or only fields with embedded delimiters.voidsetEscapedBy(char e)Sets the escaped-by character.voidsetFieldsTerminatedBy(char f)Sets the fields-terminated-by character.voidsetLinesTerminatedBy(char r)Sets the end-of-record lines-terminated-by character.java.lang.StringtoString()
-
-
-
Field Detail
-
NULL_CHAR
public static final char NULL_CHAR
- See Also:
- Constant Field Values
-
OUTPUT_FIELD_DELIM_KEY
public static final java.lang.String OUTPUT_FIELD_DELIM_KEY
- See Also:
- Constant Field Values
-
OUTPUT_RECORD_DELIM_KEY
public static final java.lang.String OUTPUT_RECORD_DELIM_KEY
- See Also:
- Constant Field Values
-
OUTPUT_ENCLOSED_BY_KEY
public static final java.lang.String OUTPUT_ENCLOSED_BY_KEY
- See Also:
- Constant Field Values
-
OUTPUT_ESCAPED_BY_KEY
public static final java.lang.String OUTPUT_ESCAPED_BY_KEY
- See Also:
- Constant Field Values
-
OUTPUT_ENCLOSE_REQUIRED_KEY
public static final java.lang.String OUTPUT_ENCLOSE_REQUIRED_KEY
- See Also:
- Constant Field Values
-
INPUT_FIELD_DELIM_KEY
public static final java.lang.String INPUT_FIELD_DELIM_KEY
Create the input variations for export instead of overloading them.- See Also:
- Constant Field Values
-
INPUT_RECORD_DELIM_KEY
public static final java.lang.String INPUT_RECORD_DELIM_KEY
- See Also:
- Constant Field Values
-
INPUT_ENCLOSED_BY_KEY
public static final java.lang.String INPUT_ENCLOSED_BY_KEY
- See Also:
- Constant Field Values
-
INPUT_ESCAPED_BY_KEY
public static final java.lang.String INPUT_ESCAPED_BY_KEY
- See Also:
- Constant Field Values
-
INPUT_ENCLOSE_REQUIRED_KEY
public static final java.lang.String INPUT_ENCLOSE_REQUIRED_KEY
- See Also:
- Constant Field Values
-
DEFAULT_DELIMITERS
public static final DelimiterSet DEFAULT_DELIMITERS
-
HIVE_DELIMITERS
public static final DelimiterSet HIVE_DELIMITERS
-
MYSQL_DELIMITERS
public static final DelimiterSet MYSQL_DELIMITERS
-
-
Constructor Detail
-
DelimiterSet
public DelimiterSet()
Create a delimiter set with the default delimiters (comma for fields, newline for records).
-
DelimiterSet
public DelimiterSet(char field, char record, char enclose, char escape, boolean isEncloseRequired)Create a delimiter set with the specified delimiters.- Parameters:
field- the fields-terminated-by delimiterrecord- the lines-terminated-by delimiterenclose- the enclosed-by characterescape- the escaped-by characterisEncloseRequired- If true, enclosed-by is applied to all fields. If false, only applied to fields that embed delimiters.
-
-
Method Detail
-
copy
public DelimiterSet copy()
Identical to clone() but does not throw spurious exceptions.- Returns:
- a new copy of this same set of delimiters.
-
setFieldsTerminatedBy
public void setFieldsTerminatedBy(char f)
Sets the fields-terminated-by character.
-
getFieldsTerminatedBy
public char getFieldsTerminatedBy()
- Returns:
- the fields-terminated-by character.
-
setLinesTerminatedBy
public void setLinesTerminatedBy(char r)
Sets the end-of-record lines-terminated-by character.
-
getLinesTerminatedBy
public char getLinesTerminatedBy()
- Returns:
- the end-of-record (lines-terminated-by) character.
-
setEnclosedBy
public void setEnclosedBy(char e)
Sets the enclosed-by character.- Parameters:
e- the enclosed-by character, or '\000' for no enclosing character.
-
getEnclosedBy
public char getEnclosedBy()
- Returns:
- the enclosed-by character, or '\000' for none.
-
setEscapedBy
public void setEscapedBy(char e)
Sets the escaped-by character.- Parameters:
e- the escaped-by character, or '\000' for no escape character.
-
getEscapedBy
public char getEscapedBy()
- Returns:
- the escaped-by character, or '\000' for none.
-
setEncloseRequired
public void setEncloseRequired(boolean required)
Set whether the enclosed-by character must be applied to all fields, or only fields with embedded delimiters.
-
isEncloseRequired
public boolean isEncloseRequired()
- Returns:
- true if the enclosed-by character must be applied to all fields, or false if it's only used for fields with embedded delimiters.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
formatConstructor
public java.lang.String formatConstructor()
Format this set of delimiters as a call to the constructor for this object, that would generate identical delimiters.- Returns:
- a String that can be embedded in generated code that provides this set of delimiters.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-