ptolemy.kernel.util
Interface Configurable

All Known Subinterfaces:
ConfigurableEntity, ConfigurableEntity, LazyComposite
All Known Implementing Classes:
ActionGUIProperty, ActorGraphTableau.Factory, ArrayPlotter, ArrayPlotterXY, BarGraph, BrowserTableau.Factory, Button, CaseGraphTableau.Factory, CaseGraphTableau.Factory, Clone, ComboBox.Item, ComboItem, ConfigurableAttribute, Configure, DebugController, Discard, DocBuilderTableau.Factory, DocTableau.Factory, EditIconTableau.Factory, EntityLibrary, Event, ExecShellTableau.Factory, Execute, ExpressionShellTableau.Factory, FileEditorTableauFactory, FmvAutomatonGraphTableau.Factory, FmvAutomatonGraphTableau.Factory, FmvState, FmvState, FSMGraphTableau.Factory, FSMGraphTableau.Factory, GeneratorTableau.Factory, GTEvent, GTTableau.Factory, GTTableau.ModalTableauFactory, HistogramPlotter, HTMLViewerTableau.Factory, ImageTableau.Factory, InitModel, InitModelWithContainer, InputModel, InterfaceAutomatonGraphTableau.Factory, InterfaceAutomatonGraphTableau.Factory, InterfaceTableau.Factory, JVMTableau.Factory, KeplerDocumentationAttribute, KielerLayoutTableauFactory, LazyTypedCompositeActor, LevelSkippingTableauFactory, LibraryAttribute, ListDirectory, Match, MatchResultTableau.Factory, MatrixTokenTableau.Factory, ModalTableauFactory, ModalTableauFactory, MoMLModelAttribute, MoMLModelAttributeControllerFactory, NavigableActorGraphTableau.Factory, NCCompositeActorTableauFactory, OutputModel, Plot, PlotTableau.Factory, Plotter, PlotterBase, PtalonActor, PtalonMatcher.NestedPtalonActor, PteraGraphTableau.Factory, PtolemyTableauFactory, PythonShellTableau.Factory, ReadModel, RealTimePlotter, ReceiveInput, Report, RunTableau.Factory, RunTableau.TopFactory, SequencePlotter, SequenceScope, SetTableau, SingletonConfigurableAttribute, SingleWindowHTMLViewerTableau.Factory, SketchedSource, Sleep, State, State, StateMatcher, Stop, TableauFactory, TclShellTableau.Factory, TDLMode, TdlTableauFactory, TdlTaskTableauFactory, Test, TextEditorTableau.Factory, TextEditorTableauFactory, TimedPlotter, TimedScope, TokenTableau.Factory, Transform, TransformationAttribute, TransientSingletonConfigurableAttribute, TreeTableau.Factory, TypeOpaqueCompositeActorTableauFactory, TypeTest, View, VisualModelReference.LookInside, WriteModel, XYPlotter, XYScope

public interface Configurable

Objects that can be configured by reading a file or configuration information given as text, typically in XML format, should implement this interface. This enables a user of a component to recognize that such file-based configuration is possible, and permits configuration to be specified via the MoML configure element. For example, a plotter actor implements this interface to allow the visual appearance of the plot to be set using PlotML. An icon for an actor implements this interface to allow the actor-specific visual features of the icon to be specified using graphics markup. Additionally, a filter actor could implement this interface to allow the filter specification to be given using markup.

This interface can also be used for actors which load configuration information from non-XML formats, such as GIF images or binary lookup tables. The source argument of the configure() method simply points to such a file.

This interface is designed to be reversible, so that an object can also provide enough information to reconstruct its current configuration. This mechanism is used when writing MoML from instantiated objects, although it could also be used to write a description of the object in other forms. In order for this to work properly calling the configure() method on any object of the same type, given the data returned by the getConfigureSource() and getConfigureText() methods should result in an object that resemble the first as closely as possible.

Since:
Ptolemy II 1.0
Version:
$Id: Configurable.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee, Steve Neuendorffer
See Also:
CompositeActor, AtomicActor
Accepted Rating:
Green (bart)
Proposed Rating:
Green (neuendor)

Method Summary
 void configure(java.net.URL base, java.lang.String source, java.lang.String text)
          Configure the object with data from the specified input source (a URL) and/or textual data.
 java.lang.String getConfigureSource()
          Return the input source that was specified the last time the configure method was called.
 java.lang.String getConfigureText()
          Return the text string that represents the current configuration of this object.
 

Method Detail

configure

void configure(java.net.URL base,
               java.lang.String source,
               java.lang.String text)
               throws java.lang.Exception
Configure the object with data from the specified input source (a URL) and/or textual data. The object should interpret the source first, if it is specified, followed by the literal text, if that is specified. The new configuration should usually override any old configuration wherever possible, in order to ensure that the current state can be successfully retrieved.

This method is defined to throw a very general exception to allow classes that implement the interface to use whatever exceptions are appropriate.

Parameters:
base - The base relative to which references within the input are found, or null if this is not known, or there is none.
source - The input source, which specifies a URL, or null if none.
text - Configuration information given as text, or null if none.
Throws:
java.lang.Exception - If something goes wrong.

getConfigureSource

java.lang.String getConfigureSource()
Return the input source that was specified the last time the configure method was called.

Returns:
The string representation of the input URL, or null if the no source has been used to configure this object, or null if no external source need be used to configure this object.

getConfigureText

java.lang.String getConfigureText()
Return the text string that represents the current configuration of this object. Note that any configuration that was previously specified using the source attribute need not be represented here as well.

Returns:
A configuration string, or null if no configuration has been used to configure this object, or null if no configuration string need be used to configure this object.