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:edu.ku.brc.specify.dbsupport.SpecifyQueryAdjusterForDomain.java
@Override public String adjustSQL(final String sql) { AppPreferences locPrefs = AppPreferences.getLocalPrefs(); boolean doGlobalSearch = permsOKForGlobalSearch && locPrefs.getBoolean("GLOBAL_SEARCH_AVAIL", false) && locPrefs.getBoolean("GLOBAL_SEARCH", false); //divisionCnt++; //disciplineCnt++; //collectionCnt++; // SpecifyUser should NEVER be null nor the Id ! SpecifyUser user = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); if (user != null) { Integer id = user.getId(); if (id != null) { String adjSQL = sql;//from w w w . j a va 2 s .c o m if (StringUtils.contains(adjSQL, SPECIFYUSERID)) { adjSQL = StringUtils.replace(adjSQL, SPECIFYUSERID, Integer.toString(id)); } if (StringUtils.contains(adjSQL, DIVID)) { String adjustedSQL = null; if (doGlobalSearch || divisionCnt == 1) { adjustedSQL = removeSpecialFilter(adjSQL, DIVID); } if (adjustedSQL == null) { Integer divId = null; Division division = AppContextMgr.getInstance().getClassObject(Division.class); if (division != null) { divId = division.getId(); } else { divId = Agent.getUserAgent().getDivision() != null ? Agent.getUserAgent().getDivision().getDivisionId() : null; } if (divId != null) { adjSQL = StringUtils.replace(adjSQL, DIVID, Integer.toString(divId)); } } else { adjSQL = adjustedSQL; } } //System.out.println(adjSQL); if (StringUtils.contains(adjSQL, COLMEMID)) { String adjustedSQL = null; if (doGlobalSearch || collectionCnt == 1) { adjustedSQL = removeSpecialFilter(adjSQL, COLMEMID); } if (adjustedSQL == null) { Collection collection = AppContextMgr.getInstance().getClassObject(Collection.class); if (collection != null) { adjSQL = StringUtils.replace(adjSQL, COLMEMID, Integer.toString(collection.getCollectionId())); } } else { adjSQL = adjustedSQL; } } if (StringUtils.contains(adjSQL, COLLID)) { String adjustedSQL = null; if (doGlobalSearch || collectionCnt == 1) { adjustedSQL = removeSpecialFilter(adjSQL, COLLID); } if (adjustedSQL == null) { Collection collection = AppContextMgr.getInstance().getClassObject(Collection.class); if (collection != null) { adjSQL = StringUtils.replace(adjSQL, COLLID, Integer.toString(collection.getCollectionId())); } } else { adjSQL = adjustedSQL; } } if (StringUtils.contains(adjSQL, DSPLNID)) { String adjustedSQL = null; if (doGlobalSearch || disciplineCnt == 1) { adjustedSQL = removeSpecialFilter(adjSQL, DSPLNID); } if (adjustedSQL == null) { Discipline discipline = AppContextMgr.getInstance().getClassObject(Discipline.class); if (discipline != null) { adjSQL = StringUtils.replace(adjSQL, DSPLNID, Integer.toString(discipline.getDisciplineId())); } } else { adjSQL = adjustedSQL; } } if (StringUtils.contains(adjSQL, TAXTREEDEFID)) { TaxonTreeDef taxonTreeDef = AppContextMgr.getInstance().getClassObject(TaxonTreeDef.class); if (taxonTreeDef != null) { adjSQL = StringUtils.replace(adjSQL, TAXTREEDEFID, Integer.toString(taxonTreeDef.getTaxonTreeDefId())); } } if (StringUtils.contains(adjSQL, GTPTREEDEFID)) { GeologicTimePeriodTreeDef gtpTreeDef = AppContextMgr.getInstance() .getClassObject(GeologicTimePeriodTreeDef.class); if (gtpTreeDef != null) { adjSQL = StringUtils.replace(adjSQL, GTPTREEDEFID, Integer.toString(gtpTreeDef.getGeologicTimePeriodTreeDefId())); } else { return null; } } if (StringUtils.contains(adjSQL, STORTREEDEFID)) { StorageTreeDef locTreeDef = AppContextMgr.getInstance().getClassObject(StorageTreeDef.class); if (locTreeDef != null) { adjSQL = StringUtils.replace(adjSQL, STORTREEDEFID, Integer.toString(locTreeDef.getStorageTreeDefId())); } } if (StringUtils.contains(adjSQL, LITHOTREEDEFID)) { LithoStratTreeDef lithoTreeDef = AppContextMgr.getInstance() .getClassObject(LithoStratTreeDef.class); if (lithoTreeDef != null) { adjSQL = StringUtils.replace(adjSQL, LITHOTREEDEFID, Integer.toString(lithoTreeDef.getLithoStratTreeDefId())); } else { return null; } } if (StringUtils.contains(adjSQL, GEOTREEDEFID)) { GeographyTreeDef lithoTreeDef = AppContextMgr.getInstance() .getClassObject(GeographyTreeDef.class); if (lithoTreeDef != null) { adjSQL = StringUtils.replace(adjSQL, GEOTREEDEFID, Integer.toString(lithoTreeDef.getGeographyTreeDefId())); } } return adjSQL; } throw new RuntimeException("The SpecifyUser ID cannot be null!"); } else { throw new RuntimeException("The SpecifyUser cannot be null!"); } }
From source file:com.iyonger.apm.web.model.AgentManager.java
private Set<AgentIdentity> checkAgentAvailable(User user, Set<AgentIdentity> allFreeAgents, Set<AgentIdentity> useAgents) { Set<AgentIdentity> agentIdentities = new HashSet<AgentIdentity>(); for (AgentIdentity each : allFreeAgents) { String region = ((AgentControllerIdentityImplementation) each).getRegion(); if (StringUtils.endsWith(region, "owned_" + user.getUserId()) || !StringUtils.contains(region, "owned_")) { if (useAgents.contains(each)) { agentIdentities.add(each); }/*from ww w. jav a 2 s. com*/ } } return agentIdentities; }
From source file:com.gcrm.action.crm.ListAccountAction.java
protected SearchCondition getSearchCondition(Map<String, String> fieldTypeMap, int scope, User loginUser) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); StringBuilder condition = new StringBuilder(""); // SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DATE_SIMPLE_FORMAT); if (StringUtils.isEmpty(assignTo)) { condition.append("assigned_to").append(" in ( ").append(String.valueOf(loginUser.getId())).append(" )"); }//from w ww . j av a 2 s .c om if (super.getFilters() != null && super.getFilters().trim().length() > 0) { advancedSearch(condition); } else { HashMap parameters = (HashMap) request.getParameterMap(); Iterator iterator = parameters.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String[] value = ((String[]) parameters.get(key)); // TODO:? // String val = new String(value[0].getBytes("iso8859-1")); String val = value[0]; if (value == null || StringUtils.isEmpty(value[0])) { continue; } if (!BaseListAction.GRID_FIELD_SET.contains(key)) { if (StringUtils.equals(key, "mallbdLevels")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("mallbd_level").append(" in ("); for (int i = 0; i < value.length; i++) { condition.append("'").append(value[i]).append("'"); if (i < (value.length - 1)) { condition.append(","); } } condition.append(")"); } else if (StringUtils.equals(key, "advertLevels")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("advert_level").append(" in ("); for (int i = 0; i < value.length; i++) { condition.append("'").append(value[i]).append("'"); if (i < (value.length - 1)) { condition.append(","); } } condition.append(")"); } else if (StringUtils.equals(key, "intentNames")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("accountIntent").append(" in (").append(StringUtils.join(value, ",")) .append(" )"); } else if (StringUtils.equals(key, "visitNames")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("accountVisit").append(" in (").append(StringUtils.join(value, ",")) .append(" )"); } else if (StringUtils.equals(key, "accountTypes")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("account_type").append(" in (").append(StringUtils.join(value, ",")) .append(" )"); } else if (StringUtils.equals(key, "assignTo")) { if (StringUtils.equalsIgnoreCase("all", val)) { continue; } if (condition.length() != 0) { condition.append(" AND "); } String assignedToStr = null; if (StringUtils.equalsIgnoreCase("self", val)) { // assignedToStr = String.valueOf(loginUser.getId()); } else if (StringUtils.equals(val, "underling")) { // List<Integer> userIdList = new ArrayList<Integer>(); String hql = "from User where report_to = " + loginUser.getId(); underlingUsers = userService.findByHQL(hql); if (underlingUsers == null || underlingUsers.isEmpty()) { return null; } for (User u : underlingUsers) { userIdList.add(u.getId()); } assignedToStr = StringUtils.join(userIdList, ","); } else if (StringUtils.equals(val, "selfAndunderling")) { // ? List<Integer> userIdList = new ArrayList<Integer>(); String hql = "from User where report_to = " + loginUser.getId(); underlingUsers = userService.findByHQL(hql); for (User u : underlingUsers) { userIdList.add(u.getId()); } userIdList.add(loginUser.getId()); assignedToStr = StringUtils.join(userIdList, ","); } else if (NumberUtils.toInt(val) != 0) { // ? assignedToStr = val; } if (assignedToStr != null) { condition.append("assigned_to").append(" in ( ").append(assignedToStr).append(" )"); } } else if (StringUtils.equals(key, "detailAddress")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("(province").append(" like '%").append(val).append("%'"); condition.append(" or ").append("city").append(" like '%").append(val).append("%'"); condition.append(" or ").append("district").append(" like '%").append(val).append("%'"); condition.append(" or ").append("address").append(" like '%").append(val).append("%')"); } else if (StringUtils.equals(key, "account.province")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("(province").append(" like '%").append(val).append("%')"); } else if (StringUtils.equals(key, "account.city")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("(city").append(" like '%").append(val).append("%')"); } else if (StringUtils.equals(key, "account.district")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("(district").append(" like '%").append(val).append("%')"); } else if (StringUtils.equals(key, "startAssignDate")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("updated_on").append(" >= '").append(val).append("' "); } else if (StringUtils.equals(key, "endAssignDate")) { if (condition.length() != 0) { condition.append(" AND "); } condition.append("updated_on").append(" <= '").append(val).append("' "); } else { if (condition.length() != 0) { condition.append(" AND "); } if (NumberUtils.toFloat(val) != 0.0f) { condition.append(key).append(" = ").append(val); } else { if (StringUtils.contains(val, ">")) { int index = val.indexOf(">"); String v = val.substring(index + 1); condition.append(key).append(" > ").append(v.trim()); } else if (StringUtils.contains(val, "<")) { int index = val.indexOf("<"); String v = val.substring(index + 1); condition.append(key).append(" < ").append(v.trim()); } else { condition.append(key).append(" like '%").append(val).append("%'"); } } } } } } // if (scope == Role.OWNER_OR_DISABLED) { // if (condition.length() != 0) { // condition.append(" AND "); // } // condition.append("owner = ").append(loginUser.getId()); // } int pageNo = super.getPage(); if (pageNo == 0) { pageNo = 1; } int pageSize = super.getRows(); if (pageSize == 0) { pageSize = 1; } super.setSidx("assigned_date"); super.setSord("desc"); SearchCondition searchCondition = new SearchCondition(pageNo, pageSize, super.getSidx(), super.getSord(), condition.toString()); return searchCondition; }
From source file:com.prowidesoftware.swift.model.Tag.java
/** * Tell if this tag value contains any of the given values. * This method is case sensitive. It handles null values. * Actual test is delegated to {@link StringUtils#contains(String,String)} * @param values variable list of values to test * @return <code>true</code> if the value of this tag is one of the given values. * returns <code>false</code> in any other case, including a null or empty list of values *//*from www . j ava2s. c o m*/ public boolean contains(String... values) { if (values != null && values.length > 0) { final String _v = getValue(); for (String v : values) { if (StringUtils.contains(_v, v)) { return true; } } } return false; }
From source file:com.impetus.client.mongodb.query.MongoDBQuery.java
/** * Creates MongoDB Query object from filterClauseQueue. * /*www . j av a2 s .c o m*/ * @param m * the m * @param filterClauseQueue * the filter clause queue * @return the basic db object */ public BasicDBObject createSubMongoQuery(EntityMetadata m, Queue filterClauseQueue) { BasicDBObject query = new BasicDBObject(); BasicDBObject compositeColumns = new BasicDBObject(); MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata() .getMetamodel(m.getPersistenceUnit()); AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(m.getEntityClazz()); for (Object object : filterClauseQueue) { boolean isCompositeColumn = false; boolean isSubCondition = false; if (object instanceof FilterClause) { FilterClause filter = (FilterClause) object; String property = filter.getProperty(); String condition = filter.getCondition(); Object value = filter.getValue().get(0); // value is string but field.getType is different, then get // value using Field f = null; // if alias is still present .. means it is an enclosing // document search. if (managedType.hasLobAttribute()) { EntityType entity = metaModel.entity(m.getEntityClazz()); String fieldName = m.getFieldName(property); f = (Field) entity.getAttribute(fieldName).getJavaMember(); if (value.getClass().isAssignableFrom(String.class) && f != null && !f.getType().equals(value.getClass())) { value = PropertyAccessorFactory.getPropertyAccessor(f).fromString(f.getType().getClass(), value.toString()); } value = MongoDBUtils.populateValue(value, value.getClass()); property = "metadata." + property; } else { if (((AbstractAttribute) m.getIdAttribute()).getJPAColumnName().equalsIgnoreCase(property)) { property = "_id"; f = (Field) m.getIdAttribute().getJavaMember(); if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && value.getClass().isAssignableFrom(f.getType())) { EmbeddableType compoundKey = metaModel .embeddable(m.getIdAttribute().getBindableJavaType()); compositeColumns = MongoDBUtils.getCompoundKeyColumns(m, value, compoundKey); isCompositeColumn = true; continue; } } else if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && StringUtils.contains(property, '.')) { // Means it is a case of composite column. property = property.substring(property.indexOf(".") + 1); isCompositeColumn = true; } /* * if a composite key. "." assuming "." is part of * property in case of embeddable only */ else if (StringUtils.contains(property, '.')) { EntityType entity = metaModel.entity(m.getEntityClazz()); StringTokenizer tokenizer = new StringTokenizer(property, "."); String embeddedAttributeAsStr = tokenizer.nextToken(); String embeddableAttributeAsStr = tokenizer.nextToken(); Attribute embeddedAttribute = entity.getAttribute(embeddedAttributeAsStr); EmbeddableType embeddableEntity = metaModel .embeddable(((AbstractAttribute) embeddedAttribute).getBindableJavaType()); f = (Field) embeddableEntity.getAttribute(embeddableAttributeAsStr).getJavaMember(); property = ((AbstractAttribute) embeddedAttribute).getJPAColumnName() + "." + ((AbstractAttribute) embeddableEntity.getAttribute(embeddableAttributeAsStr)) .getJPAColumnName(); } else { EntityType entity = metaModel.entity(m.getEntityClazz()); String discriminatorColumn = ((AbstractManagedType) entity).getDiscriminatorColumn(); if (!property.equals(discriminatorColumn)) { String fieldName = m.getFieldName(property); f = (Field) entity.getAttribute(fieldName).getJavaMember(); } } if (value.getClass().isAssignableFrom(String.class) && f != null && !f.getType().equals(value.getClass())) { value = PropertyAccessorFactory.getPropertyAccessor(f).fromString(f.getType().getClass(), value.toString()); } value = MongoDBUtils.populateValue(value, value.getClass()); } // Property, if doesn't exist in entity, may be there in a // document embedded within it, so we have to check that // TODO: Query should actually be in a format // documentName.embeddedDocumentName.column, remove below if // block once this is decided // Query could be geospatial in nature if (f != null && f.getType().equals(Point.class)) { GeospatialQuery geospatialQueryimpl = GeospatialQueryFactory .getGeospatialQueryImplementor(condition, value); query = (BasicDBObject) geospatialQueryimpl.createGeospatialQuery(property, value, query); } else { if (isCompositeColumn) { EmbeddableType embeddableType = metaModel .embeddable(m.getIdAttribute().getBindableJavaType()); AbstractAttribute attribute = (AbstractAttribute) embeddableType.getAttribute(property); property = new StringBuffer("_id.").append(attribute.getJPAColumnName()).toString(); } if (condition.equals("=")) { query.append(property, value); } else if (condition.equalsIgnoreCase("like")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$regex", createLikeRegex((String) value))); } else { query.append(property, new BasicDBObject("$regex", createLikeRegex((String) value))); } } else if (condition.equalsIgnoreCase(">")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$gt", value)); } else { query.append(property, new BasicDBObject("$gt", value)); } } else if (condition.equalsIgnoreCase(">=")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$gte", value)); } else { query.append(property, new BasicDBObject("$gte", value)); } } else if (condition.equalsIgnoreCase("<")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$lt", value)); } else { query.append(property, new BasicDBObject("$lt", value)); } } else if (condition.equalsIgnoreCase("<=")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$lte", value)); } else { query.append(property, new BasicDBObject("$lte", value)); } } else if (condition.equalsIgnoreCase("in")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$in", filter.getValue())); } else { query.append(property, new BasicDBObject("$in", filter.getValue())); } } else if (condition.equalsIgnoreCase("not in")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$nin", filter.getValue())); } else { query.append(property, new BasicDBObject("$nin", filter.getValue())); } } else if (condition.equalsIgnoreCase("<>")) { if (query.containsField(property)) { query.get(property); query.put(property, ((BasicDBObject) query.get(property)).append("$ne", value)); } else { query.append(property, new BasicDBObject("$ne", value)); } } } // TODO: Add support for other operators like >, <, >=, <=, // order by asc/ desc, limit, skip, count etc } } if (!compositeColumns.isEmpty()) { query.append("_id", compositeColumns); } return query; }
From source file:hydrograph.ui.common.property.util.Utils.java
private void getParamMap(List<File> FileNameList, IFile jobFile) { String activeProjectName = null; InputStream reader = null;/*from ww w . j a va 2 s .c om*/ String propFilePath = null; if (jobFile == null) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput(); IFile file = input.getFile(); activeProjectName = file.getProject().getName(); } else { activeProjectName = jobFile.getProject().getName(); } for (File propFileName : FileNameList) { if (!propFileName.isDirectory()) { String fileName = propFileName.getName(); if (StringUtils.contains(propFileName.toString(), "globalparam")) { propFilePath = "/" + activeProjectName + "/globalparam" + "/" + fileName; } else { propFilePath = "/" + activeProjectName + "/param" + "/" + fileName; } } if (propFilePath != null) { IPath propPath = new Path(propFilePath); IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(propPath); try { reader = iFile.getContents(); jobProps.load(reader); } catch (CoreException | IOException e) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "Exception occured while loading build properties from file -\n" + e.getMessage()); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioException) { ioException.printStackTrace(); } } } } Enumeration<?> e = jobProps.propertyNames(); paramsMap = new HashMap<String, String>(); while (e.hasMoreElements()) { String param = (String) e.nextElement(); paramsMap.put(param, jobProps.getProperty(param)); } } }
From source file:edu.ku.brc.specify.datamodel.DataModelObjBase.java
/** * @param ref/*from w w w.j a va 2 s. co m*/ * @param fieldName * @param doOtherSide */ public void addReference(final FormDataObjIFace ref, final String fieldName, final boolean doOtherSide) { if (ref == null) { return; } // Note that this method uses local members for the parent data object the field name. // This is because they may need to be adjusted when using '.' notation. String fldName = fieldName; FormDataObjIFace parentDataObject = this; // Check for DOT notation for setting a child // If so then we need to walk the list finding the 'true' parent of the last // item in the hierarchy list, and the let it continue with the 'adjusted' parent and // the 'real' field name (the name after the last '.') if (StringUtils.contains(fldName, '.')) { // Get the list of data objects to walk and // create a new list without the last member String[] fieldNames = StringUtils.split(fldName, '.'); String[] parentPath = new String[fieldNames.length - 1]; for (int i = 0; i < parentPath.length; i++) { parentPath[i] = fieldNames[i]; } // Now go get the 'true' parent of the incoming reference by walk the hierarchy DataObjectGettable getter = DataObjectGettableFactory.get(getClass().getName(), FormHelper.DATA_OBJ_GETTER); Object[] values = UIHelper.getFieldValues(parentPath, this, getter); parentDataObject = (FormDataObjIFace) values[parentPath.length - 1]; // Set the field name to the last item in the original list fldName = fieldNames[fieldNames.length - 1]; } DBTableInfo tblInfo = DBTableIdMgr.getInstance().getInfoById(parentDataObject.getTableId()); if (tblInfo != null) { DBRelationshipInfo rel = tblInfo.getRelationshipByName(fldName); if (rel != null) { Boolean isJavaCollection = isJavaCollection(parentDataObject, fldName); if (isJavaCollection != null) { String otherSide = rel.getOtherSide(); if (isJavaCollection) { addToCollection(parentDataObject, fldName, ref); if (StringUtils.isNotEmpty(otherSide) && doOtherSide) { Boolean isOtherSideCollection = isJavaCollection(ref, otherSide); if (isOtherSideCollection != null && isOtherSideCollection) { addToCollection(ref, otherSide, parentDataObject); } else { DataObjectSettable setter = DataObjectSettableFactory.get(ref.getClass().getName(), FormHelper.DATA_OBJ_SETTER); setter.setFieldValue(ref, otherSide, parentDataObject); } } } else if (doOtherSide) { if (otherSide != null) { addToCollection(ref, otherSide, parentDataObject); } DataObjectSettable setter = DataObjectSettableFactory.get(ref.getClass().getName(), FormHelper.DATA_OBJ_SETTER); setter.setFieldValue(parentDataObject, fldName, ref); } } else { log.error("Could not find field[" + fieldName + "] [" + fldName + "] in class[" + parentDataObject.getClass().getSimpleName() + "]"); } } else { log.error("Couldn't find relationship[" + fieldName + "] [" + fldName + "] For Table[" + ref.getTableId() + "]"); } } else { log.error("Couldn't find TableInfo [" + ref.getTableId() + "]"); } }
From source file:fr.paris.lutece.util.datatable.DataTableManager.java
/** * Set the sort url of this DataTableManager * @param strSortUrl The sort url of this DataTableManager *///from w ww . java 2s . c om public void setSortUrl(String strSortUrl) { _strSortUrl = strSortUrl; if ((_strSortUrl != null) && StringUtils.isNotEmpty(_strSortUrl) && !StringUtils.contains(_strSortUrl, getId())) { // We add to the sort URL the unique parameter of this data table manager UrlItem urlItem = new UrlItem(_strSortUrl); urlItem.addParameter(getId(), getId()); _strSortUrl = urlItem.getUrl(); } }
From source file:com.sammyun.plugin.PaymentPlugin.java
/** * GET/*w ww .ja v a2 s .co m*/ * * @param url URL * @param parameterMap ? * @return */ protected String get(String url, Map<String, Object> parameterMap) { Assert.hasText(url); String result = null; HttpClient httpClient = new DefaultHttpClient(); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); if (parameterMap != null) { for (Entry<String, Object> entry : parameterMap.entrySet()) { String name = entry.getKey(); String value = ConvertUtils.convert(entry.getValue()); if (StringUtils.isNotEmpty(name)) { nameValuePairs.add(new BasicNameValuePair(name, value)); } } } HttpGet httpGet = new HttpGet(url + (StringUtils.contains(url, "?") ? "&" : "?") + EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"))); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); result = EntityUtils.toString(httpEntity); EntityUtils.consume(httpEntity); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { httpClient.getConnectionManager().shutdown(); } return result; }
From source file:com.prowidesoftware.swift.model.Tag.java
/** * equivalent to StringUtils.contains(tag.getValue(), searchStr) * @see StringUtils#contains(String, String) *//*w ww . j a v a 2s . c o m*/ public boolean contains(String searchStr) { return StringUtils.contains(getValue(), searchStr); }