Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpErlangTuple


     * @return tree node that describes data
     */
    public ITreeNode getData(final OtpErlangObject otpErlangObject) {
        try {
            if (otpErlangObject instanceof OtpErlangTuple) {
                final OtpErlangTuple tuple = (OtpErlangTuple) otpErlangObject;

                final String atomValue = ((OtpErlangAtom) tuple.elementAt(0)).atomValue();
                if (atomValue.equals(ATOM_TRACE_TS)) {
                    // trace data: {trace_ts, Data}

                    final OtpErlangAtom traceType = (OtpErlangAtom) tuple
                            .elementAt(INDEX_TRACE_TYPE);
                    lastTraceDate = readDateTuple((OtpErlangTuple) tuple.elementAt(tuple
                            .arity() - 1));

                    switch (TraceType.valueOf(traceType.atomValue().toUpperCase())) {
                    case CALL:
                        return processCallTrace("Call", tuple);
View Full Code Here


     *            date tuple
     * @return java date
     * @throws OtpErlangRangeException
     */
    private Date readDateTuple(final OtpErlangTuple tuple) throws OtpErlangRangeException {
        final OtpErlangTuple dateTuple = (OtpErlangTuple) tuple.elementAt(0);
        final OtpErlangTuple timeTuple = (OtpErlangTuple) tuple.elementAt(1);

        final int year = ((OtpErlangLong) dateTuple.elementAt(0)).intValue();
        final int month = ((OtpErlangLong) dateTuple.elementAt(1)).intValue() - 1;
        final int day = ((OtpErlangLong) dateTuple.elementAt(2)).intValue();
        final int hour = ((OtpErlangLong) timeTuple.elementAt(0)).intValue();
        final int minute = ((OtpErlangLong) timeTuple.elementAt(1)).intValue();
        final int second = ((OtpErlangLong) timeTuple.elementAt(2)).intValue();

        final Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day, hour, minute, second);

        return calendar.getTime();
View Full Code Here

        ITreeNode processNodeNode = null;

        if (erlangObject instanceof OtpErlangTuple) {
            // tuple: {Pid(), Initial_call()|Registered_name(), Node()} |
            // {Registered_name, Node()}
            final OtpErlangTuple processTuple = (OtpErlangTuple) erlangObject;
            int index = 0;

            // pid
            OtpErlangPid pid = null;
            if (processTuple.arity() == 3) {
                // {Pid(), Initial_call()|Registered_name(), Node()}
                pid = (OtpErlangPid) processTuple.elementAt(INDEX_PROCESS_PID);
                pidNode = new TreeNode("pid: " + pid2Str(pid),
                        Activator.getImage(Images.INFO_NODE));
            } else {
                index = 1;// tuple doesn't contain Pid element
            }

            final OtpErlangObject info = processTuple.elementAt(INDEX_PROCESS_INFO
                    - index);

            // process node
            final OtpErlangObject processNode = processTuple.elementAt(INDEX_PROCESS_NODE
                    - index);
            processNodeNode = new TreeNode("node: " + processNode,
                    Activator.getImage(Images.INFO_NODE));

            if (info instanceof OtpErlangTuple) {
View Full Code Here

    private ITreeNode createFunctionNode(final String label,
            final OtpErlangObject erlangObject) {
        final ITreeNode node = new TreeNode();
        if (erlangObject instanceof OtpErlangTuple) {
            final OtpErlangTuple functionTuple = (OtpErlangTuple) erlangObject;
            final OtpErlangAtom moduleName = (OtpErlangAtom) functionTuple
                    .elementAt(INDEX_FUNCTION_MODULE);
            final OtpErlangAtom functionName = (OtpErlangAtom) functionTuple
                    .elementAt(INDEX_FUNCTION_NAME);

            // args or arity node
            final TreeNode argsNode = new TreeNode();
            argsNode.setImage(Activator.getImage(Images.INFO_NODE));
            final OtpErlangObject arityOrArgs = functionTuple
                    .elementAt(INDEX_FUNCTION_ARGS);
            int arityValue = -1;
            if (arityOrArgs instanceof OtpErlangList) {
                // last element is a list of arguments
                final OtpErlangList arguments = (OtpErlangList) arityOrArgs;
                final StringBuilder builder = new StringBuilder("arguments: ");
                for (int i = 1; i < arguments.arity(); i++) {
                    builder.append(arguments.elementAt(i)).append(", ");
                }
                arityValue = arguments.arity() - 1;
                argsNode.setLabel(builder.substring(0, builder.length() - 2));
            } else {
                // last element is arity
                try {
                    if (functionTuple.elementAt(INDEX_FUNCTION_ARGS) instanceof OtpErlangInt) {
                        arityValue = ((OtpErlangInt) functionTuple
                                .elementAt(INDEX_FUNCTION_ARGS)).intValue();
                    } else {
                        arityValue = (int) ((OtpErlangLong) functionTuple
                                .elementAt(INDEX_FUNCTION_ARGS)).longValue();
                    }
                    argsNode.setLabel("arity: " + arityValue);
                } catch (final OtpErlangRangeException e) {
                    ErlLogger.error(e);
View Full Code Here

                Activator.getImage(image));
        node.addChildren(processNode);

        final OtpErlangList list = (OtpErlangList) tuple.elementAt(INDEX_INFO);
        for (final OtpErlangObject otpErlangObject : list) {
            final OtpErlangTuple infoTuple = (OtpErlangTuple) otpErlangObject;
            final OtpErlangObject key = infoTuple.elementAt(0);
            final OtpErlangObject value = infoTuple.elementAt(1);
            final TreeNode treeNode = new TreeNode(key.toString() + ": "
                    + value.toString());
            treeNode.setImage(Activator.getImage(Images.INFO_NODE));
            node.addChildren(treeNode);
        }
View Full Code Here

        final ITreeNode processNode = createProcessNode("process: ",
                tuple.elementAt(INDEX_PROCESS));
        processNode.setImage(Activator.getImage(Images.PROCESS_NODE));

        final OtpErlangTuple exceptionTuple = (OtpErlangTuple) tuple
                .elementAt(INDEX_EXCEPTION);
        final OtpErlangObject exceptionClass = exceptionTuple
                .elementAt(INDEX_EXCEPTION_CLASS);
        final OtpErlangObject exceptionValue = exceptionTuple
                .elementAt(INDEX_EXCEPTION_VALUE);
        labelBuilder.append(exceptionClass.toString());

        final ITreeNode exceptionClassNode = new TreeNode(exceptionClass.toString(),
                Activator.getImage(Images.INFO_NODE));
View Full Code Here

            }
        } catch (final Exception e) {
            ErlLogger.warn(e);
        }
        if (r instanceof OtpErlangTuple) {
            final OtpErlangTuple t = (OtpErlangTuple) r;
            if (((OtpErlangAtom) t.elementAt(0)).atomValue().compareTo("module") == 0) {
                return true;
            }
            // code couldn't be loaded
            // maybe here we should throw exception?
            return false;
View Full Code Here

        try {
            final OtpErlangList loaded = (OtpErlangList) backend.call("code",
                    "all_loaded", "");
            final List<OtpErlangAtom> mine = new ArrayList<OtpErlangAtom>();
            for (final OtpErlangObject elem : loaded) {
                final OtpErlangTuple t = (OtpErlangTuple) elem;
                final OtpErlangAtom mod = (OtpErlangAtom) t.elementAt(0);
                if (mod.atomValue().startsWith("erlide_")) {
                    // ErlLogger.debug(">>> HAD " + mod + "   " +
                    // t.elementAt(1));
                    mine.add(mod);
                }
View Full Code Here

                                final OtpErlangAtom name = new OtpErlangAtom(
                                        tracedNode.getNodeName());
                                final OtpErlangAtom cookie = new OtpErlangAtom(
                                        tracedNode.getCookie());

                                erlangObjects.add(new OtpErlangTuple(
                                        new OtpErlangObject[] { name, cookie }));
                                notActivatedNodes.add(tracedNode.getNodeName());
                            }
                        }
                        final OtpErlangList nodes = new OtpErlangList(
View Full Code Here

        }
        return status;
    }

    private TracingStatus processResult(final OtpErlangObject callResult) {
        final OtpErlangTuple tuple = (OtpErlangTuple) callResult;
        if (((OtpErlangAtom) tuple.elementAt(0)).atomValue().equals("error")) {
            errorObject = tuple.elementAt(1);
            return TracingStatus.ERROR;
        }
        final OtpErlangList nodeNames = (OtpErlangList) tuple.elementAt(1);
        activatedNodes = new ArrayList<String>();
        for (final OtpErlangObject nodeName : nodeNames) {
            final String nodeNameString = ((OtpErlangAtom) nodeName).atomValue();
            activatedNodes.add(nodeNameString);
            notActivatedNodes.remove(nodeNameString);
View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpErlangTuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.