Class CsvGenerator
- java.lang.Object
-
- uk.gov.gchq.gaffer.data.generator.CsvGenerator
-
- All Implemented Interfaces:
Function<Iterable<? extends Element>,Iterable<? extends String>>,ObjectGenerator<String>,OneToOneObjectGenerator<String>
- Direct Known Subclasses:
Neo4jCsvGenerator
public class CsvGenerator extends Object implements OneToOneObjectGenerator<String>
Generates a CSV string for eachElement, based on the fields and constants provided.For example, if you provide:
fields=[prop1, SOURCE, DESTINATION, prop2, GROUP] and constants=["constant1", "constant2"]
The output will be:prop1Value,sourceValue,destinationValue,prop2,groupValue,constant1,constant2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCsvGenerator.Builder
-
Constructor Summary
Constructors Constructor Description CsvGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String_apply(Element element)voidaddAdditionalFieldsFromSchemaProperties(LinkedHashMap<String,Class<?>> schemaProperties)Adds all properties from a schema to the fields if includeSchemaProperties is true.StringgetCommaReplacement()LinkedHashMap<String,String>getConstants()LinkedHashMap<String,String>getFields()StringgetHeader()Generates a CSV String from, if present, the fields and constantsbooleangetIncludeDefaultFields()booleangetIncludeSchemaProperties()booleanisQuoted()voidsetCommaReplacement(String commaReplacement)voidsetConstants(LinkedHashMap<String,String> constants)voidsetFields(LinkedHashMap<String,String> fields)voidsetIncludeDefaultFields(boolean includeDefaultFields)voidsetIncludeSchemaProperties(boolean includeSchemaProperties)voidsetQuoted(boolean quoted)-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.gov.gchq.gaffer.data.generator.OneToOneObjectGenerator
apply
-
-
-
-
Method Detail
-
getFields
public LinkedHashMap<String,String> getFields()
-
setFields
public void setFields(LinkedHashMap<String,String> fields)
-
getConstants
public LinkedHashMap<String,String> getConstants()
-
setConstants
public void setConstants(LinkedHashMap<String,String> constants)
-
getIncludeDefaultFields
public boolean getIncludeDefaultFields()
-
setIncludeDefaultFields
public void setIncludeDefaultFields(boolean includeDefaultFields)
-
getIncludeSchemaProperties
public boolean getIncludeSchemaProperties()
-
setIncludeSchemaProperties
public void setIncludeSchemaProperties(boolean includeSchemaProperties)
-
addAdditionalFieldsFromSchemaProperties
public void addAdditionalFieldsFromSchemaProperties(LinkedHashMap<String,Class<?>> schemaProperties)
Adds all properties from a schema to the fields if includeSchemaProperties is true.- Parameters:
schemaProperties- a Map of property names to types.
-
_apply
public String _apply(Element element)
- Specified by:
_applyin interfaceOneToOneObjectGenerator<String>- Parameters:
element- the element to convert- Returns:
- the generated domain object
-
getHeader
public String getHeader()
Generates a CSV String from, if present, the fields and constants- Returns:
- a CSV String of all fields, or constants, or both.
-
isQuoted
public boolean isQuoted()
-
setQuoted
public void setQuoted(boolean quoted)
-
getCommaReplacement
public String getCommaReplacement()
-
setCommaReplacement
public void setCommaReplacement(String commaReplacement)
-
-