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.pureinfo.srm.config.workflow.model.WfActivity.java
public void setRoles(String _sRoleStr) throws PureException { String[] roles = StringUtils.split(_sRoleStr, ','); Map roleMap = new HashMap(); for (int i = 0; i < roles.length; i++) { WfRole role = WorkflowHelper.getRole(roles[i]); if (role == null) { logger.warn(roles[i] + " is not legel role id"); } else {/*from w w w. ja v a2 s . c o m*/ roleMap.put(roles[i], role); } } m_roles = roleMap; }
From source file:ml.shifu.shifu.udf.stats.CategoricalVarStats.java
@Override public void runVarStats(String binningInfo, DataBag databag) throws ExecException { String[] binningDataArr = StringUtils.split(binningInfo, CalculateStatsUDF.CATEGORY_VAL_SEPARATOR); log.info("Column Name - " + this.columnConfig.getColumnName() + ", Column Bin Length - " + binningDataArr.length);//from w w w .j a v a 2s.co m columnConfig.setBinCategory(Arrays.asList(binningDataArr)); categoricalBinMap = new HashMap<String, Integer>(columnConfig.getBinCategory().size()); for (int i = 0; i < columnConfig.getBinCategory().size(); i++) { List<String> catValues = CommonUtils.flattenCatValGrp(columnConfig.getBinCategory().get(i)); for (String cval : catValues) { categoricalBinMap.put(cval, Integer.valueOf(i)); } } statsCategoricalColumnInfo(databag, columnConfig); }
From source file:JSONUtil.java
/** * @param o// w w w.j ava 2 s . com * @param string * @throws JSONException */ public static void toArray(JSONObject o, String key) throws JSONException { if (o.has(key)) { Object ob = o.get(key); if (ob instanceof JSONArray) { // no action } else if (ob instanceof JSONObject) { // no action } else { String v = o.getString(key); String[] values = StringUtils.split(v, ','); JSONArray a = new JSONArray(); for (String value : values) { a.put(value); } o.put(key, a); } } else { JSONArray a = new JSONArray(); o.put(key, a); } }
From source file:cn.vlabs.duckling.vwb.tags.PermissionTag.java
/** * Sets the permissions to look for (case sensitive). See above for the * format.// ww w .j a va 2s . c o m * * @param permission * A list of permissions */ public void setPermission(String permission) { m_permissionList = StringUtils.split(permission, '|'); }
From source file:com.healthcit.analytics.servlet.DataExportServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String token = request.getParameter("token"); TOKENS_MAP.put(token, DownloadStatus.STARTED); String keys = request.getParameter("keys"); if (keys != null) { //JSONArray ownerIdsJSON = (JSONArray)JSONSerializer.toJSON(ownerIds ) ; String[] ownerIdsArray = StringUtils.split(keys, ","); response.setContentType(Constants.JSON_CONTENT_TYPE); response.addHeader(Constants.CONTENT_DISPOSITION, "attachment; filename=dataExport.zip"); response.addHeader(Constants.PRAGMA_HEADER, Constants.NO_CACHE); response.setHeader(Constants.CACHE_CONTROL_HEADER, Constants.NO_CACHE); ServletOutputStream os = response.getOutputStream(); ZipOutputStream zos = new ZipOutputStream(os); // ZipEntry entry = new ZipEntry("dataExport."+OutputFormat.JSON.toString().toLowerCase()); ZipEntry entry = new ZipEntry("dataExport." + OutputFormat.XML.toString().toLowerCase()); zos.putNextEntry(entry);/* w w w .j a v a 2s . c om*/ // OwnerDataManager ownerManager = new OwnerDataManager(OutputFormat.JSON); OwnerDataManager ownerManager = new OwnerDataManager(OutputFormat.XML); try { ownerManager.getEntitiesData(ownerIdsArray, zos); TOKENS_MAP.put(token, DownloadStatus.FINISHED); } catch (Exception e) { log.error(e.getMessage(), e); TOKENS_MAP.put(token, DownloadStatus.ERROR); } finally { zos.close(); // os.flush(); // os.close(); } } else { TOKENS_MAP.put(token, DownloadStatus.ERROR); } }
From source file:com.google.gdt.eclipse.designer.support.http.HttpRequest.java
/** * Parses request from browser./*from w w w . java2 s . c o m*/ * * @param requestLine */ private int parseRequest(String requestLine) { // parse the line into components, check if there are enough components String[] items = StringUtils.split(requestLine, " "); if (items.length < 2) { return HTTP_BAD_REQUEST; } if (!items[0].toUpperCase(Locale.ENGLISH).equals("GET")) { return HTTP_BAD_METHOD; } m_url = items[1]; return HTTP_OK; }
From source file:com.hs.mail.web.util.DataImporter.java
private User parseAccount(String str) throws ParseException { String[] astr = StringUtils.split(str, ':'); int len = astr.length; User user = new User(); MailUtils.validateAddress(astr[0]);/*www . java2 s .c o m*/ user.setUserID(astr[0]); user.setPassword("1"); // default password if (len > 1) { if (StringUtils.isNotEmpty(astr[1])) { user.setPassword(astr[1]); } if (len > 2) { if (StringUtils.isNotEmpty(astr[2])) { user.setQuota(Long.parseLong(astr[2])); } if (len > 3) { if (StringUtils.isNotEmpty(astr[3])) { MailUtils.validateAddress(astr[3]); user.setForwardTo(astr[3]); } } } } return user; }
From source file:com.ning.metrics.action.hdfs.data.parser.RowParser.java
@Inject public RowParser(final ActionCoreConfig conf) { classLoader = RowParser.class.getClassLoader(); final String defaultSerializations = "" + "com.ning.metrics.action.hdfs.data.parser.ThriftEnvelopeRowSerializer," + "com.ning.metrics.action.hdfs.data.parser.ThriftRowSerializer," + "com.ning.metrics.action.hdfs.data.parser.SmileRowSerializer," + "com.ning.metrics.action.hdfs.data.parser.WritableRowSerializer," + "com.ning.metrics.action.hdfs.data.parser.StringRowSerializer,"; // TODO ServiceLoader for (final String serializerName : StringUtils.split(defaultSerializations + conf.getRowSerializations(), ",")) { try {//w w w .j av a2 s . c o m add(serializerName); } catch (ClassNotFoundException e) { log.warn("Ignoring specified RowSerializer [{}], as it is not in classpath", serializerName); } catch (InstantiationException e) { log.warn("Ignoring specified RowSerializer [{}]: {}", serializerName, e); } catch (IllegalAccessException e) { log.warn("Ignoring specified RowSerializer [{}]: {}", serializerName, e); } } }
From source file:com.xpn.xwiki.plugin.lucene.RemoteIndexesSearcher.java
private void setSlaveListLength(String slavelist) { String[] slaves = StringUtils.split(slavelist, ","); this.slaveListLength = slaves.length; }
From source file:com.ning.metrics.action.hdfs.data.RowTextFileContentsIterator.java
public RowTextFileContentsIterator(final String pathname, final RowParser rowParser, final Registrar registrar, final InputStream origStream, final boolean rawContents) throws IOException { super(pathname, rowParser, registrar, rawContents); final String[] tokenizedPathname = StringUtils.split(pathname, "."); String suffix = tokenizedPathname[tokenizedPathname.length - 1]; // First check if the file has been compressed final InputStream stream = DecompressedStreamFactory.wrapStream(suffix, origStream); if (stream != null) { in = stream;//ww w . ja va2 s. c o m suffix = tokenizedPathname[tokenizedPathname.length - 2]; } else { // Nope in = origStream; } // Then handling serialization format binary = suffix.equals("smile") || suffix.equals("thrift"); if (suffix.equals("smile")) { reader = null; streamReader = new BufferedSmileReader(registrar, in); } else if (suffix.equals("thrift")) { reader = null; streamReader = new BufferedThriftReader(registrar, in); } else { streamReader = null; reader = new BufferedReader(new InputStreamReader(in)); } }