ptolemy.actor.gui
Class EffigyFactory

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.kernel.CompositeEntity
                      extended by ptolemy.actor.gui.EffigyFactory
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
Direct Known Subclasses:
BrowserEffigy.Factory, DocBuilderEffigy.Factory, DocEffigy.Factory, HSIFEffigyFactory, HTMLEffigyFactory, NavigableEffigy.Factory, PlotEffigy.Factory, PtolemyEffigy.Factory, TextEffigy.Factory, TokenEffigy.Factory

public class EffigyFactory
extends CompositeEntity

A configuration contains an instance of this class, and uses it to create effigies from a URL, or to create blank effigies of a particular kind. This base class assumes that it contains other effigy factories. Its createEffigy() methods defer to each contained factory in order until one is capable of creating an effigy. Subclasses of this class will usually be inner classes of an Effigy and will create the Effigy, or they might themselves be aggregates of instances of EffigyFactory.

Since:
Ptolemy II 1.0
Version:
$Id: EffigyFactory.java 59167 2010-09-21 17:08:02Z cxh $
Author:
Steve Neuendorffer and Edward A. Lee
See Also:
Configuration, Effigy, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
 
Field Summary
 
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
EffigyFactory(CompositeEntity container, java.lang.String name)
          Create a factory with the given name and container.
EffigyFactory(Workspace workspace)
          Create a factory in the specified workspace.
 
Method Summary
 boolean canCreateBlankEffigy()
          Return true if this effigy factory is capable of creating an effigy without a URL being specified.
static boolean checkForDTD(java.net.URL input, java.lang.String dtdStart, java.lang.String dtdEndRegExp)
          Check the URL input for a DTD.
 Effigy createEffigy(CompositeEntity container)
          Create a new blank effigy in the given container.
 Effigy createEffigy(CompositeEntity container, java.net.URL base, java.net.URL in)
          Create a new effigy in the given container by reading the specified URL.
static java.lang.String getExtension(java.net.URL url)
          Return the extension on the name of the specified URL.
 
Methods inherited from class ptolemy.kernel.CompositeEntity
_addEntity, _addRelation, _adjustDeferrals, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _recordDecoratedAttributes, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allCompositeEntityList, allowLevelCrossingConnect, classDefinitionList, clone, connect, connect, containedObjectsIterator, deepEntityList, deepGetEntities, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, isOpaque, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, newRelation, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, setContainer, statistics, uniqueName
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_addPort, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, newPort, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getDisplayName, getFullName, getName, getName
 

Constructor Detail

EffigyFactory

public EffigyFactory(Workspace workspace)
Create a factory in the specified workspace.

Parameters:
workspace - The workspace.

EffigyFactory

public EffigyFactory(CompositeEntity container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Create a factory with the given name and container.

Parameters:
container - The container.
name - The name.
Throws:
IllegalActionException - If the container is incompatible with this entity.
NameDuplicationException - If the name coincides with an entity already in the container.
Method Detail

canCreateBlankEffigy

public boolean canCreateBlankEffigy()
Return true if this effigy factory is capable of creating an effigy without a URL being specified. That is, it is capable of creating a blank effigy with no model data. In this base class, this method returns true if at least one contained effigy factory returns true.

Returns:
True if this factory can create a blank effigy.

checkForDTD

public static boolean checkForDTD(java.net.URL input,
                                  java.lang.String dtdStart,
                                  java.lang.String dtdEndRegExp)
                           throws java.io.IOException
Check the URL input for a DTD. Only the first 5 lines are read from the URL. Any text that matches <?xml.*?> is removed before checking.

Parameters:
input - The DTD to check.
dtdStart - The start of the DTD, typically "dtdEndRegExp - The optional ending regular expression. If this parameter is null, then it is ignored.
Returns:
True if the input starts with dtdStart and, if dtdEndRegExp is non-null, ends with dtdEndRegExp.
Throws:
java.io.IOException - if there is a problem opening or reading the input.

createEffigy

public Effigy createEffigy(CompositeEntity container)
                    throws java.lang.Exception
Create a new blank effigy in the given container. This base class defers to each contained effigy factory until one returns an effigy. If there are no contained effigies, or if none returns an effigy, then this method returns null. Subclasses will override this method to create an effigy of an appropriate type.

Parameters:
container - The container for the effigy.
Returns:
A new effigy.
Throws:
java.lang.Exception - If the effigy created by one of the contained factories is incompatible with the specified container, or a name duplication occurs.

createEffigy

public Effigy createEffigy(CompositeEntity container,
                           java.net.URL base,
                           java.net.URL in)
                    throws java.lang.Exception
Create a new effigy in the given container by reading the specified URL. If the specified URL is null, then create a blank effigy. The specified base is used to expand any relative file references within the URL. This base class defers to each contained effigy factory until one returns an effigy. If there are no contained effigies, or if none returns an effigy, then this method returns null. Subclasses will override this method to create an effigy of an appropriate type.

Parameters:
container - The container for the effigy.
base - The base for relative file references, or null if there are no relative file references.
in - The input URL.
Returns:
A new effigy.
Throws:
java.lang.Exception - If the stream cannot be read, or if the data is malformed in some way.

getExtension

public static java.lang.String getExtension(java.net.URL url)
Return the extension on the name of the specified URL. This is a utility method designed to help derived classes decide whether the URL matches the particular type of effigy they can create. If the URL has no extension, return an empty string.

Parameters:
url - A URL.
Returns:
The extension on the URL.