List of usage examples for org.apache.commons.lang StringUtils replace
public static String replace(String text, String searchString, String replacement)
Replaces all occurrences of a String within another String.
From source file:com.safetys.framework.jmesa.util.ExportUtils.java
/** * Use the view caption for the export. If the caption is not defined then use a default. * //from w w w . j a v a2 s. c om * @param view The view to export. * @param exportType The type of view to export. * @return The file name of export. */ public static String exportFileName(View view, String exportType) { String caption = view.getTable().getCaption(); if (StringUtils.isNotBlank(caption)) { StringUtils.replace(caption, " ", "_"); return caption.toLowerCase() + "." + exportType; } return "table-data." + exportType; }
From source file:com.hangum.tadpole.rdb.erd.core.relation.CubridTableRelation.java
/** * ? relation ?/*from w w w . j av a 2s . co m*/ * * @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(); if (rs.getString("FK_NAME") == null || "".equals(rs.getString("FK_NAME"))) ref.setConstraint_name(rs.getString("FK_NAME")); else ref.setConstraint_name(rs.getString("fk_name")); // Table names if (rs.getString("FKTABLE_NAME") == null || "".equals(rs.getString("FKTABLE_NAME"))) ref.setTable_name(rs.getString("FKTABLE_NAME")); else ref.setTable_name(rs.getString("fktable_name")); if (rs.getString("FKCOLUMN_NAME") == null || "".equals(rs.getString("FKCOLUMN_NAME"))) ref.setColumn_name(rs.getString("FKCOLUMN_NAME")); else ref.setColumn_name(rs.getString("fkcolumn_name")); if (rs.getString("PKTABLE_NAME") == null || "".equals(rs.getString("PKTABLE_NAME"))) ref.setReferenced_table_name(rs.getString("PKTABLE_NAME")); else ref.setReferenced_table_name(rs.getString("pktable_name")); if (rs.getString("PKCOLUMN_NAME") == null || "".equals(rs.getString("PKCOLUMN_NAME"))) ref.setReferenced_column_name(rs.getString("PKCOLUMN_NAME")); else 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.jstar.eclipse.processing.annotations.objects.ImportObject.java
@Override public void generateFile(Writer writer) throws IOException { for (final String specFile : specFiles) { writer.write("import \"" + StringUtils.replace(specFile, ".", "/") + ".spec\";\n"); }/*from ww w .j a va 2 s. com*/ }
From source file:ext.sns.openapi.UserInfo.java
public void setAvatarUrl(String avatarUrl) { String replace = StringUtils.replace(avatarUrl, "\\/", "/"); this.avatarUrl = replace; }
From source file:com.sfs.whichdoctor.xml.writer.helper.WorkshopXmlHelper.java
/** * Output the workshop collection as an XML string. * * @param workshops the workshops// w ww. j ava2s. co m * * @return the xml string */ public static String getWorkshopsXml(final Collection<WorkshopBean> workshops) { final XmlWriter xmlwriter = new XmlWriter(); xmlwriter.writeEntity("workshops"); for (WorkshopBean workshop : workshops) { xmlwriter.writeEntity("workshop").writeAttribute("GUID", workshop.getGUID()) .writeAttribute("workshopId", workshop.getId()); xmlwriter.writeEntity("type").writeText(workshop.getType()).endEntity(); xmlwriter.writeEntity("date").writeText(Formatter.convertDate(workshop.getWorkshopDate())).endEntity(); if (StringUtils.isNotBlank(workshop.getMemo())) { StringBuffer message = new StringBuffer(); message.append("<p>"); message.append(StringUtils.replace(workshop.getMemo(), "\n", "</p><p>")); message.append("</p>"); xmlwriter.writeEntity("message").writeXml(message.toString()).endEntity().endEntity(); } xmlwriter.endEntity(); } xmlwriter.endEntity(); return xmlwriter.getXml(); }
From source file:com.voa.weixin.task.FansInfoTask.java
@Override public void generateUrl() { this.url = StringUtils.replace(this.url, "OPENID", openId); }
From source file:com.bfd.harpc.common.configure.PathUtils.java
/** * Normalize the path by suppressing sequences like "path/.." and inner * simple dots./*from w ww .j a v a 2s. c o m*/ * <p> * The result is convenient for path comparison. For other uses, notice that * Windows separators ("\") are replaced by simple slashes. * * @param path * the original path * @return the normalized path */ public static String cleanPath(String path) { if (StringUtils.isEmpty(path)) { return null; } // ClassLoader.getResource??jar if (path.startsWith("jar:file")) { path = cleanJarPath(path); } String pathToUse = StringUtils.replace(path, ResourceConstants.WINDOWS_FOLDER_SEPARATOR.getValue(), ResourceConstants.FOLDER_SEPARATOR.getValue()); // Strip prefix from path to analyze, to not treat it as part of the // first path element. This is necessary to correctly parse paths like // "file:core/../core/io/Resource.class", where the ".." should just // strip the first "core" directory while keeping the "file:" prefix. int prefixIndex = pathToUse.indexOf(":"); String prefix = ""; if (prefixIndex != -1) { prefix = pathToUse.substring(0, prefixIndex + 1); pathToUse = pathToUse.substring(prefixIndex + 1); } if (pathToUse.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) { prefix = prefix + ResourceConstants.FOLDER_SEPARATOR.getValue(); pathToUse = pathToUse.substring(1); } String[] pathArray = StringUtils.split(pathToUse, ResourceConstants.FOLDER_SEPARATOR.getValue()); List<String> pathElements = new LinkedList<String>(); int tops = 0; for (int i = pathArray.length - 1; i >= 0; i--) { String element = pathArray[i]; if (ResourceConstants.CURRENT_PATH.getValue().equals(element)) { // Points to current directory - drop it. } else if (ResourceConstants.TOP_PATH.getValue().equals(element)) { // Registering top path found. tops++; } else { if (tops > 0) { // Merging path element with element corresponding to top // path. tops--; } else { // Normal path element found. pathElements.add(0, element); } } } // Remaining top paths need to be retained. for (int i = 0; i < tops; i++) { pathElements.add(0, ResourceConstants.TOP_PATH.getValue()); } return prefix + StringUtils.join(pathElements, ResourceConstants.FOLDER_SEPARATOR.getValue()); }
From source file:jetbrick.tools.chm.reader.KeyManager.java
public KeyManager(String key) { this.key = key; this.url = "redirs/" + StringUtils.replace(key, "()", "_") + Math.abs(key.hashCode()) + ".html"; }
From source file:com.taobao.top.common.server.RefundMessageUrlKit.java
public static String perform(String prefixUrl, String dbUrl) { if (StringUtils.isNotEmpty(dbUrl) && dbUrl.length() > 2) { if (StringUtils.isBlank(prefixUrl)) { prefixUrl = DEFAULT_ONLINE_PICTURL; }//from www . ja va 2 s . c om if (!prefixUrl.startsWith(preFix_http)) { prefixUrl = preFix_http + prefixUrl; } int index = prefixUrl.indexOf("."); String target = prefixUrl.substring(0, index) + "0" + getRandomNumber() + prefixUrl.substring(index); target = StringUtils.replace(target, ".taobao.", ".taobaocdn."); if (!target.endsWith(SEP)) { target = target + SEP; } return target + REFUND + SEP + dbUrl; } return null; }
From source file:eionet.cr.dao.helpers.QueryHelper.java
/** * * @param query/*from w ww .j a v a 2 s . c o m*/ * @param bindings * @return */ public static String getFormatedQuery(String query, Bindings bindings) { if (bindings != null) { if (!bindings.getBindings().isEmpty()) { for (String key : bindings.getBindings().keySet()) { String value = bindings.getBindings().get(key).toString(); if (URIUtil.isSchemedURI(value)) { value = "<" + value + ">"; } else { value = "'" + value + "'"; } query = StringUtils.replace(query, "?" + key, key); query = StringUtils.replace(query, key, value); } } } // On some cases the binding value alrady is surrounded by "'", so this removes the redundant apostrophes query = StringUtils.replace(query, "''", "'"); return formatSparqlQuery(query); }