source: java/main/src/main/java/com/framsticks/util/lang/Strings.java @ 97

Last change on this file since 97 was 97, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • add proper exception passing between communication sides:

if exception occur during handling client request, it is
automatically passed as comment to error response.

it may be used to snoop communication between peers

  • fix algorithm choosing text controls in GUI
  • allow GUI testing in virtual frame buffer (xvfb)

FEST had some problem with xvfb but workaround was found

supports tab-completion based on requests history

CHANGELOG:
Further improve handling of exceptions in GUI.

Add StatusBar? implementing ExceptionResultHandler?.

Make completion processing asynchronous.

Minor changes.

Improve completion in console.

Improve history in InteractiveConsole?.

First working version of DirectConsole?.

Minor changes.

Make Connection.address non final.

It is more suitable to use in configuration.

Improvement of consoles.

Improve PopupMenu? and closing of FrameJoinable?.

Fix BrowserTest?.

Found bug with FEST running under xvfb.

JButtonFixture.click() is not working under xvfb.
GuiTest? has wrapper which uses JButton.doClick() directly.

Store CompositeParam? param in TreeNode?.

Simplify ClientSideManagedConnection? connecting.

There is now connectedFunctor needed, ApplicationRequests? can be
send right after creation. They are buffered until the version
and features are negotiated.

Narow down interface of ClientSideManagedConnection?.

Allow that connection specialization send only
ApplicationRequests?.

Improve policy of text control choosing.

Change name of Genotype in BrowserTest?.

Make BrowserTest? change name of Genotype.

Minor change.

First working draft of TrackConsole?.

Simplify Consoles.

More improvements with gui joinables.

Unify initialization on gui joinables.

More rework of Frame based entities.

Refactorize structure of JFrames based entities.

Extract GuiTest? from BrowserBaseTest?.

Reorganize Console classes structure.

Add Collection view to JoinableCollection?.

Configure timeout in testing.

Minor changes.

Rework connections hierarchy.

Add Mode to the get operation.

Make get and set in Tree take PrimitiveParam?.

Unify naming of operations.

Make RunAt? use the given ExceptionHandler?.

It wraps the virtual runAt() method call with
try-catch passing exception to handler.

Force RunAt? to include ExceptionHandler?.

Improve ClientAtServer?.

Minor change.

Another sweep with FindBugs?.

Rename Instance to Tree.

Minor changes.

Minor changes.

Further clarify semantics of Futures.

Add FutureHandler?.

FutureHandler? is refinement of Future, that proxifies
exception handling to ExceptionResultHandler? given
at construction time.

Remove StateFunctor? (use Future<Void> instead).

Make Connection use Future<Void>.

Unparametrize *ResponseFuture?.

Remove StateCallback? not needed anymore.

Distinguish between sides of ResponseFuture?.

Base ResponseCallback? on Future (now ResponseFuture?).

Make asynchronous store taking Future for flags.

Implement storeValue in ObjectInstance?.

File size: 1.6 KB
Line 
1package com.framsticks.util.lang;
2
3import com.framsticks.util.FramsticksException;
4
5/**
6 * @author Piotr Sniegowski
7 */
8public abstract class Strings {
9
10        public static String valueOf(Object o) {
11                if (o == null) {
12                        return null;
13                }
14                return o.toString();
15        }
16
17        public static boolean notEmpty(String str) {
18                return str != null && !str.equals("");
19        }
20
21        public static void assureNotEmpty(String str) {
22                if (!notEmpty(str)) {
23                        throw new FramsticksException().msg("string is empty");
24                }
25        }
26
27        public static String toStringNullProof(Object object) {
28                return toStringNullProof(object, "");
29        }
30
31        public static String toStringNullProof(Object object, String def) {
32                if (object == null) {
33                        return def;
34                }
35                return object.toString();
36        }
37
38        public static String collapse(String s) {
39                if (s == null) {
40                        return null;
41                }
42                s = s.trim();
43                return (s.equals("")) ? null : s;
44        }
45
46        public static Pair<String, String> splitIntoPair(String string, char separator, String second) {
47                int pos = string.indexOf(separator);
48                if (pos == -1) {
49                        return new Pair<String, String>(string, second);
50                } else {
51                        return new Pair<String, String>(string.substring(0, pos), string.substring(pos + 1));
52                }
53        }
54
55        public static String capitalize(String input) {
56                return input.substring(0, 1).toUpperCase() + input.substring(1);
57        }
58
59        public static String uncapitalize(String input) {
60                return input.substring(0, 1).toLowerCase() + input.substring(1);
61        }
62
63        public static String commonPrefix(String a, String b) {
64                int length = Math.min(a.length(), b.length());
65                int i = 0;
66                while ((i < length) && (a.charAt(i) == b.charAt(i))) {
67                        ++i;
68                }
69                return a.substring(0, i);
70        }
71
72}
Note: See TracBrowser for help on using the repository browser.