01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.server.web;
07:
08: import org.h2.util.StringUtils;
09:
10: /**
11: * The connection info object is a wrapper for database connection information
12: * such as the database URL, user name and password.
13: * This class is used by the H2 Console.
14: */
15: public class ConnectionInfo {
16: String name, driver, url, user;
17: int lastAccess;
18:
19: ConnectionInfo() {
20: }
21:
22: ConnectionInfo(String data) {
23: String[] array = StringUtils.arraySplit(data, '|', false);
24: name = get(array, 0);
25: driver = get(array, 1);
26: url = get(array, 2);
27: user = get(array, 3);
28: }
29:
30: private String get(String[] array, int i) {
31: return array != null && array.length > i ? array[i] : "";
32: }
33:
34: String getString() {
35: return StringUtils.arrayCombine(new String[] { name, driver,
36: url, user }, '|');
37: }
38:
39: }
|