List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified.
From source file:ipLock.Signal.java
public static Signal valueOf(String data) { try {//from www . j a v a 2 s. c om String[] fields = StringUtils.split(data, ':'); Integer senderId = Integer.valueOf(fields[0]); SignalCode code = SignalCode.valueOf(fields[1]); String[] params = Arrays.copyOfRange(fields, 2, fields.length); return new Signal(senderId, code, params); } catch (RuntimeException e) { String msg = String.format("message '%s' can not be parsed into client signal", data); throw new IllegalArgumentException(msg, e); } }
From source file:com.intel.cosbench.driver.generator.ConstantIntGenerator.java
private static ConstantIntGenerator tryParse(String pattern) { pattern = StringUtils.substringBetween(pattern, "(", ")"); String[] args = StringUtils.split(pattern, ','); int value = Integer.parseInt(args[0]); return new ConstantIntGenerator(value); }
From source file:com.xwtec.xwserver.util.json.JSONFunction.java
/** * Constructs a JSONFunction from a text representation */// w w w .ja v a 2 s .c om public static JSONFunction parse(String str) { if (!JSONUtils.isFunction(str)) { throw new JSONException("String is not a function. " + str); } else { String params = JSONUtils.getFunctionParams(str); String text = JSONUtils.getFunctionBody(str); return new JSONFunction((params != null) ? StringUtils.split(params, ",") : null, text != null ? text : ""); } }
From source file:com.hangum.tadpole.rdb.erd.core.relation.CubridTableRelation.java
/** * ? relation ?/*from ww w. java2 s .co m*/ * * @param userDB * @return */ public static List<ReferencedTableDAO> makeCubridRelation(UserDBDAO userDB, String tableName) throws Exception { List<ReferencedTableDAO> listRealRefTableDAO = new ArrayList<ReferencedTableDAO>(); Connection conn = null; ResultSet rs = null; String[] tableNames = StringUtils.split(tableName, ','); for (String table : tableNames) { table = StringUtils.replace(table, "'", ""); try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); conn = sqlClient.getDataSource().getConnection(); rs = conn.getMetaData().getImportedKeys("", "", table); while (rs.next()) { ReferencedTableDAO ref = new ReferencedTableDAO(); if (rs.getString("FK_NAME") == null || "".equals(rs.getString("FK_NAME"))) ref.setConstraint_name(rs.getString("FK_NAME")); else ref.setConstraint_name(rs.getString("fk_name")); // Table names if (rs.getString("FKTABLE_NAME") == null || "".equals(rs.getString("FKTABLE_NAME"))) ref.setTable_name(rs.getString("FKTABLE_NAME")); else ref.setTable_name(rs.getString("fktable_name")); if (rs.getString("FKCOLUMN_NAME") == null || "".equals(rs.getString("FKCOLUMN_NAME"))) ref.setColumn_name(rs.getString("FKCOLUMN_NAME")); else ref.setColumn_name(rs.getString("fkcolumn_name")); if (rs.getString("PKTABLE_NAME") == null || "".equals(rs.getString("PKTABLE_NAME"))) ref.setReferenced_table_name(rs.getString("PKTABLE_NAME")); else ref.setReferenced_table_name(rs.getString("pktable_name")); if (rs.getString("PKCOLUMN_NAME") == null || "".equals(rs.getString("PKCOLUMN_NAME"))) ref.setReferenced_column_name(rs.getString("PKCOLUMN_NAME")); else ref.setReferenced_column_name(rs.getString("pkcolumn_name")); if (logger.isDebugEnabled()) logger.debug(ref.toString()); listRealRefTableDAO.add(ref); } } catch (Exception e) { logger.error("cubrid relation", e); throw new Exception("Cubrid relation exception " + e.getMessage()); } finally { if (rs != null) try { rs.close(); } catch (Exception e) { } if (conn != null) try { conn.close(); } catch (Exception e) { } } } // end last for return listRealRefTableDAO; }
From source file:com.microsoft.alm.plugin.external.models.ToolVersion.java
/** * constructor that takes a version string and creates a ToolVersion object by parsing the string. * Ex. 14.0.3.201603291047/*from www . j a v a 2 s .c o m*/ */ public ToolVersion(final String versionString) { final String[] parts = StringUtils.split(versionString, '.'); major = getIntegerPart(parts, 0, 0); minor = getIntegerPart(parts, 1, 0); revision = getIntegerPart(parts, 2, 0); if (parts.length > 3) { build = parts[3]; } else { build = StringUtils.EMPTY; } }
From source file:com.common.poi.excel.util.Reflections.java
/** * Setter, ???//from w w w. j a va 2 s . c o m * ???.??. */ public static void invokeSetter(Object obj, String propertyName, Object value) { Object object = obj; String[] names = StringUtils.split(propertyName, "."); for (int i = 0; i < names.length; i++) { if (i < names.length - 1) { String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } else { String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); invokeMethodByName(object, setterMethodName, new Object[] { value }); } } }
From source file:net.logstash.logback.appender.DestinationParser.java
/** * Constructs {@link InetSocketAddress}es by parsing the given {@link String} value. * <p>/*from w w w. j a va 2 s . c om*/ * The string is a comma separated list of destinations in the form of hostName[:portNumber]. * <p> * * For example, "host1.domain.com,host2.domain.com:5560" * <p> * * If portNumber is not provided, then the given defaultPort will be used. */ public static List<InetSocketAddress> parse(String destinations, int defaultPort) { /* * Multiple destinations can be specified on one single line, separated by comma */ String[] destinationStrings = StringUtils.split(StringUtils.trimToEmpty(destinations), ','); List<InetSocketAddress> destinationList = new ArrayList<InetSocketAddress>(destinationStrings.length); for (String entry : destinationStrings) { /* * For #134, check to ensure properties are defined when destinations * are set using properties. */ if (entry.contains(CoreConstants.UNDEFINED_PROPERTY_SUFFIX)) { throw new IllegalArgumentException( "Invalid destination '" + entry + "': unparseable value (expected format 'host[:port]')."); } Matcher matcher = DESTINATION_PATTERN.matcher(entry); if (!matcher.matches()) { throw new IllegalArgumentException( "Invalid destination '" + entry + "': unparseable value (expected format 'host[:port]')."); } String host = matcher.group(HOSTNAME_GROUP); String portString = matcher.group(PORT_GROUP); int port; try { port = (portString != null) ? Integer.parseInt(portString) : defaultPort; } catch (NumberFormatException e) { throw new IllegalArgumentException( "Invalid destination '" + entry + "': unparseable port (was '" + portString + "')."); } destinationList.add(InetSocketAddress.createUnresolved(host, port)); } return destinationList; }
From source file:com.qualogy.qafe.gwt.server.ui.assembler.ElementUIAssembler.java
public static ElementGVO convert(Element object, Window currentWindow, ApplicationMapping applicationMapping, ApplicationContext context, SessionContainer sc) { ElementGVO vo = null;//from www. j ava 2s .c om if (object != null) { vo = new ElementGVO(); vo.setComponent(ComponentUIAssembler.convert(object.getComponent(), currentWindow, applicationMapping, context, sc)); vo.setGridheight(object.getGridheight()); vo.setGridwidth(object.getGridwidth()); vo.setStyle(object.getStyle()); vo.setStyleClass(object.getStyleClass()); vo.setX(object.getX()); vo.setY(object.getY()); String[] properties = StringUtils.split(object.getStyle() == null ? "" : object.getStyle(), ';'); String[][] styleProperties = new String[properties.length][2]; for (int i = 0; i < properties.length; i++) { styleProperties[i] = StringUtils.split(properties[i], ':'); } /* * Modify the properties since this is DOM manipulation : font-size for css has to become fontSize for DOM */ for (int i = 0; i < styleProperties.length; i++) { styleProperties[i][0] = StyleDomUtil.initCapitalize(styleProperties[i][0]); } vo.setStyleProperties(styleProperties); } return vo; }
From source file:net.sf.oreka.tapestry.TableHeader.java
public List getColumns() { String[] columnsArray = StringUtils.split(getColumnsCSV(), ", "); //logger.log(Level.INFO, "ColumnsCSV: "+getColumnsCSV()); List columns = new ArrayList(); for (int i = 0; i < columnsArray.length; i++) { TableColumn column = new TableColumn(); column.setSortable(true);/* w w w . j a v a 2s . co m*/ String columnKey = columnsArray[i]; if (columnsArray[i].charAt(0) == '!') { column.setSortable(false); columnKey = columnsArray[i].substring(1); } column.setKey(columnKey); String LocalizedMessage = getPage().getMessages().getMessage(columnKey); column.setMessage(LocalizedMessage); columns.add(column); } return columns; }
From source file:com.elasticbox.jenkins.k8s.plugin.clouds.PodSlaveConfigurationParams.java
public String[] getLabels() { return StringUtils.split(labels, " ,"); }