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:com.egt.core.db.util.DBUtils.java
/** * Busca el nombre del constraint en el mensaje que envia el RDBMS cuando se produce un conflicto * * @param message Cadena correspondiente al mensaje que envia el RDBMS * @param status Entero correspondiente al tipo de conflicto (cualquiera de las constantes ROW_CONFLICT de * SyncResolver)// w ww .ja va2s. c o m * @return Si se consigue, el nombre del constraint; de lo contratio retorna null */ public static String getConstraintMessageKey(String message, int status) { String trimmed = StringUtils.trimToNull(message); if (trimmed != null) { String[] tokens = StringUtils.split(trimmed, SEPARADORES); if (tokens != null && tokens.length > 0) { String key; for (int i = 0; i < tokens.length; i++) { key = tokens[i].toLowerCase(); if (key.endsWith(SUFIJO) && StringUtils.startsWithAny(key, PREFIJOS)) { if (status == 1 && key.startsWith("fk_")) { key += "_" + status; } return "<" + key + ">"; } } } } return null; }
From source file:com.jsqlboxdemo.dispatcher.Dispatcher.java
public static void dispach(PageContext pageContext) throws Exception { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); String uri = StringUtils.substringBefore(request.getRequestURI(), "."); String contextPath = request.getContextPath(); if (!StringUtils.isEmpty(contextPath)) uri = StringUtils.substringAfter(uri, contextPath); if (StringUtils.isEmpty(uri) || "/".equals(uri)) uri = "/home"; String[] paths = StringUtils.split(uri, "/"); String[] pathParams;/*from ww w .j ava2 s .c o m*/ String resource = null; String operation = null; if (paths.length >= 2) {// /team/add/100... resource = paths[0]; operation = paths[1]; pathParams = new String[paths.length - 2]; for (int i = 2; i < paths.length; i++) pathParams[i - 2] = paths[i]; } else { // /home_default resource = paths[0]; pathParams = new String[0]; } if (operation == null) operation = "default"; StringBuilder controller = new StringBuilder("com.jsqlboxdemo.controller.").append(resource).append("$") .append(resource).append("_").append(operation); if ("POST".equals(request.getMethod())) controller.append("_post"); WebBox box; try { Class boxClass = Class.forName(controller.toString()); box = BeanBox.getPrototypeBean(boxClass); } catch (Exception e) { throw new ClassNotFoundException("There is no WebBox classs '" + controller + "' found."); } request.setAttribute("pathParams", pathParams); box.show(pageContext); }
From source file:com.bstek.dorado.common.ClientType.java
public static int parseClientTypes(String clientTypes) { int clientTypesValue = 0; if (StringUtils.isNotBlank(clientTypes)) { String[] clientTypeArray = StringUtils.split(clientTypes.toLowerCase(), ",; "); if (ArrayUtils.indexOf(clientTypeArray, DESKTOP_NAME) >= 0) { clientTypesValue += ClientType.DESKTOP; }/*www . ja v a 2s. co m*/ if (ArrayUtils.indexOf(clientTypeArray, TOUCH_NAME) >= 0) { clientTypesValue += ClientType.TOUCH; } } return clientTypesValue; }
From source file:io.apiman.common.config.options.AbstractOptions.java
protected static String[] split(String str, char splitter) { if (str == null) return null; String[] splitStr = StringUtils.split(str, splitter); String[] out = new String[splitStr.length]; for (int i = 0; i < splitStr.length; i++) { out[i] = StringUtils.trim(splitStr[i]); }//from w w w .j a v a 2 s . c om return out; }
From source file:com.xx_dev.apn.proxy.utils.HostNamePortUtil.java
public static String getHostName(HttpRequest httpRequest) { String originalHostHeader = httpRequest.headers().get(HttpHeaders.Names.HOST); if (StringUtils.isBlank(originalHostHeader) && httpRequest.getMethod().equals(HttpMethod.CONNECT)) { originalHostHeader = httpRequest.getUri(); }/*from w w w .j a v a 2 s . c om*/ if (StringUtils.isNotBlank(originalHostHeader)) { String originalHost = StringUtils.split(originalHostHeader, ": ")[0]; return originalHost; } else { String uriStr = httpRequest.getUri(); try { URI uri = new URI(uriStr); String schema = uri.getScheme(); String originalHost = uri.getHost(); return originalHost; } catch (URISyntaxException e) { logger.error(e.getMessage(), e); return null; } } }
From source file:com.reizes.shiva.net.mail.EmailSender.java
public static String sendHtmlMail(String host, int port, String from, String to, String subject, String html) throws IOException, EmailException { if (to != null && host != null) { String[] emailTo = StringUtils.split(to, ';'); MultiPartEmail email = new MultiPartEmail(); email.setCharset("UTF-8"); email.setHostName(host);//from www.ja va2 s . co m email.setSmtpPort(port); email.setFrom(from); for (String recv : emailTo) { email.addTo(recv); } email.setSubject(subject); email.setMsg(html); return email.send(); } return null; }
From source file:com.github.ipaas.ifw.util.IPUtil.java
/** * IP???/*from w ww .j a v a2 s . co m*/ * * @param ip * @return */ public static long convertIpToInt(String ip) { // IP String[] ipArray = StringUtils.split(ip, '.'); // IP long ipInt = 0; // try { for (int i = 0; i < ipArray.length; i++) { if (ipArray[i] == null || ipArray[i].trim().equals("")) { ipArray[i] = "0"; } if (new Integer(ipArray[i].toString()).intValue() < 0) { Double j = new Double(Math.abs(new Integer(ipArray[i].toString()).intValue())); ipArray[i] = j.toString(); } if (new Integer(ipArray[i].toString()).intValue() > 255) { ipArray[i] = "255"; } } ipInt = new Double(ipArray[0]).longValue() * 256 * 256 * 256 + new Double(ipArray[1]).longValue() * 256 * 256 + new Double(ipArray[2]).longValue() * 256 + new Double(ipArray[3]).longValue(); // } catch (Exception e) { e.printStackTrace(); } return ipInt; }
From source file:gov.nih.nci.cma.web.graphing.CustomOverlibToolTipTagFragmentGenerator.java
public String generateToolTipFragment(String toolTipText) { String ttip = ""; //holds the ttip text String _extra = ""; //holds any extra if (toolTipText.indexOf("|") != -1) { String[] tps = StringUtils.split(toolTipText, "|"); _extra = " " + tps[0]; ttip = tps[1];/*from w ww . j av a 2s .c o m*/ } else { ttip = toolTipText; } return this.extra + " " + _extra + " onMouseOver=\"return overlib('" + ttip + "', CAPTION, 'Additional Info', FGCOLOR, '#FFFFFF', BGCOLOR, '#000000', WIDTH, 150, HEIGHT, 25);\" onMouseOut=\"return nd();\""; }
From source file:com.hangum.tadpole.erd.core.relation.CubridTableRelation.java
/** * ? relation ?//from w w w .ja va 2s. c om * * @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(); ref.setConstraint_name(rs.getString("FK_NAME")); // ? ref.setTable_name(rs.getString("FKTABLE_NAME")); ref.setColumn_name(rs.getString("FKCOLUMN_NAME")); ref.setReferenced_table_name(rs.getString("PKTABLE_NAME")); 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.swtxml.swt.types.PointType.java
public Point convert(String value) { String[] sizes = StringUtils.split(value, ",x"); return new Point(Integer.parseInt(sizes[0]), Integer.parseInt(sizes[1])); }