Package org.apache.sis.feature
Class StringJoinOperation
java.lang.Object
org.apache.sis.feature.AbstractIdentifiedType
org.apache.sis.feature.AbstractOperation
org.apache.sis.feature.StringJoinOperation
- All Implemented Interfaces:
Serializable,BiFunction<AbstractFeature,,org.opengis.parameter.ParameterValueGroup, Object> Deprecable
An operation concatenating the string representations of the values of multiple properties.
This operation can be used for creating a compound key as a
String
that consists of two or more attribute values that uniquely identify a feature instance.
This operation supports both reading and writing. When setting a value on the attribute created by this operation, the value will be split and forwarded to each single attribute.
- Since:
- 0.7
- Version:
- 1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classA pseudo-converter returning the identifier of a feature.private final classThe attributes that contains the result of concatenating the string representation of other attributes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String[]The name of the properties (attributes of operations producing attributes) from which to get the values to concatenate.private final ObjectConverter<? super String,?>[] Converters for parsing strings as attribute values.(package private) final StringThe characters to use a delimiter between each single attribute value.The property names as an unmodifiable set, created when first needed.private static final org.opengis.parameter.ParameterDescriptorGroupThe parameter descriptor for the "String join" operation, which does not take any parameter.(package private) static final charThe character used for escaping occurrences of the delimiter inside a value.(package private) final StringThe characters to use at the beginning of the concatenated string, or an empty string if none.private final DefaultAttributeType<String>The type of the result returned by the string concatenation operation.private static final longFor cross-version compatibility.(package private) final StringThe characters to use at the end of the concatenated string, or an empty string if none.Fields inherited from class org.apache.sis.feature.AbstractOperation
RESULT_PREFIXFields inherited from class org.apache.sis.feature.AbstractIdentifiedType
DEFINITION_KEY, deprecated, DEPRECATED_KEY, DESCRIPTION_KEY, DESIGNATION_KEY, NAME_KEY -
Constructor Summary
ConstructorsConstructorDescriptionStringJoinOperation(Map<String, ?> identification, String delimiter, String prefix, String suffix, AbstractIdentifiedType[] singleAttributes) Creates a new operation for string concatenations using the given prefix, suffix and delimeter. -
Method Summary
Modifier and TypeMethodDescriptionapply(AbstractFeature feature, org.opengis.parameter.ParameterValueGroup parameters) Returns the concatenation of property values of the given feature.booleanCompares this operation with the given object for equality.(package private) static <S> Objectformat(ObjectConverter<S, ?> converter, Object value) Formats the given value using the given converter.(package private) voidformatResultFormula(Appendable buffer) Appends a string representation of the "formula" used for computing the result.Returns the names of feature properties that this operation needs for performing its task.org.opengis.parameter.ParameterDescriptorGroupReturns an empty group of parameters since this operation does not require any parameter.Returns the type of results computed by this operation, which isAttributeType<String>.inthashCode()Computes a hash-code value for this operation.Methods inherited from class org.apache.sis.feature.AbstractOperation
defaultFormula, resultIdentification, toStringMethods inherited from class org.apache.sis.feature.AbstractIdentifiedType
createName, getDefinition, getDescription, getDesignation, getName, getRemarks, isDeprecated, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.BiFunction
andThen
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
ESCAPE
static final char ESCAPEThe character used for escaping occurrences of the delimiter inside a value.- See Also:
-
EMPTY_PARAMS
private static final org.opengis.parameter.ParameterDescriptorGroup EMPTY_PARAMSThe parameter descriptor for the "String join" operation, which does not take any parameter. -
attributeNames
The name of the properties (attributes of operations producing attributes) from which to get the values to concatenate. -
converters
Converters for parsing strings as attribute values. Those converters will be used byStringJoinOperation.Result.setValue(String)whileStringJoinOperation.Result.getValue()will use the inverse of those converters.Note: we store converters from string to value instead of the converse because the inverse conversion is often a simple call to
Object.toString(), so there is a risk that some of the latter converters do not bother to remember their inverse. -
dependencies
The property names as an unmodifiable set, created when first needed. -
resultType
The type of the result returned by the string concatenation operation. -
prefix
The characters to use at the beginning of the concatenated string, or an empty string if none. -
suffix
The characters to use at the end of the concatenated string, or an empty string if none. -
delimiter
The characters to use a delimiter between each single attribute value.
-
-
Constructor Details
-
StringJoinOperation
StringJoinOperation(Map<String, ?> identification, String delimiter, String prefix, String suffix, AbstractIdentifiedType[] singleAttributes) throws UnconvertibleObjectExceptionCreates a new operation for string concatenations using the given prefix, suffix and delimeter. It is caller's responsibility to ensure thatdelimiterandsingleAttributesare not null. This private constructor does not verify that condition on the assumption that the public API did.
-
-
Method Details
-
getParameters
public org.opengis.parameter.ParameterDescriptorGroup getParameters()Returns an empty group of parameters since this operation does not require any parameter.- Specified by:
getParametersin classAbstractOperation- Returns:
- empty parameter group.
-
getResult
Returns the type of results computed by this operation, which isAttributeType<String>. The attribute type name depends on the value of"result.*"properties (if any) given at construction time.- Specified by:
getResultin classAbstractOperation- Returns:
- an
AttributeType<String>.
-
getDependencies
Returns the names of feature properties that this operation needs for performing its task.- Overrides:
getDependenciesin classAbstractOperation- Returns:
- the names of feature properties needed by this operation for performing its task.
-
format
Formats the given value using the given converter. This method is a workaround for the presence of the first?inObjectConverter<?,?>: defining a separated method allows us to replace that<?>by<S>, thus allowing the compiler to verify consistency.- Parameters:
converter- the converter to use for formatting the given value.value- the value to format, ornull.
-
apply
public Property apply(AbstractFeature feature, org.opengis.parameter.ParameterValueGroup parameters) Returns the concatenation of property values of the given feature.- Specified by:
applyin interfaceBiFunction<AbstractFeature,org.opengis.parameter.ParameterValueGroup, Object> - Specified by:
applyin classAbstractOperation- Parameters:
feature- the feature on which to execute the operation.parameters- ignored (can benull).- Returns:
- the concatenation of feature property values.
-
hashCode
public int hashCode()Computes a hash-code value for this operation.- Overrides:
hashCodein classAbstractOperation- Returns:
- the hash code for this type.
-
equals
Compares this operation with the given object for equality.- Overrides:
equalsin classAbstractOperation- Parameters:
obj- the object to compare with this type.- Returns:
trueif the given object is equal to this type.
-
formatResultFormula
Appends a string representation of the "formula" used for computing the result.- Overrides:
formatResultFormulain classAbstractOperation- Parameters:
buffer- where to format the "formula".- Throws:
IOException- if an error occurred while writing inbuffer.
-