Package ptolemy.data

Examples of ptolemy.data.StringToken


                lineBuffer = lineBuffer.append(line);
                lineBuffer = lineBuffer.append(newlineValue);
            }

            output.broadcast(new StringToken(lineBuffer.toString()));
        } catch (Throwable throwable) {
            throw new IllegalActionException(this, throwable,
                    "Failed to write '" + fileOrURL + "'");
        } finally {
            if (fileOrURL != null) {
View Full Code Here


        } else if (object instanceof Complex) {
            returnValue = new ComplexToken((Complex) object);
        } else if (object instanceof FixPoint) {
            returnValue = new FixToken((FixPoint) object);
        } else if (object instanceof String) {
            returnValue = new StringToken((String) object);
        } else if (object instanceof boolean[][]) {
            returnValue = new BooleanMatrixToken((boolean[][]) object);
        } else if (object instanceof int[][]) {
            returnValue = new IntMatrixToken((int[][]) object);
        } else if (object instanceof long[][]) {
            returnValue = new LongMatrixToken((long[][]) object);
        } else if (object instanceof double[][]) {
            returnValue = new DoubleMatrixToken((double[][]) object);
        } else if (object instanceof Complex[][]) {
            returnValue = new ComplexMatrixToken((Complex[][]) object);
        } else if (object instanceof FixPoint[][]) {
            returnValue = new FixMatrixToken((FixPoint[][]) object);
        } else if (object instanceof double[]) {
            DoubleToken[] temp = new DoubleToken[((double[]) object).length];

            for (int j = 0; j < temp.length; j++) {
                temp[j] = new DoubleToken(((double[]) object)[j]);
            }

            returnValue = new ArrayToken(temp);
        } else if (object instanceof Complex[]) {
            ComplexToken[] temp = new ComplexToken[((Complex[]) object).length];

            for (int j = 0; j < temp.length; j++) {
                temp[j] = new ComplexToken(((Complex[]) object)[j]);
            }

            returnValue = new ArrayToken(temp);
        } else if (object instanceof int[]) {
            IntToken[] temp = new IntToken[((int[]) object).length];

            for (int j = 0; j < temp.length; j++) {
                temp[j] = new IntToken(((int[]) object)[j]);
            }

            returnValue = new ArrayToken(temp);
        } else if (object instanceof long[]) {
            LongToken[] temp = new LongToken[((long[]) object).length];

            for (int j = 0; j < temp.length; j++) {
                temp[j] = new LongToken(((long[]) object)[j]);
            }

            returnValue = new ArrayToken(temp);
        } else if (object instanceof boolean[]) {
            BooleanToken[] temp = new BooleanToken[((boolean[]) object).length];

            for (int j = 0; j < temp.length; j++) {
                temp[j] = new BooleanToken(((boolean[]) object)[j]);
            }

            returnValue = new ArrayToken(temp);
        } else if (object instanceof String[]) {
            StringToken[] temp = new StringToken[((String[]) object).length];

            for (int j = 0; j < temp.length; j++) {
                temp[j] = new StringToken(((String[]) object)[j]);
            }

            returnValue = new ArrayToken(temp);
        } else if (object instanceof FixPoint[]) {
            // Create back an ArrayToken containing FixTokens
View Full Code Here

        super.fire();
        start.update();
        stop.update();

        if (input.hasToken(0)) {
            StringToken inputToken = (StringToken) input.get(0);
            String value = inputToken.stringValue();
            int startValue = ((IntToken) start.getToken()).intValue();
            int stopValue = ((IntToken) stop.getToken()).intValue();
            String substringValue;

            if (stopValue == -1) {
                substringValue = value.substring(startValue);
            } else {
                substringValue = value.substring(startValue, stopValue);
            }

            output.send(0, new StringToken(substringValue));
        }
    }
View Full Code Here

            ArrayList portTypes = new ArrayList();

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                TypedIOPort port = (TypedIOPort) ports.next();
                portNames.add(port.getName());
                portTypes.add(new StringToken(port.getType().toString()));
            }

            if (portNames.size() > 0) {
                portActorNameList.add(entity.getName());
                portAssignments.add(new RecordToken((String[]) portNames
                        .toArray(new String[portNames.size()]),
                        (Token[]) portTypes
                                .toArray(new Token[portTypes.size()])));
            }

            ArrayList paramNames = new ArrayList();
            ArrayList paramTypes = new ArrayList();

            for (Iterator params = entity.attributeList(Parameter.class)
                    .iterator(); params.hasNext();) {
                Parameter param = (Parameter) params.next();
                paramNames.add(param.getName());
                paramTypes.add(new StringToken(param.getType().toString()));
            }

            if (paramNames.size() > 0) {
                parameterActorNameList.add(entity.getName());
                parameterAssignments.add(new RecordToken((String[]) paramNames
                        .toArray(new String[paramNames.size()]),
                        (Token[]) paramTypes.toArray(new Token[paramTypes
                                .size()])));
            }
        }

        RecordToken actualPortTypes = new RecordToken(
                (String[]) portActorNameList
                        .toArray(new String[portActorNameList.size()]),
                (Token[]) portAssignments.toArray(new Token[portAssignments
                        .size()]));
        RecordToken actualParameterTypes = new RecordToken(
                (String[]) parameterActorNameList
                        .toArray(new String[parameterActorNameList.size()]),
                (Token[]) parameterAssignments
                        .toArray(new Token[parameterAssignments.size()]));

        if (((BooleanToken) trainingMode.getToken()).booleanValue()) {
            if (NonStrictTest.isRunningNightlyBuild()) {
                throw new IllegalActionException(this,
                        NonStrictTest.TRAINING_MODE_ERROR_MESSAGE);
            } else {
                System.err.println("Warning: '" + this.getFullName()
                        + "' is in training mode, set the trainingMode "
                        + "parameter to false before checking in");
            }

            if (actualPortTypes.length() > 0) {
                portTypes.setToken(actualPortTypes);
            } else {
                portTypes.setToken((Token) null);
            }

            if (actualParameterTypes.length() > 0) {
                parameterTypes.setToken(actualParameterTypes);
            } else {
                parameterTypes.setToken((Token) null);
            }
        } else {
            RecordToken correctPortTypes = (RecordToken) portTypes.getToken();
            RecordToken correctParameterTypes = (RecordToken) parameterTypes
                    .getToken();

            if (correctPortTypes != null) {
                for (Iterator actorNames = correctPortTypes.labelSet()
                        .iterator(); actorNames.hasNext();) {
                    String actorName = (String) actorNames.next();
                    RecordToken assignment = (RecordToken) correctPortTypes
                            .get(actorName);

                    for (Iterator names = assignment.labelSet().iterator(); names
                            .hasNext();) {
                        String name = (String) names.next();
                        StringToken value = (StringToken) assignment.get(name);

                        if (actualPortTypes.get(actorName) == null) {
                            throw new IllegalActionException(
                                    this,
                                    "actualPortTypes.get("
                                            + actorName
                                            + ") returned null.  Perhaps there is no "
                                            + "actor by that name?");
                        }

                        StringToken actualValue = (StringToken) ((RecordToken) actualPortTypes
                                .get(actorName)).get(name);

                        if (!value.equals(actualValue)) {
                            throw new IllegalActionException(
                                    this,
                                    "Type of port "
                                            + ((CompositeEntity) getContainer())
                                                    .getEntity(actorName)
                                                    .getFullName() + "." + name
                                            + " should have been " + value
                                            + " but was " + actualValue + ".");
                        }
                    }
                }
            }

            if (correctParameterTypes != null) {
                for (Iterator actorNames = correctParameterTypes.labelSet()
                        .iterator(); actorNames.hasNext();) {
                    String actorName = (String) actorNames.next();
                    RecordToken assignment = (RecordToken) correctParameterTypes
                            .get(actorName);

                    for (Iterator names = assignment.labelSet().iterator(); names
                            .hasNext();) {
                        String name = (String) names.next();
                        StringToken value = (StringToken) assignment.get(name);
                        StringToken actualValue = (StringToken) ((RecordToken) actualParameterTypes
                                .get(actorName)).get(name);

                        if (!value.equals(actualValue)) {
                            throw new IllegalActionException(
                                    this,
View Full Code Here

            String uniqueName = _actor.uniqueName(symbol);

            if (_getType(symbol).equals("import")) {
                PtalonActor actor = new PtalonActor(_actor, uniqueName);
                URL url = _imports.get(symbol);
                actor.ptalonCodeLocation.setToken(new StringToken(url.toString()));
                actor.setNestedDepth(_actor.getNestedDepth() + 1);
                _currentActorTree.assignPtalonParameters(actor);
                _currentActorTree.makeConnections(actor);
                _currentActorTree.removeDynamicLeftHandSides();
            } else if (_getType(symbol).equals("actorparameter")) {
                PtalonParameter parameter = (PtalonParameter) _actor
                        .getAttribute(getMappedName(symbol));
                if (!parameter.hasValue()) {
                    throw new PtalonRuntimeException("Parameter" + symbol
                            + "has no value");
                }
                String expression = parameter.getExpression();
                String[] parsedExpression;
                if (expression.contains("(")) {
                    parsedExpression = _parseActorExpression(expression);
                } else {
                    parsedExpression = new String[1];
                    parsedExpression[0] = expression;
                }
                String actor = parsedExpression[0];
                if (actor.startsWith("ptalonActor:")) {
                    PtalonActor ptalonActor = new PtalonActor(_actor,
                            uniqueName);
                    // Set ptalonCodeLocation to a path to the .ptln file.
                    // The path will have $CLASSPATH in it so that this works
                    // in WebStart and the installer.
                    ptalonActor.ptalonCodeLocation.setToken(new StringToken(
                                    _parameterToImport(actor)));
                    ptalonActor.setNestedDepth(_actor.getNestedDepth() + 1);
                    for (int i = 1; i < parsedExpression.length; i = i + 2) {
                        String lhs = parsedExpression[i];
                        String rhs = parsedExpression[i + 1];
View Full Code Here

    // Look up a property and add it to the _table.
    // If the property is not available because of a securityException,
    // then ignore the securityException and do nothing.
    private static void _putProperty(String variableName, String property) {
        try {
            _table.put(variableName, new StringToken(StringUtilities
                    .getProperty(property)));
        } catch (SecurityException ex) {
            System.out.println("Warning: While trying to set '" + variableName
                    + "', failed to read '" + property + "' property "
                    + "(-sandbox always causes this)");
View Full Code Here

        }
        //Write outputs.
        for (int i = 0; i < outputs; i++) {
            while (!_keyBuffers.get(i).isEmpty()
                    && !_valueBuffers.get(i).isEmpty()) {
                StringToken key = new StringToken(_keyBuffers.get(i).remove());
                StringToken value = new StringToken(_valueBuffers.get(i)
                        .remove());
                outputKey.send(i, key);
                outputValue.send(i, value);
            }
        }
View Full Code Here

                    while (!algorithm.isReduceFinished()) {
                        //Wait for the algorithm to finish.
                    }
                    List<String> outputs = algorithm.reduceOutput;
                    for (String value : outputs) {
                        outputKey.send(0, new StringToken(key));
                        outputValue.send(0, new StringToken(value));
                    }
                }
            }
        }
    }
View Full Code Here

     @param propertyName The name of property.
     *  @return A token containing the string value of the property.
     *  @see ptolemy.util.StringUtilities#getProperty(String)
     */
    public static StringToken property(String propertyName) {
        return new StringToken(StringUtilities.getProperty(propertyName));
    }
View Full Code Here

                            "Problem closing '" + file + "'");
                }
            }
        }

        return new StringToken(result.toString());
    }
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.