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


Java NumberConstraint类代码示例

本文整理汇总了Java中de.invation.code.toval.constraint.NumberConstraint的典型用法代码示例。如果您正苦于以下问题:Java NumberConstraint类的具体用法?Java NumberConstraint怎么用?Java NumberConstraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NumberConstraint类属于de.invation.code.toval.constraint包,在下文中一共展示了NumberConstraint类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCheckStateGuard

import de.invation.code.toval.constraint.NumberConstraint; //导入依赖的package包/类
@Test
public void testCheckStateGuard() throws ParameterException {

	// Get a simple standard SNet and two of its transitions
	IFNet sNet = IFNetTestUtil.createSimpleIFNet();
	RegularIFNetTransition trans = (RegularIFNetTransition) sNet.getTransition("tIn");

	// create aGuardDataContainer
	TestGuardDataContainer tgdc = new TestGuardDataContainer(sNet.getTokenColors());

	// create two guards
	NumberConstraint trueConstraint = new NumberConstraint("green", NumberOperator.IN_INTERVAL, -1, 1);
	NumberConstraint falseConstraint = new NumberConstraint("green", NumberOperator.IN_INTERVAL, 2, 3);

	// check state with true constraint
	trans.setGuardDataContainer(tgdc);
	trans.addGuard(trueConstraint);
	trans.checkState();
	assertTrue("An enabled transition is reported to be disabled", trans.isEnabled());

	// check state with additional false constraint
	trans.addGuard(falseConstraint);
	trans.checkState();
	assertFalse("An disabled transition is reported to be enabled", trans.isEnabled());
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:26,代码来源:RegularIFNetTransitionTest.java

示例2: testRemoveGuard

import de.invation.code.toval.constraint.NumberConstraint; //导入依赖的package包/类
@Test
public void testRemoveGuard() throws ParameterException {
	IFNet sNet = IFNetTestUtil.createSimpleIFNet();
	RegularIFNetTransition trans = (RegularIFNetTransition) sNet.getTransition("tIn");

	// Get the gurads and check there are no guards initially
	Set<AbstractConstraint<?>> guards = trans.getGuards();
	assertTrue(guards.isEmpty());

	// add a guard and make sure it is really there
	trans.setGuardDataContainer(new TestGuardDataContainer(sNet.getTokenColors()));
	NumberConstraint nc = new NumberConstraint("green", NumberOperator.LARGER, -3);
	trans.addGuard(nc);
	assertFalse(guards.isEmpty());

	// remove it again
	trans.removeGuard(nc);
	assertTrue(guards.isEmpty());
}
 
开发者ID:iig-uni-freiburg,项目名称:SEPIA,代码行数:20,代码来源:RegularIFNetTransitionTest.java

示例3: getConstraint

import de.invation.code.toval.constraint.NumberConstraint; //导入依赖的package包/类
/**
 * Extracts the constraint with the given name in form of a constraint-object.<br>
 * @param constraintName The property-name of the constraint (CONSTRAINT_X)
 * @return The constraint-representation of the constraint-property
 * @throws PropertyException if there is no constraint with the given name or the value cannot be converted into a number- or string-constraint.
 */
private AbstractConstraint<?> getConstraint(String constraintName) throws PropertyException{
	String constraintString = props.getProperty(constraintName);
	if(constraintString == null)
		throw new PropertyException(ConstraintContextProperty.CONSTRAINT, constraintName, "Unparseable constraint");
	AbstractConstraint<?> result = null;
	try{
		result = NumberConstraint.parse(constraintString);
	}catch(Exception e){
		try{
			result = StringConstraint.parse(constraintString);
		}catch(Exception e1){
			throw new PropertyException(ConstraintContextProperty.CONSTRAINT, constraintName, "Unparseable constraint", e1);
		}
	}
	return result;
}
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:23,代码来源:ConstraintContextProperties.java

示例4: main

import de.invation.code.toval.constraint.NumberConstraint; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
                Map<String, Set<DataUsage>> usage1 = new HashMap<>();
                Set<DataUsage> modes1 = new HashSet<>(Arrays.asList(DataUsage.READ, DataUsage.WRITE));
                usage1.put("attribute1", modes1);

                Map<String, Set<DataUsage>> usage2 = new HashMap<>();
                Set<DataUsage> modes2 = new HashSet<>(Arrays.asList(DataUsage.READ, DataUsage.DELETE));
                usage2.put("attribute2", modes2);

                Set<String> activities = new HashSet<>(Arrays.asList("act1", "act2"));
                Set<String> attributes = new HashSet<>(Arrays.asList("attribute1", "attribute2"));
                Set<String> subjects = new HashSet<>(Arrays.asList("s1", "s2"));
                ConstraintContext c = new ConstraintContext("c1");
                c.setActivities(activities);
                c.addAttributes(attributes);
                c.addSubjects(subjects);
                c.setDataUsageFor("act1", usage1);
                c.setDataUsageFor("act2", usage2);
                c.addRoutingConstraint("act1", NumberConstraint.parse("attribute1 < 200"));

                ACLModel acModel = new ACLModel("acl1", c);
                acModel.setName("acmodel1");
                acModel.setActivityPermission("s1", activities);
                c.setACModel(acModel);

                c.showDialog(null);

//        System.out.println(c);
//
//        c.getProperties().store("/Users/stocker/Desktop/processContext");
//
//        ConstraintContextProperties properties = new ConstraintContextProperties();
//        properties.load("/Users/stocker/Desktop/processContext");
//        SOABase c1 = SOABase.createFromProperties(properties);
//        System.out.println(c1);
//        System.out.println(c1.equals(c));
//        System.out.println(properties.getBaseClass());
//        System.out.println(c1.getClass());
        }
 
开发者ID:iig-uni-freiburg,项目名称:SEWOL,代码行数:40,代码来源:ConstraintContext.java


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