public static String unescapeForExcelXML(final String s) { String unescaped = unescapeForXML(s); unescaped = StringUtils.replace(unescaped, " ", "\n"); unescaped = StringUtils.replace(unescaped, "--", "--"); unescaped = StringUtils.replace(unescaped, " ", "\r"); return unescaped; }
public static String escapeForExcelXML(final String s) { String escapedLabel = escapeForXML(s); escapedLabel = StringUtils.replace(escapedLabel, "\n", " "); escapedLabel = StringUtils.replace(escapedLabel, "\r", " "); escapedLabel = StringUtils.replace(escapedLabel, "--", "--"); return escapedLabel; }
/** * 设置下载文件中文件的名称 * * @param filename * @param request * @return */ public static String encodeFilename(String filename, HttpServletRequest request) { /** * 获取客户端浏览器和操作系统信息 在IE浏览器中得到的是:User-Agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; * SV1; Maxthon; Alexa Toolbar) 在Firefox中得到的是:User-Agent=Mozilla/5.0 (Windows; U; Windows NT * 5.1; zh-CN; rv:1.7.10) Gecko/20050717 Firefox/1.0.6 */ String agent = request.getHeader("USER-AGENT"); try { if ((agent != null) && (-1 != agent.indexOf("MSIE"))) { String newFileName = URLEncoder.encode(filename, "UTF-8"); newFileName = StringUtils.replace(newFileName, "+", "%20"); if (newFileName.length() > 150) { newFileName = new String(filename.getBytes("GB2312"), "ISO8859-1"); newFileName = StringUtils.replace(newFileName, " ", "%20"); } return newFileName; } if ((agent != null) && (-1 != agent.indexOf("Mozilla"))) return MimeUtility.encodeText(filename, "UTF-8", "B"); return filename; } catch (Exception ex) { return filename; } }
public String betweenQuery(Condition condition) { if (condition.getType().equals(GridConstant.TYPE_IS_DATETIME)) { String firstValue = "to_date('" + StringUtils.replace(condition.getFirstValue(), "T", " ") + "','yyyy-mm-dd hh24:mi:ss')"; String secondValue = "to_date('" + StringUtils.replace(condition.getSecondValue(), "T", " ") + "','yyyy-mm-dd hh24:mi:ss')"; return getColumnName(condition) + " between " + firstValue + " AND " + secondValue; } else if (condition.getType().equals(GridConstant.TYPE_IS_STRING)) { return getColumnName(condition) + " between '" + condition.getFirstValue() + "' AND '" + condition.getSecondValue() + "'"; } else { return getColumnName(condition) + " between " + condition.getFirstValue() + " AND " + condition.getSecondValue(); } }
private ActionForward getReturnToAwardForward(BudgetForm budgetForm) throws Exception { assert budgetForm != null : "the form is null"; final DocumentService docService = KraServiceLocator.getService(DocumentService.class); Award award = ((AwardDocument) budgetForm.getBudgetDocument().getParentDocument()).getAward(); // find the newest, uncanceled award document to return to String docNumber = budgetForm.getBudgetDocument().getParentDocument().getDocumentNumber(); List<VersionHistory> versions = KraServiceLocator.getService(VersionHistoryService.class) .loadVersionHistory(Award.class, award.getAwardNumber()); for (VersionHistory version : versions) { if (version.getSequenceOwnerSequenceNumber() > award.getSequenceNumber() && version.getStatus() != VersionStatus.CANCELED) { docNumber = ((Award) version.getSequenceOwner()).getAwardDocument().getDocumentNumber(); } } final AwardDocument awardDocument = (AwardDocument) docService.getByDocumentHeaderId(docNumber); String forwardUrl = buildForwardUrl(awardDocument.getDocumentHeader().getWorkflowDocument().getRouteHeaderId()); if (budgetForm.isAuditActivated()) { forwardUrl = StringUtils.replace(forwardUrl, "Award.do?", "Actions.do?"); } // add showAllBudgetVersion to the url to persist that flag until they leave the document forwardUrl = StringUtils.replace( forwardUrl, ".do?", ".do?showAllBudgetVersions=" + budgetForm.isShowAllBudgetVersions() + "&"); return new ActionForward(forwardUrl, true); }
public static String unescapeForXML(final String s) { String unescaped = s; unescaped = StringUtils.replace(unescaped, "<", "<"); unescaped = StringUtils.replace(unescaped, ">", ">"); unescaped = StringUtils.replace(unescaped, """, "\""); unescaped = StringUtils.replace(unescaped, "&", "&"); return unescaped; }
public static String escapeForXML(final String s) { String escapedLabel = s; escapedLabel = StringUtils.replace(escapedLabel, "&", "&"); escapedLabel = StringUtils.replace(escapedLabel, "<", "<"); escapedLabel = StringUtils.replace(escapedLabel, ">", ">"); escapedLabel = StringUtils.replace(escapedLabel, "\"", """); return escapedLabel; }
private void formatAndTest(String compare, String output) { // fix for introduced carriage return / line feeds output = StringUtils.replace(output, "\r", ""); output = StringUtils.replace(output, "\n", ""); output = output.trim(); // System.out.println("Testing [" + compare + "] == [" + output + "]"); assertEquals(compare, output); }
/* * 공통 정규식 후처리는 아래에서 구현하고 * 사이트별 후처리는 사이트별 filter에서 처리하자 * 정규식이 2가지가 될 수 있기에 if 문으로 나누어서 후처리 한다. * 정규식이 1가지만으로 처리 된다면 filterPostprocessing 에 직접 로직을 구현하자. * @see search.crawl.napoli.filter.Filter#filterPostprocessing() */ public Map<String, String> regexpPostprocessing(Map<String, String> result) { result = super.regexpPostprocessing(result); int retState = 1; result.put("section", "질문과답변"); result.put("quesdate", StringUtils.replace(result.get("quesdate"), ".", "-")); // 답변 나누기 String[] ansList = StringUtils.splitByWholeSeparator(result.get("0,a_answerlist"), "<!-- 답변 1시작 -->"); // selectedAnswerCount=0; this.answerCount = ansList.length; int tmpInx = 0; if (this.answerCount > 0) { String selectedString = "<span class=\"tx14_black2\"[^>]*>(.*)<td class=\"tx11_black\"[^>]*>.*" + "등록일 : </b>([^ ]*) ([^ ]*) <font color=\"#7A8AAC\">\\|</font><b> id : </b>([^<]*).*" + "<td class=\"tx13_black\"[^>]*>(.*)<td style=\"padding-bottom:10px;\">"; InterruptibleCharSequence ics = new InterruptibleCharSequence(ansList[0]); Matcher matcher = Pattern.compile(selectedString, Pattern.MULTILINE | Pattern.DOTALL) .matcher(ics.toString()); if (matcher.find()) { result.put("0,a_title", matcher.group(1)); result.put("0,a_date", matcher.group(2)); result.put("0,a_time", matcher.group(2)); result.put("0,a_id", matcher.group(2)); result.put("0,a_bodyhtml", matcher.group(2)); result.put("0,a_date", StringUtils.replace(result.get("0,a_date"), ".", "-")); this.selectedAnswerCount++; tmpInx++; } else { this.answerCount--; } } String a_regexp = "<td height=\"26\" bgcolor=\"F6F6F6\" class=\"tx14_black3\"[^>]*>(.*)<td width=\"5\" height=\"5\"[^>]*>.*" + "등록일 : </b>([^ ]*) ([^ ]*) <font color=\"#7A8AAC\">\\|</font><b> id : </b>([^<]*).*" + "<td class=\"tx13_black\"[^>]*>(.*)<td style=\"padding-bottom:10px;\">"; InterruptibleCharSequence ics = null; Matcher matcher = null; for (int i = tmpInx; i < this.answerCount; i++) { ics = new InterruptibleCharSequence(ansList[i]); matcher = Pattern.compile(a_regexp, Pattern.MULTILINE | Pattern.DOTALL).matcher(ics.toString()); if (matcher.find()) { result.put(i + ",a_title", matcher.group(1)); result.put(i + ",a_date", StringUtils.replace(matcher.group(2), ".", "-")); result.put(i + ",a_time", matcher.group(3)); result.put(i + ",a_id", matcher.group(4)); result.put(i + ",a_bodyhtml", matcher.group(5)); } } result.put("filterstate", "1"); return result; }
private String memberSearchToSql(@Nullable String s) { String sql = null; if (s != null) { sql = StringUtils.replace(StringUtils.upperCase(s), "%", "/%"); sql = StringUtils.replace(sql, "_", "/_"); sql = "%" + sql + "%"; } return sql; }
private static String process(String pattern, VisualStudioProject currentProject) { String output = StringUtils.replace(pattern, ASSEMBLY_NAME_KEY, currentProject.getRealAssemblyName()); output = StringUtils.replace(output, PROJECT_NAME_KEY, currentProject.getName()); output = StringUtils.replace(output, ASSEMBLY_VERSION_KEY, currentProject.getAssemblyVersion()); output = StringUtils.replace(output, OUTPUT_TYPE_KEY, currentProject.getExtension()); output = StringUtils.replace(output, ROOT_NAMESPACE_KEY, currentProject.getRootNamespace()); return output; }
private List<Node> getLastEditedNode(String noOfItem, String showGadgetWs) throws Exception { if (showGadgetWs != null && showGadgetWs.length() > 0) { show_gadget = Boolean.parseBoolean(showGadgetWs); } ArrayList<Node> lstNode = new ArrayList<Node>(); StringBuffer bf = new StringBuffer(1024); List<String> lstNodeType = templateService.getDocumentTemplates(); if (lstNodeType != null) { for (String nodeType : lstNodeType) { bf.append("(") .append(JCR_PRIMARYTYPE) .append("=") .append("'") .append(nodeType) .append("'") .append(")") .append(" OR "); } } if (bf.length() == 1) return null; bf.delete(bf.lastIndexOf("OR") - 1, bf.length()); if (noOfItem == null || noOfItem.trim().length() == 0) noOfItem = String.valueOf(NO_PER_PAGE); String queryStatement = StringUtils.replace(QUERY_STATEMENT, "$0", NT_BASE); queryStatement = StringUtils.replace(queryStatement, "$1", bf.toString()); queryStatement = StringUtils.replace(queryStatement, "$2", DATE_MODIFIED); ManageableRepository manageableRepository = repositoryService.getCurrentRepository(); try { String[] workspaces = manageableRepository.getWorkspaceNames(); List<String> lstWorkspace = new ArrayList<String>(); // Arrays.asList() return fixed size list; lstWorkspace.addAll(Arrays.asList(workspaces)); if (!show_gadget && lstWorkspace.contains(GADGET)) { lstWorkspace.remove(GADGET); } SessionProvider provider = WCMCoreUtils.createAnonimProvider(); QueryImpl query = null; Session session = null; QueryResult queryResult = null; QueryManager queryManager = null; for (String workspace : lstWorkspace) { session = provider.getSession(workspace, manageableRepository); queryManager = session.getWorkspace().getQueryManager(); query = (QueryImpl) queryManager.createQuery(queryStatement, Query.SQL); query.setLimit(Integer.parseInt(noOfItem)); query.setOffset(0); queryResult = query.execute(); puttoList(lstNode, queryResult.getNodes()); session.logout(); } } catch (RepositoryException e) { if (LOG.isErrorEnabled()) { LOG.error("Exception when execute SQL " + queryStatement, e); } } return lstNode; }
private String getSql(String queryName) { String query = SystemGlobals.getSql(queryName); query = StringUtils.replace(query, "${phpbb}", SystemGlobals.getValue(ConfigKeys.DATABASE_PHPBB)); query = StringUtils.replace( query, "${table.prefix}", SystemGlobals.getValue(ConfigKeys.PHPBB_TABLE_PREFIX)); return query; }
/** * Splice sequence, i.e. remove intronic part which has to be in lowercase letters * * @param sequence * @return spliced sequence */ public static String splice(String sequence) { String sequence2 = sequence; sequence2 = StringUtils.replace(sequence2, "a", ""); sequence2 = StringUtils.replace(sequence2, "c", ""); sequence2 = StringUtils.replace(sequence2, "g", ""); sequence2 = StringUtils.replace(sequence2, "t", ""); // TODO: Hardcoded removal of UTR of exon 1 // sequence2 = StringUtils.substring(sequence2, 108); return sequence2; }
private String removeExpressions(String directory) { String value = StringUtils.replace( directory, "${appserver.base}", registry.getString("appserver.base", "${appserver.base}")); value = StringUtils.replace( value, "${appserver.home}", registry.getString("appserver.home", "${appserver.home}")); return value; }
/** * Add RegEx patterns to include/exclude in the report. * * @param patterns RegEx patterns * @param pattern String of RegEx patterns */ private void addPatterns(final Set<Pattern> patterns, final String pattern) { if (StringUtils.isNotBlank(pattern)) { String[] split = StringUtils.split(pattern, ','); for (String singlePattern : split) { String trimmed = StringUtils.trim(singlePattern); String directoriesReplaced = StringUtils.replace(trimmed, "**", "*"); // NOCHECKSTYLE patterns.add( Pattern.compile(StringUtils.replace(directoriesReplaced, "*", ".*"))); // NOCHECKSTYLE } } }
/** @see org.kuali.core.lookup.KualiLookupableImpl#getCreateNewUrl() */ @Override public String getCreateNewUrl() { String url = super.getCreateNewUrl(); url = StringUtils.replace( url, KFSConstants.MAINTENANCE_ACTION, KFSConstants.RICE_PATH_PREFIX + KFSConstants.MAINTENANCE_ACTION); url = StringUtils.replace(url, "images/", KFSConstants.RICE_PATH_PREFIX + "images/"); return url; }
private static void addAllClassPathEntries( TreeLogger logger, ClassLoader classLoader, List<ClassPathEntry> classPath) { // URL is expensive in collections, so we use URI instead // See: http://michaelscharf.blogspot.com/2006/11/javaneturlequals-and-hashcode-make.html Set<URI> seenEntries = new HashSet<URI>(); for (; classLoader != null; classLoader = classLoader.getParent()) { if (classLoader instanceof URLClassLoader) { URLClassLoader urlClassLoader = (URLClassLoader) classLoader; URL[] urls = urlClassLoader.getURLs(); for (URL url : urls) { URI uri; try { // XXX >>> Instantiations // probably bug in GWT: having gwt-user.jar somewhere in path with spaces, url.toURI() // complains on invalid character String urlString = url.toExternalForm(); urlString = StringUtils.replace(urlString, " ", "%20"); urlString = StringUtils.replace(urlString, "file://Users/", "file:/Users/"); try { url = new URL(urlString); } catch (MalformedURLException e) { // ignore } // XXX <<< Instantiations uri = url.toURI(); } catch (URISyntaxException e) { logger.log(TreeLogger.WARN, "Error processing classpath URL '" + url + "'", e); continue; } if (seenEntries.contains(uri)) { continue; } seenEntries.add(uri); Throwable caught; try { ClassPathEntry entry = createEntryForUrl(logger, url); if (entry != null) { classPath.add(entry); } continue; } catch (AccessControlException e) { logger.log(TreeLogger.DEBUG, "Skipping URL due to access restrictions: " + url); continue; } catch (URISyntaxException e) { caught = e; } catch (IOException e) { caught = e; } logger.log(TreeLogger.WARN, "Error processing classpath URL '" + url + "'", caught); } } } }
public static File convertRpmToZip(File file) throws Exception { LOG.info("File: " + file.getAbsolutePath()); FileInputStream fis = new FileInputStream(file); ReadableChannelWrapper in = new ReadableChannelWrapper(Channels.newChannel(fis)); InputStream uncompressed = new GZIPInputStream(fis); in = new ReadableChannelWrapper(Channels.newChannel(uncompressed)); String rpmZipName = file.getName(); rpmZipName = StringUtils.replace(rpmZipName, ".", "-"); rpmZipName = rpmZipName + ".zip"; String rpmZipPath = FilenameUtils.getFullPath(file.getAbsolutePath()); File rpmZipOutput = new File(rpmZipPath + File.separator + rpmZipName); LOG.info("Converting RPM: " + file.getName() + " to ZIP: " + rpmZipOutput.getName()); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(rpmZipOutput)); String rpmName = file.getName(); rpmName = StringUtils.replace(rpmName, ".", "-"); CpioHeader header; int total = 0; do { header = new CpioHeader(); total = header.read(in, total); if (header.getFileSize() > 0) { BoundedInputStream bis = new BoundedInputStream(uncompressed, header.getFileSize()); String relPath = FilenameUtils.separatorsToSystem(header.getName()); relPath = StringUtils.removeStart(relPath, "."); relPath = StringUtils.removeStart(relPath, "/"); relPath = rpmName + File.separator + relPath; relPath = StringUtils.replace(relPath, "\\", "/"); ZipEntry zipEntry = new ZipEntry(relPath); zos.putNextEntry(zipEntry); IOUtils.copy(bis, zos); } else { final int skip = header.getFileSize(); if (uncompressed.skip(skip) != skip) throw new RuntimeException("Skip failed."); } total += header.getFileSize(); } while (!header.isLast()); zos.flush(); zos.close(); return rpmZipOutput; }
/** * Tadpole Editor grant text * * @param initContent * @return */ public static String getGrantText(String initContent) { String strInitContent = initContent; try { strInitContent = StringUtils.replace(initContent, PublicTadpoleDefine.LINE_SEPARATOR, "\\n"); strInitContent = StringUtils.replace(strInitContent, "\"", "'"); } catch (Exception e) { logger.error("Tadpole Editor grant utils", e); } return strInitContent; }
@Override public String formatRawCellContents( double value, int formatIndex, String formatString, boolean use1904Windowing) { // TDP-1656 (olamy) for some reasons poi use date format with only 2 digits for years // even the excel data ws using 4 so force the pattern here if (DateUtil.isValidExcelDate(value) && StringUtils.countMatches(formatString, "y") == 2) { formatString = StringUtils.replace(formatString, "yy", "yyyy"); } if (DateUtil.isValidExcelDate(value) && StringUtils.countMatches(formatString, "Y") == 2) { formatString = StringUtils.replace(formatString, "YY", "YYYY"); } return super.formatRawCellContents(value, formatIndex, formatString, use1904Windowing); }
/** * Escapes the given string so that it can be used as an argument to a method in the acceptance * test framework. * * <p>Examples: * basic -> basic * two words -> "two words" * with"quote -> "with\"quote" * * with\backslash -> with\\backslash * null -> null * (nothing) -> "" * * @param s, the String to escape and quote. * @return the escaped and quoted version of the input. */ public static String escapeAndQuoteForTestArg(String s) { if (null == s) { return "null"; } s = StringUtils.replace(s, "\\", "\\\\"); s = StringUtils.replace(s, "\"", "\\\""); if (s.isEmpty() || s.contains(" ") || s.contains("\"")) { // We have to make sure to put quotes if the String is empty, // because it would be ignored otherwise. s = '"' + s + '"'; } return s; }
public String createEPTemplate(String templateContent, String type) throws IOException { String newContent = ""; if (type.equals("Sequence Template")) { newContent = MessageFormat.format(templateContent, templateModel.getTemplateName()); } else { templateContent = templateContent.replaceAll("\\{", "<"); templateContent = templateContent.replaceAll("\\}", ">"); newContent = StringUtils.replace(templateContent, "<ep.name>", templateModel.getTemplateName()); if (type.equals("Address Endpoint Template")) { newContent = StringUtils.replace(newContent, "<address.uri>", templateModel.getAddressEPURI()); } else if (type.equals("WSDL Endpoint Template")) { newContent = StringUtils.replace(newContent, "<wsdl.uri>", templateModel.getWsdlEPURI()); newContent = StringUtils.replace(newContent, "<service.name>", templateModel.getWsdlEPService()); newContent = StringUtils.replace(newContent, "<service.port>", templateModel.getWsdlEPPort()); } else if (type.equals("HTTP Endpoint Template")) { newContent = StringUtils.replace( newContent, "<http.uritemplate>", templateModel.getHttpUriTemplate()); if (!HttpMethodType.Leave_as_is.name().equals(templateModel.getHttpMethod().name())) { newContent = StringUtils.replace( newContent, "<http.method>", templateModel.getHttpMethod().name().toLowerCase()); } else { newContent = StringUtils.replace(newContent, "<http.method>", ""); } } } return newContent; }
/** {@inheritDoc} */ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException { Colorpicker cp = (Colorpicker) w; String snippetName = "colorpicker"; String snippet = getSnippet(snippetName); // set the default send-update frequency to 200ms String frequency = cp.getFrequency() == 0 ? "200" : Integer.toString(cp.getFrequency()); // get RGB hex value State state = itemUIRegistry.getState(cp); String hexValue = "#ffffff"; if (state instanceof HSBType) { HSBType hsbState = (HSBType) state; Color color = hsbState.toColor(); hexValue = "#" + Integer.toHexString(color.getRGB()).substring(2); } String label = getLabel(cp); String purelabel = label; if (label.contains("<span>")) { purelabel = purelabel.substring(0, label.indexOf("<span>")); } snippet = StringUtils.replace(snippet, "%id%", itemUIRegistry.getWidgetId(cp)); snippet = StringUtils.replace(snippet, "%icon%", escapeURLPath(itemUIRegistry.getIcon(cp))); snippet = StringUtils.replace(snippet, "%item%", w.getItem()); snippet = StringUtils.replace(snippet, "%label%", label); snippet = StringUtils.replace(snippet, "%purelabel%", purelabel); snippet = StringUtils.replace(snippet, "%state%", hexValue); snippet = StringUtils.replace(snippet, "%frequency%", frequency); snippet = StringUtils.replace(snippet, "%servletname%", WebAppServlet.SERVLET_NAME); String style = ""; String color = itemUIRegistry.getLabelColor(w); if (color != null) { style = "color:" + color; } snippet = StringUtils.replace(snippet, "%labelstyle%", style); style = ""; color = itemUIRegistry.getValueColor(w); if (color != null) { style = "color:" + color; } snippet = StringUtils.replace(snippet, "%valuestyle%", style); sb.append(snippet); return null; }
/** {@inheritDoc} */ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException { Slider s = (Slider) w; String snippetName = "slider"; String snippet = getSnippet(snippetName); // set the default send-update frequency to 200ms String frequency = s.getFrequency() == 0 ? "200" : Integer.toString(s.getFrequency()); snippet = StringUtils.replace(snippet, "%id%", itemUIRegistry.getWidgetId(s)); snippet = StringUtils.replace(snippet, "%icon%", escapeURLPath(itemUIRegistry.getIcon(s))); snippet = StringUtils.replace(snippet, "%item%", w.getItem()); snippet = StringUtils.replace(snippet, "%label%", getLabel(s)); snippet = StringUtils.replace(snippet, "%state%", itemUIRegistry.getState(s).toString()); snippet = StringUtils.replace(snippet, "%frequency%", frequency); snippet = StringUtils.replace(snippet, "%switch%", s.isSwitchEnabled() ? "1" : "0"); snippet = StringUtils.replace(snippet, "%servletname%", WebAppServlet.SERVLET_PATH); // Process the color tags snippet = processColor(w, snippet); sb.append(snippet); return null; }
private String normalizePath(String path) { // remove double slashes & backslashes path = StringUtils.replace(path, "//", "/"); if (Path.WINDOWS) { path = StringUtils.replace(path, "\\", "/"); } // trim trailing slash from non-root path (ignoring windows drive) int minLength = hasWindowsDrive(path, true) ? 4 : 1; if (path.length() > minLength && path.endsWith("/")) { path = path.substring(0, path.length() - 1); } return path; }
private void writeToCellFormatted(HSSFCell cell, String value) { double numeric = NON_NUMERIC; // try { // numeric = Double.parseDouble(value); // } catch (Exception e) { // numeric = NON_NUMERIC; // } if (value.startsWith("$") || value.endsWith("%") || value.startsWith("($")) { boolean moneyFlag = (value.startsWith("$") || value.startsWith("($")); boolean percentFlag = value.endsWith("%"); value = StringUtils.replace(value, "$", ""); value = StringUtils.replace(value, "%", ""); value = StringUtils.replace(value, ",", ""); value = StringUtils.replace(value, "(", "-"); value = StringUtils.replace(value, ")", ""); try { numeric = Double.parseDouble(value); } catch (Exception e) { numeric = NON_NUMERIC; } cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); if (moneyFlag) { // format money cell.setCellStyle((HSSFCellStyle) styles.get("moneyStyle")); } else if (percentFlag) { // format percent numeric = numeric / 100; cell.setCellStyle((HSSFCellStyle) styles.get("percentStyle")); } } else if (numeric != NON_NUMERIC) { // format numeric cell.setCellStyle((HSSFCellStyle) styles.get("numericStyle")); } else { // format text if (value.trim().equals(NBSP)) { value = ""; } cell.setCellStyle((HSSFCellStyle) styles.get("textStyle")); } fixWidthAndPopulate(cell, numeric, value); }
/** * This will build the target string that you can use to substitute the original with. * * @param map The map of values to hole keys. * @param grammar_r The grammar item which will have the values plugged into the "holes". * @return The final expression ready for substitution. */ String populateTargetString(final Map map, String grammar_r) { for (final Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { final String key = (String) iter.next(); grammar_r = StringUtils.replace(grammar_r, key, (String) map.get(key)); } return grammar_r; }
private void initializeSourceFileMap() { Map<File, SourceFile> allFiles = new LinkedHashMap<File, SourceFile>(); // Case of a regular project if (projectFile != null) { List<String> filesPath = ModelFactory.getFilesPath(projectFile); for (String filePath : filesPath) { try { // We build the file and retrieves its canonical path File file = new File(directory, filePath).getCanonicalFile(); String fileName = file.getName(); String folder = StringUtils.replace( StringUtils.removeEnd(StringUtils.removeEnd(filePath, fileName), "\\"), "\\", "/"); SourceFile sourceFile = new SourceFile(this, file, folder, fileName); allFiles.put(file, sourceFile); } catch (IOException e) { LOG.error("Bad file :" + filePath, e); } } } else { // For web projects, we take all the C# files List<File> csharpFiles = listRecursiveFiles(directory, ".cs"); for (File file : csharpFiles) { SourceFile sourceFile = new SourceFile(this, file, file.getParent(), file.getName()); allFiles.put(file, sourceFile); } } this.sourceFileMap = allFiles; }
private void addJsonAnnotations(ModelAndView mav, String style, boolean prefix) { if (prefix) { mav.addObject("mapPrefix", "map"); mav.addObject("mimetype", "application/x-javascript"); } else { mav.addObject("mimetype", "application/json"); } List<ConceptAnnotation> annotations = (List<ConceptAnnotation>) mav.getModel().get("annotations"); if (annotations != null) { JSONArray mappings = new JSONArray(); for (ConceptAnnotation annotation : annotations) { JSONObject mapping = new JSONObject(); mapping.accumulate("id", String.valueOf(annotation.getOid())); mapping.accumulate("start", String.valueOf(annotation.getBegin())); mapping.accumulate("end", String.valueOf(annotation.getEnd())); mapping.accumulate("pname", annotation.getPname()); mapping.accumulate("group", annotation.getStygroup()); mapping.accumulate("codes", StringUtils.replace(annotation.getStycodes(), "\"", "")); mapping.accumulate("text", annotation.getCoveredText()); mappings.put(mapping); } mav.addObject( "stringAnnotations", "pretty".equals(style) ? mappings.toString(2) : mappings.toString()); } }