|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.ceryle.wiki.plugin.util.PluginTextUtils
public class PluginTextUtils
Some text processing utilities for wiki plugin use.
XMLCharTok
that provide character and String tests for many of the XML productions such as
Names, Name characters, whitespace, etc. Because the intention is here for
plugin support, the methods isLetter(char) and isDigit(char)
simply use the existing Java-based tests, which are similar but not necessarily
XML compatible. This simplifies the methods considerably. In later versions of
this plugin, all earlier dependencies on org.ceryle.xml.XML and
org.ceryle.xml.XHTML have been removed.
| Field Summary | |
|---|---|
static int |
OUTPUT_BAR
An int constant (indicated by "bar") directing that output should be formatted as a vertical bar-delimited list. |
static int |
OUTPUT_BULLET
An int constant (indicated by "bullet") directing that output should be formatted as a bulleted list. |
static int |
OUTPUT_COLON
An int constant (indicated by "colon") directing that output should be formatted as a colon-delimited list. |
static int |
OUTPUT_COMMA
An int constant (indicated by "comma") directing that output should be formatted as a comma-delimited list. |
static int |
OUTPUT_COUNT
An int constant (indicated by "count") directing that output should only contain the list size (page count). |
static int |
OUTPUT_LIST
An int constant (indicated by "list") directing that output should be formatted as a simple vertical list. |
static int |
OUTPUT_NONE
An int constant (indicated by "none") directing that output should be suppressed (no list output). |
static int |
OUTPUT_NUMBER
An int constant (indicated by "number") directing that output should be formatted as a numbered list. |
static String[] |
OUTPUT_PARAMS
A String array containing the output format parameter names. |
static int |
OUTPUT_SPACE
An int constant (indicated by "space") directing that output should be formatted as a space-delimited list. |
static int |
OUTPUT_TABLE
An int constant (indicated by "table") directing that output should be formatted as a table. |
| Constructor Summary | |
|---|---|
PluginTextUtils()
|
|
| Method Summary | |
|---|---|
static String |
beautifyTitle(WikiPage page,
WikiContext context)
|
static int |
convertOutputFormat(String format)
Returns an int value for the output format, based on a string match of the parameter format. |
static String |
entify(String s,
boolean asNumeric)
Return a string with markup-sensitive characters (LT,GT,AMP,APOS and QUOT) expressed as either numeric or named character entities, depending on the boolean asNumeric. |
static String |
extractSectionData(int sectionNumber,
String pageData,
String sectionDivider)
Returns a section of wiki text from pageData. |
static String |
formatOutput(WikiEngine engine,
Collection content,
int format,
boolean addLinks)
Format the Iterator containing plugin results (expected as a list of page names, otherwise the Object's toString() is called) into XHTML output suitable for display on the page. |
static Locale |
getLocale(WikiContext context)
Returns the locale of the HTTP request if available, otherwise returns the default Locale of the server. |
static boolean |
isDigit(char c)
Returns true if char c is a digit, using the Java method Character.isDigit(char). |
static boolean |
isLetter(char c)
Returns true if char c is an alphabet characer, using the Java method Character.isDigit(char). |
static boolean |
isName(String s)
Returns true if String s conforms to Name [XML 1.1 production 5]. |
static boolean |
isNameChar(char c)
Returns true if char c is a member of NameChar [XML 1.1 production 4a]. |
static boolean |
isNameStartChar(char c)
Returns true if char c is an allowed first character of an XML 1.1 Name [XML 1.1 production 4]. |
static boolean |
isSpace(char c)
Returns true if char c is a member of S (space) [XML 1.1 production 3]. |
static boolean |
isSpace(String s)
Returns true if the String s is completely composed of whitespace. |
static boolean |
isURL(String s)
Returns true if the supplied String s can be made into URL. |
static void |
outputMap(StringBuffer out,
Map map)
Print the Map as a key="value" list to the provided StringBuffer. |
static String |
stripBrackets(String s)
If the String s both starts and ends with square brackets, this strips them, otherwise returns the String unmodified. |
static String |
stripShebang(String s)
Strips the wiki 'she-bang' from the beginning of a String. |
static String |
wordWrap(String text,
int length)
Word wraps the textual content at the provided line length. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int OUTPUT_NONE
public static final int OUTPUT_COUNT
public static final int OUTPUT_LIST
public static final int OUTPUT_BULLET
public static final int OUTPUT_NUMBER
public static final int OUTPUT_SPACE
public static final int OUTPUT_COMMA
public static final int OUTPUT_COLON
public static final int OUTPUT_BAR
public static final int OUTPUT_TABLE
public static final String[] OUTPUT_PARAMS
| Constructor Detail |
|---|
public PluginTextUtils()
| Method Detail |
|---|
public static Locale getLocale(WikiContext context)
public static String beautifyTitle(WikiPage page,
WikiContext context)
public static String stripBrackets(String s)
public static String extractSectionData(int sectionNumber,
String pageData,
String sectionDivider)
sectionNumber - Must be greater than or equal to 1.pageData - must not be nullsectionDivider - The delimiter of sections in the pageData.
public static String wordWrap(String text,
int length)
public static final String entify(String s,
boolean asNumeric)
Note that use of numeric entities allows for more "entification" than simply XML's five built-in entities. While not currently supported, use of numeric entities may in the future mean support for characters not included in the current encoding.
If the provided String is either null or empty, an empty String is returned.
public static String stripShebang(String s)
public static void outputMap(StringBuffer out,
Map map)
public static int convertOutputFormat(String format)
OUTPUT_LIST.
public static String formatOutput(WikiEngine engine,
Collection content,
int format,
boolean addLinks)
OUTPUT_NONE OUTPUT_COUNT OUTPUT_LIST OUTPUT_BULLET OUTPUT_NUMBER OUTPUT_SPACE OUTPUT_COMMA OUTPUT_COLON OUTPUT_BAR OUTPUT_TABLE
engine - The WikiEngine used.content - A Collection containing the output contents to be formatted.format - The int constant indicating the output format.addLinks - If true and the Collection contains Strings, the list items
will be treated as Wiki page names and link markup will be
added accordingly. If false or the Collection contains other
Object types, only the content necessary to fulfill the needs
of the format will be added.
public static boolean isName(String s)
public static boolean isNameStartChar(char c)
public static boolean isNameChar(char c)
public static boolean isLetter(char c)
Character.isDigit(char).
public static boolean isDigit(char c)
Character.isDigit(char).
public static boolean isSpace(String s)
public static boolean isSpace(char c)
public static final boolean isURL(String s)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||