Class Serializers
- java.lang.Object
-
- de.isas.mztab2.io.serialization.Serializers
-
public class Serializers extends Object
Utility class providing helper methods for other serializers.
- Since:
- 11/30/17
- Author:
- nilshoffmann
-
-
Constructor Summary
Constructors Constructor Description Serializers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends IndexedElement>
voidaddIndexedLine(com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, String prefix, Object element, List<T> indexedElementList)
addIndexedLine for elements like assay[1] that have an id and a list of additional property elementsstatic <T extends IndexedElement>
voidaddIndexedLine(com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, String prefix, Object element, T indexedElement)
addIndexedLine for elements like assay[1] that have an id and one additional property elementstatic void
addLine(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, Object... value)
addLine.static void
addLineWithMetadataProperty(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, MetadataProperty property, Object element, Object... value)
addLineWithMetadataProperty.static void
addLineWithNullProperty(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, String propertyName, Object element)
addLineWithNullProperty.static void
addLineWithParameters(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, List<Parameter> parameterList)
addLineWithParameters.static void
addLineWithProperty(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, String propertyName, Object element, Object... value)
addLineWithProperty.static void
addLineWithPropertyParameters(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, String propertyName, Object element, List<Parameter> value)
addLineWithPropertyParameters.static void
addSubElementParameter(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, String subElementName, Parameter subElement)
addSubElementParameter.static void
addSubElementParameters(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, String subElementName, List<Parameter> subElements, boolean oneLine)
addSubElementParameters.static void
addSubElementStrings(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, String subElementName, List<?> subElements, boolean oneLine)
addSubElementStrings.static Map<String,Object>
asMap(Object element)
asMap.static String
camelCaseToUnderscoreLowerCase(String camelCase)
camelCaseToUnderscoreLowerCase.static boolean
checkForNull(Object element, List<?> subElements, String subElementName)
checkForNull.static void
checkIndexedElement(IndexedElement element)
static Optional<String>
getElementName(Object element)
getElementName.static List<String>
getPropertyNames(Object element)
getPropertyNames.static String
getReference(Object element, Integer idx)
getReference.static String
printAbundanceAssay(Assay a)
printAbundanceAssay.static String
printAbundanceCoeffVarStudyVar(StudyVariable sv)
printAbundanceCoeffVarStudyVar.static String
printAbundanceStudyVar(StudyVariable sv)
printAbundanceStudyVar.static String
printOptColumnMapping(OptColumnMapping ocm)
printOptColumnMapping.static void
writeAsNumberArray(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, List<? extends Number> elements)
writeAsNumberArray.static void
writeAsNumberArray(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, List<? extends Number> elements)
writeAsNumberArray.static void
writeAsStringArray(com.fasterxml.jackson.core.JsonGenerator jg, List<String> elements)
writeAsStringArray.static void
writeAsStringArray(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, List<String> elements)
writeAsStringArray.static void
writeAsStringArray(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, List<String> elements)
writeAsStringArray.static void
writeIndexedDoubles(String prefix, com.fasterxml.jackson.core.JsonGenerator jg, List<Double> values)
writeIndexedValues.static void
writeNumber(com.fasterxml.jackson.core.JsonGenerator jg, Double value)
writeNumber.static void
writeNumber(com.fasterxml.jackson.core.JsonGenerator jg, Integer value)
writeNumber.static void
writeNumber(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, Double value)
writeNumber.static void
writeNumber(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, Integer value)
writeNumber.static void
writeNumber(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, Double value)
writeNumber.static void
writeNumber(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, Integer value)
writeNumber.static void
writeObject(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, Object value)
writeObject.static void
writeObject(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, Object value)
writeObject.static void
writeOptColumnMappings(List<OptColumnMapping> optColumnMappings, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp)
writeOptColumnMappings.static void
writeString(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, String value)
writeString.static void
writeString(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, String value)
writeString.
-
-
-
Constructor Detail
-
Serializers
public Serializers()
-
-
Method Detail
-
getReference
public static String getReference(Object element, Integer idx)
getReference.
-
printAbundanceAssay
public static String printAbundanceAssay(Assay a)
printAbundanceAssay.
-
printAbundanceStudyVar
public static String printAbundanceStudyVar(StudyVariable sv)
printAbundanceStudyVar.
- Parameters:
sv
- aStudyVariable
object.- Returns:
- a
String
object.
-
printAbundanceCoeffVarStudyVar
public static String printAbundanceCoeffVarStudyVar(StudyVariable sv)
printAbundanceCoeffVarStudyVar.
- Parameters:
sv
- aStudyVariable
object.- Returns:
- a
String
object.
-
printOptColumnMapping
public static String printOptColumnMapping(OptColumnMapping ocm)
printOptColumnMapping.
- Parameters:
ocm
- aOptColumnMapping
object.- Returns:
- a
String
object.
-
addIndexedLine
public static <T extends IndexedElement> void addIndexedLine(com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, String prefix, Object element, T indexedElement)
addIndexedLine for elements like assay[1] that have an id and one additional property element
- Type Parameters:
T
- the type ofIndexedElement
.- Parameters:
jg
- aJsonGenerator
object.sp
- aSerializerProvider
object.prefix
- aString
object.element
- aObject
object.indexedElement
- aParameter
object.
-
addIndexedLine
public static <T extends IndexedElement> void addIndexedLine(com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, String prefix, Object element, List<T> indexedElementList)
addIndexedLine for elements like assay[1] that have an id and a list of additional property elements
- Type Parameters:
T
- the type ofIndexedElement
.- Parameters:
jg
- aJsonGenerator
object.sp
- aSerializerProvider
object.prefix
- aString
object.element
- aObject
object.indexedElementList
- aList
object.
-
addLineWithParameters
public static void addLineWithParameters(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, List<Parameter> parameterList)
addLineWithParameters.
-
addLineWithPropertyParameters
public static void addLineWithPropertyParameters(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, String propertyName, Object element, List<Parameter> value)
addLineWithPropertyParameters.
-
addLineWithMetadataProperty
public static void addLineWithMetadataProperty(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, MetadataProperty property, Object element, Object... value)
addLineWithMetadataProperty.
- Parameters:
jg
- aJsonGenerator
object.prefix
- aString
object.property
- aMetadataProperty
object.element
- aObject
object.value
- aObject
object.
-
addLineWithNullProperty
public static void addLineWithNullProperty(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, String propertyName, Object element)
addLineWithNullProperty.
-
addLineWithProperty
public static void addLineWithProperty(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, String propertyName, Object element, Object... value)
addLineWithProperty.
-
addLine
public static void addLine(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, Object... value)
addLine.
-
getElementName
public static Optional<String> getElementName(Object element)
getElementName.
-
getPropertyNames
public static List<String> getPropertyNames(Object element)
getPropertyNames.
-
camelCaseToUnderscoreLowerCase
public static String camelCaseToUnderscoreLowerCase(String camelCase)
camelCaseToUnderscoreLowerCase.
-
addSubElementStrings
public static void addSubElementStrings(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, String subElementName, List<?> subElements, boolean oneLine)
addSubElementStrings.
-
addSubElementParameter
public static void addSubElementParameter(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, String subElementName, Parameter subElement)
addSubElementParameter.
-
addSubElementParameters
public static void addSubElementParameters(com.fasterxml.jackson.core.JsonGenerator jg, String prefix, Object element, String subElementName, List<Parameter> subElements, boolean oneLine)
addSubElementParameters.
-
checkForNull
public static boolean checkForNull(Object element, List<?> subElements, String subElementName)
checkForNull.
-
writeString
public static void writeString(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, String value) throws IOException
writeString.
- Parameters:
columnName
- aString
object.jg
- aJsonGenerator
object.value
- aString
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeString
public static void writeString(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, String value) throws IOException
writeString.
- Parameters:
column
- aIMZTabColumn
object.jg
- aJsonGenerator
object.value
- aString
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeObject
public static void writeObject(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, Object value) throws IOException
writeObject.
- Parameters:
columnName
- aString
object.jg
- aJsonGenerator
object.sp
- aSerializerProvider
object.value
- aObject
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeObject
public static void writeObject(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp, Object value) throws IOException
writeObject.
- Parameters:
column
- aIMZTabColumn
object.jg
- aJsonGenerator
object.sp
- aSerializerProvider
object.value
- aObject
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeAsNumberArray
public static void writeAsNumberArray(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, List<? extends Number> elements)
writeAsNumberArray.
- Parameters:
column
- aIMZTabColumn
object.jg
- aJsonGenerator
object.elements
- aList
object.
-
writeAsNumberArray
public static void writeAsNumberArray(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, List<? extends Number> elements)
writeAsNumberArray.
-
writeAsStringArray
public static void writeAsStringArray(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, List<String> elements)
writeAsStringArray.
- Parameters:
column
- aIMZTabColumn
object.jg
- aJsonGenerator
object.elements
- aList
object.
-
writeAsStringArray
public static void writeAsStringArray(com.fasterxml.jackson.core.JsonGenerator jg, List<String> elements)
writeAsStringArray.
- Parameters:
jg
- aJsonGenerator
object.elements
- aList
object.
-
writeAsStringArray
public static void writeAsStringArray(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, List<String> elements)
writeAsStringArray.
-
writeNumber
public static void writeNumber(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, Integer value) throws IOException
writeNumber.
- Parameters:
columnName
- aString
object.jg
- aJsonGenerator
object.value
- aInteger
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeNumber
public static void writeNumber(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, Integer value) throws IOException
writeNumber.
- Parameters:
column
- aIMZTabColumn
object.jg
- aJsonGenerator
object.value
- aInteger
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeNumber
public static void writeNumber(String columnName, com.fasterxml.jackson.core.JsonGenerator jg, Double value) throws IOException
writeNumber.
- Parameters:
columnName
- aString
object.jg
- aJsonGenerator
object.value
- aDouble
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeNumber
public static void writeNumber(IMZTabColumn column, com.fasterxml.jackson.core.JsonGenerator jg, Double value) throws IOException
writeNumber.
- Parameters:
column
- aIMZTabColumn
object.jg
- aJsonGenerator
object.value
- aDouble
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeNumber
public static void writeNumber(com.fasterxml.jackson.core.JsonGenerator jg, Integer value) throws IOException
writeNumber.
- Parameters:
jg
- aJsonGenerator
object.value
- aInteger
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeNumber
public static void writeNumber(com.fasterxml.jackson.core.JsonGenerator jg, Double value) throws IOException
writeNumber.
- Parameters:
jg
- aJsonGenerator
object.value
- aDouble
object.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeOptColumnMappings
public static void writeOptColumnMappings(List<OptColumnMapping> optColumnMappings, com.fasterxml.jackson.core.JsonGenerator jg, com.fasterxml.jackson.databind.SerializerProvider sp) throws IOException
writeOptColumnMappings.
- Parameters:
optColumnMappings
- aList
object.jg
- aJsonGenerator
object.sp
- the serialization provider.- Throws:
IOException
- if an operation on the JsonGenerator object fails.
-
writeIndexedDoubles
public static void writeIndexedDoubles(String prefix, com.fasterxml.jackson.core.JsonGenerator jg, List<Double> values)
writeIndexedValues.
-
checkIndexedElement
public static void checkIndexedElement(IndexedElement element)
-
-