001/*
002 Copyright (c) 2006-2014 The Regents of the University of California.
003 All rights reserved.
004
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023 */
024
025package ptolemy.kernel.util.test;
026
027import java.lang.ref.WeakReference;
028import java.util.Iterator;
029import java.util.LinkedList;
030import java.util.List;
031
032import ptolemy.kernel.util.Attribute;
033import ptolemy.kernel.util.IllegalActionException;
034import ptolemy.kernel.util.Instantiable;
035import ptolemy.kernel.util.NameDuplicationException;
036import ptolemy.kernel.util.NamedObj;
037import ptolemy.kernel.util.Workspace;
038
039public class TestInstantiableAttribute extends Attribute
040        implements Instantiable {
041
042    public TestInstantiableAttribute() {
043        super();
044    }
045
046    public TestInstantiableAttribute(Workspace workspace) {
047        super(workspace);
048    }
049
050    public TestInstantiableAttribute(NamedObj container, String name)
051            throws IllegalActionException, NameDuplicationException {
052        super(container, name);
053    }
054
055    @Override
056    public List getChildren() {
057        List results = new LinkedList();
058        Iterator attributes = attributeList().iterator();
059        while (attributes.hasNext()) {
060            Attribute attribute = (Attribute) attributes.next();
061            results.add(new WeakReference(attribute));
062        }
063        return results;
064    }
065
066    @Override
067    public Instantiable getParent() {
068        NamedObj container = getContainer();
069        if (container instanceof Instantiable) {
070            return (Instantiable) container;
071        }
072        return null;
073    }
074
075    @Override
076    public Instantiable instantiate(NamedObj container, String name)
077            throws CloneNotSupportedException, IllegalActionException,
078            NameDuplicationException {
079        return null;
080    }
081
082    @Override
083    public boolean isClassDefinition() {
084        return false;
085    }
086
087}