Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Attribute


     @param object The object.
     *  @param name The property name.
     *  @return True if the property is set.
     */
    protected boolean _isPropertySet(NamedObj object, String name) {
        Attribute attribute = object.getAttribute(name);

        if (attribute == null) {
            return false;
        }

View Full Code Here


        // Operate on a copy of the attribute list to avoid
        // ConcurrentModificationException.
        List copy = new LinkedList(attributeList());
        Iterator parameters = copy.iterator();
        while (parameters.hasNext()) {
            Attribute attribute = (Attribute) parameters.next();
            String name = attribute.getName();
            int n = name.indexOf(" (parameter)");
            if (n >= 0) {
                // Attribute is a parameter.
                name = name.substring(0, n);
                if (container.getAttribute(name) == null) {
                    // Entry is obsolete.  Delete it.
                    try {
                        attribute.setContainer(null);
                    } catch (KernelException ex) {
                        // Should not occur.
                        throw new InternalErrorException(ex);
                    }
                }
            } else {
                n = name.indexOf(" (port-parameter)");
                if (n >= 0) {
                    // Attribute is a port parameter.
                    name = name.substring(0, n);
                    if (!(container instanceof Entity)
                            || ((Entity) container).getPort(name) == null) {
                        // Entry is obsolete.  Delete it.
                        try {
                            attribute.setContainer(null);
                        } catch (KernelException ex) {
                            // Should not occur.
                            throw new InternalErrorException(ex);
                        }
                    }
                } else {
                    n = name.indexOf(" (port)");
                    if (n >= 0) {
                        // Attribute is a port parameter.
                        name = name.substring(0, n);
                        if (!(container instanceof Entity)
                                || ((Entity) container).getPort(name) == null) {
                            // Entry is obsolete.  Delete it.
                            try {
                                attribute.setContainer(null);
                            } catch (KernelException ex) {
                                // Should not occur.
                                throw new InternalErrorException(ex);
                            }
                        }
                    }
                }
            }
        }

        parameters = container.attributeList(Settable.class).iterator();
        while (parameters.hasNext()) {
            NamedObj attribute = (NamedObj) parameters.next();
            if (((Settable) attribute).getVisibility() == Settable.FULL) {
                String modifier = " (parameter)";
                if (attribute instanceof PortParameter) {
                    modifier = " (port-parameter)";
                }
                String name = attribute.getName() + modifier;
                if (getAttribute(name) == null) {
                    try {
                        new StringParameter(this, name);
                    } catch (KernelException e) {
                        throw new InternalErrorException(e);
View Full Code Here

        super("", tableau, owner, target, configuration);

        _owner = owner;
        _target = target;

        Attribute attribute = null;

        if (GTTools.isInPattern(target)) {
            if (target instanceof GTEntity) {
                attribute = target.getAttribute("criteria");
            } else {
View Full Code Here

        // If the object is an instance of CompositeEntity, but does not
        // contain an attribute named "_libraryMarker", then treat it as an
        // atomic entity.
        if (object instanceof CompositeEntity) {
            Attribute marker = ((CompositeEntity) object)
                    .getAttribute("_libraryMarker");

            if (marker == null) {
                return true;
            }
View Full Code Here

        for (Iterator attributes = attributeList.iterator(); attributes
                .hasNext();) {
            Object object = attributes.next();
            System.out.println("object = " + object.getClass());

            Attribute attribute = (Attribute) object;

            if (_isIgnorableAttribute(attribute)) {
                continue;
            }

            String className = attribute.getClass().getName();
            /* Type attributeType =*/RefType.v(className);
            String attributeName = attribute.getName(context);
            /*String fieldName =*/getFieldNameForAttribute(attribute, context);

            Local local = attributeLocal;
            body.getUnits().insertBefore(
                    Jimple.v().newAssignStmt(
View Full Code Here

        Local variableLocal = Jimple.v().newLocal("variable", variableType);
        body.getLocals().add(variableLocal);

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

            if (_isIgnorableAttribute(attribute)) {
                continue;
            }

            SootClass attributeClass = (SootClass) _objectToClassMap
                    .get(attribute);

            if (attributeClass == null) {
                attributeClass = Scene.v().loadClassAndSupport(
                        attribute.getClass().getName());
            }

            String className = attributeClass.getName();
            Type attributeType = RefType.v(className);
            String attributeName = attribute.getName(context);
            String fieldName = getFieldNameForAttribute(attribute, context);

            Local local;

            if (objectNameToCreatorName.keySet().contains(
                    attribute.getFullName())) {
                //     System.out.println("already has " + attributeName);
                // If the class for the object already creates the
                // attribute, then get a reference to the existing attribute.
                // Note that if the class creates the attribute, but
                // doesn't also create a field for it, that we will
                // fail later when we try to replace getAttribute
                // calls with references to fields.
                local = attributeLocal;
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                attributeLocal,
                                Jimple.v().newVirtualInvokeExpr(
                                        contextLocal,
                                        PtolemyUtilities.getAttributeMethod
                                                .makeRef(),
                                        StringConstant.v(attributeName))));
            } else {
                //System.out.println("creating " + attribute.getFullName());
                // If the class does not create the attribute,
                // then create a new attribute with the right name.
                local = PtolemyUtilities.createNamedObjAndLocal(body,
                        className, namedObjLocal, attribute.getName());

                // System.out.println("created local");
                // NOTE: Assume that attributes that contain other
                // attributes must implement a workspace constructor
                try {
                    Attribute classAttribute = (Attribute) _findDeferredInstance(attribute);
                    updateCreatedSet(namedObj.getFullName() + "."
                            + attribute.getName(), classAttribute,
                            classAttribute, objectNameToCreatorName);
                } catch (Exception ex) {
                    String name = namedObj.getFullName() + "."
View Full Code Here

            return;
        }

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

            if (_isIgnorableAttribute(attribute)) {
                continue;
            }

            SootMethod method = new SootMethod(
                    getAttributeComputationFunctionName(attribute, context),
                    Collections.EMPTY_LIST, VoidType.v(), Modifier.PUBLIC);
            Type variableType = RefType.v(PtolemyUtilities.variableClass);
            theClass.addMethod(method);

            JimpleBody body = Jimple.v().newBody(method);
            method.setActiveBody(body);
            body.insertIdentityStmts();

            Stmt insertPoint = Jimple.v().newReturnVoidStmt();
            body.getUnits().add(insertPoint);

            if (_constAnalysis.getConstVariables(namedObj).contains(attribute)) {
                Local local = SootUtilities.createRuntimeException(body,
                        insertPoint,
                        "Parameter is constant and should not be re-evaluated");
                body.getUnits().insertBefore(Jimple.v().newThrowStmt(local),
                        insertPoint);
                continue;
            }

            // A local that we will use to set the value of our
            // settable attributes.
            Local attributeLocal = Jimple.v().newLocal("attribute",
                    PtolemyUtilities.attributeType);
            body.getLocals().add(attributeLocal);

            Local settableLocal = Jimple.v().newLocal("settable",
                    PtolemyUtilities.settableType);
            body.getLocals().add(settableLocal);

            //String className = attribute.getClass().getName();
            //Type attributeType = RefType.v(className);
            String attributeName = attribute.getName(context);
            //String fieldName = getFieldNameForAttribute(attribute, context);

            Local local = attributeLocal;
            body.getUnits().insertBefore(
                    Jimple.v().newAssignStmt(
View Full Code Here

     */
    protected String _displayString() {
        NamedObj container = getContainer();

        if (container != null) {
            Attribute associatedAttribute = container
                    .getAttribute(attributeName.getExpression());

            if (associatedAttribute instanceof Settable) {
                String value = ((Settable) associatedAttribute).getExpression();
                String truncated = value;
View Full Code Here

        // A list of locals that we will validate.
        List validateLocalsList = new LinkedList();

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

            if (_isIgnorableAttribute(attribute)) {
                continue;
            }

            //String className = attribute.getClass().getName();
            //Type attributeType = RefType.v(className);
            String attributeName = attribute.getName(context);
            //String fieldName = getFieldNameForAttribute(attribute, context);

            Local local = attributeLocal;
            body.getUnits().insertBefore(
                    Jimple.v().newAssignStmt(
View Full Code Here

            }
        }

        for (Iterator attributes = object.attributeList().iterator(); attributes
                .hasNext();) {
            Attribute attribute = (Attribute) attributes.next();
            updateCreatedSet(prefix, context, attribute,
                    objectNameToCreatorName);
        }
    }
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.