public class Encoder extends Object
| Constructor and Description |
|---|
Encoder() |
| Modifier and Type | Method and Description |
|---|---|
static String |
encodeDotUrl(String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced with the
UTF-8-in-URL proposal.
|
static String |
encodeHtml(String text) |
static void |
encodeHtml(String text,
StringBuilder buffer)
copy the text in the resulting buffer and escape special html characters
(< > " ( " ) & ')
|
static String |
encodeTitleDotUrl(String wikiTitle,
boolean firstCharacterAsUpperCase) |
static String |
encodeTitleLocalUrl(String title)
Encode name for local file system
|
static String |
encodeTitleToUrl(String wikiTitle,
boolean firstCharacterAsUpperCase)
Encode the wiki links title into a URL for HTML hyperlinks (i.e.
|
static String |
encodeUrl(String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced with the
UTF-8-in-URL proposal.
|
static boolean |
isUrlIdentifierPart(char ch)
Determines if the specified character may be part of a url
|
static String |
normaliseTitle(String value,
boolean underScoreIsWhitespace,
char whiteSpaceChar,
boolean firstCharacterAsUpperCase)
Normalises the given title, i.e.
|
static String |
normaliseTitle(String value,
boolean underScoreIsWhitespace,
char whiteSpaceChar,
boolean firstCharacterAsUpperCase,
boolean encodeUrl)
Normalises the given title, i.e.
|
public static String encodeUrl(String s)
The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.
The unreserved characters - _ . ! ~ * ' ( ) / remain the same.
The '#' character remains the same.
The space character ' ' is converted into a underscore sign '_' (not a plus sign '+'!).
All other ASCII characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the character code
All non-ASCII characters are encoded in two steps: first to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; secondly each of these bytes is encoded as ".xx".
s - The string to be encodedpublic static String encodeDotUrl(String s)
The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.
The unreserved characters - _ . ! ~ * ' ( ) / remain the same.
The space character ' ' is converted into a underscore sign '_' (not a plus sign '+').
All other ASCII characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the character code
All non-ASCII characters are encoded in two steps: first to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; secondly each of these bytes is encoded as ".xx".
s - The string to be encodedpublic static String encodeTitleToUrl(String wikiTitle, boolean firstCharacterAsUpperCase)
firstCharacterAsUpperCase
parameters must be set to true.wikiTitle - the raw wiki titlefirstCharacterAsUpperCase - if true convert the first of the title to upper casepublic static String encodeTitleDotUrl(String wikiTitle, boolean firstCharacterAsUpperCase)
public static String encodeTitleLocalUrl(String title)
public static String normaliseTitle(String value, boolean underScoreIsWhitespace, char whiteSpaceChar, boolean firstCharacterAsUpperCase)
value - the stringunderScoreIsWhitespace - whether '_' should be seen as whitespace or notwhiteSpaceChar - the character to replace whitespace withfirstCharacterAsUpperCase - if true convert the first of the title to upper casepublic static String normaliseTitle(String value, boolean underScoreIsWhitespace, char whiteSpaceChar, boolean firstCharacterAsUpperCase, boolean encodeUrl)
encodeUrl(StringBuilder, int) after all
the previous replacements!value - the stringunderScoreIsWhitespace - whether '_' should be seen as whitespace or notwhiteSpaceChar - the character to replace whitespace withfirstCharacterAsUpperCase - if true convert the first of the title to upper
caseencodeUrl - finally mangles each character through
encodeUrl(StringBuilder, int)public static void encodeHtml(String text, StringBuilder buffer)
buffer - add converted text into the resulting bufferpublic static boolean isUrlIdentifierPart(char ch)
Copyright © 2017 Java Wikipedia API (Bliki engine). All rights reserved.