de.tuberlin.cs.flp.jspwiki.util


Class WikiToolbox


public class WikiToolbox
Namespace: util
Has stereotypes: << utility >>


Collection of tool functions used by package de.tuberlin.cs.flp.jspwiki.*.
Authors:
Jens Gulden


Method Summary
public static String   capitalize(String s)
Sets the first charcater in s to upper case.  
public static int[]  determineImageSize(InputStream in)
 
public static String   escape(String s, char c)
Escapes all occurrences of c in s by a backslash.  
public static Attachment  findImageAttachment(WikiEngine engine, String pagename)
Returns first image-attachment, or null if no attachment is an image or no attachments at all exist.  
public static Attachment  findImageAttachment(WikiEngine engine, String pagename, Collection attachments)
Returns first image-attachment, or null if no attachment is an image or no attachments at all exist.  
public static String   format(Map m, String f)
Entries starting with % will be replaced by values in map.  
public static String   getProperty(WikiEngine engine, String propertyName, String defaultPagename)
 
public static boolean  isImage(WikiEngine engine, String name)
 
public static String   keyByValue(Properties p, String v)
Gets the key of a property entry by the given value.  
public static String   makePagename(WikiEngine engine, String s)
Creates a valid wiki page name from s. I.e., blanks are removes and the string is converted to CamelCase. ### Is there any corresponding function available in JSPWiki?  
public static String   normalizeLF(String s)
Makes sure only '\n' is used as linebreak, not '\r\n'.  
public static String   normalizeName(String name)
Makes sure that an entry's name can be used as a filename.  
public static boolean  parseBoolean(String s)
 
public static boolean  parseBoolean(String s, boolean deflt)
 
public static Collection   parseList(String s)
Parses a comma-seperated list of strings.  
public static Collection   parseMultiParameter(HttpServletRequest request, String name)
 
public static Properties   parseProperties(String s, String entryDelim)
 
public static Collection   parseWikiLinks(String pagedata)
Parses Wiki-markup and returns a collection of all links included in the page. The links are capitalized (first letter upper case), in order to be usable as page-names, which seem to be all uppercase in JSPWiki. (I.e., all strings that are enclosed by "[]".)  
public static Collection   parseWikiLinks(WikiEngine engine, String pagename)
Returns all Wiki-link targets included in a page. These are all pages referenced by the specified page.  
public static byte[]  readInputStream(InputStream in)
 
public static String   repeat(int cnt, char c)
Creates a string in which c is repeated cnt times.  
public static String   replace(String s, String search, String repl)
 
public static Collection   split(String s, char c)
Splits a string at the specified character occurrences.  
public static Collection   split(String s, String delim)
Splits a string at the specified substring occurrences.  
public static Collection   split(String s)
Split at commas (',').  
public static List   splitCamelCase(String s)
 
public static Collection   splitLines(String s)
Split at line-feed ('\n').  
public static Map   subMap(Map map, String prefix)
 
public static String   toCamelCase(String s)
 

Tagged Values
static false
documentation#author Jens Gulden

Method Detail

capitalize

public static String capitalize(String s)


Sets the first charcater in s to upper case.
Parameters:
s - The string to be capitalized.
Returns:
Capitalized string.


determineImageSize

public static int[] determineImageSize(InputStream in)

Parameters:
in -
Returns:


escape

public static String escape(String s, char c)


Escapes all occurrences of c in s by a backslash.
Parameters:
s - The string to be escaped.
c - The character to be escaped.
Returns:
The escaped string.


findImageAttachment

public static Attachment findImageAttachment(WikiEngine engine, String pagename)


Returns first image-attachment, or null if no attachment is an image or no attachments at all exist.
Parameters:
engine -
pagename -
Returns:


findImageAttachment

public static Attachment findImageAttachment(WikiEngine engine, String pagename, Collection attachments)


Returns first image-attachment, or null if no attachment is an image or no attachments at all exist.
Parameters:
engine -
pagename -
attachments -
Returns:


format

public static String format(Map m, String f)


Entries starting with % will be replaced by values in map.
Parameters:
m - The map.
f - Template string including %xxx-substrings that will be replaced by map values.
Returns:
String with %xxx-substrings resolved.


getProperty

public static String getProperty(WikiEngine engine, String propertyName, String defaultPagename)

Parameters:
engine -
propertyName -
defaultPagename -
Returns:


isImage

public static boolean isImage(WikiEngine engine, String name)

Parameters:
engine -
name -
Returns:


keyByValue

public static String keyByValue(Properties p, String v)


Gets the key of a property entry by the given value.
Parameters:
p - The properties.
v - The value string.
Returns:
The key, or null if the value was not found.


makePagename

public static String makePagename(WikiEngine engine, String s)


Creates a valid wiki page name from s. I.e., blanks are removes and the string is converted to CamelCase. ### Is there any corresponding function available in JSPWiki?
Parameters:
engine -
s -
Returns:


normalizeLF

public static String normalizeLF(String s)


Makes sure only '\n' is used as linebreak, not '\r\n'.
Parameters:
s -
Returns:


normalizeName

public static String normalizeName(String name)


Makes sure that an entry's name can be used as a filename.
Parameters:
name - The entry name.
Returns:
A normalized representation of the name.


parseBoolean

public static boolean parseBoolean(String s)

Parameters:
s -
Returns:


parseBoolean

public static boolean parseBoolean(String s, boolean deflt)

Parameters:
s -
deflt -
Returns:


parseList

public static Collection parseList(String s)


Parses a comma-seperated list of strings.
Parameters:
s - comma-seperated list of string
Returns:
Collection with individual strings, each one trimmed.


parseMultiParameter

public static Collection parseMultiParameter(HttpServletRequest request, String name)

Parameters:
request -
name -
Returns:


parseProperties

public static Properties parseProperties(String s, String entryDelim)

Parameters:
s -
entryDelim -
Returns:


parseWikiLinks

public static Collection parseWikiLinks(String pagedata)


Parses Wiki-markup and returns a collection of all links included in the page. The links are capitalized (first letter upper case), in order to be usable as page-names, which seem to be all uppercase in JSPWiki. (I.e., all strings that are enclosed by "[]".)
Parameters:
pagedata - The page text.
Returns:
The names of all pages referenced by the Wiki-links in the page text.


parseWikiLinks

public static Collection parseWikiLinks(WikiEngine engine, String pagename)


Returns all Wiki-link targets included in a page. These are all pages referenced by the specified page.
Parameters:
engine - The WikiEngine
pagename - name of the page to retrieve links from.
Returns:
all links contained in the page


readInputStream

public static byte[] readInputStream(InputStream in)

Parameters:
in -
Returns:


repeat

public static String repeat(int cnt, char c)


Creates a string in which c is repeated cnt times.
Parameters:
cnt - Number of repetitions.
c - The characater to be repeated.
Returns:
The string conatining the repeated character.


replace

public static String replace(String s, String search, String repl)

Parameters:
s -
search -
repl -
Returns:


split

public static Collection split(String s, char c)


Splits a string at the specified character occurrences.
Parameters:
s - The string to be split.
c - The character at the occurrences of which the splitting is performed.
Returns:
Collection of all substrings between the occurrences of c. Contains a single element (whole s) if c is not contained in s.


split

public static Collection split(String s, String delim)


Splits a string at the specified substring occurrences.
Parameters:
s - The string to be split.
delim - The substring at the occurrences of which the splitting is performed.
Returns:
Collection of all substrings between the occurrences of c. Contains a single element (whole s) if c is not contained in s.


split

public static Collection split(String s)


Split at commas (',').
Parameters:
s -
Returns:


splitCamelCase

public static List splitCamelCase(String s)

Parameters:
s -
Returns:


splitLines

public static Collection splitLines(String s)


Split at line-feed ('\n').
Parameters:
s -
Returns:


subMap

public static Map subMap(Map map, String prefix)

Parameters:
map -
prefix -
Returns:


toCamelCase

public static String toCamelCase(String s)

Parameters:
s -
Returns:

previous   TOC   next

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in the USA and other countries. Copyright 2003-2006 Gentleware AG, Ludwigstr. 12, 20357 Hamburg, Germany. All Rights Reserved.
UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.