Package org.codelibs.fess.dict.mapping
Class CharMappingItem
java.lang.Object
org.codelibs.fess.dict.DictionaryItem
org.codelibs.fess.dict.mapping.CharMappingItem
Represents a single character mapping rule that defines how input characters are mapped to output characters
for text analysis and search processing. This class is used in character mapping dictionaries to transform
text during indexing and search operations.
Each mapping item consists of one or more input character sequences that are mapped to a single output character sequence. The mapping supports both original values and new values for update operations.
-
Field Summary
Fields inherited from class org.codelibs.fess.dict.DictionaryItem
id -
Constructor Summary
ConstructorsConstructorDescriptionCharMappingItem(long id, String[] inputs, String output) Constructs a new CharMappingItem with the specified ID, input sequences, and output sequence. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this CharMappingItem with another object for equality.String[]Returns the array of input character sequences that are mapped to the output.Returns all input sequences joined with newline characters as a single string.String[]Returns the array of new input character sequences for update operations.Returns the new output character sequence for update operations.Returns the output character sequence that inputs are mapped to.inthashCode()Calculates the hash code for this CharMappingItem based on inputs and output.booleanChecks whether this mapping item is marked for deletion.booleanChecks whether this mapping item has pending updates.voidsetNewInputs(String[] newInputs) Sets the array of new input character sequences for update operations.voidsetNewOutput(String newOutput) Sets the new output character sequence for update operations.voidsort()Sorts both the current inputs and new inputs arrays in place.Returns a compact string representation of this mapping item in the format "input1,input2=>output".toString()Returns a string representation of this CharMappingItem including all fields.Methods inherited from class org.codelibs.fess.dict.DictionaryItem
getId
-
Constructor Details
-
CharMappingItem
Constructs a new CharMappingItem with the specified ID, input sequences, and output sequence.- Parameters:
id- the unique identifier for this mapping iteminputs- array of input character sequences that will be mapped to the outputoutput- the output character sequence that inputs will be mapped to
-
-
Method Details
-
getNewInputs
Returns the array of new input character sequences for update operations. Returns a defensive copy to prevent external modification.- Returns:
- array of new input sequences (defensive copy), or null if no updates are pending
-
setNewInputs
Sets the array of new input character sequences for update operations.- Parameters:
newInputs- array of new input sequences to set
-
getNewOutput
Returns the new output character sequence for update operations.- Returns:
- the new output sequence, or null if no updates are pending
-
setNewOutput
Sets the new output character sequence for update operations. Newline characters in the output are automatically replaced with spaces.- Parameters:
newOutput- the new output sequence to set
-
getInputs
Returns the array of input character sequences that are mapped to the output. Returns a defensive copy to prevent external modification.- Returns:
- array of input sequences (defensive copy)
-
getInputsValue
Returns all input sequences joined with newline characters as a single string. This is useful for display purposes in forms and user interfaces.- Returns:
- string representation of all inputs separated by newlines, or empty string if inputs is null
-
getOutput
Returns the output character sequence that inputs are mapped to.- Returns:
- the output sequence
-
isUpdated
public boolean isUpdated()Checks whether this mapping item has pending updates.- Returns:
- true if both newInputs and newOutput are not null, indicating pending updates
-
isDeleted
public boolean isDeleted()Checks whether this mapping item is marked for deletion. An item is considered deleted if it has updates pending and the new inputs array is empty.- Returns:
- true if the item is marked for deletion
-
sort
public void sort()Sorts both the current inputs and new inputs arrays in place. This ensures consistent ordering for comparison and equality operations. -
hashCode
public int hashCode()Calculates the hash code for this CharMappingItem based on inputs and output. -
equals
Compares this CharMappingItem with another object for equality. Two CharMappingItem objects are equal if they have the same inputs and output. Note: inputs arrays are sorted in the constructor, so no sorting is needed here. -
toString
Returns a string representation of this CharMappingItem including all fields. -
toLineString
Returns a compact string representation of this mapping item in the format "input1,input2=>output". If the item has pending updates, the new values are used; otherwise, the current values are used.- Returns:
- compact string representation of the mapping rule
-