本文整理汇总了Java中org.apache.commons.lang.StringUtils类的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringUtils类属于org.apache.commons.lang包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTable
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
protected void createTable(List<List<Integer>> records) throws SQLException {
PreparedStatement s = conn.prepareStatement("DROP TABLE \"" + TABLE_NAME + "\" IF EXISTS");
try {
s.executeUpdate();
} finally {
s.close();
}
s = conn.prepareStatement("CREATE TABLE \"" + TABLE_NAME
+ "\" (id INT NOT NULL PRIMARY KEY, val INT, LASTMOD timestamp)");
try {
s.executeUpdate();
} finally {
s.close();
}
for (List<Integer> record : records) {
final String values = StringUtils.join(record, ", ");
s = conn
.prepareStatement("INSERT INTO \"" + TABLE_NAME + "\" VALUES (" + values + ", now())");
try {
s.executeUpdate();
} finally {
s.close();
}
}
conn.commit();
}
示例2: doAfter
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
public void doAfter(Class<?> objectClass, Method method,Object[] arguments, Object returnValue) throws Exception {
DataRequest req=new DataRequest();
req.setBeanId("bdf2.roleMaintain");
req.setMethodName(method.getName());
String suffix="dorado/webservice/SpringBeanRPC";
if(StringUtils.isEmpty(remoteServerUsernamePassword)){
IUser user=ContextHolder.getLoginUser();
this.username=user.getUsername();
this.password=user.getPassword();
}
for(String url:remoteServerUrls.split(",")){
if(url.endsWith("/")){
url=url+suffix;
}else{
url=url+"/"+suffix;
}
WebServiceClient client=new WebServiceClient(url);
client.setUsernameToken(username, password, true);
client.setMarshallerClasses(new Class<?>[]{DataRequest.class,DataResponse.class});
DataResponse res=(DataResponse)client.sendAndReceive(req);
if(!res.isSuccessful()){
throw new RuntimeException(res.getReturnValue());
}
}
}
示例3: check
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
public boolean check(String action, String method) {
if (!StringUtil.isBlank(action)) {
PatternMatcher matcher = new Perl5Matcher();
Iterator<ActionPatternHolder> iter = actionPatternList.iterator();
while (iter.hasNext()) {
ActionPatternHolder holder = (ActionPatternHolder) iter.next();
if (StringUtils.isNotEmpty(action) && matcher.matches(action, holder.getActionPattern())
&& StringUtils.isNotEmpty(method) && matcher.matches(method, holder.getMethodPattern())) {
if (logger.isDebugEnabled()) {
logger.debug("Candidate is: '" + action + "|" + method + "'; pattern is "
+ holder.getActionName() + "|" + holder.getMethodName() + "; matched=true");
}
return true;
}
}
}
return false;
}
示例4: SidebarMatchModule
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
public SidebarMatchModule(Match match, BaseComponent title) {
super(match);
this.legacyTitle = StringUtils.left(
ComponentRenderers.toLegacyText(
new Component(title, ChatColor.AQUA),
NullCommandSender.INSTANCE
),
32
);
}
示例5: getTrueFalse
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
/**
* Caches the parameter value for later substitution in engine xml.
* @param propertyName
* @return
*/
protected TypeTrueFalse getTrueFalse(String propertyName) {
logger.debug("Getting TrueFalse Value for {}={}", new Object[] {propertyName, properties.get(propertyName) });
TypeTrueFalse typeTrueFalse = new TypeTrueFalse();
if (StringUtils.isNotBlank((String) properties.get(propertyName))) {
try{
Object object = properties.get(propertyName);
typeTrueFalse.setValue(TrueFalse.fromValue(StringUtils.lowerCase((String)object)));
}
catch(IllegalArgumentException exception){
ComponentXpath.INSTANCE.getXpathMap().put((ComponentXpathConstants.COMPONENT_XPATH_BOOLEAN.value()
.replace(ID, componentName))
.replace(Constants.PARAM_PROPERTY_NAME, propertyName),
new ComponentsAttributeAndValue(null, properties.get(propertyName).toString()));
typeTrueFalse.setValue(TrueFalse.TRUE);
}
}
return typeTrueFalse;
}
示例6: applyIdentifierModifications
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
/**
*
* @param pi
* @return
* @throws FatalIndexerException
* @should trim identifier
* @should apply replace rules
* @should replace spaces with underscores
* @should replace commas with underscores
*/
public static String applyIdentifierModifications(String pi) throws FatalIndexerException {
if (StringUtils.isEmpty(pi)) {
return pi;
}
String ret = pi.trim();
// Apply replace rules defined for the field PI
List<FieldConfig> configItems = Configuration.getInstance().getMetadataConfigurationManager().getConfigurationListForField(SolrConstants.PI);
if (configItems != null && !configItems.isEmpty()) {
Map<Object, String> replaceRules = configItems.get(0).getReplaceRules();
if (replaceRules != null && !replaceRules.isEmpty()) {
ret = MetadataHelper.applyReplaceRules(ret, replaceRules);
}
}
ret = ret.replace(" ", "_");
ret = ret.replace(",", "_");
ret = ret.replace(":", "_");
return ret;
}
示例7: filter
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
public void filter(String url, Component component, UserAuthentication authentication) throws Exception {
Action action = (Action) component;
boolean authority = true;
String id = action.getId();
if (StringUtils.isNotEmpty(id)) {
authority = SecurityUtils.checkComponent(authentication, AuthorityType.read, url, id);
}
if (!authority) {
action.setIgnored(true);
return;
}
if (StringUtils.isNotEmpty(id)) {
authority = SecurityUtils.checkComponent(authentication, AuthorityType.write, url, id);
}
if (!authority) {
action.setDisabled(true);
return;
}
}
示例8: isJarPresentInLibFolder
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
private boolean isJarPresentInLibFolder(IPath path) {
String currentProjectName = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject().getName();
if (StringUtils.equals(currentProjectName, path.segment(0))
&& StringUtils.equals(PathConstant.PROJECT_LIB_FOLDER, path.segment(1)))
return true;
return false;
}
示例9: setToolTipForGenerateRecordGridRow
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
private String setToolTipForGenerateRecordGridRow(GenerateRecordSchemaGridRow generateRecordSchemaGridRow, String componentType){
String tooltip = null;
if (StringUtils.isNotBlank(generateRecordSchemaGridRow.getRangeFrom())
|| StringUtils.isNotBlank(generateRecordSchemaGridRow.getRangeTo())){
tooltip = setToolTipForSchemaRange(generateRecordSchemaGridRow);
}
if (tooltip != null){
return tooltip;
}else if(StringUtils.equalsIgnoreCase(generateRecordSchemaGridRow.getDataTypeValue(), JAVA_UTIL_DATE)
&& StringUtils.isBlank(generateRecordSchemaGridRow.getDateFormat())){
return setToolTipForDateFormatIfBlank(generateRecordSchemaGridRow);
}else if((StringUtils.equalsIgnoreCase(generateRecordSchemaGridRow.getDataTypeValue(), JAVA_MATH_BIG_DECIMAL))){
return setToolTipForBigDecimal(generateRecordSchemaGridRow, componentType);
}
return "";
}
示例10: fetchFile
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
@Override
public boolean fetchFile(String type, String key, File localFile, boolean folder) throws FileCacheException {
if (StringUtils.isEmpty(key)) {
throw new FileCacheException("cache key is empty ");
}
File cacheFile = getLocalCacheFile(type, key);
try {
if (cacheFile.exists() && cacheFile.length() > 0) {
if (cacheFile.isDirectory()) {
FileUtils.copyDirectory(cacheFile, localFile);
} else {
FileUtils.copyFile(cacheFile, localFile);
}
}
} catch (IOException e) {
throw new FileCacheException(e.getMessage(), e);
}
return true;
}
示例11: validate
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
@Override
public boolean validate() {
if (StringUtils.isEmpty(bizContent.outTradeNo)) {
throw new NullPointerException("out_trade_no should not be NULL!");
}
if (StringUtils.isEmpty(bizContent.totalAmount)) {
throw new NullPointerException("total_amount should not be NULL!");
}
if (StringUtils.isEmpty(bizContent.subject)) {
throw new NullPointerException("subject should not be NULL!");
}
if (StringUtils.isEmpty(bizContent.storeId)) {
throw new NullPointerException("store_id should not be NULL!");
}
return true;
}
示例12: render
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
private void render(final Project project, GraphRenderer renderer, boolean lastChild,
final StyledTextOutput textOutput) {
renderer.visit(new Action<StyledTextOutput>() {
public void execute(StyledTextOutput styledTextOutput) {
styledTextOutput.text(StringUtils.capitalize(project.toString()));
if (GUtil.isTrue(project.getDescription())) {
textOutput.withStyle(Description).format(" - %s", project.getDescription());
}
}
}, lastChild);
renderer.startChildren();
List<Project> children = getChildren(project);
for (Project child : children) {
render(child, renderer, child == children.get(children.size() - 1), textOutput);
}
renderer.completeChildren();
}
示例13: add
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
@RequestMapping("/add")
@ResponseBody
@PermessionLimit(superUser = true)
public ReturnT<String> add(XxlApiUser xxlApiUser) {
// valid
if (StringUtils.isBlank(xxlApiUser.getUserName())) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“登录账号”");
}
if (StringUtils.isBlank(xxlApiUser.getPassword())) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "请输入“登录密码”");
}
// valid
XxlApiUser existUser = xxlApiUserDao.findByUserName(xxlApiUser.getUserName());
if (existUser != null) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "“登录账号”重复,请更换");
}
int ret = xxlApiUserDao.add(xxlApiUser);
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
}
示例14: getMetadataForEntry
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
/**
* Gets a HashMap representation of metadata for an entry or set of entries associated with a given container
* (since each kaltura entry can have multiple permissions related to each collection)
* NOTE: this will always return a map which is the same size as the input array of entries
*
* OPTIMIZATION method (fetch lots of metadata at once)
*
* @param containerId the id of the container (typically this will be the collection id or site id)
* @param entryId the id of the entry (can be 1 or many values)
* @return Map of the {entryId -> Map of metadata {key -> value} }
*/
protected Map<String, Map<String, String>> getMetadataForEntry(String containerId, String... entryIds) {
if (StringUtils.isEmpty(containerId)) {
throw new IllegalArgumentException("container id must be set");
}
if (entryIds == null || entryIds.length == 0) {
throw new IllegalArgumentException("entry ids must be set and not empty");
}
if (log.isDebugEnabled()) log.debug("getMetadataForEntry(containerId="+containerId+", entryId="+ArrayUtils.toString(entryIds)+")");
Map<String, Map<String, String>> metadata = new LinkedHashMap<String, Map<String, String>>(entryIds.length);
// generate the default set of metadata permissions for when they do not exist
Map<String, String> defaultMetadata = decodeMetadataPermissions(null, false);
HashSet<String> containerIds = new HashSet<String>(1);
containerIds.add(containerId);
// get a set of metadata entries (only includes the entries which have metadata)
Map<String, Map<String, String>> entriesMetadata = getMetadataForContainersEntries(containerIds, entryIds).get(containerId);
// construct a map with all entries and fill in any missing metadata with default metadata (to ensure every input entry id is returned)
for (String entryId : entryIds) {
if (entriesMetadata.containsKey(entryId)) {
metadata.put(entryId, entriesMetadata.get(entryId));
} else {
metadata.put(entryId, defaultMetadata);
}
}
return metadata;
}
示例15: findByCon
import org.apache.commons.lang.StringUtils; //导入依赖的package包/类
@Override
public FacetedPage<Topic> findByCon(NativeSearchQueryBuilder searchQueryBuilder, String q , final int p , final int ps) {
FacetedPage<Topic> pages = null ;
if(!StringUtils.isBlank(q)){
searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
}
SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
if(elasticsearchTemplate.indexExists(Topic.class)){
if(!StringUtils.isBlank(q)){
pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class , new UKResultMapper());
}else{
pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class);
}
}
return pages ;
}