@PublicAPI public interface NameConverter
Molecule convert(java.lang.String name) throws NameFormatException
The failure to convert the name can be indicated either by returning
or by throwing a
When a converter fails by returning null or throwing
converters of lower priority will be called with the same name. To prevent that and guarantee that the name is
not converted at all, a converter should throw
name- the chemical name to be converted
nullif the name is not recognized.
NameFormatException- when the name does not correspond to a structure
NameFormatException.FilteredCase- when the name does not correspond to a structure, and not other converter should be tried on this name.
NamePrefixException- when the name does not correspond to a structure, but is a possible prefix of a valid name.
boolean setPrefixMode(boolean prefixMode)
The prefix mode is an optimization, only used when extracting structures from text documents. It is irrelevant when converting a single name to a structure.
When converting a document, it is not directly possible to know where name start and end. For instance, suppose that a converter knows the structure for "Prussian Blue" by looking it up in a database. Given the sentence "The Prussian Blue chemical was used to color textiles in blue", the word "Prussian" alone would be passed to the converter. If prefix mode has been successfully activated, the converter should throw a NamePrefixException, indicating that it knows a name starting with this prefix.
The prefix mode is an optional optimization. If a converter does not support it, it can return false to this call. In this case, the system will always try to call again after concatenating several words (up to a limit or a detected end of sentence). This ensures that names containing spaces will be recognized, at the cost of more conversion attempts.