public abstract class ModelComponentBase extends java.lang.Object implements ModelComponent, java.lang.Cloneable
ModelComponent.FilePathSaveType, ModelComponent.NavpanelVisibility| Modifier and Type | Field and Description |
|---|---|
static boolean |
enforceUniqueCompositeNames |
static boolean |
enforceUniqueNames |
int |
myNumber |
static PropertyList |
myProps |
static java.lang.Object |
NULL_OBJ |
static boolean |
useCompactPathNames |
| Constructor and Description |
|---|
ModelComponentBase() |
ModelComponentBase(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkFlag(int mask) |
static java.lang.String |
checkName(java.lang.String name,
ModelComponent comp)
Check to see if a String represents a valid name for a model
component.
|
static void |
checkNameUniqueness(ModelComponent comp,
CompositeComponent parent)
Check name uniqueness restrictions of a component with respect
to a specific parent, and throw an exception if these are violated.
|
void |
clearFlag(int mask) |
java.lang.Object |
clone() |
void |
connectToHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is added to the component hierarchy (i.e., added as
a child of another CompositeComponent).
|
ModelComponent |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap) |
static int |
createTempFlag() |
void |
disconnectFromHierarchy(CompositeComponent hcomp)
Called by the system after this component, or an ancestor of this
component, is removed from the component hierarchy (i.e., removed as a
child of its parent).
|
PropertyInfoList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
java.util.Iterator<? extends HierarchyNode> |
getChildren() |
CompositeComponent |
getGrandParent() |
void |
getHardReferences(java.util.List<ModelComponent> refs)
Appends all hard references for this component to a list.
|
java.lang.String |
getName()
Gets the name of this component.
|
Range |
getNameRange() |
ModelComponent.NavpanelVisibility |
getNavpanelVisibility() |
static ModelComponent.NavpanelVisibility |
getNavpanelVisibility(int flags) |
int |
getNumber()
Gets the number of this component.
|
CompositeComponent |
getParent()
Returns the current parent of this ModelComponent, if any.
|
Property |
getProperty(java.lang.String path)
Returns a property associated with a specified path name.
|
void |
getSoftReferences(java.util.List<ModelComponent> refs)
Appends all soft references for this component to a list.
|
boolean |
hasChildren() |
boolean |
hasState()
Queries if this component has state.
|
boolean |
isFixed()
Returns true if this model component is fixed.
|
boolean |
isMarked()
Returns true if this model component is marked.
|
boolean |
isScanning() |
boolean |
isSelected()
Returns true if this model component is selected.
|
boolean |
isWritable()
Returns
true if this component should in fact be written to
secondary storage. |
static java.lang.String |
makeValidName(java.lang.String name)
Makes a valid component name from the string provided.
|
static java.lang.String |
makeValidName(java.lang.String name,
ModelComponent comp,
CompositeComponent parent)
Makes a valid component name from the string provided.
|
void |
notifyParentOfChange(ComponentChangeEvent e)
Notifies the parent of this component (if any) of changes within in its
descendants.
|
void |
postscan(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor)
Performs any required post-scanning for this component.
|
void |
printReferences()
Diagnostic method that prints the references associated with
this component.
|
static boolean |
recursivelyContained(ModelComponent comp,
CompositeComponent ancestor,
java.util.Collection<? extends ModelComponent> collection) |
static boolean |
recursivelyContains(ModelComponent ancestor,
ModelComponent comp)
Queries whether if a component is a descendant of a specified
ancestor.
|
static void |
removeTempFlag(int mask) |
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setFixed(boolean fixed)
Fixes or unfixes this component.
|
void |
setFlag(int mask) |
void |
setMarked(boolean marked)
Marks or unmarks this component.
|
void |
setName(java.lang.String name)
Sets the name of this component.
|
void |
setNavpanelVisibility(ModelComponent.NavpanelVisibility visibility) |
static int |
setNavpanelVisibility(ModelComponent.NavpanelVisibility visibility,
int flags) |
void |
setNumber(int num)
Sets the number of this component.
|
void |
setParent(CompositeComponent parent)
Sets the parent for this component.
|
void |
setScanning(boolean scanning) |
void |
setSelected(boolean selected)
Selects or deselects this component.
|
void |
setWritable(boolean writable)
Sets this component to be writable or non-writable.
|
void |
updateReferences(boolean undo,
java.util.Deque<java.lang.Object> undoInfo)
May be called by the system if any of the soft references for
this component are removed from the the component hierarchy.
|
void |
write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes a text description of this element to a PrintWriter.
|
public int myNumber
public static final java.lang.Object NULL_OBJ
public static boolean enforceUniqueNames
public static boolean enforceUniqueCompositeNames
public static boolean useCompactPathNames
public static PropertyList myProps
public ModelComponentBase(java.lang.String name)
public ModelComponentBase()
public static int createTempFlag()
public static void removeTempFlag(int mask)
public PropertyInfoList getAllPropertyInfo()
HasPropertiesgetAllPropertyInfo in interface HasPropertiespublic Property getProperty(java.lang.String path)
.' characters. A sub-property
exists if the value of a property is itself an object which exports
properties. It is only possible to obtain a sub-property handle if each of
its ancestor properties exports their values by reference.getProperty in interface HasPropertiespath - name of the desired property or sub-propertypublic java.lang.String getName()
getName in interface ModelComponentpublic void setName(java.lang.String name)
notifyParentOfChange with a NameChangeEvent so that it's
parent can update the name map entry and other ancestors can adjust for
the new name.
Component names can be specified as null. However, if not null, they
should have non-zero length and should not begin with a digit or contain
the characters '.' or '/'. Implementations can use ModelComponentBase.checkName() to determine if a proposed name is valid.
setName in interface ModelComponentname - new component namepublic Range getNameRange()
public void write(java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
throws java.io.IOException
scan and complete
enough to allow full reconstruction of the element.public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
write.scan in interface ModelComponentscan in interface Scannablertok - Tokenizer from which to scan the elementref - optional reference object which can be used for resolving references to
other objectsjava.io.IOException - if an I/O or formatting error occuredpublic void postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
PostScannablescan() method and stored in the token queue.
The most common use of this method is to resolve the paths
of component references, which may not have been created
at the time of the initial scan() call.postscan in interface PostScannabletokens - token information that was stored during
scan().ancestor - ancestor component with respect to which
reference component paths are defined.java.io.IOException - if an error is encountered (such as a reference to a
non-existent component)public void connectToHierarchy(CompositeComponent hcomp)
When this method is called, ModelComponent.getParent() will return the new
parent component; the system will have set this beforehand.
connectToHierarchy in interface ModelComponenthcomp - hierarchy component to which this component,
or its ancestor, was attachedpublic void disconnectFromHierarchy(CompositeComponent hcomp)
When this method is called, ModelComponent.getParent() will still return this
original parent component; the system will set this to null
after.
disconnectFromHierarchy in interface ModelComponenthcomp - hierarchy component from which this component,
or its ancestor, was detachedpublic CompositeComponent getParent()
getParent in interface ModelComponentgetParent in interface HierarchyNodepublic void setParent(CompositeComponent parent)
null
is specified when the component is being removed from the hierarchy.
This method is intended for internal use by the system only.
setParent in interface ModelComponentparent - new parent component, or null.public CompositeComponent getGrandParent()
public boolean isSelected()
isSelected in interface ModelComponentpublic void setSelected(boolean selected)
setSelected in interface ModelComponentselected - if true, this component is selectedpublic boolean isMarked()
isMarked in interface ModelComponentpublic void setMarked(boolean marked)
setMarked in interface ModelComponentmarked - if true, this component is markedpublic boolean isWritable()
true if this component should in fact be written to
secondary storage. This gives subclasses control over whether or
not they are actually written out.isWritable in interface Scannabletrue if this component should be written to
secondary storage.public void setWritable(boolean writable)
Some components may be intrinsicly non-writable, in which case calling this method will have no effect.
setWritable in interface ModelComponentwritable - if true, component is made writablepublic boolean isFixed()
isFixed in interface ModelComponentpublic void setFixed(boolean fixed)
setFixed in interface ModelComponentfixed - if true, this component will be fixed to its parent.public static int setNavpanelVisibility(ModelComponent.NavpanelVisibility visibility, int flags)
public static ModelComponent.NavpanelVisibility getNavpanelVisibility(int flags)
public ModelComponent.NavpanelVisibility getNavpanelVisibility()
getNavpanelVisibility in interface ModelComponentpublic void setNavpanelVisibility(ModelComponent.NavpanelVisibility visibility)
public void setScanning(boolean scanning)
public boolean isScanning()
public boolean checkFlag(int mask)
public void setFlag(int mask)
public void clearFlag(int mask)
public void getHardReferences(java.util.List<ModelComponent> refs)
getHardReferences in interface ModelComponentrefs - list to which hard references are appendedpublic void getSoftReferences(java.util.List<ModelComponent> refs)
updateReferences() method will
be called to update its internal reference information.getSoftReferences in interface ModelComponentrefs - list to which soft references are appendedpublic static boolean recursivelyContains(ModelComponent ancestor, ModelComponent comp)
ancestor - ancestor component to checkcomp - component to check for descendence from ancestortrue if comp is a descendant of
ancestorpublic static boolean recursivelyContained(ModelComponent comp, CompositeComponent ancestor, java.util.Collection<? extends ModelComponent> collection)
public int getNumber()
getNumber in interface ModelComponentpublic void setNumber(int num)
setNumber in interface ModelComponentnum - new component numberpublic void notifyParentOfChange(ComponentChangeEvent e)
componentChanged method.notifyParentOfChange in interface ModelComponente - optional argument giving specific information about the changepublic java.util.Iterator<? extends HierarchyNode> getChildren()
getChildren in interface HierarchyNodepublic boolean hasChildren()
hasChildren in interface HierarchyNodepublic java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic ModelComponent copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
public void printReferences()
public static java.lang.String makeValidName(java.lang.String name,
ModelComponent comp,
CompositeComponent parent)
comp (and possibly parent) is
also specified, then the method will also ensure that the
name is unique to the component's parent.name - name to validatecomp - Component for which the name is intended.
If null, name uniqueness will not be checked.parent - Parent of the component. May be null, in
which case the component's current parent will be used.public static java.lang.String makeValidName(java.lang.String name)
name - name to modifypublic static void checkNameUniqueness(ModelComponent comp, CompositeComponent parent)
comp - component whose name should be checkedparent - parent component in which name may have to be unique.public static java.lang.String checkName(java.lang.String name,
ModelComponent comp)
null if it is, and
an error message otherwise.name - name to be validatedcomp - Component for which the name is intended.
May be null, in which case duplicate sibling names
will not be checked.null, or error message if the name is not valid.public boolean hasState()
ModelComponenthasState in interface ModelComponenttrue if this component has statepublic void updateReferences(boolean undo,
java.util.Deque<java.lang.Object> undoInfo)
undo equal to false,
this component should then examine its soft references and
use ComponentUtils.areConnected()
to determine which of them have been disconnected from the hierarchy.
Disconnected references should be removed, and sufficient information
should be appended to undoInfo to allow this update
to be undone if this method is called later with undo
equal to true. When undoing an update, the undo
information should be removed from the front of undoInfo.updateReferences in interface ModelComponentundo - if true, indicates that the most
recent reference update should be undone, using the supplied
undo information.undoInfo - if undo is false, should be used
to store information allowing the reference update to be undone.
Otherwise, if undo is true, then this
supplied information to undo the most recent update.