List of usage examples for org.apache.commons.lang3 StringUtils substringAfter
public static String substringAfter(final String str, final String separator)
Gets the substring after the first occurrence of a separator.
From source file:org.zht.framework.zhtdao.base.impl.BaseDaoImpl.java
@Override public List<?> findJustList(String queryStr, ParamObject paramObject) throws DaoException { if (paramObject == null) { throw new DaoException("?"); }/*from w ww. j av a 2s . c om*/ if (paramObject.getIsNeedCount() == null) { throw new DaoException("[NeedCount]?"); } if (paramObject.getIsSql() == null) { throw new DaoException("[isSql]?"); } if (paramObject.getIsOffset() == null) { throw new DaoException("[isOffset]?"); } // if(queryStr==null||!(queryStr.contains("@from")||queryStr.contains("@FROM"))){ // throw new DaoException("?,[@from]"); // } queryStr = queryStr.replace("@from", "from").replace("@FROM", "FROM"); Query queryData; if (paramObject.getIsSql()) { queryData = this.getCurrentSession().createSQLQuery(queryStr); } else { queryData = this.getCurrentSession().createQuery(queryStr); } Map<String, Object> parmeterSet = paramObject.getQueryParams(); String tempSql = new String(queryStr); if (parmeterSet != null && parmeterSet.size() > 0) { while (tempSql.contains(":")) { tempSql = StringUtils.substringAfter(tempSql, ":"); String key = StringUtils.substringBefore(tempSql, " "); if (key != null && key.trim().endsWith(")")) { key = key.replace(")", ""); } if (parmeterSet.keySet().contains(key)) { Object paramValue = parmeterSet.get(key); //?null//// if (paramValue == null) { queryData.setParameter(key, paramValue); } else { if (paramValue instanceof Collection) { queryData.setParameterList(key, (Collection<?>) paramValue); } else if (paramValue.getClass().isArray()) { queryData.setParameterList(key, (Object[]) paramValue); } else if ("true".equalsIgnoreCase("" + paramValue) || "false".equalsIgnoreCase("" + paramValue)) { queryData.setParameter(key, Boolean.valueOf("" + paramValue)); } else { queryData.setParameter(key, paramValue); } } } } } List<?> entityList = queryData.list(); if (entityList != null && entityList.size() > 0) { return entityList; } return null; }
From source file:org.zht.framework.zhtdao.hibernate.impl.HibernateBaseDaoImpl.java
public int executeUpdate(String queryStr, ParamObject paramObject) throws DaoException { Query query = null;/*from w w w .java 2s .c o m*/ if (paramObject.getIsSql()) { query = this.getCurrentSession().createSQLQuery(queryStr); } else { query = this.getCurrentSession().createQuery(queryStr); } Map<String, Object> parmeterSet = paramObject.getQueryParams(); String tempSql = new String(queryStr); if (parmeterSet != null && parmeterSet.size() > 0) { while (tempSql.contains(":")) { tempSql = StringUtils.substringAfter(tempSql, ":"); String key = StringUtils.substringBefore(tempSql, " "); if (key != null && key.trim().endsWith(")")) { key = key.replace(")", ""); } if (parmeterSet.keySet().contains(key)) { Object paramValue = parmeterSet.get(key); //?null//// if (paramValue == null) { query.setParameter(key, paramValue); } else { if (paramValue instanceof Collection) { query.setParameterList(key, (Collection<?>) paramValue); } else if (paramValue.getClass().isArray()) { query.setParameterList(key, (Object[]) paramValue); } else { query.setParameter(key, paramValue); } } } } } return query.executeUpdate(); }
From source file:pl.madshai.rjmock.mocks.MocksHelper.java
/** * Get category// ww w .ja v a 2 s . c o m * @param url * @return */ public static String getPackageFromUrl(String url) { String removeFirstSlash = StringUtils.substringAfter(url, RJMOCK); return StringUtils.substringBefore(removeFirstSlash, "/"); }
From source file:pl.madshai.rjmock.mocks.MocksHelper.java
/** * Get subpath/*from ww w .ja v a2s .c o m*/ * @param url * @return */ public static String getSubpathFromUrl(String url) { String removeFirstSlash = StringUtils.substringAfter(url, RJMOCK); String subpath = StringUtils.substringAfter(removeFirstSlash, "/"); if (subpath.contains("?")) { subpath = StringUtils.substringBefore(subpath, "?"); } return subpath; }
From source file:reconf.server.services.CrudServiceUtils.java
public static String getBaseUrl(HttpServletRequest req) { if (StringUtils.isNotBlank(req.getHeader(ReConfConstants.H_REQUEST_URL))) { return req.getHeader(ReConfConstants.H_REQUEST_URL) + ReConfConstants.CRUD_ROOT; }/*ww w . java 2 s .com*/ String url = req.getRequestURL().toString(); return StringUtils.replace(url, StringUtils.substringAfter(url, ReConfConstants.CRUD_ROOT), ""); }
From source file:repast.simphony.visualization.gui.styleBuilder.EditedStyleDialog.java
/** * Checks if the selected path contains the project root and if so, remove * the project root from the path, making it a relative path. * // www . j a v a 2s . com * @param fileName the full path to the file * @return the relative path to the project root */ private String makeRelativePath(String fileName) { String path; String projectRoot = ScenarioUtils.getScenarioDir().getParentFile().getAbsolutePath(); if (fileName.startsWith(projectRoot)) path = StringUtils.substringAfter(fileName, projectRoot); else { path = fileName; //TODO warn user about icons external to project. //TODO offer to copy icon into user project? } // force the file separator to "/" path = StringUtils.replace(path, "\\", "/"); // strip leading file separators if any if (path.charAt(0) == '/') path = StringUtils.substringAfter(path, String.valueOf(path.charAt(0))); return path; }
From source file:se.trixon.toolbox.checksum.ChecksumRow.java
public ChecksumRow(String row) { mChecksum = StringUtils.substringBefore(row, " ").trim(); mFile = StringUtils.substringAfter(row, " ").trim(); }
From source file:se.trixon.toolbox.checksum.ChecksumTopComponent.java
private String getRelativePath(File file, File base) { return StringUtils.substringAfter(file.getAbsolutePath(), base.getAbsolutePath() + SystemUtils.FILE_SEPARATOR); }
From source file:Singletons.HeuristicsLoader.java
@PostConstruct public void load() { Categories.populate();/* ww w.j a v a 2s.c o m*/ Set<File> setPathResources = new TreeSet(); // setPathResources.addAll(FacesContext.getCurrentInstance().getExternalContext().getResourcePaths("/resources/private/")); // File file = new File ("/usr/sharedfilesapps/lexicons"); File file; if (Parameters.local) { file = new File( "H:\\Docs Pro Clement\\NetBeansProjects\\Umigon_mavenized\\src\\main\\webapp\\resources\\private\\"); } else { file = new File("/usr/sharedfilesapps/lexicons"); } File[] files = file.listFiles(); setPathResources.addAll(Arrays.asList(files)); // System.out.println("folder is: " + folder.getCanonicalPath()); mapHeuristics = new HashMap(); setNegations = new HashSet(); setTimeTokens = new HashSet(); setFalsePositiveOpinions = new HashSet(); setIronicallyPositive = new HashSet(); setModerators = new HashSet(); mapH1 = new HashMap(); mapH2 = new HashMap(); mapH4 = new HashMap(); mapH3 = new HashMap(); mapH5 = new HashMap(); mapH6 = new HashMap(); mapH7 = new HashMap(); mapH8 = new HashMap(); mapH9 = new HashMap(); mapH10 = new HashMap(); mapH11 = new HashMap(); mapH12 = new HashMap(); mapH13 = new HashMap(); // for (File file : arrayFiles) { for (File filezz : setPathResources) { try { InputStream inp = new FileInputStream(filezz.getPath()); br = new BufferedReader(new InputStreamReader(inp)); if (!filezz.getPath().contains("_")) { continue; } String fileName; if (Parameters.local) { fileName = StringUtils.substring(filezz.getPath(), StringUtils.lastIndexOf(filezz.getPath(), "\\") + 1); } else { fileName = StringUtils.substring(filezz.getPath(), StringUtils.lastIndexOf(filezz.getPath(), "/") + 1); } int map = Integer.parseInt(StringUtils.left(fileName, fileName.indexOf("_"))); if (map == 0) { continue; } // System.out.println("map: " + map); // System.out.println("loading " + pathFile); // System.out.println("folder is: " + folder.getCanonicalPath()); String term = null; String featureString; String feature; String rule = null; String fields[]; String[] parametersArray; String[] featuresArray; Set<String> featuresSet; Iterator<String> featuresSetIterator; String field0; String field1; String field2; //mapFeatures: //key: a feature //value: a set of parameters for the given feature Multimap<String, Set<String>> mapFeatures; while ((string = br.readLine()) != null) { fields = string.split("\t", -1); mapFeatures = HashMultimap.create(); //sometimes the heuristics is just a term, not followed by a feature or a rule //in this case put a null value to these fields field0 = fields[0].trim(); if (field0.isEmpty()) { continue; } field1 = (fields.length < 2) ? null : fields[1].trim(); field2 = (fields.length < 3) ? null : fields[2].trim(); term = field0; featureString = field1; rule = field2; //parse the "feature" field to disentangle the feature from the parameters //this parsing rule will be extended to allow for multiple features // if (featureString.contains("+++")) { // System.out.println("featureString containing +++ " + featureString); // } featuresArray = featureString.split("\\+\\+\\+"); featuresSet = new HashSet(Arrays.asList(featuresArray)); featuresSetIterator = featuresSet.iterator(); while (featuresSetIterator.hasNext()) { featureString = featuresSetIterator.next(); // System.out.println("featureString: " + featureString); // if (featureString.contains("///")) { // System.out.println("featureString containing ||| " + featureString); // } if (featureString.contains("///")) { parametersArray = StringUtils.substringAfter(featureString, "///").split("\\|"); feature = StringUtils.substringBefore(featureString, "///"); mapFeatures.put(feature, new HashSet(Arrays.asList(parametersArray))); } else { mapFeatures.put(featureString, null); } } // if (term.equals("I was wondering")){ // System.out.println("HERE!!!!"); // } // System.out.println("feature: "+feature); heuristic = new Heuristic(); heuristic.generateNewHeuristic(term, mapFeatures, rule); mapHeuristics.put(term, heuristic); //positive if (map == 1) { mapH1.put(term, heuristic); continue; } //negative if (map == 2) { mapH2.put(term, heuristic); continue; } //strong if (map == 3) { mapH3.put(term, heuristic); continue; } //time if (map == 4) { mapH4.put(term, heuristic); continue; } //question if (map == 5) { mapH5.put(term, heuristic); continue; } //subjective if (map == 6) { mapH6.put(term, heuristic); continue; } //address if (map == 7) { mapH7.put(term, heuristic); continue; } //humor if (map == 8) { mapH8.put(term, heuristic); continue; } //commercial offer if (map == 9) { mapH9.put(term, heuristic); continue; } //negations if (map == 10) { setNegations.add(term); continue; } //hints difficulty if (map == 11) { mapH11.put(term, heuristic); continue; } //time indications if (map == 12) { setTimeTokens.add(term); continue; } //time indications if (map == 13) { mapH13.put(term, heuristic); continue; } //set of terms which look like opinions but are false postives if (map == 12) { setFalsePositiveOpinions.add(term); continue; } //set of terms which look like opinions but are false postives if (map == 15) { setIronicallyPositive.add(term); continue; } //set of moderators if (map == 16) { setModerators.add(term); continue; } } br.close(); } // System.out.println( // "total number heuristics used: " + mapHeuristics.keySet().size()); // System.out.println( // "--------------------------------------------"); // // System.out.println( // "positive tone: " + mapH1.keySet().size()); // System.out.println( // "negative tone: " + mapH2.keySet().size()); // System.out.println( // "strength of opinion: " + mapH3.keySet().size()); // System.out.println( // "time related: " + mapH4.keySet().size()); // System.out.println( // "question: " + mapH5.keySet().size()); // System.out.println( // "self turned: " + mapH6.keySet().size()); // System.out.println( // "humor or light: " + mapH8.keySet().size()); // System.out.println( // "direct address: " + mapH7.keySet().size()); // System.out.println( // "commercial offer: " + mapH9.keySet().size()); catch (IOException ex) { Logger.getLogger(HeuristicsLoader.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:suonos.services.player.mplayer.MPlayerProcessInstance.java
private void process_IDENTIFY(String line) { line = StringUtils.substringAfter(line, "IDENTIFY: "); if (line.startsWith("ID_LENGTH=")) { double len = getNumber(line, "="); playbackInfo.lengthInSecs = len; }// www . j av a 2 s. c o m if (line.startsWith("ID_FILENAME=")) { playbackInfo.fileName = StringUtils.substringAfter(line, "="); } if (line.startsWith("ID_SEEKABLE=")) { playbackInfo.seekable = StringUtils.substringAfter(line, "=").equals("1"); } }