Package ptolemy.data

Examples of ptolemy.data.StringToken


     */
    public void fire() throws IllegalActionException {
        super.fire();
        if (input.hasToken(0)) {
            String string = input.get(0).toString();
            output.broadcast(new StringToken(string));
        } else {
            output.broadcast(new StringToken("absent"));
        }
    }
View Full Code Here


                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());
                    }
                }
            }
            for (int i = 0; i < input.getWidth(); i++) {
                if (input.hasToken(i)) {
                    XMLToken in = (XMLToken) input.get(i);
                    Document doc = in.getDomTree();

                    try {
                        javax.xml.transform.Source xmlSource = new javax.xml.transform.dom.DOMSource(
                                doc);
                        _transformer.transform(xmlSource, result);

                        if (_debugging) {
                            _debug("--- transform the xmlSource: "
                                    + in.toString() + "\n");
                        }

                        if (out != null) {
                            if (_debugging) {
                                _debug("--- moml change request string: "
                                        + out.toString() + "\n");
                            }

                            StringToken outputToken = new StringToken(out
                                    .toString());
                            output.broadcast(outputToken);

                            if (_debugging) {
                                _debug("--- change request string token "
                                        + "send out. \n");
                            }
                        }
                    } catch (TransformerException ex) {
                        throw new IllegalActionException(this, ex,
                                "Failed  to process '" + in + "'");
                    }

                    try {
                        out.flush();
                        out.close();
                    } catch (IOException ex) {
                        throw new IllegalActionException(this, ex,
                                "Failed  to close or flush '" + out + "'");
                    }
                }
            }
        } else {
            // If there is no transformer, then output the xml string.
            for (int i = 0; i < input.getWidth(); i++) {
                if (input.hasToken(i)) {
                    XMLToken in = (XMLToken) input.get(i);
                    output.broadcast(new StringToken(in.toString()));
                }
            }
        }
    }
View Full Code Here

            dataBytes[j] = (byte) dataIntOneToken.intValue(); //Keep low 8 bits
        }

        // Note:  Following line may assume 1 byte per character, not sure.
        String outputValue = new String(dataBytes);
        output.send(0, new StringToken(outputValue));
    }
View Full Code Here

        } else if (result instanceof Integer) {
            resultToken = new IntToken(((Integer) result).intValue());
        } else if (result instanceof Long) {
            resultToken = new LongToken(((Long) result).longValue());
        } else if (result instanceof String) {
            resultToken = new StringToken((String) result);
        } else if (result instanceof Boolean) {
            resultToken = new BooleanToken(((Boolean) result).booleanValue());
        } else if (result instanceof Complex) {
            resultToken = new ComplexToken((Complex) result);
        } else if (result instanceof FixPoint) {
View Full Code Here

                    _numOutChannels++;
                }
            }
        }

        StringToken token;

        while (true) {
            token = new StringToken(_strValue);

            int numBranches = _numInChannels + _numOutChannels;
            ConditionalBranch[] branches = new ConditionalBranch[numBranches];

            // Receive Branches
            for (int i = 0; i < _numInChannels; i++) {
                branches[i] = new ConditionalReceive(true, input, i, i);
            }

            // Send Branches
            for (int i = 0; i < _numOutChannels; i++) {
                branches[i + _numInChannels] = new ConditionalSend(true,
                        output, i, i + _numInChannels, token);
            }

            int br = chooseBranch(branches);

            // Sleep so that graphical displays involving this
            // applet will pause after colors are changed.
            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                throw new TerminateProcessException(this, "Terminated");
            }

            if ((br >= 0) && (br < _numInChannels)) {
                token = (StringToken) branches[br].getToken();
                _strValue = token.toString();
            } else if ((br >= _numInChannels) && (br < numBranches)) {
                _strValue = "write";
            } else if (br == -1) {
                return;
            }
View Full Code Here

        ctdir.minStepSize.setToken(new DoubleToken(1e-6));

        //StringToken token1 = new StringToken(
        //        "ptolemy.domains.ct.kernel.solver.BackwardEulerSolver");
        //ctdir.BreakpointODESolver.setToken(token1);
        StringToken token2 = new StringToken(
                "ptolemy.domains.ct.kernel.solver.ExplicitRK23Solver");
        ctdir.ODESolver.setToken(token2);

        // CT Actor Parameters
        scale0.factor.setToken(new DoubleToken(50.0));
View Full Code Here

            }

            if (read) {
                memoryInput.get(0);
            } else {
                StringToken strToken = new StringToken(getName());
                memoryOutput.broadcast(strToken);
            }

            return;
        } else {
View Full Code Here

        super(container, name);

        // Set the type of the input port.
        output.setMultiport(true);
        output.setTypeEquals(BaseType.DOUBLE);
        sourceURL = new Parameter(this, "sourceURL", new StringToken(""));
        sourceURL.setTypeEquals(BaseType.STRING);

        refresh = new Parameter(this, "refresh", new BooleanToken(false));
        refresh.setTypeEquals(BaseType.BOOLEAN);
View Full Code Here

     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == sourceURL) {
            try {
                StringToken URLToken = (StringToken) sourceURL.getToken();

                if (URLToken == null) {
                    _source = null;
                    setReader(null);
                } else {
                    _source = URLToken.stringValue();

                    if (_source.equals("")) {
                        setReader(null);
                    } else {
                        URL url = new URL(_source);
View Full Code Here

                ArrayToken demoTokens = (ArrayToken) applicationDemos
                        .getToken();

                for (int i = 0; i < demoTokens.length(); i++) {
                    StringToken demoToken = (StringToken) demoTokens
                            .getElement(i);
                    htmlBuffer.append(_aboutHTML(demoToken.stringValue()));
                    _demosURLs.add(demoToken.stringValue());
                }
            }
        } catch (Exception ex) {
            throw new InternalErrorException(configuration, ex,
                    "Bad configuration for " + applicationName);
View Full Code Here

TOP

Related Classes of ptolemy.data.StringToken

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.