Class ConditionalMapper.Builder
- java.lang.Object
-
- org.daisy.dotify.common.text.ConditionalMapper.Builder
-
- Enclosing class:
- ConditionalMapper
public static class ConditionalMapper.Builder extends Object
Creates a new mapper builder.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder with no specified trigger character.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConditionalMapperbuild()Builds the mapper with the current configuration.ConditionalMapper.Buildermap(String replace, String with)Defines that characters found in thereplacestring are to be replaced by the character at the corresponding position in thewithstring.ConditionalMapper.Builderput(char key, String value)Defines a replacement string for the specified character.ConditionalMapper.Builderput(int key, String value)Defines a replacement string for the specified Unicode code point.ConditionalMapper.BuilderputIgnorable(char value)Adds a transparent mapping for the specified character.ConditionalMapper.BuilderputIgnorable(int value)Adds a transparent mapping for the specified Unicode code point.ConditionalMapper.Buildertrigger(char trigger)Sets a trigger that activates the character mapper.ConditionalMapper.Buildertrigger(int trigger)Sets a trigger that activates the character mapper.
-
-
-
Constructor Detail
-
Builder
public Builder()
Creates a builder with no specified trigger character. Unless a trigger is specified usingtrigger(char)ortrigger(int), the mapper will always be active.
-
-
Method Detail
-
trigger
public ConditionalMapper.Builder trigger(char trigger)
Sets a trigger that activates the character mapper.- Parameters:
trigger- the trigger- Returns:
- returns this builder
-
trigger
public ConditionalMapper.Builder trigger(int trigger)
Sets a trigger that activates the character mapper.- Parameters:
trigger- the trigger- Returns:
- returns this builder
-
map
public ConditionalMapper.Builder map(String replace, String with)
Defines that characters found in the
replacestring are to be replaced by the character at the corresponding position in thewithstring.If there is a character in the
replacestring with no character at a corresponding position in thewithstring (becausereplaceis longer thanwith), then that character will be replaced by an empty string.If a character occurs more than once in the
replacestring, then the last occurrence determines the replacement character.If the
withstring is longer than the second argument string, then excess characters are ignored.Calling
map("abc", "ABC")is equal to calling:put('a', "A"); put('b', "B"); put('c', "C");Note however that
put(int, String)andput(char, String)also allow a replacement that contains more than one character, whichmap(String, String)does not.- Parameters:
replace- a list of characters to replacewith- a list of replacement characters- Returns:
- returns this builder
-
put
public ConditionalMapper.Builder put(char key, String value)
Defines a replacement string for the specified character.- Parameters:
key- the charactervalue- the replacement- Returns:
- returns this builder
-
put
public ConditionalMapper.Builder put(int key, String value)
Defines a replacement string for the specified Unicode code point.- Parameters:
key- the code pointvalue- the replacement- Returns:
- returns this builder
-
putIgnorable
public ConditionalMapper.Builder putIgnorable(char value)
Adds a transparent mapping for the specified character. In other words, this character will not be replaced, but will not cause the mapper to deactivate either.- Parameters:
value- the character- Returns:
- returns this builder
-
putIgnorable
public ConditionalMapper.Builder putIgnorable(int value)
Adds a transparent mapping for the specified Unicode code point. In other words, this code point will not be replaced, but will not cause the mapper to deactivate either.- Parameters:
value- the character- Returns:
- returns this builder
-
build
public ConditionalMapper build()
Builds the mapper with the current configuration.- Returns:
- returns a new mapper instance
-
-