List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:cec.easyshop.storefront.filters.StorefrontFilter.java
protected boolean isSessionNotInitialized(final HttpSession session, final String queryString) { return session.isNew() || StringUtils.contains(queryString, CMSFilter.CLEAR_CMSSITE_PARAM) || !isSessionInitialized(session); }
From source file:com.impetus.client.crud.compositeType.CQLTranslatorTest.java
@Test public void testPrepareColumns() { logger.info("On prepare columns."); CQLTranslator translator = new CQLTranslator(); UUID timeLineId = UUID.randomUUID(); Date currentDate = new Date(); CassandraCompoundKey key = new CassandraCompoundKey("mevivs", 1, timeLineId); CassandraPrimeUser user = new CassandraPrimeUser(key); user.setTweetBody("my first tweet"); user.setTweetDate(currentDate);// www . ja va 2s . c o m EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata( ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), CassandraPrimeUser.class); Map<String, StringBuilder> translatedSql = translator.prepareColumnOrColumnValues(user, entityMetadata, TranslationType.VALUE, null, ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance()) .get(TranslationType.VALUE); String columnAsCsv = "'mevivs',1," + timeLineId /*+ ",'my first tweet','" + currentDate.getTime() + */ /*+ "'"*/; Assert.assertTrue( StringUtils.contains(translatedSql.get(entityMetadata.getTableName()).toString(), columnAsCsv)); // Assert.assertEquals(columnAsCsv, translatedSql); }
From source file:com.impetus.kundera.client.cassandra.composite.DSCQLTranslatorTest.java
@Test public void testPrepareColumns() { logger.info("On prepare columns."); CQLTranslator translator = new CQLTranslator(); UUID timeLineId = UUID.randomUUID(); Date currentDate = new Date(); UserTimeLine key = new UserTimeLine("mevivs", 1, timeLineId); PrimeUser user = new PrimeUser(key); user.setTweetBody("my first tweet"); user.setTweetDate(currentDate);//from ww w .j a v a2s.c o m EntityMetadata entityMetadata = KunderaMetadataManager .getEntityMetadata(((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), PrimeUser.class); Map<String, StringBuilder> translatedSql = translator.prepareColumnOrColumnValues(user, entityMetadata, TranslationType.VALUE, null, ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance()) .get(TranslationType.VALUE); String columnAsCsv = "'mevivs',1," + timeLineId /*+ ",'my first tweet','" + currentDate.getTime() + */ /*+ "'"*/; Assert.assertTrue( StringUtils.contains(translatedSql.get(entityMetadata.getTableName()).toString(), columnAsCsv)); // Assert.assertEquals(columnAsCsv, translatedSql); }
From source file:com.hangum.tadpole.engine.sql.util.sqlscripts.scripts.MSSQL_8_LE_DDLScript.java
@Override public String getTableScript(TableDAO tableDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); List<HashMap> srcList = client.queryForList("getTableScript", tableDAO.getName()); StringBuilder result = new StringBuilder(""); // result.append("/* DROP TABLE " + tableDAO.getName() + " CASCADE CONSTRAINT; */ \n\n"); result.append("CREATE TABLE " + tableDAO.getName() + "( \n"); for (int i = 0; i < srcList.size(); i++) { HashMap<String, Object> source = srcList.get(i); result.append("\t"); if (i > 0) result.append(","); result.append(source.get("COLUMN_NAME")).append(" "); result.append(source.get("DATA_TYPE")); if (source.get("DATA_PRECISION") != null && ((Integer) source.get("DATA_PRECISION")).intValue() > 0) { result.append("(" + source.get("DATA_PRECISION")); if (source.get("DATA_SCALE") != null && ((Integer) source.get("DATA_SCALE")).intValue() > 0) { result.append("," + source.get("DATA_SCALE")); }/*w ww. j a v a 2s . com*/ result.append(")"); } else if (!StringUtils.contains((String) source.get("DATA_TYPE"), "DATE") && !StringUtils.contains((String) source.get("DATA_TYPE"), "NUMBER") && ((Integer) source.get("DATA_LENGTH")).intValue() > 0) { result.append("(" + source.get("DATA_LENGTH") + ")"); } else { result.append(" "); } if (source.get("DATA_DEFAULT") != null) { if (StringUtils.contains((String) source.get("DATA_TYPE"), "CHAR")) { result.append(" DEFAULT '" + (String) source.get("DATA_DEFAULT") + "'"); } else { result.append(" DEFAULT " + (String) source.get("DATA_DEFAULT")); } } if ("NO".equals(source.get("NULLABLE"))) { result.append(" NOT NULL "); } result.append("\n"); } // primary key List<HashMap> srcPkList = client.queryForList("getTableScript.pk", tableDAO.getName()); for (int i = 0; i < srcPkList.size(); i++) { HashMap<String, Object> source = srcPkList.get(i); if (i == 0) { result.append("\t,CONSTRAINT ").append(source.get("CONSTRAINT_NAME")).append(" PRIMARY KEY "); if ("CLUSTERED".equals(source.get("INDEX_TYPE"))) { result.append(" CLUSTERED "); } result.append(" ( ").append(source.get("COLUMN_NAME")); if ((Boolean) source.get("DESCENDING")) { result.append(" DESC "); } } else { result.append(", " + source.get("COLUMN_NAME")); if ((Boolean) source.get("DESCENDING")) { result.append(" DESC "); } } if (i == srcPkList.size() - 1) { result.append(") \n"); } } result.append("); \n\n"); // table, column comments List<String> srcCommentList = client.queryForList("getTableScript.comments", tableDAO.getName()); for (int i = 0; i < srcCommentList.size(); i++) { result.append(srcCommentList.get(i) + "\n"); } // foreign key // column constraint (? ? ) // partition table define // storage option // iot_type table define // table grant // table trigger // table synonyms return result.toString(); }
From source file:com.hangum.tadpole.engine.security.DBPasswordDialog.java
@Override protected void okPressed() { // ? ? .//from ww w . j a v a 2 s.c o m try { userDB.setPasswd(StringUtils.trim(textPassword.getText())); TadpoleSQLManager.getInstance(userDB); } catch (Exception e) { logger.error("test passwd Connection error "); String msg = e.getMessage(); if (StringUtils.contains(msg, "No more data to read from socket")) { MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, msg + CommonMessages.get().Check_DBAccessSystem); } else { MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, msg); } textPassword.setFocus(); return; } super.okPressed(); }
From source file:com.hangum.tadpole.engine.sql.util.sqlscripts.scripts.OracleDDLScript.java
@Override public String getTableScript(TableDAO tableDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); List<HashMap> srcList = client.queryForList("getTableScript", tableDAO.getName()); StringBuilder result = new StringBuilder(""); // result.append("/* DROP TABLE " + tableDAO.getName() + " CASCADE CONSTRAINT; */ \n\n"); result.append("CREATE TABLE " + tableDAO.getName() + "( \n"); for (int i = 0; i < srcList.size(); i++) { HashMap<String, Object> source = srcList.get(i); result.append("\t"); if (i > 0) result.append(","); result.append(source.get("COLUMN_NAME")).append(" "); result.append(source.get("DATA_TYPE")); if (source.get("DATA_PRECISION") != null && ((BigDecimal) source.get("DATA_PRECISION")).intValue() > 0) { result.append("(" + source.get("DATA_PRECISION")); if (source.get("DATA_SCALE") != null && ((BigDecimal) source.get("DATA_SCALE")).intValue() > 0) { result.append("," + source.get("DATA_SCALE")); }//from w w w . j a v a2 s .com result.append(")"); } else if (!StringUtils.contains((String) source.get("DATA_TYPE"), "DATE") && !StringUtils.contains((String) source.get("DATA_TYPE"), "NUMBER") && ((BigDecimal) source.get("DATA_LENGTH")).intValue() > 0) { result.append("(" + source.get("DATA_LENGTH") + ")"); } else { result.append(" "); } if (source.get("DATA_DEFAULT") != null) { if (StringUtils.contains((String) source.get("DATA_TYPE"), "CHAR")) { result.append(" DEFAULT '" + source.get("DATA_DEFAULT") + "'"); } else { result.append(" DEFAULT " + source.get("DATA_DEFAULT")); } } if ("NO".equals(source.get("NULLABLE"))) { result.append(" NOT NULL "); } result.append("\n"); } // primary key List<HashMap> srcPkList = client.queryForList("getTableScript.pk", tableDAO.getName()); for (int i = 0; i < srcPkList.size(); i++) { HashMap<String, Object> source = srcPkList.get(i); if (i == 0) { result.append("\t,CONSTRAINT ").append(source.get("CONSTRAINT_NAME")).append(" PRIMARY KEY ( ") .append(source.get("COLUMN_NAME")); } else { result.append(", " + source.get("COLUMN_NAME")); } if (i == srcPkList.size() - 1) { result.append(") \n"); } } result.append("); \n\n"); // table, column comments List<String> srcCommentList = client.queryForList("getTableScript.comments", tableDAO.getName()); for (int i = 0; i < srcCommentList.size(); i++) { result.append(srcCommentList.get(i) + "\n"); } // foreign key // column constraint (? ? ) // partition table define // storage option // iot_type table define // table grant // table trigger // table synonyms return result.toString(); }
From source file:com.jgeppert.struts2.jquery.showcase.Autocompleter.java
@Actions({ @Action(value = "/autocompleter-select", results = { @Result(location = "autocompleter-select.jsp", name = "success") }), @Action(value = "/autocompleter", results = { @Result(location = "autocompleter.jsp", name = "success") }), @Action(value = "/jsonlanguages", results = { @Result(type = "json", name = "success", params = { "root", "languages" }) }), @Action(value = "/jsoncustomers", results = { @Result(type = "json", name = "success") }) }) public String execute() throws Exception { if (term != null && term.length() > 1) { ArrayList<String> tmp = new ArrayList<String>(); for (int i = 0; i < staticLanguages.length; i++) { if (StringUtils.contains(staticLanguages[i].toLowerCase(), term.toLowerCase())) { tmp.add(staticLanguages[i]); }/*from w w w. j a v a 2 s . c o m*/ } languages = tmp.toArray(new String[tmp.size()]); } return SUCCESS; }
From source file:com.bibisco.export.HTMLParser.java
private static ParagraphAligment getParagraphAlignment(String pStrStyle) { if (StringUtils.contains(pStrStyle, "text-align: center;")) { return ParagraphAligment.CENTER; } else if (StringUtils.contains(pStrStyle, "text-align: right;")) { return ParagraphAligment.RIGHT; } else if (StringUtils.contains(pStrStyle, "text-align: left;")) { return ParagraphAligment.LEFT; }/*ww w. j ava 2s .c o m*/ return ParagraphAligment.JUSTIFY; }
From source file:com.glaf.core.db.DataTableBean.java
/** * ????/*from w ww . j a v a 2 s .c o m*/ * * @param sysDataTable * ? * @param loginContext * * @param ipAddress * IP? */ public void checkPermission(SysDataTable sysDataTable, LoginContext loginContext, String ipAddress) { boolean hasPermission = false; /** * ?????? */ if (!StringUtils.equals(sysDataTable.getAccessType(), "PUB")) { /** * IP??? */ if (StringUtils.isNotEmpty(sysDataTable.getAddressPerms())) { List<String> addressList = StringTools.split(sysDataTable.getAddressPerms()); for (String addr : addressList) { if (StringUtils.equals(ipAddress, addr)) { hasPermission = true; } if (StringUtils.equals(ipAddress, "127.0.0.1")) { hasPermission = true; } if (StringUtils.equals(ipAddress, "localhost")) { hasPermission = true; } if (addr.endsWith("*")) { String tmp = addr.substring(0, addr.indexOf("*")); if (StringUtils.contains(ipAddress, tmp)) { hasPermission = true; } } } if (!hasPermission) { throw new RuntimeException("Permission denied."); } } /** * ??? */ if (StringUtils.isNotEmpty(sysDataTable.getPerms()) && !StringUtils.equalsIgnoreCase(sysDataTable.getPerms(), "anyone")) { if (loginContext.hasSystemPermission() || loginContext.hasAdvancedPermission()) { hasPermission = true; } List<String> permissions = StringTools.split(sysDataTable.getPerms()); for (String perm : permissions) { if (loginContext.getPermissions().contains(perm)) { hasPermission = true; } if (loginContext.getRoles().contains(perm)) { hasPermission = true; } if (StringUtils.isNotEmpty(perm) && StringUtils.isNumeric(perm)) { if (loginContext.getRoleIds().contains(Long.parseLong(perm))) { hasPermission = true; } } } if (!hasPermission) { throw new RuntimeException("Permission denied."); } } } }
From source file:com.adobe.acs.commons.quickly.impl.QuicklyFilter.java
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; if (!accepts(request)) { filterChain.doFilter(servletRequest, servletResponse); return;//from www .jav a 2s . c o m } final BufferingResponse capturedResponse = new BufferingResponse(response); filterChain.doFilter(request, capturedResponse); // Get contents final String contents = capturedResponse.getContents(); if (contents != null && StringUtils.contains(response.getContentType(), "html")) { final int bodyIndex = contents.indexOf("</body>"); if (bodyIndex != -1) { final PrintWriter printWriter = response.getWriter(); printWriter.write(contents.substring(0, bodyIndex)); printWriter.write(appHTML); printWriter.write(contents.substring(bodyIndex)); return; } } if (contents != null) { response.getWriter().write(contents); } }