Class AdeptDataConversion
java.lang.Object
de.aristaflow.adept2.model.datamanagement.AdeptDataConversion
Provides methods to derive the ADEPT2 data type of a value from its class, to convert values of
one ADEPT2 data type to another where possible, to convert a value into its typed text form and
back, and to check the values of a parameter map against a parameter collection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum number of characters of the typed text form of an accepted value. -
Method Summary
Modifier and TypeMethodDescriptionstatic Serializableconvert(Serializable value, ProcessConstants.AdeptDataType targetDataType) Converts the given value to the specified target data type and returns it.getDataType(Object value) Gets the ADEPT2 data type of the designated value derived from its class:INTEGERfor aLong,FLOATfor aDouble,BOOLEANfor aBoolean,STRINGfor aString,DATEfor aDate,URIfor aURIandUSERDEFINEDfor aUDTValue.static Collection<String>getMissingValues(Map<String, ?> paramValues, Collection<? extends Parameter> acceptedParams) Gets the names of the parameters in the designated parameter collection which are not optional and have no value in the designated parameter map, anullvalue counting as none.static SerializableparseTypedText(String typedText) Parses the designated typed text form, astoTypedText(Object)writes it, into the value it represents.rejectParams(Map<String, ?> paramValues, Collection<? extends Parameter> acceptedParams) Gets the values in the designated parameter map which the designated parameter collection does not accept, each with the first of these reasons which applies: the value isnull, there is no parameter of its name, the value has another ADEPT2 data type than its parameter, it has no typed text form, or its typed text form has more than 4000 characters.static StringtoTypedText(Object value) Converts the designated value into its typed text form: the name of its data type, a colon and its text form as written byConfigurationTools, e. g.
-
Field Details
-
MAX_TYPED_TEXT_LENGTH
public static final int MAX_TYPED_TEXT_LENGTHThe maximum number of characters of the typed text form of an accepted value.- See Also:
-
-
Method Details
-
getDataType
Gets the ADEPT2 data type of the designated value derived from its class:INTEGERfor aLong,FLOATfor aDouble,BOOLEANfor aBoolean,STRINGfor aString,DATEfor aDate,URIfor aURIandUSERDEFINEDfor aUDTValue. A placeholder has the data type of the value it stands for.- Parameters:
value- The value of which to get the data type. This must not benull.- Returns:
- The ADEPT2 data type of the designated value or
nullif its class has none. - Throws:
NullArgumentException- If the designated value isnull, aNullArgumentExceptionwill be thrown.
-
convert
public static Serializable convert(Serializable value, ProcessConstants.AdeptDataType targetDataType) throws ConversionException Converts the given value to the specified target data type and returns it.Conversions between data types. BOOLEAN INTEGER
(accepts allNumbersFLOAT
(accepts allNumbersSTRING DATE URI USERDEFINED BOOLEAN -> as is false -> 0L
true -> 1Lfalse -> 0d
true -> 1dfalse -> "false"
true -> "true"- - - INTEGER -> 0 -> false; true otherwise as is
(cast toLongif necessary)cast to Doublesigned decimal representation taken as milliseconds since 1970-01-01, 00:00:00 GMT - - FLOAT -> 0 -> false; true otherwise
(accepts allNumbers)discards fractional digits while casting to Long
(accepts allNumbers)as is
(accepts allNumbers; will be cast toDouble)computerized scientific notation taken as milliseconds since 1970-01-01, 00:00:00 GMT; discards fractional digits - - STRING -> "true" (ignoring case) -> true, false otherwise ( Boolean.parseBoolean(String))parsed as signed decimal representation ( Long.parseLong(String))parsed as computerized scientific notation ( Double.parseDouble(String))as is parsed as ISO 8601 parsed as URI ( URI.create(String))encoded as UTF-8 DATE -> - milliseconds since 1970-01-01, 00:00:00 GMT as Longmilliseconds since 1970-01-01, 00:00:00 GMT as Doubleformatted as ISO 8601 as is - - URI -> - - - as string - as is - USERDEFINED -> - - - decoded as UTF-8 - - as is (cloned) - Parameters:
value- the value to be converted; this should typically be a direct equivalent to an ADEPT2 data type. The caller is responsible for closing.targetDataType- the target data type to which the value should be converted- Returns:
- the converted value. The caller is responsible for closing if appropriate.
- Throws:
ConversionException- if the conversion is not possible
-
toTypedText
Converts the designated value into its typed text form: the name of its data type, a colon and its text form as written byConfigurationTools, e. g.INTEGER:7,STRING:7orDATE:2026-10-01T04:00:00Z, a date being an ISO-8601 instant. AUDTValueisUSERDEFINED, a colon, its UDT name, a colon and its content gzipped and Base64-encoded. The first colon ends the data type, whose names contain none, and the last colon ends a UDT name, since Base64 contains none, so the text needs no escape.parseTypedText(String)parses a typed text form without further information.- Parameters:
value- The value to convert. This must not benull. The caller stays responsible for closing aUDTValue.- Returns:
- The typed text form of the designated value. This will never be
null. - Throws:
ConversionException- If the class of the designated value has no ADEPT2 data type, the value is a placeholder or aUDTValuewithout a name, or the content of aUDTValuecannot be read, aConversionExceptionwill be thrown.NullArgumentException- If the designated value isnull, aNullArgumentExceptionwill be thrown.
-
parseTypedText
Parses the designated typed text form, astoTypedText(Object)writes it, into the value it represents. The text after the data type is read asConfigurationToolsreads it, so it may also have another form thatConfigurationToolsaccepts, e. g.BOOLEAN:yes.- Parameters:
typedText- The typed text form to parse. This must not benull.- Returns:
- The value which the designated typed text form represents. This will never be
null. The caller is responsible for closing aUDTValue. - Throws:
ConversionException- If the designated text does not start with the name of an ADEPT2 data type and a colon or the text after it is no value of this data type, aConversionExceptionwill be thrown.NullArgumentException- If the designated text isnull, aNullArgumentExceptionwill be thrown.
-
rejectParams
public static Map<String,String> rejectParams(Map<String, ?> paramValues, Collection<? extends Parameter> acceptedParams) Gets the values in the designated parameter map which the designated parameter collection does not accept, each with the first of these reasons which applies: the value isnull, there is no parameter of its name, the value has another ADEPT2 data type than its parameter, it has no typed text form, or its typed text form has more than 4000 characters. AUDTValuefits a parameter of the data typeUSERDEFINEDwhatever its UDT name, as in a data container. The reasons do not say what the parameters belong to; a caller adds this in its own messages, e. g. the template whose input parameters they are.- Parameters:
paramValues- The parameter map, from the name of a parameter to its value. This must not benull. The caller stays responsible for closing aUDTValue.acceptedParams- The collection of accepted parameters ornullif it is unknown, in which case only the checks which do not depend on it apply.- Returns:
- The reasons why values (or parameters) are not accepted, indexed by the names of their
parameters in the order of the designated parameter map. This will never be
null. - Throws:
NullArgumentException- If the designated parameter value map isnull, aNullArgumentExceptionwill be thrown.
-
getMissingValues
public static Collection<String> getMissingValues(Map<String, ?> paramValues, Collection<? extends Parameter> acceptedParams) Gets the names of the parameters in the designated parameter collection which are not optional and have no value in the designated parameter map, anullvalue counting as none. A value whichrejectParams(Map, Collection)reports counts as a value, so a caller which drops the rejected values asks for the missing ones afterwards.- Parameters:
paramValues- The parameter map, from the name of a parameter to its value. This must not benull.acceptedParams- The parameter collection ornullif it is unknown, in which case none is reported.- Returns:
- The names of the parameters which are not optional and have no value, in the order of
the designated parameter collection. This will never be
null. - Throws:
NullArgumentException- If the designated parameter value map isnull, aNullArgumentExceptionwill be thrown.
-