本文整理汇总了Java中de.invation.code.toval.misc.ArrayUtils类的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils类的具体用法?Java ArrayUtils怎么用?Java ArrayUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayUtils类属于de.invation.code.toval.misc包,在下文中一共展示了ArrayUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRoutingConstraint
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Adds a routing constraint for an activity.
* @param activity The name of the activity for which the constraint is added.
* @param constraint The routing constraint to add.
* @throws ParameterException if the given parameters are invalid.
* @throws PropertyException if the given constraint cannot be added as a property.
* @see #addConstraint(AbstractConstraint)
* @see #addActivityWithConstraints(String)
*/
public void addRoutingConstraint(String activity, AbstractConstraint<?> constraint) throws PropertyException{
Validate.notNull(activity);
Validate.notEmpty(activity);
Validate.notNull(constraint);
//1. Add constraint itself
// This also adds the constraint to the list of constraints
String propertyNameForNewConstraint = addConstraint(constraint);
//2. Add constraint name to the list of constraints for this activity
Set<String> currentConstraintNames = getConstraintNames(activity);
currentConstraintNames.add(propertyNameForNewConstraint);
if(currentConstraintNames.size() == 1){
//Add the activity to the list of activities with routing constraints
addActivityWithConstraints(activity);
}
props.setProperty(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity), ArrayUtils.toString(currentConstraintNames.toArray()));
}
示例2: setDataUsage
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
public void setDataUsage(String activity, Map<String, Set<DataUsage>> dataUsage) throws PropertyException {
Validate.notNull(activity);
Validate.notEmpty(activity);
Validate.notNull(dataUsage);
Validate.noNullElements(dataUsage.keySet());
Validate.noNullElements(dataUsage.values());
//1. Add data usages
// This also adds the data usages to the list of data usages
List<String> propertyNamesForDataUsages = new ArrayList<>();
for (String attribute : dataUsage.keySet()) {
propertyNamesForDataUsages.add(addDataUsage(attribute, dataUsage.get(attribute)));
}
//2. Add data usage names to the list of data usages for this activity
addActivityWithDataUsage(activity);
props.setProperty(String.format(ACTIVITY_DATA_USAGES_FORMAT, activity), ArrayUtils.toString(propertyNamesForDataUsages.toArray()));
}
示例3: getDataUsageNames
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Returns the property-names of all data usages related to the given
* activity.<br>
* These names are required to extract data usage property-values.
*
* @param activity The name of the activity
* @return A set of data usage property-names related to the given activity.
* @throws ParameterException if the given activity name is <code>null</code or invalid.
*/
private Set<String> getDataUsageNames(String activity) {
Validate.notNull(activity);
Validate.notEmpty(activity);
Set<String> result = new HashSet<>();
String propertyValue = props.getProperty(String.format(ACTIVITY_DATA_USAGES_FORMAT, activity));
if (propertyValue == null) {
return result;
}
StringTokenizer subjectTokens = StringUtils.splitArrayString(propertyValue, String.valueOf(ArrayUtils.VALUE_SEPARATION));
while (subjectTokens.hasMoreTokens()) {
String nextToken = subjectTokens.nextToken();
result.add(nextToken);
}
return result;
}
示例4: getValidUsageModes
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
public Set<DataUsage> getValidUsageModes() throws PropertyException {
String propertyValue = getProperty(ProcessContextProperty.VALID_USAGE_MODES);
if (propertyValue == null) {
throw new PropertyException(ACModelProperty.VALID_USAGE_MODES, propertyValue);
}
StringTokenizer tokens = StringUtils.splitArrayString(propertyValue, String.valueOf(ArrayUtils.VALUE_SEPARATION));
Set<DataUsage> result = new HashSet<>();
while (tokens.hasMoreTokens()) {
String nextToken = tokens.nextToken();
if (nextToken.length() < 3) {
throw new PropertyException(ACModelProperty.VALID_USAGE_MODES, propertyValue);
}
nextToken = nextToken.substring(1, nextToken.length() - 1);
DataUsage nextUsage = null;
try {
nextUsage = DataUsage.parse(nextToken);
} catch (Exception e) {
throw new PropertyException(ACModelProperty.VALID_USAGE_MODES, nextToken, e);
}
result.add(nextUsage);
}
return result;
}
示例5: setObjectPermission
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
public void setObjectPermission(String subject, Map<String, Set<DataUsage>> permissions) throws PropertyException{
validateStringValue(subject);
Validate.notNull(permissions);
if(permissions.isEmpty())
return;
validateStringCollection(permissions.keySet());
Validate.noNullElements(permissions.values());
//1. Add permissions
// This also adds the permissions to the list of permissions
List<String> propertyNamesForPermissions = new ArrayList<String>();
for(String object: permissions.keySet()){
propertyNamesForPermissions.add(addObjectPermission(object, permissions.get(object)));
}
//2. Add permissions for this activity
props.setProperty(String.format(SUBJECT_OBJECT_PERMISSION_FORMAT, subject), ArrayUtils.toString(propertyNamesForPermissions.toArray()));
}
示例6: getValidUsageModes
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
public Set<DataUsage> getValidUsageModes() throws PropertyException {
String propertyValue = getProperty(ACModelProperty.VALID_USAGE_MODES);
if (propertyValue == null) {
throw new PropertyException(ACModelProperty.VALID_USAGE_MODES, propertyValue);
}
StringTokenizer tokens = StringUtils.splitArrayString(propertyValue, String.valueOf(ArrayUtils.VALUE_SEPARATION));
Set<DataUsage> result = new HashSet<DataUsage>();
while (tokens.hasMoreTokens()) {
String nextToken = tokens.nextToken();
if (nextToken.length() < 3) {
throw new PropertyException(ACModelProperty.VALID_USAGE_MODES, propertyValue);
}
nextToken = nextToken.substring(1, nextToken.length() - 1);
DataUsage nextUsage = null;
try {
nextUsage = DataUsage.parse(nextToken);
} catch (Exception e) {
throw new PropertyException(ACModelProperty.VALID_USAGE_MODES, nextToken);
}
result.add(nextUsage);
}
return result;
}
示例7: addActivityWithConstraints
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Adds an activity to the list of activities with routing constraints.
* @param activity The name of the activity to add.
* @throws ParameterException if the activity name is invalid.
*/
private void addActivityWithConstraints(String activity) {
Validate.notNull(activity);
Validate.notEmpty(activity);
Set<String> currentActivities = getActivitiesWithRoutingConstraints();
currentActivities.add(activity);
setProperty(ConstraintContextProperty.ACTIVITIES_WITH_CONSTRAINTS, ArrayUtils.toString(currentActivities.toArray()));
}
示例8: removeActivityWithConstraints
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Removes an activity from the list of activities with routing constraints.
* @param activity The name of the activity to remove.
* @throws ParameterException if the activity name is invalid.
*/
private void removeActivityWithConstraints(String activity) {
Validate.notNull(activity);
Validate.notEmpty(activity);
Set<String> currentActivities = getActivitiesWithRoutingConstraints();
currentActivities.remove(activity);
setProperty(ConstraintContextProperty.ACTIVITIES_WITH_CONSTRAINTS, ArrayUtils.toString(currentActivities.toArray()));
}
示例9: addConstraintNameToList
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Adds a new constraint property name to the list of constraint properties (CONSTRAINTS-field).
* @param constraintName The name of the constraint-property to add (e.g. CONSTRAINT_5).
* @throws ParameterException if the given property name is invalid.
*/
private void addConstraintNameToList(String constraintName) {
validateStringValue(constraintName);
Set<String> currentValues = getConstraintNameList();
currentValues.add(constraintName);
setProperty(ConstraintContextProperty.ALL_CONSTRAINTS, ArrayUtils.toString(currentValues.toArray()));
}
示例10: removeConstraintNameFromList
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Removes the constraint property with the given name from the list of constraint properties (CONSTRAINTS-field).
* @param constraintName The name of the constraint-property to remove (e.g. CONSTRAINT_5).
* @throws ParameterException if the given property name is invalid.
*/
private void removeConstraintNameFromList(String constraintName) {
validateStringValue(constraintName);
Set<String> currentValues = getConstraintNameList();
currentValues.remove(constraintName);
setProperty(ConstraintContextProperty.ALL_CONSTRAINTS, ArrayUtils.toString(currentValues.toArray()));
}
示例11: getConstraintNameList
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Returns all property names for routing constraints, <br>
* i.e. the value of the context property CONSTRAINTS.
* @return A set of all used property names for routing constraints.
*/
private Set<String> getConstraintNameList(){
Set<String> result = new HashSet<>();
String propertyValue = getProperty(ConstraintContextProperty.ALL_CONSTRAINTS);
if(propertyValue == null)
return result;
StringTokenizer attributeTokens = StringUtils.splitArrayString(propertyValue, String.valueOf(ArrayUtils.VALUE_SEPARATION));
while(attributeTokens.hasMoreTokens()){
String nextToken = attributeTokens.nextToken();
result.add(nextToken);
}
return result;
}
示例12: getConstraintNames
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Returns the property-names of all routing constraints related to the given activity.<br>
* These names are required to extract constraint property-values.
* @param activity The name of the activity
* @return A set of constraint property-names related to the given activity.
* @throws ParameterException if the given activity name is <code>null</code or invalid.
*/
private Set<String> getConstraintNames(String activity) {
Validate.notNull(activity);
Validate.notEmpty(activity);
Set<String> result = new HashSet<>();
String propertyValue = props.getProperty(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity));
if(propertyValue == null)
return result;
StringTokenizer subjectTokens = StringUtils.splitArrayString(propertyValue, String.valueOf(ArrayUtils.VALUE_SEPARATION));
while(subjectTokens.hasMoreTokens()){
String nextToken = subjectTokens.nextToken();
result.add(nextToken);
}
return result;
}
示例13: removeRoutingConstraint
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
public void removeRoutingConstraint(String activity, AbstractConstraint<?> constraint) throws PropertyException{
Validate.notNull(activity);
Validate.notEmpty(activity);
Validate.notNull(constraint);
//Find name of the given constraint
Set<String> propertyNamesForActivityConstraints = getConstraintNames(activity);
if(propertyNamesForActivityConstraints.isEmpty()){
//This activity has no constraints.
return;
}
String propertyNameForConstraintToRemove = null;
for(String propertyNameForActivityConstraint: propertyNamesForActivityConstraints){
AbstractConstraint<?> activityConstraint = getConstraint(propertyNameForActivityConstraint);
if(activityConstraint.equals(constraint)){
propertyNameForConstraintToRemove = propertyNameForActivityConstraint;
break;
}
}
if(propertyNameForConstraintToRemove == null){
//There is no stored reference to the given constraint to remove
//-> Removal not necessary
return;
}
//1. Remove the constraint itself
props.remove(propertyNameForConstraintToRemove);
//2. Remove the constraint from the list of constraints
removeConstraintNameFromList(propertyNameForConstraintToRemove);
//3. Remove the constraint from the activity constraint list.
Set<String> currentConstraintNames = getConstraintNames(activity);
currentConstraintNames.remove(propertyNameForConstraintToRemove);
if(currentConstraintNames.isEmpty()){
removeActivityWithConstraints(activity);
props.remove(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity));
} else {
props.setProperty(String.format(ACTIVITY_CONSTRAINTS_FORMAT, activity), ArrayUtils.toString(currentConstraintNames.toArray()));
}
}
示例14: addActivityWithDataUsage
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Adds an activity to the list of activities with data usage.
*
* @param activity The name of the activity to add.
* @throws ParameterException if the activity name is invalid.
*/
private void addActivityWithDataUsage(String activity) {
Validate.notNull(activity);
Validate.notEmpty(activity);
Set<String> currentActivities = getActivitiesWithDataUsage();
currentActivities.add(activity);
setProperty(ProcessContextProperty.ACTIVITIES_WITH_DATA_USAGE, ArrayUtils.toString(currentActivities.toArray()));
}
示例15: getDataUsageNameList
import de.invation.code.toval.misc.ArrayUtils; //导入依赖的package包/类
/**
* Returns all property names for data usages, <br>
* i.e. the value of the context property ACTIVITY_DATA_USAGES.
*
* @return A set of all used property names for data usages.
*/
private Set<String> getDataUsageNameList() {
Set<String> result = new HashSet<>();
String propertyValue = getProperty(ProcessContextProperty.ALL_DATA_USAGES);
if (propertyValue == null) {
return result;
}
StringTokenizer attributeTokens = StringUtils.splitArrayString(propertyValue, String.valueOf(ArrayUtils.VALUE_SEPARATION));
while (attributeTokens.hasMoreTokens()) {
String nextToken = attributeTokens.nextToken();
result.add(nextToken);
}
return result;
}