Last change
on this file since 77 was
77,
checked in by psniegowski, 11 years ago
|
Add new java codebase.
|
File size:
965 bytes
|
Line | |
---|
1 | package com.framsticks.util; |
---|
2 | |
---|
3 | /** |
---|
4 | * @author Piotr Sniegowski |
---|
5 | */ |
---|
6 | public abstract class Strings { |
---|
7 | public static String valueOf(Object o) { |
---|
8 | if (o == null) { |
---|
9 | return null; |
---|
10 | } |
---|
11 | return o.toString(); |
---|
12 | } |
---|
13 | |
---|
14 | public static boolean notEmpty(String str) { |
---|
15 | return str != null && !str.equals(""); |
---|
16 | } |
---|
17 | |
---|
18 | public static String toStringNullProof(Object object) { |
---|
19 | if (object == null) { |
---|
20 | return ""; |
---|
21 | } |
---|
22 | return object.toString(); |
---|
23 | } |
---|
24 | |
---|
25 | public static String collapse(String s) { |
---|
26 | if (s == null) { |
---|
27 | return null; |
---|
28 | } |
---|
29 | s = s.trim(); |
---|
30 | return (s.equals("")) ? null : s; |
---|
31 | } |
---|
32 | |
---|
33 | public static Pair<String, String> splitIntoPair(String string, char separator, String second) { |
---|
34 | int pos = string.indexOf(separator); |
---|
35 | if (pos == -1) { |
---|
36 | return new Pair<String, String>(string.substring(0, string.length() - 1), second); |
---|
37 | } else { |
---|
38 | return new Pair<String, String>(string.substring(0, pos), string.substring(pos + 1)); |
---|
39 | } |
---|
40 | } |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.