Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Attribute


    protected void _exportMoMLContents(Writer output, int depth)
            throws IOException {
        Iterator attributes = attributeList().iterator();

        while (attributes.hasNext()) {
            Attribute attribute = (Attribute) attributes.next();
            attribute.exportMoML(output, depth);
        }

        Iterator ports = portList().iterator();

        while (ports.hasNext()) {
View Full Code Here


     *   no container.
     */
    public int moveToFirst() throws IllegalActionException {
        try {
            new SingletonAttribute(this, "_renderFirst");
            Attribute renderLast = getAttribute("_renderLast");

            if (renderLast != null) {
                renderLast.setContainer(null);
            }
        } catch (NameDuplicationException e) {
            // Ignore.  This will result in a rendering error,
            // but that is better than trashing user data.
        }
View Full Code Here

     *   no container.
     */
    public int moveToLast() throws IllegalActionException {
        try {
            new SingletonAttribute(this, "_renderLast");
            Attribute renderFirst = getAttribute("_renderFirst");

            if (renderFirst != null) {
                renderFirst.setContainer(null);
            }
        } catch (NameDuplicationException e) {
            // Ignore.  This will result in a rendering error,
            // but that is better than trashing user data.
        }
View Full Code Here

            boolean match = false;
            Iterator models = _models.iterator();

            while (models.hasNext()) {
                CompositeActor model = (CompositeActor) models.next();
                Attribute attribute = model.getAttribute(name);

                if (attribute instanceof Variable) {
                    match = true;
                    ((Variable) attribute).setExpression(value);
View Full Code Here

                    if (SootUtilities.derivesFrom(type.getSootClass(),
                            PtolemyUtilities.settableClass)) {
                        // If we are invoking a method on a
                        // variable class, then attempt to get the
                        // constant value of the variable.
                        Attribute attribute = (Attribute) namedObjAnalysis
                                .getObject((Local) r.getBase());

                        if (debug) {
                            System.out.println("Settable base = " + attribute);
                        }

                        // If the attribute resolves to null, then
                        // replace the invocation with an exception
                        // throw.  It would be nice to do this, but
                        // some strange cases fail as a result, in
                        // particular, if you showName on a
                        // PortParameter it fails (!)
                        //                         if (attribute == null) {
                        //                             if (debug) System.out.println("replacing with NullPointerException!");
                        //                             Local exceptionLocal =
                        //                                 SootUtilities.createRuntimeException(
                        //                                         body, stmt,
                        //                                         "NullPointerException: " + r);
                        //                             body.getUnits().swapWith(stmt,
                        //                                     Jimple.v().newThrowStmt(
                        //                                             exceptionLocal));
                        //                             continue;
                        //                         }
                        // Inline getType, setTypeEquals, etc...
                        if (attribute instanceof Typeable) {
                            if (PtolemyUtilities.inlineTypeableMethods(body,
                                    stmt, box, r, (Typeable) attribute)) {
                                continue;
                            }
                        }

                        // Inline namedObj methods on the attribute.
                        if (r.getMethod().getSubSignature().equals(
                                PtolemyUtilities.getFullNameMethod
                                        .getSubSignature())) {
                            box.setValue(StringConstant.v(attribute
                                    .getFullName()));
                            continue;
                        }

                        if (r.getMethod().getSubSignature().equals(
                                PtolemyUtilities.getNameMethod
                                        .getSubSignature())) {
                            box.setValue(StringConstant.v(attribute.getName()));
                            continue;
                        }

                        if (r instanceof SpecialInvokeExpr) {
                            continue;
View Full Code Here

                "java.lang.String");
        Type stringType = RefType.v(stringClass);

        for (Iterator attributes = container.attributeList().iterator(); attributes
                .hasNext();) {
            Attribute attribute = (Attribute) attributes.next();

            if (attributeToValueFieldMap.get(attribute) != null) {
                throw new RuntimeException(
                        "already created field for attribute" + attribute);
            }

            if (attribute instanceof Settable) {
                Settable settable = (Settable) attribute;

                if (debug) {
                    System.out.println("creating field for " + settable);
                }

                String fieldName = StringUtilities.sanitizeName(attribute
                        .getName(context));
                SootField field;

                // Create a field to contain the value of the attribute.
                if (settable instanceof Variable) {
View Full Code Here

        Token result = _evaluator.evaluateParseTree(node, scope);

        // If a target was specified, instantiate a new token.
        if (targetName != null) {
            Attribute attribute = model.getAttribute(targetName);

            if ((attribute != null) && !(attribute instanceof Parameter)) {
                attribute.setContainer(null);
                attribute = null;
            }

            if (attribute == null) {
                attribute = new Parameter(model, targetName);
View Full Code Here

     */
    protected void _setAttributeName(final String attributeName) {
        NamedObj container = getContainer();

        if (container != null) {
            Attribute newAttribute = ModelScope.getScopedVariable(null,
                    container, attributeName);
            if (newAttribute == null) {
                // Either the specified attribute name is invalid,
                // or this is getting invoked in the constructor, and the
                // attribute being referenced has not yet been constructed.
View Full Code Here

            throws IllegalActionException {
        if (attribute instanceof Locatable) {
            Locatable location = (Locatable) attribute;

            if (_port != null) {
                Attribute portAttribute = _port.getAttribute("_location");
                Locatable portLocation = null;

                if (portAttribute instanceof Locatable) {
                    portLocation = (Locatable) portAttribute;
                } else {
View Full Code Here

        try {
            // NOTE: Used to call uniqueName() here to choose the name for the
            // marker.  This is a bad idea.  This calls getEntity(), which
            // triggers populate() on the library, defeating deferred
            // evaluation.
            new Attribute(this, "_libraryMarker");
        } catch (KernelException ex) {
            throw new InternalErrorException(null, ex, null);
        }
    }
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.Attribute

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.