Slug.Builder
Modifier and Type | Field and Description |
---|---|
private static Pattern |
ALPHA_NUMERIC
Matches alpha numeric characters.
|
private CharacterMappper |
characterMapper
Maps general characters.
|
private static String |
MARK
Punctuation characters.
|
private Options |
options
Holds the slugger options.
|
private static Pattern |
TITLE
Matches each word for titles.
|
private static String |
URIC_SLASH
URI characters with slash.
|
private static String |
URIC_WITHOUT_SLASH
URI characters without slash.
|
private Validator |
validator
Validates input.
|
Constructor and Description |
---|
SlugImplementation()
Creates slugger with default options.
|
SlugImplementation(Options options)
Dedicated constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) String |
cleanupReplacements(String input,
String separator)
Cleans the resulting slug from duplicate separators and such.
|
(package private) String |
currentCharacter(String input,
int position)
Returns character at a given position from a string.
|
(package private) String |
generateAllowedCharatcers(String separator)
Generates a string containing all allowed characters.
|
String |
get(String input)
Generates a slug from given input string.
|
String |
get(String rawInput,
String separator)
Generates a slug from given input string with custom separator.
|
Map<String,String> |
getCustom()
Get the custom mapping option.
|
Language |
lang()
Get the language option.
|
boolean |
maintainCase()
Get the maintain case option.
|
boolean |
mark()
Get the mark option.
|
private String |
processByCharacters(String input,
String separator,
String allowedChars)
Processes each character of the input string.
|
(package private) String |
replaceCharacters(String ch,
boolean lastCharWasSymbol)
Replace characters.
|
(package private) String |
replaceDuplicateSeparators(String input,
String separator)
Removes duplicate separators.
|
(package private) String |
replaceLanguageCharacters(boolean lastCharWasSymbol,
String ch)
Replace language depending characters.
|
(package private) String |
replaceLeadingAndTrailingSeparator(String input,
String separator)
Removes leading and trailing separators.
|
(package private) String |
replaceNotAllowedCharacters(String ch,
String allowedChars,
String separator)
Replace all not allowed characters.
|
(package private) String |
replaceSymbols(String ch,
boolean lastCharWasSymbol,
String result,
String separator,
String input,
int currentPos)
Replace symbol characters.
|
(package private) String |
replaceWhitespaces(String input,
String separator)
Replace all whitespaces with separators.
|
String |
separator()
Get the separator option.
|
boolean |
titleCase()
Get the title case option.
|
Set<String> |
titleCaseExclude()
Get the title case excludes option.
|
(package private) String |
transformCase(String input,
Map<String,String> exclusiions)
Make each word which starts with alphanumeric character to upper case,
except them in the replacement mapCharacter.
|
int |
truncate()
Get the truncate length option.
|
(package private) String |
ucfirst(String input)
Makes the first character upper case.
|
boolean |
uric()
Get the URI characters option.
|
boolean |
uricNoSlash()
Get the URI characters without slash option.
|
private static final String URIC_WITHOUT_SLASH
private static final String URIC_SLASH
private static final String MARK
private static final Pattern ALPHA_NUMERIC
private static final Pattern TITLE
private final Validator validator
private final CharacterMappper characterMapper
private final Options options
SlugImplementation()
SlugImplementation(Options options)
options
- must not be null
public String separator()
Slug
public boolean maintainCase()
Slug
maintainCase
in interface Slug
public boolean titleCase()
Slug
public Set<String> titleCaseExclude()
Slug
titleCaseExclude
in interface Slug
null
public int truncate()
Slug
public boolean uric()
Slug
public boolean uricNoSlash()
Slug
uricNoSlash
in interface Slug
public boolean mark()
Slug
public Map<String,String> getCustom()
Slug
public String get(String input)
Slug
public String get(String rawInput, String separator)
Slug
This method overwrites the separator configured by Slug.Builder.separator(java.lang.String)
.
private String processByCharacters(String input, String separator, String allowedChars)
input
- must not be null
separator
- must not be null
or emptyallowedChars
- must not be null
null
String generateAllowedCharatcers(String separator)
separator
- must not be null
or emptynull
String currentCharacter(String input, int position)
input
- string to get character fromposition
- the obtained positionnull
String replaceSymbols(String ch, boolean lastCharWasSymbol, String result, String separator, String input, int currentPos)
ch
- the current character to replacelastCharWasSymbol
- whether the last character was a symbolresult
- the current resultseparator
- must not be null
or emptyinput
- the preprocessed input stringcurrentPos
- the current position in the input stringnull
String replaceCharacters(String ch, boolean lastCharWasSymbol)
ch
- the current character to replacelastCharWasSymbol
- whether the last character was a symbolnull
String replaceLanguageCharacters(boolean lastCharWasSymbol, String ch)
lastCharWasSymbol
- whether the last character was a symbolch
- the current character to replacenull
String replaceNotAllowedCharacters(String ch, String allowedChars, String separator)
ch
- the current character to replaceallowedChars
- string containing all allowed charactersseparator
- must not be null
or emptynull
String cleanupReplacements(String input, String separator)
input
- will be cleanedseparator
- must not be null
or emptynull
String replaceWhitespaces(String input, String separator)
input
- will be processedseparator
- must not be null
or emptynull
String replaceDuplicateSeparators(String input, String separator)
input
- will be processedseparator
- must not be null
or emptynull
String replaceLeadingAndTrailingSeparator(String input, String separator)
input
- will be processedseparator
- must not be null
or emptynull
String transformCase(String input, Map<String,String> exclusiions)
input
- may be null
or emptyexclusiions
- mapCharacter with key and value samenull
, may be emptyCopyright © 2012 Sven Strittmatter. All Rights Reserved.