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:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java
/** * other object compile//from w ww.j a va2 s. c o m * * @param actionType * @param objType * @param objName * @param userDB */ public static String otherObjectCompile(PublicTadpoleDefine.QUERY_DDL_TYPE actionType, String objType, String objName, UserDBDAO userDB) throws Exception { // ? DEBUG? ? ? ?. //TODO: DAO? ? ? ?? . Map<String, String> paramMap = new HashMap<String, String>(); if (StringUtils.contains(objName, '.')) { //?? ?? ... paramMap.put("schema_name", StringUtils.substringBefore(objName, ".")); paramMap.put("object_name", SQLUtil.makeIdentifierName(userDB, StringUtils.substringAfter(objName, "."))); paramMap.put("full_name", SQLUtil.makeIdentifierName(userDB, objName)); } else { // ? . paramMap.put("schema_name", userDB.getSchema()); paramMap.put("object_name", SQLUtil.makeIdentifierName(userDB, objName)); paramMap.put("full_name", userDB.getSchema() + "." + SQLUtil.makeIdentifierName(userDB, objName)); } if (PublicTadpoleDefine.QUERY_DDL_TYPE.JAVA == actionType) { //Java object ? ? . return otherObjectCompile(actionType, objType, paramMap, userDB, false); } else { return otherObjectCompile(actionType, objType, paramMap, userDB, userDB.getDBDefine() == DBDefine.ORACLE_DEFAULT); } }
From source file:com.glaf.core.db.DataServiceBean.java
/** * ????/*from ww w. j a v a 2 s . c o m*/ * * @param sysData * ? * @param loginContext * * @param ipAddress * IP? */ public void checkPermission(SysData sysData, LoginContext loginContext, String ipAddress) { boolean hasPermission = false; /** * ?????? */ if (!StringUtils.equals(sysData.getAccessType(), "PUB")) { /** * IP??? */ if (StringUtils.isNotEmpty(sysData.getAddressPerms())) { List<String> addressList = StringTools.split(sysData.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(sysData.getPerms()) && !StringUtils.equalsIgnoreCase(sysData.getPerms(), "anyone")) { if (loginContext.hasSystemPermission() || loginContext.hasAdvancedPermission()) { hasPermission = true; } List<String> permissions = StringTools.split(sysData.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.htmlhifive.tools.codeassist.core.proposal.collector.EventHandlerCollector.java
/** * ??????????????./* w w w .j av a 2 s .c om*/ * * @param field * @return ????? */ protected boolean supportField(IObjectLiteralField field) { // // 1.???? // 2.????????('{rootElement} click' : function()...) // 3.?????? // 4.?null?????? // 5.??????? IExpression fieldName = field.getFieldName(); if (!(fieldName instanceof IStringLiteral)) { return false; } if (!StringUtils.contains(String.valueOf(((IStringLiteral) fieldName).source()), " ")) { return false; } if (!(field.getInitializer() instanceof IFunctionExpression)) { return false; } IFunctionDeclaration functionDec = ((IFunctionExpression) field.getInitializer()).getMethodDeclaration(); return functionDec != null && functionDec.getArguments() != null && functionDec.getArguments().length > 0; }
From source file:hudson.plugins.clearcase.history.FieldFilter.java
public boolean accept(String value) { switch (type) { case Equals://from w w w . j a va2 s.co m return StringUtils.equals(value, patternText); case EqualsIgnoreCase: return StringUtils.equalsIgnoreCase(value, patternText); case NotEquals: return !StringUtils.equals(value, patternText); case NotEqualsIgnoreCase: return !StringUtils.equalsIgnoreCase(value, patternText); case StartsWith: return value != null && value.startsWith(patternText); case StartsWithIgnoreCase: return value != null && value.toLowerCase().startsWith(patternText); case EndsWith: return value != null && value.endsWith(patternText); case EndsWithIgnoreCase: return value != null && value.toLowerCase().endsWith(patternText); case Contains: return StringUtils.contains(value, patternText); case ContainsIgnoreCase: return StringUtils.contains(StringUtils.lowerCase(value), patternText); case DoesNotContain: return !StringUtils.contains(value, patternText); case DoesNotContainIgnoreCase: LOGGER.fine(StringUtils.lowerCase(value) + " <>" + patternText); return !StringUtils.contains(StringUtils.lowerCase(value), patternText); case ContainsRegxp: Matcher m = pattern.matcher(StringUtils.defaultString(value)); return m.find(); case DoesNotContainRegxp: Matcher m2 = pattern.matcher(StringUtils.defaultString(value)); return !m2.find(); } return true; }
From source file:com.googlecode.jtiger.modules.ecside.core.RetrievalUtils.java
static Collection retrieveCollectionFromScope(WebContext context, String collection, String scope) throws Exception { Collection results = null;/* w w w . ja v a2s .co m*/ if (StringUtils.isBlank(collection) || "null".equals(collection)) { if (logger.isDebugEnabled()) { logger.debug("The collection is not defined."); } return Collections.EMPTY_LIST; } if (StringUtils.contains(collection, ".")) { results = retrieveNestedCollection(context, collection, scope); } else { results = retrieveCollectionAsObject(context, collection, scope); } if (results == null) { if (logger.isDebugEnabled()) { logger.debug("Could not find the Collection."); } return Collections.EMPTY_LIST; } return results; }
From source file:it.av.es.service.impl.CustomerServiceHibernate.java
@Override public List<Customer> get(User user, int firstResult, int maxResult, String sortProperty, boolean isAscending) { Criterion critByUser = null;//from w ww .j a v a 2 s.c o m if (!(user.getUserProfile().equals(profileService.getOperatorUserProfile()) || user.getUserProfile().equals(profileService.getAdminUserProfile()))) { critByUser = Restrictions.eq(Customer.USER_FIELD, user); } Order orderByName = null; if (StringUtils.isNotBlank(sortProperty) && !StringUtils.contains(sortProperty, "defaultShippingAddresses")) { if (isAscending) { orderByName = Order.asc(sortProperty); } else { orderByName = Order.desc(sortProperty); } } else { orderByName = Order.asc(Customer.CORPORATENAME_FIELD); } return findByCriteria(orderByName, firstResult, maxResult, critByUser); }
From source file:mitm.common.util.StandardHttpURLBuilder.java
@Override public String buildURL() throws URLBuilderException { String url = baseURL;/*from www. j a va 2 s .c o m*/ if (!StringUtils.contains(url, '?') && parameters.size() > 0) { url = url + '?'; } url = url + buildQueury(); return url; }
From source file:com.jgeppert.struts2.jquery.showcase.Autocompleter.java
public List<Customer> getCustomers() { List<Customer> list = new ArrayList<Customer>(); if (term != null && term.length() > 0) { for (Customer customer : staticCustomers) { if (StringUtils.contains(customer.getName().toLowerCase(), term.toLowerCase())) { list.add(customer);/* w w w. j av a2 s .c o m*/ } } } else { // Return all Customers for Select Box Example return staticCustomers; } return list; }
From source file:com.hangum.tadpole.engine.security.DBLockDialog.java
@Override protected void okPressed() { String strPassword = textPassword.getText(); // ? ? ?? ? . if (PublicTadpoleDefine.YES_NO.NO.name().equals(GetAdminPreference.getSaveDBPassword())) { if (!"".equals(textPassword.getText())) { userDB.setPasswd(CipherManager.getInstance().encryption(textPassword.getText())); } else {/*from w ww .j av a 2 s.c o m*/ userDB.setPasswd(""); } // ? ? . try { TadpoleSQLManager.getInstance(userDB); } catch (Exception e) { 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; } } else if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDB.getIs_lock())) { if (!strPassword.equals(userDB.getPasswd())) { MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, Messages.get().DBLockDialog_3); textPassword.setFocus(); return; } } super.okPressed(); }
From source file:$.MessageLogParser.java
/** * Gets lines from the log file which corresponds with specified correlation ID. */*from w w w . ja v a2 s . c o m*/ * @param correlationId the correlation ID * @param logDate which date to search log files for * @return log lines * @throws IOException when error occurred during file reading */ List<String> getLogLines(String correlationId, Date logDate) throws IOException { File logFolder = new File(logFolderPath); if (!logFolder.exists() || !logFolder.canRead()) { throw new FileNotFoundException("there is no readable log folder - " + logFolderPath); } final String logDateFormatted = fileFormat.format(logDate); // filter log files for current date IOFileFilter nameFilter = new IOFileFilter() { @Override public boolean accept(File file) { return logNameFilter.accept(file) && (StringUtils.contains(file.getName(), logDateFormatted) || file.getName().endsWith(BASE_FILE_EXTENSION)); } @Override public boolean accept(File dir, String name) { return StringUtils.contains(name, logDateFormatted) || name.endsWith(BASE_FILE_EXTENSION); } }; List<File> logFiles = new ArrayList<File>(FileUtils.listFiles(logFolder, nameFilter, null)); Collections.sort(logFiles, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); // go through all log files List<String> logLines = new ArrayList<String>(); for (File logFile : logFiles) { logLines.addAll(getLogLines(logFile, correlationId)); } return logLines; }