本文整理汇总了Java中com.ericsson.otp.erlang.OtpErlangTuple类的典型用法代码示例。如果您正苦于以下问题:Java OtpErlangTuple类的具体用法?Java OtpErlangTuple怎么用?Java OtpErlangTuple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OtpErlangTuple类属于com.ericsson.otp.erlang包,在下文中一共展示了OtpErlangTuple类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: load
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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: updateConfiguration
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例3: rebuildSigs
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
/** Sometimes we might want to override type definitions provided by typer. This function permits one to construct alphabet based on updated types.
* @param updatesToTypes overrides to type information
*/
public void rebuildSigs(Configuration config,Map<String, OtpErlangTuple> updatesToTypes)
{
sigTypes.putAll(updatesToTypes);sigs.clear();
for(Entry<String,OtpErlangTuple> entry:sigTypes.entrySet())
{
OtpErlangTuple functionDescr = entry.getValue();
if (functionDescr.arity() > 3)
{
FuncSignature s = new FuncSignature(config,functionDescr, null);
if (!s.getQualifiedName().equals(entry.getKey()))
throw new IllegalArgumentException("invalid override, expected name "+entry.getKey()+", got "+s.getQualifiedName());
sigs.put(entry.getKey(), s);
}
else
throw new IllegalArgumentException("invalid type of an Erlang function");
}
behaviour = OTPBehaviour.obtainDeclaredBehaviour(config.getErlangSourceFile(), config, this,ignoredBehaviours);
}
开发者ID:kirilluk,项目名称:statechum,代码行数:22,代码来源:ErlangModule.java
示例4: loadDependencies
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例5: parseStatemachine
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例6: constructFSM
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例7: updateFrom
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例8: RecordSignature
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例9: typeCompatible
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
/** Given that orderedSignatures starts with an atom reflecting the tag of this record,
* checking is identical to that for the tuple.
*/
@Override
public boolean typeCompatible(OtpErlangObject term)
{
if (!(term instanceof OtpErlangTuple)) return false;
OtpErlangTuple tuple = (OtpErlangTuple)term;
if (tuple.arity() != orderedSignatures.size()) return false;
Iterator<Signature> sigIterator = orderedSignatures.iterator();
for(int i=0;i<orderedSignatures.size();++i)
if (!sigIterator.next().typeCompatible(tuple.elementAt(i)))
return false;
return true;
}
开发者ID:kirilluk,项目名称:statechum,代码行数:19,代码来源:RecordSignature.java
示例10: typeCompatible
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
@Override
public boolean typeCompatible(OtpErlangObject term)
{
if (!(term instanceof OtpErlangTuple)) return false;
OtpErlangTuple tuple = (OtpErlangTuple)term;
if (tuple.arity() != elems.size()) return false;
Iterator<Signature> sigIterator = elems.iterator();
for(int i=0;i<elems.size();++i)
{
Signature sig = sigIterator.next();
if (!sig.typeCompatible(tuple.elementAt(i)))
return false;
}
return true;
}
开发者ID:kirilluk,项目名称:statechum,代码行数:18,代码来源:TupleSignature.java
示例11: testClosedRunner2
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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.OtpErlangTuple; //导入依赖的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.OtpErlangTuple; //导入依赖的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: testSetRed2
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的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
示例15: runDialyzerAndTyperAsAProcessInsideErlang
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
/** Only used for testing against runTyperAsAProcess.
* @throws IOException */
protected String runDialyzerAndTyperAsAProcessInsideErlang(File f) throws IOException
{
ErlangRunner.compileErl(f, runner, true);
OtpErlangObject otpArgs[] = new OtpErlangObject[]{
null,
new OtpErlangList(new OtpErlangObject[]{new OtpErlangString(ErlangRunner.getName(f, ERL.BEAM, true))}),
new OtpErlangString(ErlangRunner.getName(f, ERL.PLT, true)),
new OtpErlangList(new OtpErlangObject[]{new OtpErlangString(ErlangRunner.getName(f, ERL.ERL, false))}),
new OtpErlangAtom("text")
};
otpArgs[0]=new OtpErlangAtom("dialyzer");
runner.call(otpArgs,"Could not run dialyzer");
otpArgs[0]=new OtpErlangAtom("typer");
OtpErlangTuple response = runner.call(otpArgs,"Could not run typer");
return ((OtpErlangString)response.elementAt(1)).stringValue();
}
开发者ID:kirilluk,项目名称:statechum,代码行数:19,代码来源:TestErlangModule.java
示例16: testEncode
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
@Test
public void testEncode()
throws OtpErlangDecodeException, DecoderException
{
OtpErlangObject[] list = {new OtpErlangLong(12),
new OtpErlangAtom("[email protected]")};
OtpErlangObject[] list2 = {new OtpErlangTuple(list),
new OtpErlangAtom("[email protected]")};
OtpErlangTuple t = new OtpErlangTuple(list2);
SplitTask splitTask = new SplitTask("[email protected]", t);
byte[] b = splitTask.term2binary(t);
OtpErlangObject o = splitTask.binary2term(b);
assertEquals(t, (OtpErlangTuple)o);
String s = splitTask.toString();
SplitTask task2 = new SplitTask(s);
assertEquals(s, task2.toString());
assertEquals(splitTask.getHost(), task2.getHost());
assertEquals(splitTask.getTask(), task2.getTask());
assertEquals(t, task2.getTask());
}
开发者ID:kuenishi,项目名称:presto-riak,代码行数:25,代码来源:TestSplitTask.java
示例17: populateFromMfaList
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
public void populateFromMfaList(OtpErlangList stackTrace) {
try {
for (OtpErlangObject obj : stackTrace) {
if(obj instanceof OtpErlangString) {
OtpErlangString errorMessage = (OtpErlangString) obj;
getItems().add(new ErlyberlyStackTraceElement(errorMessage.stringValue()));
}
else {
OtpErlangTuple tuple = OtpUtil.toTuple(obj);
OtpErlangAtom module = (OtpErlangAtom) tuple.elementAt(0);
OtpErlangAtom function = (OtpErlangAtom) tuple.elementAt(1);
OtpErlangLong arity = (OtpErlangLong) tuple.elementAt(2);
ModFunc modFunc = mfaToModFunc(module, function, arity);
getItems().add(new ErlyberlyStackTraceElement(modFunc, "", 0L));
}
}
}
catch (Exception e) {
// try/catch so if there is a problem decoding the process_dump, it won't
// stop the trace log from being shown.
e.printStackTrace();
}
}
开发者ID:andytill,项目名称:erlyberly,代码行数:24,代码来源:StackTraceView.java
示例18: onViewDict
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
public void onViewDict(ActionEvent e) {
TreeItem<TermTreeItem> item = getSelectionModel().getSelectedItem();
if(item == null)
return;
if(item.getValue() == null || !DICT_ATOM.equals(item.getValue().getObject()))
return;
if(item.getParent() == null || !(item.getParent().getValue().getObject() instanceof OtpErlangTuple))
return;
OtpErlangObject dict = item.getParent().getValue().getObject();
try {
OtpErlangList props = ErlyBerly.nodeAPI().dictToPropslist(dict);
TermTreeView parentControl = new TermTreeView();
parentControl.populateFromTerm(props);
ErlyBerly.showPane("dict_to_list", ErlyBerly.wrapInPane(parentControl));
}
catch (Exception e1) {
e1.printStackTrace();
}
}
开发者ID:andytill,项目名称:erlyberly,代码行数:22,代码来源:TermTreeView.java
示例19: tracePropsToString
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
private String tracePropsToString() {
StringBuilder sb = new StringBuilder(1024);
boolean appendArity = false;
toCallString(sb, appendArity);
sb.append(" => ");
if(map.containsKey(RESULT_ATOM)) {
ErlyBerly.getTermFormatter().appendToString((OtpErlangObject) map.get(RESULT_ATOM), sb);
}
else if(isExceptionThrower()) {
OtpErlangTuple exception = (OtpErlangTuple) map.get(EXCEPTION_FROM_ATOM);
ErlyBerly.getTermFormatter().exceptionToString(
(OtpErlangAtom) exception.elementAt(0), exception.elementAt(1)
);
}
return sb.toString();
}
开发者ID:andytill,项目名称:erlyberly,代码行数:20,代码来源:TraceLog.java
示例20: modFuncArgsToString
import com.ericsson.otp.erlang.OtpErlangTuple; //导入依赖的package包/类
/**
* Convert an MFA tuple to a string, where the MFA must have the type:
*
* {Module::atom(), Function::atom(), Args::[any()]}.
*/
@Override
public String modFuncArgsToString(OtpErlangTuple mfa) {
StringBuilder sb = new StringBuilder();
sb.append(moduleNameToString((OtpErlangAtom) mfa.elementAt(0)))
.append(".")
.append(funToStringNoQuotes((OtpErlangAtom) mfa.elementAt(1)))
.append("(");
OtpErlangList args = (OtpErlangList) mfa.elementAt(2);
ArrayList<String> stringArgs = new ArrayList<>();
for (OtpErlangObject arg : args) {
stringArgs.add(toString(arg));
}
sb.append(String.join(", ", stringArgs));
sb.append(")");
return sb.toString();
}
开发者ID:andytill,项目名称:erlyberly,代码行数:22,代码来源:ElixirFormatter.java
注:本文中的com.ericsson.otp.erlang.OtpErlangTuple类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论