Class CharMappingItem

java.lang.Object
org.codelibs.fess.dict.DictionaryItem
org.codelibs.fess.dict.mapping.CharMappingItem

public class CharMappingItem extends DictionaryItem
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

    Constructors
    Constructor
    Description
    CharMappingItem(long id, String[] inputs, String output)
    Constructs a new CharMappingItem with the specified ID, input sequences, and output sequence.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares this CharMappingItem with another object for equality.
    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.
    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.
    int
    Calculates the hash code for this CharMappingItem based on inputs and output.
    boolean
    Checks whether this mapping item is marked for deletion.
    boolean
    Checks whether this mapping item has pending updates.
    void
    setNewInputs(String[] newInputs)
    Sets the array of new input character sequences for update operations.
    void
    setNewOutput(String newOutput)
    Sets the new output character sequence for update operations.
    void
    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".
    Returns a string representation of this CharMappingItem including all fields.

    Methods inherited from class org.codelibs.fess.dict.DictionaryItem

    getId

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CharMappingItem

      public CharMappingItem(long id, String[] inputs, String output)
      Constructs a new CharMappingItem with the specified ID, input sequences, and output sequence.
      Parameters:
      id - the unique identifier for this mapping item
      inputs - array of input character sequences that will be mapped to the output
      output - the output character sequence that inputs will be mapped to
  • Method Details

    • getNewInputs

      public String[] 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

      public void setNewInputs(String[] newInputs)
      Sets the array of new input character sequences for update operations.
      Parameters:
      newInputs - array of new input sequences to set
    • getNewOutput

      public String getNewOutput()
      Returns the new output character sequence for update operations.
      Returns:
      the new output sequence, or null if no updates are pending
    • setNewOutput

      public void setNewOutput(String newOutput)
      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

      public String[] 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

      public String 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

      public String 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.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this object
    • equals

      public boolean equals(Object obj)
      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.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with
      Returns:
      true if the objects are equal, false otherwise
    • toString

      public String toString()
      Returns a string representation of this CharMappingItem including all fields.
      Overrides:
      toString in class Object
      Returns:
      string representation of this object
    • toLineString

      public String 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