info.bliki.wiki.filter
Class Encoder

java.lang.Object
  extended by info.bliki.wiki.filter.Encoder

public class Encoder
extends java.lang.Object

Some helper methods for encoding strings to HTML, URL or local files system names


Constructor Summary
Encoder()
           
 
Method Summary
static java.lang.String encodeDotUrl(java.lang.String s)
          Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal.
static java.lang.String encodeHtml(java.lang.String text)
           
static void encodeHtml(java.lang.String text, java.lang.StringBuilder buffer)
          copy the text in the resulting buffer and escape special html characters (< > " ( " ) & ')
static java.lang.String encodeTitleDotUrl(java.lang.String wikiTitle, boolean firstCharacterAsUpperCase)
           
static java.lang.String encodeTitleLocalUrl(java.lang.String wikiTitle)
          Encode name for local file system
static java.lang.String encodeTitleToUrl(java.lang.String wikiTitle, boolean firstCharacterAsUpperCase)
          Encode the wiki links title into a URL for HTML hyperlinks (i.e.
static java.lang.String encodeUrl(java.lang.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 boolean isWikiPluginIdentifierPart(char ch)
          Determines if the specified character may be part of a wiki plugin identifier as other than the first character
static boolean isWikiPluginIdentifierStart(char ch)
          Determines if the specified character may be part the first character of a wiki plugin identifier
static char toChar(java.lang.String number)
           
static java.lang.String toEntity(int c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Encoder

public Encoder()
Method Detail

toEntity

public static java.lang.String toEntity(int c)

toChar

public static char toChar(java.lang.String number)

encodeUrl

public static java.lang.String encodeUrl(java.lang.String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. This is what happens: See http://www.w3.org/International/URLUTF8Encoder.java ) Exception: a ' ' (space) will be replaced by a '_' (underscore) not '+' (plus); a '#' remain the same.

Parameters:
s - The string to be encoded
Returns:
The encoded string

encodeDotUrl

public static java.lang.String encodeDotUrl(java.lang.String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. This is what happens: 8see http://www.w3.org/International/URLUTF8Encoder.java ) Exception: a ' ' (space) will be replaced by a '_' (underscore) not '+' (plus)

Parameters:
s - The string to be encoded
Returns:
The encoded string

encodeTitleToUrl

public static java.lang.String encodeTitleToUrl(java.lang.String wikiTitle,
                                                boolean firstCharacterAsUpperCase)
Encode the wiki links title into a URL for HTML hyperlinks (i.e. create the href attribute representation for the a tag). To get the behavior of the MediaWiki software, which is configured to convert the first letter to upper case, the firstCharacterAsUpperCase parameters must be set to true.

Parameters:
wikiTitle - the raw wiki title
firstCharacterAsUpperCase - if true convert the first of the title to upper case
Returns:
the encoded wiki title

encodeTitleDotUrl

public static java.lang.String encodeTitleDotUrl(java.lang.String wikiTitle,
                                                 boolean firstCharacterAsUpperCase)

encodeTitleLocalUrl

public static java.lang.String encodeTitleLocalUrl(java.lang.String wikiTitle)
Encode name for local file system


encodeHtml

public static void encodeHtml(java.lang.String text,
                              java.lang.StringBuilder buffer)
copy the text in the resulting buffer and escape special html characters (< > " ( " ) & ')

Parameters:
buffer - add converted text into the resulting buffer

encodeHtml

public static java.lang.String encodeHtml(java.lang.String text)

isUrlIdentifierPart

public static boolean isUrlIdentifierPart(char ch)
Determines if the specified character may be part of a url


isWikiPluginIdentifierPart

public static boolean isWikiPluginIdentifierPart(char ch)
Determines if the specified character may be part of a wiki plugin identifier as other than the first character


isWikiPluginIdentifierStart

public static boolean isWikiPluginIdentifierStart(char ch)
Determines if the specified character may be part the first character of a wiki plugin identifier



Copyright © 2012 Java Wikipedia API (Bliki engine). All Rights Reserved.