本文整理汇总了Java中org.h2.util.StringUtils.arraySplit方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.arraySplit方法的具体用法?Java StringUtils.arraySplit怎么用?Java StringUtils.arraySplit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.arraySplit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: passive
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private void passive() throws IOException {
send("PASV");
readCode(226, 227);
int first = message.indexOf('(') + 1;
int last = message.indexOf(')');
String[] address = StringUtils.arraySplit(
message.substring(first, last), ',', true);
StatementBuilder buff = new StatementBuilder();
for (int i = 0; i < 4; i++) {
buff.appendExceptFirst(".");
buff.append(address[i]);
}
String ip = buff.toString();
InetAddress addr = InetAddress.getByName(ip);
int port = (Integer.parseInt(address[4]) << 8) | Integer.parseInt(address[5]);
Socket socketData = NetUtils.createSocket(addr, port, false);
inData = socketData.getInputStream();
outData = socketData.getOutputStream();
}
示例2: getHtml
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* Generate the HTML for the given syntax.
*
* @param bnf the BNF parser
* @param syntaxLines the syntax
* @return the HTML
*/
public String getHtml(Bnf bnf, String syntaxLines) {
syntaxVisitor = new BnfSyntax();
this.config = bnf;
syntaxLines = StringUtils.replaceAll(syntaxLines, "\n ", " ");
String[] syntaxList = StringUtils.arraySplit(syntaxLines, '\n', true);
StringBuilder buff = new StringBuilder();
for (String s : syntaxList) {
bnf.visit(this, s);
html = StringUtils.replaceAll(html, "</code></td>" +
"<td class=\"d\"><code class=\"c\">", " ");
if (buff.length() > 0) {
buff.append("<br />");
}
buff.append(html);
}
return buff.toString();
}
示例3: getFunctions
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private String getFunctions(String section) throws SQLException {
try {
checkClosed();
PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT TOPIC "
+ "FROM INFORMATION_SCHEMA.HELP WHERE SECTION = ?");
prep.setString(1, section);
ResultSet rs = prep.executeQuery();
StatementBuilder buff = new StatementBuilder();
while (rs.next()) {
String s = rs.getString(1).trim();
String[] array = StringUtils.arraySplit(s, ',', true);
for (String a : array) {
buff.appendExceptFirst(",");
String f = a.trim();
if (f.indexOf(' ') >= 0) {
// remove 'Function' from 'INSERT Function'
f = f.substring(0, f.indexOf(' ')).trim();
}
buff.append(f);
}
}
rs.close();
prep.close();
return buff.toString();
} catch (Exception e) {
throw logAndConvert(e);
}
}
示例4: readSettingsFromURL
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private void readSettingsFromURL() {
DbSettings defaultSettings = DbSettings.getDefaultSettings();
int idx = url.indexOf(';');
if (idx >= 0) {
String settings = url.substring(idx + 1);
url = url.substring(0, idx);
String[] list = StringUtils.arraySplit(settings, ';', false);
for (String setting : list) {
if (setting.length() == 0) {
continue;
}
int equal = setting.indexOf('=');
if (equal < 0) {
throw getFormatException();
}
String value = setting.substring(equal + 1);
String key = setting.substring(0, equal);
key = StringUtils.toUpperEnglish(key);
if (!isKnownSetting(key) && !defaultSettings.containsKey(key)) {
throw DbException.get(ErrorCode.UNSUPPORTED_SETTING_1, key);
}
String old = prop.getProperty(key);
if (old != null && !old.equals(value)) {
throw DbException.get(ErrorCode.DUPLICATE_PROPERTY_1, key);
}
prop.setProperty(key, value);
}
}
}
示例5: setIgnoreList
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static void setIgnoreList(FullTextSettings setting,
String commaSeparatedList) {
String[] list = StringUtils.arraySplit(commaSeparatedList, ',', true);
HashSet<String> set = setting.getIgnoreList();
for (String word : list) {
String converted = setting.convertWord(word);
if (converted != null) {
set.add(converted);
}
}
}
示例6: split
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private static String[] split(String s) {
String[] list = new String[10];
String[] t = StringUtils.arraySplit(s, ' ', true);
System.arraycopy(t, 0, list, 0, t.length);
for (int i = 0; i < list.length; i++) {
if ("null".equals(list[i])) {
list[i] = null;
}
}
return list;
}
示例7: ConnectionInfo
import org.h2.util.StringUtils; //导入方法依赖的package包/类
public ConnectionInfo(String data) {
String[] array = StringUtils.arraySplit(data, '|', false);
name = get(array, 0);
driver = get(array, 1);
url = get(array, 2);
user = get(array, 3);
}
示例8: contextInitialized
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
try {
org.h2.Driver.load();
// This will get the setting from a context-param in web.xml if
// defined:
ServletContext servletContext = servletContextEvent.getServletContext();
String url = getParameter(servletContext, "db.url", "jdbc:h2:~/test");
String user = getParameter(servletContext, "db.user", "sa");
String password = getParameter(servletContext, "db.password", "sa");
// Start the server if configured to do so
String serverParams = getParameter(servletContext, "db.tcpServer", null);
if (serverParams != null) {
String[] params = StringUtils.arraySplit(serverParams, ' ', true);
server = Server.createTcpServer(params);
server.start();
}
// To access the database in server mode, use the database URL:
// jdbc:h2:tcp://localhost/~/test
conn = DriverManager.getConnection(url, user, password);
servletContext.setAttribute("connection", conn);
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: setOptions
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* INTERNAL.
* Parse and set the CSV options.
*
* @param options the the options
* @return the character set
*/
public String setOptions(String options) {
String charset = null;
String[] keyValuePairs = StringUtils.arraySplit(options, ' ', false);
for (String pair : keyValuePairs) {
if (pair.length() == 0) {
continue;
}
int index = pair.indexOf('=');
String key = StringUtils.trim(pair.substring(0, index), true, true, " ");
String value = pair.substring(index + 1);
char ch = value.length() == 0 ? 0 : value.charAt(0);
if (isParam(key, "escape", "esc", "escapeCharacter")) {
setEscapeCharacter(ch);
} else if (isParam(key, "fieldDelimiter", "fieldDelim")) {
setFieldDelimiter(ch);
} else if (isParam(key, "fieldSeparator", "fieldSep")) {
setFieldSeparatorRead(ch);
setFieldSeparatorWrite(value);
} else if (isParam(key, "lineComment", "lineCommentCharacter")) {
setLineCommentCharacter(ch);
} else if (isParam(key, "lineSeparator", "lineSep")) {
setLineSeparator(value);
} else if (isParam(key, "null", "nullString")) {
setNullString(value);
} else if (isParam(key, "charset", "characterSet")) {
charset = value;
} else if (isParam(key, "preserveWhitespace")) {
setPreserveWhitespace(Boolean.parseBoolean(value));
} else if (isParam(key, "writeColumnHeader")) {
setWriteColumnHeader(Boolean.parseBoolean(value));
} else if (isParam(key, "caseSensitiveColumnNames")) {
setCaseSensitiveColumnNames(Boolean.parseBoolean(value));
} else {
throw DbException.getUnsupportedException(key);
}
}
return charset;
}
示例10: execute
import org.h2.util.StringUtils; //导入方法依赖的package包/类
private void execute(String line) throws IOException {
String[] commands = StringUtils.arraySplit(line, ';', true);
for (String command : commands) {
String[] list = StringUtils.arraySplit(command, ' ', true);
if (!execute(list)) {
break;
}
}
}
示例11: convertTableToClassName
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* Tries to create a convert a SQL table name to a camel case class name.
*
* @param tableName the SQL table name
* @return the class name
*/
static String convertTableToClassName(String tableName) {
String[] chunks = StringUtils.arraySplit(tableName, '_', false);
StringBuilder className = new StringBuilder();
for (String chunk : chunks) {
if (chunk.length() == 0) {
// leading or trailing _
continue;
}
className.append(Character.toUpperCase(chunk.charAt(0)));
className.append(chunk.substring(1).toLowerCase());
}
return className.toString();
}
示例12: init
import org.h2.util.StringUtils; //导入方法依赖的package包/类
/**
* INTERNAL
*/
@Override
public void init(Connection conn, String schemaName, String triggerName,
String tableName, boolean before, int type) throws SQLException {
this.schema = schemaName;
this.table = tableName;
this.indexPath = getIndexPath(conn);
this.indexAccess = getIndexAccess(conn);
ArrayList<String> keyList = New.arrayList();
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs = meta.getColumns(null,
StringUtils.escapeMetaDataPattern(schemaName),
StringUtils.escapeMetaDataPattern(tableName),
null);
ArrayList<String> columnList = New.arrayList();
while (rs.next()) {
columnList.add(rs.getString("COLUMN_NAME"));
}
columnTypes = new int[columnList.size()];
columns = new String[columnList.size()];
columnList.toArray(columns);
rs = meta.getColumns(null,
StringUtils.escapeMetaDataPattern(schemaName),
StringUtils.escapeMetaDataPattern(tableName),
null);
for (int i = 0; rs.next(); i++) {
columnTypes[i] = rs.getInt("DATA_TYPE");
}
if (keyList.size() == 0) {
rs = meta.getPrimaryKeys(null,
StringUtils.escapeMetaDataPattern(schemaName),
tableName);
while (rs.next()) {
keyList.add(rs.getString("COLUMN_NAME"));
}
}
if (keyList.size() == 0) {
throw throwException("No primary key for table " + tableName);
}
ArrayList<String> indexList = New.arrayList();
PreparedStatement prep = conn.prepareStatement(
"SELECT COLUMNS FROM " + SCHEMA
+ ".INDEXES WHERE SCHEMA=? AND TABLE=?");
prep.setString(1, schemaName);
prep.setString(2, tableName);
rs = prep.executeQuery();
if (rs.next()) {
String cols = rs.getString(1);
if (cols != null) {
for (String s : StringUtils.arraySplit(cols, ',', true)) {
indexList.add(s);
}
}
}
if (indexList.size() == 0) {
indexList.addAll(columnList);
}
keys = new int[keyList.size()];
setColumns(keys, keyList, columnList);
indexColumns = new int[indexList.size()];
setColumns(indexColumns, indexList, columnList);
}
示例13: getValueForColumnList
import org.h2.util.StringUtils; //导入方法依赖的package包/类
@Override
public ValueResultSet getValueForColumnList(Session session,
Expression[] argList) {
switch (info.type) {
case CSVREAD: {
String fileName = argList[0].getValue(session).getString();
if (fileName == null) {
throw DbException.get(ErrorCode.PARAMETER_NOT_SET_1, "fileName");
}
String columnList = argList.length < 2 ?
null : argList[1].getValue(session).getString();
Csv csv = new Csv();
String options = argList.length < 3 ?
null : argList[2].getValue(session).getString();
String charset = null;
if (options != null && options.indexOf('=') >= 0) {
charset = csv.setOptions(options);
} else {
charset = options;
String fieldSeparatorRead = argList.length < 4 ?
null : argList[3].getValue(session).getString();
String fieldDelimiter = argList.length < 5 ?
null : argList[4].getValue(session).getString();
String escapeCharacter = argList.length < 6 ?
null : argList[5].getValue(session).getString();
setCsvDelimiterEscape(csv, fieldSeparatorRead, fieldDelimiter,
escapeCharacter);
}
char fieldSeparator = csv.getFieldSeparatorRead();
String[] columns = StringUtils.arraySplit(columnList, fieldSeparator, true);
ResultSet rs = null;
ValueResultSet x;
try {
rs = csv.read(fileName, columns, charset);
x = ValueResultSet.getCopy(rs, 0);
} catch (SQLException e) {
throw DbException.convert(e);
} finally {
csv.close();
JdbcUtils.closeSilently(rs);
}
return x;
}
default:
break;
}
return (ValueResultSet) getValueWithArgs(session, argList);
}