Package ptolemy.data

Examples of ptolemy.data.RecordToken


        ptolemy.data.Token token = _evaluateChild(node, 0);
        String result = _childCode;

        // Handle indexing into a record.
        if ((argCount == 1) && token instanceof RecordToken) {
            RecordToken record = (RecordToken) token;

            if (record.labelSet().contains(node.getMethodName())) {
                _evaluatedChildToken = (record.get(node.getMethodName()));
                return;
            }
        }

        // The first child is the object to invoke the method on.
View Full Code Here


                        + "match in parsing a record expression.");

        String[] labels = (String[]) node.getFieldNames().toArray(
                new String[numChildren]);

        _evaluatedChildToken = (new RecordToken(labels, tokens));

        //if (node.isConstant()) {
        //    node.setToken(_evaluatedChildToken);
        //}
View Full Code Here

        if (_debugging) {
            _debug("--- open an output stream for the result. \n");
        }

        if (_transformer != null) {
            RecordToken parameters = (RecordToken) (styleSheetParameters
                    .getToken());
            if (parameters != null) {
                Iterator labels = parameters.labelSet().iterator();

                while (labels.hasNext()) {
                    String name = (String) labels.next();
                    Token token = parameters.get(name);
                    if (token instanceof StringToken) {
                        StringToken s = (StringToken) token;
                        _transformer.setParameter(name, s.stringValue());
                    } else {
                        _transformer.setParameter(name, token.toString());
View Full Code Here

            IOPort port = (IOPort) portArray[i];
            labels[i] = port.getName();
            values[i] = port.get(0);
        }

        RecordToken result = new RecordToken(labels, values);

        output.send(0, result);
    }
View Full Code Here

        // The following code is mostly copied from data.expr.ASTPtFunctionNode
        Object[] argValues = new Object[args];

        if (args > 0) {
            RecordToken argRecord = null;

            if (argv instanceof RecordToken) {
                argRecord = (RecordToken) argv;
            } else if (args > 1) {
                throw new IllegalActionException(this, "cannot convert "
                        + "input token to method call arguments.");
            }

            for (int i = 0; i < args; ++i) {
                Token arg = null;

                if (argRecord != null) {
                    arg = argRecord.get("arg" + (i + 1));
                } else {
                    // this is the case when the method takes one argument
                    // and the input token is not a record token
                    arg = argv;
                }
View Full Code Here

            frame.addComponentListener(this);
            _listeningTo = frame;
        }

        try {
            RecordToken value = (RecordToken) getToken();

            if (value == null) {
                return true;
            }

            ArrayToken boundsToken = (ArrayToken) value.get("bounds");
            BooleanToken maximizedToken = (BooleanToken) value.get("maximized");
            int x = ((IntToken) boundsToken.getElement(0)).intValue();
            int y = ((IntToken) boundsToken.getElement(1)).intValue();
            int width = ((IntToken) boundsToken.getElement(2)).intValue();
            int height = ((IntToken) boundsToken.getElement(3)).intValue();
View Full Code Here

        // Pack a HashMap with all of the record entries from
        // the original record and all of the updating ports.
        HashMap outputMap = new HashMap();

        RecordToken record = (RecordToken) input.get(0);
        Set recordLabels = record.labelSet();

        for (Iterator i = recordLabels.iterator(); i.hasNext();) {
            String name = (String) i.next();
            Token value = record.get(name);
            outputMap.put(name, value);
        }

        List inputPorts = inputPortList();
        Iterator inputPortsIterator = inputPorts.iterator();

        while (inputPortsIterator.hasNext()) {
            TypedIOPort inputPort = (TypedIOPort) inputPortsIterator.next();

            if (inputPort != input) {
                outputMap.put(inputPort.getName(), inputPort.get(0));
            }
        }

        // Construct a RecordToken and fill it with the values
        // in the HashMap.
        String[] labels = new String[outputMap.size()];
        Token[] values = new Token[outputMap.size()];

        int j = 0;

        for (Iterator i = outputMap.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            labels[j] = (String) entry.getKey();
            values[j] = (Token) entry.getValue();
            j++;
        }

        RecordToken result = new RecordToken(labels, values);
        output.send(0, result);
    }
View Full Code Here

TOP

Related Classes of ptolemy.data.RecordToken

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.