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.netscape.cmscore.dbs.CSCfgDatabase.java
public boolean requiresApproval() throws EBaseException { String value = configStore.getString("target.agent_approve.list", ""); return Arrays.asList(StringUtils.split(value, ",")).contains(substoreName); }
From source file:com.intellij.plugins.haxe.model.FullyQualifiedInfo.java
public FullyQualifiedInfo(@Nullable String fullyQualifiedIdentifier) { this(new ArrayList<>(fullyQualifiedIdentifier != null ? Arrays.asList(StringUtils.split(fullyQualifiedIdentifier, PATH_SEPARATOR)) : Collections.emptyList())); }
From source file:com.liferay.sync.engine.lan.session.SNISSLConnectionSocketFactory.java
@Override public Socket createLayeredSocket(Socket socket, String target, int port, HttpContext httpContext) throws IOException { HttpClientContext httpClientContext = (HttpClientContext) httpContext; HttpRequest httpRequest = httpClientContext.getRequest(); RequestLine requestLine = httpRequest.getRequestLine(); String[] parts = StringUtils.split(requestLine.getUri(), "/"); String sniCompliantLanServerUuid = LanClientUtil.getSNIHostname(parts[0]); return super.createLayeredSocket(socket, sniCompliantLanServerUuid, port, httpContext); }
From source file:gov.nih.nci.eagle.util.PatientGroupManager.java
private void buildPatientMap() { patientMap = new HashMap<String, Map>(); File inFile = new File(patientFileName); BufferedReader br;//from w w w.j a v a2 s. c o m try { br = new BufferedReader(new InputStreamReader(new FileInputStream(inFile))); String line = br.readLine(); while (line != null) { String[] values = StringUtils.split(line, ","); HashMap<String, String> patient = new HashMap<String, String>(); if (values == null || values.length < 1) { line = br.readLine(); continue; } patient.put("patientId", values[0]); String sex = null; if (values[1].equals("1.00")) { sex = "M"; } else { sex = "F"; } patient.put("sex", sex); String smoke = null; if (values[2].equals("0.00")) { smoke = "NEVER"; } else if (values[2].equals("1.00")) { smoke = "FORMER"; } else if (values[2].equals("2.00")) { smoke = "CURRENT"; } else { //some are 9.0 == n/a smoke = "N/A"; } patient.put("smoking_status", smoke); patient.put("age", values[3]); if (values.length > 4) { patient.put("grade", values[4]); } else { patient.put("grade", "N/A"); //no grade for these } patientMap.put(values[0], patient); line = br.readLine(); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:de.thischwa.pmcms.tool.file.FileComparator.java
@Override public int compare(final File f1, final File f2) { if (f1.getAbsolutePath().equals(f2.getAbsolutePath())) return 0; String path1 = FilenameUtils.getFullPath(f1.getAbsolutePath()); String path2 = FilenameUtils.getFullPath(f2.getAbsolutePath()); String name1 = FilenameUtils.getName(f1.getAbsolutePath()); String name2 = FilenameUtils.getName(f2.getAbsolutePath()); if (path1.equals(path2) || (StringUtils.isBlank(path1) && StringUtils.isBlank(path2))) return name1.compareTo(name2); String[] pathParts1 = StringUtils.split(FilenameUtils.getFullPathNoEndSeparator(path1), File.separatorChar); String[] pathParts2 = StringUtils.split(FilenameUtils.getFullPathNoEndSeparator(path2), File.separatorChar); if (pathParts1.length < pathParts2.length) return -1; if (pathParts1.length > pathParts2.length) return +1; int i = 0;//from ww w. j ava 2 s .c o m while (i < pathParts1.length && i < pathParts2.length) { if (!pathParts1[i].equals(pathParts2[i])) return pathParts1[i].compareTo(pathParts2[i]); i++; } return 0; }
From source file:com.pureinfo.common.nsms.action.SMSSendAction.java
/** * @see com.pureinfo.ark.interaction.ActionBase#executeAction() *//*from w w w.j av a 2s . c om*/ public ActionForward executeAction() throws PureException { String sIds = request.getRequiredParameter("receiveIds", ""); String sContent = request.getString("body", true); // 2. to read mapping parameter MappingString mappingParameters = new MappingString(mapping.getParameter()); String sMark = mappingParameters.getTrimed("mark"); mappingParameters.clear(); if (sMark == null) { throw new PureException(PureException.PARAMETER_REQUIRED, "parameter [mark] missing in mapping config!"); } // 3. to send SMS sContent = (sContent == null) ? sMark : sContent + sMark; String[] idArray = StringUtils.split(sIds, ','); IContentMgr mgr = ArkContentHelper.lookupTypeById(ArkTypes.USER).getManagerBean(); for (int i = 0; i < idArray.length; i++) { int nId = Integer.parseInt(idArray[i]); User usr = (User) mgr.lookupById(nId); String sPhoneNumber = usr.getMobile(); User admin = (User) loginUser; if (sPhoneNumber != null && sPhoneNumber.length() != 0) { SenderHelper.getSender(SenderHelper.TYPE_SMS).send(admin.getMobile(), admin.getTrueName(), sPhoneNumber, usr.getTrueName(), "", sContent); } } return mapping.findForward("success"); }
From source file:AIR.Common.Web.PatternUrlRewriter.java
public PatternUrlRewriter() { try {/*from w w w .ja v a2 s .c o m*/ /* * Shiva hack!!! This is a quick fix for multiple regexes. Tab separated * file. */ InputStream in = this.getClass().getClassLoader().getResourceAsStream("PatternUrlRewriter.txt"); try (BufferedReader bfr = new BufferedReader(new InputStreamReader(in))) { String line = null; while ((line = bfr.readLine()) != null) { line = line.trim(); if (!StringUtils.isEmpty(line)) { final String[] pair = StringUtils.split(line, '\t'); _patterns.add(new PatternReplacement() { { this._pattern = Pattern.compile(pair[0].trim()); this._replacement = pair[1].trim(); } }); } } } } catch (Exception exp) { System.out.println("Error reading patterns from external file."); } }
From source file:PCATestApplet.java
public void init() { /*//from w w w. j ava 2 s . com // Data definition int n = 10; //read params to create these double[][] datas1 = new double[n][3]; double[][] datas2 = new double[n][3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { // 3 == set the x,y,z...goto next of the 10 datas1[i][j] = Math.random(); datas2[i][j] = Math.random(); } } */ Plot3DPanel plotpanel = new Plot3DPanel(); plotpanel.setAxeLabel(0, "PC1"); plotpanel.setAxeLabel(1, "PC2"); plotpanel.setAxeLabel(2, "PC3"); plotpanel.addLegend("SOUTH"); String totalPts = getParameter("totalPts"); String totalGps = getParameter("totalGps"); //groupLabel_x //groupCount_x //pt_x_x (group#_pt#) for (int i = 0; i < Integer.parseInt(totalGps); i++) { String thisGrpLabel = getParameter("groupLabel_" + i); String thisGrpCount = getParameter("groupCount_" + i); String thisGrpColor = getParameter("groupColor_" + i); double[][] lumpData = new double[Integer.parseInt(thisGrpCount)][3]; for (int t = 0; t < Integer.parseInt(thisGrpCount); t++) { String v = getParameter("pt_" + i + "_" + t); String[] xyz = StringUtils.split(v, ","); for (int j = 0; j < 3; j++) { lumpData[t][j] = Double.valueOf(xyz[j]).doubleValue(); } } //plotpanel.addScatterPlot(thisGrpLabel, lumpData); plotpanel.addScatterPlot(thisGrpLabel, new Color(Integer.parseInt(thisGrpColor)), lumpData); lumpData = null; } /* //lump data example double[][] lumpData = new double[Integer.parseInt(totalPts)][3]; for(int i=0; i<Integer.parseInt(totalPts); i++){ String v = getParameter("pt_"+i); String[] xyz = StringUtils.split(v, ","); for(int j=0; j<3; j++){ lumpData[i][j] = Double.valueOf(xyz[j]); } } */ // PlotPanel construction //Plot3DPanel plotpanel = new Plot3DPanel(); //plotpanel.setAxeLabel(0, "PC1"); //plotpanel.setAxeLabel(1, "PC2"); //plotpanel.setAxeLabel(2, "PC3"); //plotpanel.addLegend("SOUTH"); // Data plots addition //plotpanel.addScatterPlot("lump data", lumpData); //plotpanel.addScatterPlot(totalPts + " datas1", datas1); //plotpanel.addScatterPlot("datas2", datas2); //plotpanel.addBarPlot("datas2", datas2); // include plot in applet add(plotpanel); }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.IssuePattern.java
/** * Create a new {@link IssuePattern} from the given line describing the resourcePattern, the rulePattern and * the lines in the resource/*w ww . j a v a2s . c om*/ * * @param line each line must consist out of the resourcePattern, rulePattern and lineValues, * separated by a ';' (lines can be given as values ([1,3]) or as ranges ([5-10]) or a combination of both ([1,3,5-10])) * * @return the new {@link IssuePattern} from the given line */ public static IssuePattern parseLine(final String line) { final String[] fields = StringUtils.split(line, ';'); if (fields.length != 3) { throw new IllegalArgumentException("The line does not define 3 fields separated by ';': " + line); } final String resourcePattern = fields[0]; if (StringUtils.isBlank(resourcePattern)) { throw new IllegalArgumentException("The first field does not define a resource pattern: " + line); } final String rulePattern = fields[1]; if (StringUtils.isBlank(rulePattern)) { throw new IllegalArgumentException("The second field does not define a rule pattern: " + line); } final String lineValues = fields[2]; if (StringUtils.isBlank(lineValues)) { throw new IllegalArgumentException("The third field does not define a range of lines: " + line); } final SortedSet<Integer> lines = parseLineValues(lineValues); return new IssuePattern(resourcePattern, rulePattern, lines); }
From source file:com.btobits.automator.fix.utils.FileMessageFactory.java
public FileMessageFactory(final String inFile, final String inSkip) throws Exception { try {/*from w w w.java2 s .c o m*/ skip = StringUtils.split(inSkip, "|"); file = new File(inFile); } catch (Exception ex) { throw new Exception("Error open message file:", ex); } }