当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.contains方法代码示例

本文整理汇总了Java中org.apache.commons.lang.StringUtils.contains方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.contains方法的具体用法?Java StringUtils.contains怎么用?Java StringUtils.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@Override
public boolean validate(Object object, String propertyName,Map<String,List<FixedWidthGridRow>> inputSchemaMap,
		boolean isJobImported){
	String value = (String) object;
	if(StringUtils.isNotBlank(value)){
		Matcher matcher=Pattern.compile("[\\d]*").matcher(value);
		if((matcher.matches())|| 
			((StringUtils.startsWith(value, "@{") && StringUtils.endsWith(value, "}")) &&
					!StringUtils.contains(value, "@{}"))){
			return true;
		}
		errorMessage = propertyName + " is mandatory";
	}
	errorMessage = propertyName + " is not integer value or valid parameter";
	return false;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:IntegerOrParameterValidationRule.java

示例2: checkSign

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@EventHandler
public void checkSign(SignChangeEvent event) {
	if (ConfigFunction.AntiSpamenable && ConfigFunction.enableAntiDirty) {
		String[] lines = event.getLines();
		for (String line : lines) {
			Player player = event.getPlayer();
			if (AzureAPI.hasPerm(player, "EscapeLag.bypass.Spam")) {
				return;
			}
			for (String each : ConfigFunction.AntiSpamDirtyList) {
				boolean deny = true;
				for (char c : each.toLowerCase().toCharArray()) {
					if (!StringUtils.contains(line, c))
						deny = false;
				}
				if (deny) {
					event.setCancelled(true);
					AzureAPI.log(player, ConfigFunction.AntiSpamDirtyWarnMessage);
				}
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:24,代码来源:AntiSpam.java

示例3: checkDirty

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkDirty(AsyncPlayerChatEvent evt) {
	if (ConfigFunction.AntiSpamenable && ConfigFunction.enableAntiDirty) {
		Player player = evt.getPlayer();
		String message = evt.getMessage().toLowerCase();
		if (AzureAPI.hasPerm(player, "EscapeLag.bypass.Spam")) {
			return;
		}

		for (String each : ConfigFunction.AntiSpamDirtyList) {
			boolean deny = true;
			for (char c : each.toLowerCase().toCharArray()) {
				if (!StringUtils.contains(message, c))
					deny = false;
			}
			if (deny) {
				evt.setCancelled(true);
				AzureAPI.log(player, ConfigFunction.AntiSpamDirtyWarnMessage);
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:23,代码来源:AntiSpam.java

示例4: prepareSegmentConditions

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private static Formula prepareSegmentConditions(String resourceType, String resourceName,
		List<Attribute> attributes) {
	List<Term> conditions = new ArrayList<>();
	if (StringUtils.isNotBlank(resourceType) && !StringUtils.contains(resourceType, ':')) {
		conditions.add(new Atomic(String.format("s.[sling:resourceType] = '%s'", resourceType)));
	}
	if (StringUtils.isNotBlank(resourceName)) {
		conditions.add(new Atomic(String.format("NAME(s) = '%s'", resourceName)));
	}
	if (attributes != null) {
		for (Attribute a : attributes) {
			String attributeCondition = getAttributeCondition(a);
			if (StringUtils.isNotBlank(attributeCondition)) {
				conditions.add(new Atomic(attributeCondition));
			}
		}
	}
	if (conditions.isEmpty()) {
		return null;
	} else {
		return new Formula(Operator.AND, conditions);
	}
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:24,代码来源:JcrQueryBuilder.java

示例5: isJson

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
* 
* @Title: isJson 
* @Description: Check if it is JSON string 
* @param @param content
* @param @return 
* @return boolean
* @throws
 */
public static boolean isJson(String json)
{
    if (StringUtils.isEmpty(json))
    {
        return false;
    }

    if (!StringUtils.contains(json, "{"))
    {
        return false;
    }

    JsonParser p = new JsonParser();
    try
    {
        p.parse(json);
    }
    catch(JsonSyntaxException e)
    {
        return false;
    }

    return true;
}
 
开发者ID:wisdomtool,项目名称:formatter,代码行数:34,代码来源:FormatUtil.java

示例6: constructURL

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 构造小说阅读页URL
 * 
 * @param chapter
 *            章节信息
 * @return 小说阅读页URL
 */
private String constructURL(TChapter chapter, boolean isCreateMobileSiteMap) {
    String loc = YiDuConstants.yiduConf.getString(YiDuConfig.XML_SITEMAP_READER_URL);
    String uri = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
    if (isCreateMobileSiteMap) {
        uri = YiDuConstants.yiduConf.getString(YiDuConfig.MOBILE_URI);
    }
    int subDir = chapter.getArticleno() / YiDuConstants.SUB_DIR_ARTICLES;
    int articleNo = chapter.getArticleno();
    int chapterNo = chapter.getChapterno();

    if (StringUtils.contains(loc, "{pinyin}")) {
        TArticle article = articleService.getByNo(articleNo);
        loc = loc.replace("{sub_dir}", String.valueOf(subDir)).replace("{article_no}", String.valueOf(articleNo))
                .replace("{chapter_no}", String.valueOf(chapterNo))
                .replace("{pinyin}", String.valueOf(article.getPinyin()));
    } else {
        loc = loc.replace("{sub_dir}", String.valueOf(subDir)).replace("{article_no}", String.valueOf(articleNo))
                .replace("{chapter_no}", String.valueOf(chapterNo));
    }
    if (!uri.endsWith("/") && !loc.startsWith("/")) {
        uri += "/";
    }
    return uri + loc;
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:32,代码来源:CreateSiteMapJob.java

示例7: constructReaderURL

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * 构造小说阅读页URL
 * 
 * @param chapter
 *            章节信息
 * @return 小说阅读页URL
 */
private String constructReaderURL(int articleNo, int chapterNo, boolean isCreateMobileSiteMap) {
    String loc = YiDuConstants.yiduConf.getString(YiDuConfig.XML_SITEMAP_READER_URL);
    String uri = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
    if (isCreateMobileSiteMap) {
        uri = YiDuConstants.yiduConf.getString(YiDuConfig.MOBILE_URI);
    }
    int subDir = articleNo / YiDuConstants.SUB_DIR_ARTICLES;

    if (StringUtils.contains(loc, "{pinyin}")) {
        TArticle article = articleService.getByNo(articleNo);
        loc = loc.replace("{sub_dir}", String.valueOf(subDir)).replace("{article_no}", String.valueOf(articleNo))
                .replace("{chapter_no}", String.valueOf(chapterNo)).replace("{pinyin}", String.valueOf(article.getPinyin()));
    } else {
        loc = loc.replace("{sub_dir}", String.valueOf(subDir)).replace("{article_no}", String.valueOf(articleNo))
                .replace("{chapter_no}", String.valueOf(chapterNo));
    }
    if (!uri.endsWith("/") && !loc.startsWith("/")) {
        uri += "/";
    }
    return uri + loc;
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:29,代码来源:CreateStructuringDataJob.java

示例8: createPlaceHolderFromSource

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private void createPlaceHolderFromSource(IMethod iMethod, String className) throws JavaModelException {
	StringBuffer buffer = new StringBuffer(iMethod.getSource());
	int indexOfPlaceHolder = buffer.lastIndexOf("@see");
	if (indexOfPlaceHolder != -1 && iMethod.getParameterNames() != null && iMethod.getParameterNames().length > 0) {
		buffer = buffer.delete(0, indexOfPlaceHolder + 4);
		buffer = buffer.delete(buffer.indexOf("\n")+1, buffer.capacity());
		if(StringUtils.contains(buffer.toString(), className + Constants.DOT+iMethod.getElementName())){
			placeHolder = StringUtils.trim(buffer.toString());
		}
		else
			placeHolder = createDefaultPlaceHolder(iMethod, className);
	} else {
		placeHolder = createDefaultPlaceHolder(iMethod, className);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:MethodDetails.java

示例9: getTableMeta

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache) {
    try {
        return tableMetaCache.getTableMeta(dbName, tbName, useCache);
    } catch (Exception e) {
        String message = ExceptionUtils.getRootCauseMessage(e);
        if (filterTableError) {
            if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) {
                return null;
            }
        }

        throw new CanalParseException(e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:15,代码来源:LogEventConvert.java

示例10: getDistinguishedNameField

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static String getDistinguishedNameField(String certificateSubject, String fieldName) {
   String fieldValue = substringAfter(certificateSubject, fieldName + "=");
   // If serial number contains ',' then it is not the last value
   if (StringUtils.contains(fieldValue, ',')) {
      fieldValue = substringBefore(fieldValue, ",");
   }
   if (log.isDebugEnabled()) {
      log.debug("Parsed " + fieldName + " =" + fieldValue);
   }
   return trimToNull(fieldValue);
}
 
开发者ID:nortal,项目名称:cas-modules,代码行数:12,代码来源:X509CredentialsToPrincipalResolver.java

示例11: getCollectionMediaItem

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Retrieve a media item for a playlist (only if it exists in the playlist)
 * 
 * @param kalturaEntryId the kaltura entry id of this media item
 * @param collection the collction (with playlist) that contains the entry
 * @param populate if true then populate the item with permissions and content
 * @return a populated media item OR null if none is found with the given id in the given collection
 * @throws IllegalArgumentException if the params are invalid
 * @throws SecurityException if the user does not have permissions
 */
public MediaItem getCollectionMediaItem(String kalturaEntryId, MediaCollection collection, boolean populate) {
    if (StringUtils.isEmpty(kalturaEntryId)) {
        throw new IllegalArgumentException("kalturaEntryId must not be null");
    }
    if (collection == null) {
        throw new IllegalArgumentException("collection must not be null");
    }
    KalturaPlaylist playlist = collection.getKalturaPlaylist();
    if (playlist == null) {
        throw new IllegalArgumentException("playlist must not be null");
    }
    // verify the entry is a real one
    KalturaMediaEntry kme = kalturaAPIService.getKalturaItem(kalturaEntryId);
    if (kme == null) {
        throw new RuntimeException("kaltura media entry doesn't exist");
    }
    String collectionId = playlist.id;
    boolean playlistContainsItem = StringUtils.contains(playlist.playlistContent, kalturaEntryId);
    MediaItem mi = null;
    if (playlistContainsItem) {
        /* collection is input now
        String locationId = findLocationFromPlaylist(playlist);
        Map<String, String> plMetadata = kalturaAPIService.getPlaylistMetadataFields(playlist.id).get(collectionId);
        MediaCollection mc = new MediaCollection(playlist, locationId, plMetadata);
        */
        Map<String, String> kmeMetadata = kalturaAPIService.getMetadataForEntry(playlist.id, kalturaEntryId).get(kalturaEntryId);
        mi = new MediaItem(collection, kme, kmeMetadata);
        populateMediaItemData(mi); // fill in the permissions
        if (! canViewMI(mi, collection) ) {
            throw new SecurityException("user (" + external.getCurrentUserId() + ") cannot view item (" + kalturaEntryId + ") in collection ("+collectionId+")");
        }
        if (populate) {
            populateItem(mi);
        }
    }
    return mi;
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:48,代码来源:MediaService.java

示例12: isDevLaunchMode

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * Checks whether tool is launched in development mode.
 * 
 * @param argumentsMap
 * @return true if tool is launched in development mode, else returns false
 */
@SuppressWarnings("unchecked")
public static boolean isDevLaunchMode(Map argumentsMap) {
	 logger.debug("Checking whether tool is launched in development mode");
	 for(Entry< Object, String[]> entry:((Map<Object, String[]>)argumentsMap).entrySet()){
			for(String value:entry.getValue()){
				if(StringUtils.contains(value, DOSGI_REQUIRED_JAVA_VERSION_PARAMETER_IN_INI_FILE)){
					return false;
				}
			}
		}
		return true;
	}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:19,代码来源:PreStartActivity.java

示例13: getErrorMessage

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private Message getErrorMessage(Exception e) {
	if(StringUtils.contains(e.getMessage(), UNKNOWN_HOST_EXCEPTION)){
		return new Message(MessageType.UNKNOWN_HOST, UNKNOWN_HOST_MESSAGE); 
	}else if(StringUtils.contains(e.getMessage(), AUTH_FAIL_EXCEPTION)){
		return new Message(MessageType.INVALID_USERNAME_PASSWORD, AUTHENTICATION_FAILED_MESSAGE); 
	}else{
		return new Message(MessageType.ERROR, GENERAL_ERROR_MESSAGE);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:10,代码来源:SCPUtility.java

示例14: arrangeItems

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
    * Get contents of lams_configuration and group them using header names as key.
    *
    * @param filter
    *            ITEMS_ALL: include all items; ITEMS_NON_LDAP: include non-ldap items only; ITEMS_ONLY_LDAP: include
    *            ldap-only items.
    * @return
    */
   public HashMap<String, ArrayList<ConfigurationItem>> arrangeItems(int filter) {
List<ConfigurationItem> originalList = Configuration.getAllItems();
HashMap<String, ArrayList<ConfigurationItem>> groupedList = new HashMap<String, ArrayList<ConfigurationItem>>();

for (int i = 0; i < originalList.size(); i++) {
    ConfigurationItem item = originalList.get(i);
    String header = item.getHeaderName();

    switch (filter) {
	case ITEMS_ALL:
	    // all items included
	    break;
	case ITEMS_NON_LDAP:
	    // non-ldap items only
	    if (StringUtils.contains(header, "config.header.ldap")) {
		continue;
	    }
	    break;
	case ITEMS_ONLY_LDAP:
	    // ldap-only items
	    if (!StringUtils.contains(header, "config.header.ldap")) {
		continue;
	    }
	    break;
	default:
	    break;
    }

    if (!groupedList.containsKey(header)) {
	groupedList.put(header, new ArrayList<ConfigurationItem>());
    }
    ArrayList<ConfigurationItem> currentList = groupedList.get(header);
    currentList.add(item);
    groupedList.put(header, currentList);
}

return groupedList;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:Configuration.java

示例15: updatePropertyMap

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private Map<String, String> updatePropertyMap(Map<String, String> parameterMap){
	Map<String,String> map=new  LinkedHashMap<>(parameterMap);
	for(Entry<String, String> entry:parameterMap.entrySet()){
		if(StringUtils.contains(entry.getValue(), ESCAPE_CHAR)){
			map.put(entry.getKey(), StringUtils.replaceChars(entry.getValue(),ESCAPE_CHAR, BACKWARD_SLASH));
		}
	}
	return map;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:10,代码来源:ParameterFileManager.java


注:本文中的org.apache.commons.lang.StringUtils.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。