jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: String taglib proposal
Date Thu, 12 Jul 2001 18:10:29 GMT
Hi Bay

Those look great so far. This library looks a good place for other text
based escape tags too - like escaping HTML, XML, URLs and so on.

James

----- Original Message -----
From: <bayard@generationjava.com>
To: <taglibs-dev@jakarta.apache.org>
Sent: Thursday, July 12, 2001 5:14 PM
Subject: Re: String taglib proposal


>
> Great to get a positive response :)
>
> I agree that the <string:capitalise..> syntax is nicer. I will make a move
> towards that.
> After a quick peek at scrape and regexp, I don't think I impinge too
> heavily on them. Maybe one or two functions that would be better served
> in their libraries.
>
> Following James' advice I will list the tags I currently have implemented.
> The only difference being that I will get rid of the action attribute and
> create a more explicit tld.
>
> Here goes:
>
>   <string action="upperCase">xx</string>
>   - Turns body into uppercase
>
>   <string action="lowerCase">XX</string>
>   - Lowercases all letters in the body
>
>   <string action="trim">  XX  </string>
>   - Removes whitespace from the start and end of the body
>
>   <string action="substring" start="1" end="4">XX</string>
>   - Get a substring from the body.
>
>   <string action="capitalise">XX</string>
>   - Titlecase the first character of the body.
>
>   <string action="overlay" with="newtext" start="2" end="4">XX</string>
>   - Replace a part of the body with another string.
>
>   <string action="repeat" count="5">XX</string>
>   - Repeat the body - 5 times.
>
>   <string action="center" width="20" delimiter=" ">XX</string>
>   - Center the body in a string of width 20, using spaces as a delimiter
>
>   <string action="chomp" delimiter="\n">XX</string>
>   - Remove the last newline, and everything after it from the body
>
>   <string action="getChomp" delimiter="\n">XX</string>
>   - Get everything after the last newline in the body
>
>   <string action="prechomp" delimiter="\n">XX</string>
>   - Remove the first newline, and everything before it in the body
>
>   <string action="getPrechomp" delimiter="\n">XX</string>
>   - Get everything before the first newline in the body
>
>   <string action="chop">XX</string>
>   - Remove the last character from the body. Will remove a \r if it's
>     before a \n. Not sure if this is needed in Java however.
>
>   <string action="chopNewline">XX</string>
>   - Remove last character if it's a newline.
>
>   <string action="count" set="abc">XX</string>
>   - Count the occurences of any letters in the set.
>     So Abracadabra would return 7. Case sensitive.
>
>   <string action="delete" set="abc">XX</string>
>   - Delete any occurences of letters passed in the set.
>     So Abracadabra => Ardr.  Case sensitive.
>
>   <string action="squeeze" set="abc">XX</string>
>   - Remove any multiple instances of characters in the passed in set.
>     So Abracadabra is unchanged. However, abbr would become abr.
>     Case sensitive.
>
>   <string action="escape">XX</string>
>   - Java escape the string. So tabs goto \t etc.
>
>   <string action="rightPad" width="20" delimiter=" ">XX</string>
>   - Right pad to a width of 20 with spaces.
>
>   <string action="leftPad" width="20" delimiter=" ">XX</string>
>   - Left pad to a width of 20 with spaces.
>
>   <string action="reverse">XX</string>
>   - Reverse the body.
>
>   <string action="strip" delimiter=" ">XX</string>
>   - Strip the body of spaces on both sides. Equivalent to trim,
>     but delimiter is settable.
>
>   <string action="swapCase">XX</string>
>   - Swap the case of all characters in the body.
>
>   <string action="translate" replace="aieou" with="AIEOU">XX</string>
>   - Translate any instances of characters in 'replace' with the
>     corresponding character in 'with'.
>
>   <string action="stripEnd" delimiter=" ">XX</string>
>   - Strip spaces from the end of the body.
>
>   <string action="stripStart" delimiter=" ">XX</string>
>   - Strip spaces from the start of the body.
>
>   <string action="soundex">XX</string>
>   - Return the soundex.
>
>   <string action="metaphone">XX</string>
>   - Return the metaphone.
>
>   <string action="quoteRegexp">XX</string>
>   - Quote any regexp characters. So:  ? -> \?
>
>   <string action="capitaliseAllWords">XX</string>
>   - Titlecase any characters in the body that are preceded by
>     a whitespace or the start of the body.
>
>   <string action="wordWrap" width="80" delimiter="\n"
split="-">XX</string>
>   - Word-wrap the body to a width of 80. Using a delimiter of \n and
>     using a - to split words if need be.
>
>   <string action="nestedString" open="pre" close="post">XX</string>
>   - Get the string that is nested in between 'pre' and 'post'.
>     ie) In a body of:  Someprethingpost.   The above tag would
>     evaluate to 'thing'.
>
>   <string action="countMatches" substring="he">XX</string>
>   - How many times is the substring 'he' mentioned in the body.
>
>   <string action="default" value="null" default="n/a">XX</string>
>   - If the body is the string null, then print n/a.
>
>   <string action="removeXml">XX</string>
>   - Remove any <..> tags from the body.
>
>   <string action="replace" count="5" replace="hen" with="hou">XX</string>
>   - Replace the first 5 instances of hen with hou.
>
> //  <string action="escapeXml">XX</string>
>   - todo. just not around to coding.
> //  <string action="implode" property="name-of-list" delimiter=",
">XX</string>
>   - todo. unsure how to pass in an iterator, list, etc. Not sure if it
>     really fits in a taglib.
>
>
> As for uploading the code, I can stick a jar on my website whenever people
> think is best. Currently I think I should probably move from using action
> before putting anything up.
>
> Thanks,
>
> Bay
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Mime
View raw message