The getCount method allows you to get the number of character replacements defined in the dictionary.
To add character replacements to the dictionary, use the addRange method.
To remove character replacements from the dictionary, the removeRange method is used.
The contains method is used to determine if the dictionary contains a replacement for the specified character.
To get a replacement for the specified character, use the getReplacement method.
To remove all replacements from the dictionary, use the clear method.
To export all replacements to a file, use the exportDictionary method.
To import character replacements from a file, use the importDictionary method.
The following example demonstrates the use of the character replacement dictionary methods.
StringindexFolder="c:\\MyIndex\\";// Creating an index from in specified folder
Indexindex=newIndex(indexFolder);if(index.getDictionaries().getCharacterReplacements().getCount()>0){// Deleting all character replacements from the dictionary
index.getDictionaries().getCharacterReplacements().clear();}if(index.getDictionaries().getCharacterReplacements().contains('-')){charreplacement=index.getDictionaries().getCharacterReplacements().getReplacement('-');System.out.println("The replacement for hyphen is "+replacement);// Deleting the hyphen character replacement from the dictionary
index.getDictionaries().getCharacterReplacements().removeRange(newchar[]{'-'});}// Export character replacements to a file
index.getDictionaries().getCharacterReplacements().exportDictionary("C:\\CharacterReplacements.dat");// Import character replacements from a file
index.getDictionaries().getCharacterReplacements().importDictionary("C:\\CharacterReplacements.dat");
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: