Definition at line 16 of file StringUtil.java.
Static Public Member Functions | |
| final RE | newRE (String s) |
| final String | replicate (int replications, String s) |
| final String | stripNonAlphabetics (String v) |
| final String | stripNonDigits (Object vv) |
| final String | join (char delimiter, List args) |
| final String | join (char delimiter, Object[] strings) |
| final String | alignLeft (int width, String s) |
| final String[] | split (char delimiter, String string) |
| String | toJavaString (int m, String s) |
| String | replace (Object pattern, Object replacement, Object source) |
| final String | asButton (String op, Object value) |
| final String | asField (String op, Object value, int width) |
| final String | className (Class c) |
| final String | toString (Object o, Validatable[] args) |
Static Package Attributes | |
| final Logger | logger = Logger.getLogger(StringUtil.class.getName()) |
|
||||||||||||
|
Compose a submit button with the specified op and value
Definition at line 202 of file StringUtil.java.
00203 {
00204 return "<input name=\""+op+"\" value=\""+value+ "\" type=\"submit\">";
00205 }
|
|
||||||||||||||||
|
Compose an <input> field with the specified op, width, and value
Definition at line 214 of file StringUtil.java.
00215 {
00216 return "<input name=\""+op+"\" value=\""+value+ "\" size=\""+width+"\">";
00217 }
|
|
||||||||||||
|
Join the strings with the provided delimiter string Definition at line 79 of file StringUtil.java.
00080 {
00081 return join(delimiter, args.toArray());
00082 }
|
|
|
Convenience method to help subclasses build regular expressions as class initializers without screwing around with REexception. in class initializers. This class catches all REexceptions, logs them, and contiues returning null. Caveat emptor.
Definition at line 27 of file StringUtil.java.
00028 {
00029 try { return new RE(s); }
00030 catch (REException e)
00031 {
00032 logger.error("REException in\n"+" \""+s+"\"\n", e);
00033 return null;
00034 }
00035 }
|
|
||||||||||||||||
|
Replace the first occurrence of the RE pattern in source string.
Definition at line 179 of file StringUtil.java.
00180 {
00181 try
00182 {
00183 RE re = new RE(pattern.toString());
00184 return re.substitute(source.toString(), replacement.toString());
00185 }
00186 catch (Exception e)
00187 {
00188 logger.error("StringUtil.replace: Invalid RE\n"+
00189 " pattern:"+pattern+"\n"+
00190 " replacement:"+replacement+"\n"+
00191 " source:"+source, e);
00192 return source.toString();
00193 }
00194 }
|
|
|
Converts a name to the base of an interfier by stripping everything but alphabetics and truncating long ids to a maximum length of 32 chars.
Definition at line 50 of file StringUtil.java.
00051 {
00052 if (v == null) return null;
00053 StringBuffer buffer = new StringBuffer(v.length());
00054 for (int i = 0; i < v.length(); i++)
00055 {
00056 char c = v.charAt(i);
00057 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
00058 buffer.append(c);
00059 }
00060 return buffer.toString();
00061 }
|
|
||||||||||||
|
Wrap the input to m bytes/line and return the result as a concatenated Java string initializer.
Definition at line 155 of file StringUtil.java.
00156 {
00157 if (s == null) s = "";
00158 int l = s.length();
00159 StringBuffer b = new StringBuffer(s.length() + 2*(l/m)+1);
00160 for (int i = 0; i < l; i += m)
00161 {
00162 int j = i+m;
00163 if (j > l) j = l;
00164 b.append("\"" + s.substring(i, j) + "\"+\n");
00165 }
00166 return b + "\"\"";
00167 }
|