當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。