本文整理汇总了Java中org.apache.shiro.util.StringUtils.split方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.split方法的具体用法?Java StringUtils.split怎么用?Java StringUtils.split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.split方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toSet
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
protected Set<?> toSet(String sValue) {
String[] tokens = StringUtils.split(sValue);
if (tokens == null || tokens.length <= 0) {
return null;
}
//SHIRO-423: check to see if the value is a referenced Set already, and if so, return it immediately:
if (tokens.length == 1 && isReference(tokens[0])) {
Object reference = resolveReference(tokens[0]);
if (reference instanceof Set) {
return (Set)reference;
}
}
Set<String> setTokens = new LinkedHashSet<String>(Arrays.asList(tokens));
//now convert into correct values and/or references:
Set<Object> values = new LinkedHashSet<Object>(setTokens.size());
for (String token : setTokens) {
Object value = resolveValue(token);
values.add(value);
}
return values;
}
示例2: toCollection
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
private Collection<?> toCollection(String sValue) {
String[] tokens = StringUtils.split(sValue);
if (tokens == null || tokens.length <= 0) {
return null;
}
//SHIRO-423: check to see if the value is a referenced Collection already, and if so, return it immediately:
if (tokens.length == 1 && isReference(tokens[0])) {
Object reference = resolveReference(tokens[0]);
if (reference instanceof Collection) {
return (Collection)reference;
}
}
//now convert into correct values and/or references:
List<Object> values = new ArrayList<Object>(tokens.length);
for (String token : tokens) {
Object value = resolveValue(token);
values.add(value);
}
return values;
}
示例3: toList
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
protected List<?> toList(String sValue) {
String[] tokens = StringUtils.split(sValue);
if (tokens == null || tokens.length <= 0) {
return null;
}
//SHIRO-423: check to see if the value is a referenced List already, and if so, return it immediately:
if (tokens.length == 1 && isReference(tokens[0])) {
Object reference = resolveReference(tokens[0]);
if (reference instanceof List) {
return (List)reference;
}
}
//now convert into correct values and/or references:
List<Object> values = new ArrayList<Object>(tokens.length);
for (String token : tokens) {
Object value = resolveValue(token);
values.add(value);
}
return values;
}
示例4: setConfigLocations
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
public void setConfigLocations(String locations) {
if (!StringUtils.hasText(locations)) {
throw new IllegalArgumentException("Null/empty locations argument not allowed.");
}
String[] arr = StringUtils.split(locations);
setConfigLocations(arr);
}
示例5: toMap
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
protected Map<?, ?> toMap(String sValue) {
String[] tokens = StringUtils.split(sValue, StringUtils.DEFAULT_DELIMITER_CHAR,
StringUtils.DEFAULT_QUOTE_CHAR, StringUtils.DEFAULT_QUOTE_CHAR, true, true);
if (tokens == null || tokens.length <= 0) {
return null;
}
//SHIRO-423: check to see if the value is a referenced Map already, and if so, return it immediately:
if (tokens.length == 1 && isReference(tokens[0])) {
Object reference = resolveReference(tokens[0]);
if (reference instanceof Map) {
return (Map)reference;
}
}
Map<String, String> mapTokens = new LinkedHashMap<String, String>(tokens.length);
for (String token : tokens) {
String[] kvPair = StringUtils.split(token, MAP_KEY_VALUE_DELIMITER);
if (kvPair == null || kvPair.length != 2) {
String msg = "Map property value [" + sValue + "] contained key-value pair token [" +
token + "] that does not properly split to a single key and pair. This must be the " +
"case for all map entries.";
throw new ConfigurationException(msg);
}
mapTokens.put(kvPair[0], kvPair[1]);
}
//now convert into correct values and/or references:
Map<Object, Object> map = new LinkedHashMap<Object, Object>(mapTokens.size());
for (Map.Entry<String, String> entry : mapTokens.entrySet()) {
Object key = resolveValue(entry.getKey());
Object value = resolveValue(entry.getValue());
map.put(key, value);
}
return map;
}
示例6: processUserDefinitions
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
protected void processUserDefinitions(Map<String, String> userDefs) {
if (userDefs == null || userDefs.isEmpty()) {
return;
}
for (String username : userDefs.keySet()) {
String value = userDefs.get(username);
String[] passwordAndRolesArray = StringUtils.split(value);
String password = passwordAndRolesArray[0];
String partition;
Matcher matcher = usernamePartitionPattern.matcher(username);
if (matcher.matches()) {
partition = matcher.group("partition");
username = matcher.group("username");
} else {
partition = getDefaultPartitionName();
}
if (Objects.nonNull(username) && !username.isEmpty()) {
IOTAccount account = getIOTAccount(partition, username);
if (account == null) {
account = addIOTAccount(partition, username, password);
}
account.setCredential(password);
if (passwordAndRolesArray.length > 1) {
for (int i = 1; i < passwordAndRolesArray.length; i++) {
String rolename = passwordAndRolesArray[i];
account.addRole(rolename);
}
}
saveIOTAccount(account);
}
}
}
示例7: splitChainDefinition
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
private String[] splitChainDefinition(String chainDefinition) {
return StringUtils.split(
chainDefinition,
StringUtils.DEFAULT_DELIMITER_CHAR,
'[',
']',
true,
true
);
}
示例8: isRendered
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
@Override
public boolean isRendered() {
if (getSubject() == null) {
return false;
}
for (String permission : StringUtils.split(readName())) {
if (getSubject().isPermitted(permission)) {
return true;
}
}
return false;
}
示例9: isRendered
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
@Override
public boolean isRendered() {
if (getSubject() == null) {
return false;
}
for (String roleName : StringUtils.split(readName())) {
if (getSubject().hasRole(roleName)) {
return true;
}
}
return false;
}
示例10: splitChainDefinition
import org.apache.shiro.util.StringUtils; //导入方法依赖的package包/类
/**
* Splits the comma-delimited filter chain definition line into individual filter definition tokens.
* <p/>
* Example Input:
* <pre>
* foo, bar[baz], blah[x, y]
* </pre>
* Resulting Output:
* <pre>
* output[0] == foo
* output[1] == bar[baz]
* output[2] == blah[x, y]
* </pre>
* @param chainDefinition the comma-delimited filter chain definition.
* @return an array of filter definition tokens
* @since 1.2
* @see <a href="https://issues.apache.org/jira/browse/SHIRO-205">SHIRO-205</a>
*/
protected String[] splitChainDefinition(String chainDefinition) {
return StringUtils.split(chainDefinition, StringUtils.DEFAULT_DELIMITER_CHAR, '[', ']', true, true);
}