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


Java OtpErlangAtom类代码示例

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


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

示例1: load

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Loads the differences from Erlang structure
 * 
 * @param obj where to load from
 */
public static ChangesToGraph load(OtpErlangObject obj)
{
	ChangesToGraph recorder = new ChangesToGraph();
	OtpErlangTuple difference = (OtpErlangTuple)obj;
	if (difference.arity() != 7)
		throw new IllegalArgumentException("expected 7 components in diff");
	if (!((OtpErlangAtom)difference.elementAt(0)).atomValue().equals("statemachinedifference"))
		throw new IllegalArgumentException("first element of a record should be \"statemachinedifference\"");
	OtpErlangList addedTransitions = (OtpErlangList)difference.elementAt(1),removedTransitions = (OtpErlangList)difference.elementAt(2),addedStates = (OtpErlangList)difference.elementAt(3);
	OtpErlangAtom initial_state = (OtpErlangAtom)difference.elementAt(6);			
	
	Synapse.StatechumProcess.parseStatemachine(addedStates,addedTransitions,new OtpErlangList(new OtpErlangObject[0]),initial_state,recorder.added,null,false);
	Synapse.StatechumProcess.parseStatemachine(new OtpErlangList(new OtpErlangObject[0]),removedTransitions,new OtpErlangList(new OtpErlangObject[0]),null,recorder.removed,null,false);
	recorder.relabelling.clear();
	Synapse.StatechumProcess.updateMap(difference.elementAt(5),recorder.relabelling);
	return recorder;
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:22,代码来源:DifferenceVisualiser.java

示例2: initRunner

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** This one has to be called after construction of the runner. */
public void initRunner()
{
	// Now create another genserver to handle requests from this runner. Upon failure, the box remains closed.
	try
	{
		mboxOpen = true;
		call(new OtpErlangObject[] { new OtpErlangAtom("startrunner"), new OtpErlangAtom(getRunnerName()) }, "Failed to start a new runner.");
		genServerToCall = getRunnerName();
	}
	catch(IllegalArgumentException ex)
	{// if anything fails, eliminate this runner
		close();
		throw(ex);// rethrow
	}
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:17,代码来源:ErlangRunner.java

示例3: close

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Closes the mailbox, causing the linked processes to receive an exception. */
public synchronized void close()
{
	synchronized(nameToRunnerMap)
	{
		if (mboxOpen && !genServerToCall.equals(genServerDefault))
			try
			{
				call(new OtpErlangObject[] { new OtpErlangAtom("terminate") }, 1000);// a short timeout here since we do not care whether we are successful. Dormant processes are not too bad; timeouts on closing mboxes are possibly worse if we are closing many inboxes following unexpected termination of Erlang runtime. 
			}
			catch(IllegalArgumentException ex)
			{// if anything fails, ignore this
			}
		nameToRunnerMap.remove(this);
		thisMbox.close();
		mboxOpen = false;
	}
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:19,代码来源:ErlangRunner.java

示例4: updateConfiguration

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Using the supplied Erlang tuple, updates a supplied configuration. 
 * 
 * @param obj details to make to the pair.
 * @return null if everything went well or a text of an error message (mostly java-related) if it went wrong.
 */
public static String updateConfiguration(Configuration config, OtpErlangObject obj)
{
	String outcome = null;
	try
	{
		OtpErlangList list = (OtpErlangList) obj;
		for(OtpErlangObject p:list.elements())
		{
			OtpErlangTuple pair = (OtpErlangTuple) p;
			if (pair.arity() != 2)
				throw new IllegalArgumentException("key-value pair is not a pair, got "+p);
			config.assignValue(pair.elementAt(0).toString(), ((OtpErlangAtom)pair.elementAt(1)).atomValue(), true);
		}
	}
	catch(Throwable ex)
	{
		System.out.println(ex);
		outcome = ex.getMessage();
	}
	
	return outcome;
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:28,代码来源:ErlangRunner.java

示例5: loadDependencies

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/**
 * Extracts dependencies of the supplied module, assuming the module has
 * been successfully compiled and .beam file exists.
 * 
 * @param file
 *            the file of the module
 * @throws IOException
 *             if this fails.
 */
public void loadDependencies(File file, Configuration config) {
	OtpErlangTuple response = ErlangRunner.getRunner(config.getErlangMboxName()).call(
			new OtpErlangObject[] { new OtpErlangAtom("dependencies"),
					new OtpErlangAtom(ErlangRunner.getName(file, ErlangRunner.ERL.BEAM, config.getErlangCompileIntoBeamDirectory())) },
			"Could not load dependencies of " + file.getName());
	
	// the first element is 'ok'
	OtpErlangList listOfDepTuples = (OtpErlangList) response.elementAt(1);
	for (OtpErlangObject tup : listOfDepTuples.elements()) {
		String mod = ((OtpErlangAtom) ((OtpErlangTuple) tup).elementAt(0)).atomValue();
		if (!stdModsList.contains(mod) && !dependencies.contains(mod)) {
			dependencies.add(mod);
		}
	}
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:25,代码来源:OTPBehaviour.java

示例6: parseStatemachine

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Given a representation of FSM in a form of Erlang tuple, builds the corresponding graph.
		 * 
		 * @param obj FSM to parse
		 * @param gr graph to fill in (whatever was in there will be replaced by the data loaded from the graph, this is necessary since we do not know the specific type to instantiate here).
		 * @param converter label converter
		 * @param checkStates if true, will check that all source and target states have been defined earlier. If false, will add them if needed.
		 */
		public static <TARGET_TYPE,CACHE_TYPE extends CachedData<TARGET_TYPE,CACHE_TYPE>> void parseStatemachine(OtpErlangObject obj,AbstractLearnerGraph<TARGET_TYPE,CACHE_TYPE> gr, ConvertALabel converter, boolean checkStates)
		{
//		1	  states :: list(state()),
//		2	  transitions :: list(transition()),
//		3	  initial_state :: state(),
//		4	  alphabet :: list(event())
			OtpErlangTuple machine = (OtpErlangTuple)obj;
			if (machine.arity() != 5)
				throw new IllegalArgumentException("expected 5 components in FSM");
			if (!((OtpErlangAtom)machine.elementAt(0)).atomValue().equals("statemachine"))
				throw new IllegalArgumentException("first element of a record should be \"statemachine\"");
			OtpErlangList states = (OtpErlangList)machine.elementAt(1),transitions = (OtpErlangList)machine.elementAt(2),alphabet = (OtpErlangList)machine.elementAt(4);
			OtpErlangAtom initial_state = (OtpErlangAtom)machine.elementAt(3);
			
			parseStatemachine(states,transitions,alphabet,initial_state,gr,converter,checkStates);
		}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:24,代码来源:Synapse.java

示例7: constructFSM

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Turns the supplied graph into an Erlang tuple. 
 * @param gr graph to convert. 
 */
public static <TARGET_TYPE,CACHE_TYPE extends CachedData<TARGET_TYPE,CACHE_TYPE>> OtpErlangTuple constructFSM(AbstractLearnerGraph<TARGET_TYPE,CACHE_TYPE> gr)
{
	List<OtpErlangObject> statesList = new LinkedList<OtpErlangObject>(), transitions = new LinkedList<OtpErlangObject>();
	Map<String,OtpErlangObject> alphabet = new TreeMap<String,OtpErlangObject>();
	
	for(Entry<CmpVertex,Map<Label,TARGET_TYPE>> entry:gr.transitionMatrix.entrySet()) 
	{
		statesList.add(new OtpErlangAtom(entry.getKey().getStringId()));
		for(Entry<Label,TARGET_TYPE> transition:entry.getValue().entrySet())
		{
			String lblStr = transition.getKey().toErlangTerm();OtpErlangAtom lblAtom = new OtpErlangAtom(lblStr);
			alphabet.put(lblStr,lblAtom);
			for(CmpVertex target:gr.getTargets(transition.getValue()))
				transitions.add(new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom(entry.getKey().getStringId()), lblAtom, new OtpErlangAtom(target.getStringId())}));
		}
	}
	return new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom("statemachine"),new OtpErlangList(statesList.toArray(new OtpErlangObject[0])),
			new OtpErlangList(transitions.toArray(new OtpErlangObject[0])),
			new OtpErlangAtom(gr.getInit().getStringId()),new OtpErlangList(alphabet.values().toArray(new OtpErlangObject[alphabet.size()])),
	});
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:25,代码来源:Synapse.java

示例8: updateFrom

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Deserialises a map of functions to their types and updates a provided map with their values.
 * 
 * @param list what to deserialise
 * @param map what to update.
 */
public static void updateFrom(OtpErlangList list,Map<String,OtpErlangTuple> map)
{
	for(OtpErlangObject obj:list.elements())
	{
		if (!(obj instanceof OtpErlangTuple))
			throw new IllegalArgumentException("element of a list should be a tuple");
		OtpErlangTuple t=(OtpErlangTuple)obj;
		if (t.arity() != 2)
			throw new IllegalArgumentException("tuple should contain exactly two elements");
		
		if (!(t.elementAt(0) instanceof OtpErlangAtom))
			throw new IllegalArgumentException("type name should be an atom");
		if (!(t.elementAt(1) instanceof OtpErlangTuple))
			throw new IllegalArgumentException("type value should be a tuple");
		map.put( ((OtpErlangAtom)t.elementAt(0)).atomValue(), (OtpErlangTuple)t.elementAt(1));
	}
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:23,代码来源:Synapse.java

示例9: RecordSignature

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
public RecordSignature(Configuration config, OtpErlangList attributes,OtpErlangList fieldDetails) {
	if (attributes.arity() != 1) throw new IllegalArgumentException("RecordSignature expects a single attribute containing its name tag");
	orderedSignatures = new ArrayList<Signature>(fieldDetails.arity());
	nameTag = (OtpErlangAtom)attributes.elementAt(0);
	orderedSignatures.add(new AtomSignature(config,new OtpErlangList(),new OtpErlangList(new OtpErlangObject[]{
			nameTag
	})));
	name = nameTag.atomValue();
    fields = new TreeMap<String, Signature>();
    for(OtpErlangObject obj:fieldDetails)
    {
    	OtpErlangTuple nameValue = (OtpErlangTuple)obj;
    	if (nameValue.arity() != 2) throw new IllegalArgumentException("Invalid name-type field "+obj+" passed to RecordSignature");
    	Signature sig = Signature.buildFromType(config, nameValue.elementAt(1));
    	orderedSignatures.add(sig);
    	fields.put(((OtpErlangAtom)nameValue.elementAt(0)).atomValue(),sig);
    }
    erlangTermForThisType = erlangTypeToString(attributes,fieldDetails);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:20,代码来源:RecordSignature.java

示例10: ErlangLabel

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
public ErlangLabel(FuncSignature operator, String shortName,
		OtpErlangObject inputArgs, OtpErlangObject expectedOutputArgs) {
	super(
			// if there is no valid function involved, this label cannot be passed to Erlang.
			operator == null? new OtpErlangObject[]{}:
			expectedOutputArgs == null ? new OtpErlangObject[] {
			// if no outputs, generate a function/input pair
			new OtpErlangAtom(operator.getName()), inputArgs }
			: new OtpErlangObject[] { 
			// with an output, this will be a function/input/output triple.
			new OtpErlangAtom(operator.getName()),inputArgs, expectedOutputArgs });
	arity = expectedOutputArgs == null ? 2 : 3;
	function = operator;
	callName = shortName;
	input = inputArgs;
	expectedOutput = expectedOutputArgs;
	alphaNum = buildFunctionSignatureAsString();
	if (function != null)
		function.typeCompatible(this);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:21,代码来源:ErlangLabel.java

示例11: testClosedRunner2

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** Tests that an attempt to use a closed runner ID fails. */
@Test
public void testClosedRunner2()
{
	final ErlangRunner r = new ErlangRunner(erlRuntime.traceRunnerNode);
	Assert.assertFalse(r.mboxOpen);
	r.initRunner();
	Assert.assertTrue(r.mboxOpen);
	
	OtpErlangTuple response = (OtpErlangTuple)r.call(new OtpErlangObject[]{new OtpErlangAtom("echo"),
			new OtpErlangList(new OtpErlangObject[]{ new OtpErlangAtom(dataHead)})},
			0);
	Assert.assertEquals(dataHead,((OtpErlangAtom)response.elementAt(0)).atomValue());

	Assert.assertTrue(registeredProcessExists(r));

	r.close();
	Assert.assertFalse(r.mboxOpen);
	Assert.assertFalse(registeredProcessExists(r));
	
	// verify failure
	checkForCorrectException(new whatToRun() { public @Override void run() {
		r.call(new OtpErlangObject[]{new OtpErlangAtom("echoA")},200);
	}},IllegalArgumentException.class,"is closed");
	
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:27,代码来源:TestErlangRunner.java

示例12: testToString12

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
/** A bigger structure to dump. */
@Test
public void testToString12()
{
	Assert.assertEquals("{\'this is an atom\',\"this is a string\",[[-234],{}]}",
			ErlangLabel.dumpErlangObject(new OtpErlangTuple(new OtpErlangObject[]{
					new OtpErlangAtom("this is an atom"),
					new OtpErlangString("this is a string"),
					new OtpErlangList(new OtpErlangObject[]{
							new OtpErlangList(new OtpErlangObject[]{
									new OtpErlangInt(-234)
							}),
							new OtpErlangTuple(new OtpErlangObject[]{
							})
					})
			})));
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:18,代码来源:TestErlangParser.java

示例13: testParseBig

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
@Test
public void testParseBig()
{
	final String text = "{\'this is an atom\',\"this is a string\",[[-234],{}]}";
	OtpErlangObject obtained = ErlangLabel.parseText(text);
	checkResponse(runner, text, text);
	Assert.assertEquals(new OtpErlangTuple(new OtpErlangObject[]{
					new OtpErlangAtom("this is an atom"),
					new OtpErlangString("this is a string"),
					new OtpErlangList(new OtpErlangObject[]{
							new OtpErlangList(new OtpErlangObject[]{
									new OtpErlangInt(-234)
							}),
							new OtpErlangTuple(new OtpErlangObject[]{
							})
					})
			}),obtained);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:19,代码来源:TestErlangParser.java

示例14: testSetRed1

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
@Test
public void testSetRed1()
{
	Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
	LearnerGraphND grA = new LearnerGraphND(config);
	OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
            "[{'P1000',a,'P1000'},"+
            " {'P1000',b,'P1002'},"+
            " {'P1000',c,'N1000'},"+
            " {'P1002',c,'P1002'},"+
            " {'P1002',d,'P1002'}],"+
            "'P1000',"+
            "[d,b,c,a]}");
	Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
	Assert.assertEquals(0, grA.getRedStateNumber());
	Synapse.StatechumProcess.setReds(new OtpErlangList(new OtpErlangObject[]{new OtpErlangAtom("P1002")}), grA);
	Assert.assertEquals(JUConstants.RED,grA.findVertex("P1002").getColour());
	Assert.assertEquals(1, grA.getRedStateNumber());
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:20,代码来源:TestSynapseAuxiliaryFunctions.java

示例15: testSetRed2

import com.ericsson.otp.erlang.OtpErlangAtom; //导入依赖的package包/类
@Test
public void testSetRed2()
{
	Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
	final LearnerGraphND grA = new LearnerGraphND(config);
	OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
            "[{'P1000',a,'P1000'},"+
            " {'P1000',b,'P1002'},"+
            " {'P1000',c,'N1000'},"+
            " {'P1002',c,'P1002'},"+
            " {'P1002',d,'P1002'}],"+
            "'P1000',"+
            "[d,b,c,a]}");
	Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
	Assert.assertEquals(0, grA.getRedStateNumber());
	checkForCorrectException(new whatToRun() { public @Override void run() {
		Synapse.StatechumProcess.setReds(new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom("P1002")}), grA);
	}},ClassCastException.class,"OtpErlangTuple");
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:20,代码来源:TestSynapseAuxiliaryFunctions.java


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