java.lang.Object | ||
↳ | com.pnfsoftware.jeb.core.events.JebEventSource | |
↳ | com.pnfsoftware.jeb.core.units.AbstractUnit |
![]() |
![]() |
Skeleton implementation for an IUnit
. It is highly recommended that plugins extend this
class or one of the its subclasses instead of implementing IUnit entirely.
Implementors must implement their own constructor; the default constructor is used for deserialization only. Example of a typical unit constructor:
public DerivedClass(String name, IUnitProcessor unitProcessor, IUnitCreator parent, IPropertyDefinitionManager pdm) { super(..., name, unitProcessor, parent, pdm); ... }
Notes on persistence:
canBePersisted()
returns true.IUnitFormatter
for more information.custom deserializer
.Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AbstractUnit(String formatType, String name, IUnit parent)
Build a new child from parent
IUnit | |||||||||||
AbstractUnit(String formatType, String name, IUnitProcessor unitProcessor, IUnitCreator parent, IPropertyDefinitionManager pdm)
Initialize a new unit object.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
addChild(IUnit unit, boolean persisted)
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
void |
addChild(IUnit unit)
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
void |
addChildUnit(IUnit unit)
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
final void | addNotification(IUnitNotification notification) | ||||||||||
boolean |
canBePersisted()
Determine if this unit can be persisted.
| ||||||||||
void |
dispose()
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
IQuickStateObject |
generateQuickState()
The default implementation returns null.
| ||||||||||
List<? extends IUnit> |
getChildren()
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
List<IUnitContribution> |
getContributions()
Get the list of contributions attached to the unit.
| ||||||||||
long |
getCreationTimestamp()
Get the date of creation of this unit.
| ||||||||||
String |
getDescription()
Get a description string for that unit.
| ||||||||||
String |
getFormatType()
Mandatory unit type.
| ||||||||||
IUnitFormatter |
getFormatter()
Retrieve a fresh formatter for that unit.
| ||||||||||
byte[] |
getIconData()
The icon bytes representing units of such type.
| ||||||||||
List<IUnitInterpreter> |
getInterpreters()
Get the list of command interpreters attached to the unit.
| ||||||||||
IUnitLock |
getLock()
The default implementation returns a pass-through lock that never locks.
| ||||||||||
String |
getName()
Get the unit name.
| ||||||||||
String |
getNotes()
Get user-defined notes.
| ||||||||||
IUnitNotificationManager |
getNotificationManager()
Get a reference to the notification manager.
| ||||||||||
IUnitCreator |
getParent()
Retrieve the creator (or parent) of this unit.
| ||||||||||
IPropertyDefinitionManager |
getPropertyDefinitionManager()
Retrieve the PDM used by this unit.
| ||||||||||
IPropertyManager |
getPropertyManager()
Retrieve the PM used by this unit.
| ||||||||||
String |
getRealName()
Retrieve the optional real unit name.
| ||||||||||
String |
getStatus()
Get the status for the unit.
| ||||||||||
IUnitProcessor |
getUnitProcessor()
Retrieve the unit processor used by this unit.
| ||||||||||
boolean | hasChildren() | ||||||||||
void |
initializePropertyObjects(IUnitCreator parent, IUnitProcessor processor, IPropertyDefinitionManager pdm)
Overrides are allowed.
| ||||||||||
synchronized void |
internalSwapChildren()
RESERVED FOR INTERNAL USE.
| ||||||||||
boolean | isDeserialized() | ||||||||||
boolean |
isDisposed()
Indicate if the unit has been disposed
| ||||||||||
boolean |
isProcessed()
Verify if the unit was successfully processed.
| ||||||||||
boolean |
isTransientChild(IUnit unit)
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
void |
logError(boolean recordNotification, String format, Object... params)
Log an error message using the current class logger, and optionally create a persistent unit
notification as well.
| ||||||||||
void |
logException(Exception e)
Log an exception using the current class logger.
| ||||||||||
void |
logInfo(boolean recordNotification, String format, Object... params)
Log an information message using the current class logger, and optionally create a persistent
unit notification as well.
| ||||||||||
void |
logWarn(boolean recordNotification, String format, Object... params)
Log a warning message using the current class logger, and optionally create a persistent unit
notification as well.
| ||||||||||
void |
onPropertyChange(String fqPropertyName)
This method is called when a project property is changed.
| ||||||||||
void |
postDeserialization(IRuntimeProject prj)
To be overridden by subclasses if necessary.
| ||||||||||
boolean |
process()
The default implementation calls
processInternal() , and makes sure that a status
string is set on error, or nullified on success. | ||||||||||
void |
removeChild(IUnit unit)
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
boolean | setChild(IUnit oldUnit, IUnit newUnit) | ||||||||||
void |
setName(String name)
Set the unit name.
| ||||||||||
void |
setNotes(String notes)
Set user-defined notes.
| ||||||||||
void |
setParent(IUnitCreator parent)
Set the parent unit or artifact.
| ||||||||||
void |
setProcessed(boolean processed, boolean notify)
Mark the unit as processed and optionally notify clients by issuing a
UnitChange
event. | ||||||||||
final void |
setProcessed(boolean processed)
Mark the unit as processed and notify the client.
| ||||||||||
void |
setRealName(String name)
Set the optional unit's real name.
| ||||||||||
void | setStatus(String status, boolean notify) | ||||||||||
void |
setStatus(String status)
Set the plugin status.
| ||||||||||
void |
setUnitProcessor(IUnitProcessor processor)
Set the unit processor.
| ||||||||||
String | toString() |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void | addChild(IUnit unit, boolean persisted, boolean notify) | ||||||||||
boolean |
processInternal()
Plugins may override this method instead of the traditional
process() . | ||||||||||
void | removeChild(IUnit unit, boolean notify) | ||||||||||
boolean | setChild(IUnit oldUnit, IUnit newUnit, boolean notify) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Build a new child from parent IUnit
formatType | the mandatory format type, normally one provided by the identifier |
---|---|
name | the unit name |
parent | the parent unit |
Initialize a new unit object.
The PDM is provided by the IUnitIdentifier (if created from there). Else, it can be provided manually by the caller. If pdm is null, an unattached PDM will be created with no property and a region name matching the unit formatType.
formatType | the mandatory format type, normally one provided by the identifier |
---|---|
name | the unit name |
unitProcessor | the unit processor |
parent | the parent unit or artifact; if null, this unit cannot be attached to a project; practically, this field should never be null |
pdm | optional an optional property definition manager |
Sub-classes overriding this method must override related methods consistently.
unit | the child unit |
---|---|
persisted | true if the unit should be persisted upon project saving |
Sub-classes overriding this method must override related methods consistently.
unit | the child unit |
---|
Sub-classes overriding this method must override related methods consistently.
unit | the child unit |
---|
Determine if this unit can be persisted. This method can be used by parent units and client code to verify if a child unit can legally be persisted.
Sub-classes overriding this method must override related methods consistently.
The default implementation returns null.
Sub-classes overriding this method must override related methods consistently.
Get the list of contributions attached to the unit.
Get the date of creation of this unit.
Get a description string for that unit.
The unit must be processed before calling this method.
Mandatory unit type. The type should be unique across all units. It should be the same as the
identifier
's type
.
Retrieve a fresh formatter for that unit. Formatters are used to produce document outputs, that represent the unit in whole or in part.
The unit must be processed before calling this method.
The icon bytes representing units of such type. Typically, the data represents a 16x16 BMP or PNG image. Clients may use this data to represent labels for such units in a graphical way.
Get the list of command interpreters attached to the unit.
The default implementation returns a pass-through lock that never locks.
Get the unit name.
Get user-defined notes. The notes can be textual data of any sort.
Get a reference to the notification manager.
Retrieve the creator (or parent) of this unit. It can be a parent unit or a live artifact, for top-level units.
Retrieve the PDM used by this unit. For consistency, it is recommend that all units of a given type return equivalent PDMs.
Retrieve the PM used by this unit.
Retrieve the optional real unit name.
Get the status for the unit. Plugins should set a status if processing failed. Implementors
must notify their listeners by issuing a UnitStatusChanged
event.
Retrieve the unit processor used by this unit.
Overrides are allowed. If so, super.initializePropertyObjects()
must be called
first.
parent | the parent unit or artifact |
---|---|
processor | the processor |
pdm | the property definition manager for units of this type |
RESERVED FOR INTERNAL USE.
Indicate if the unit has been disposed
Verify if the unit was successfully processed.
Sub-classes overriding this method must override related methods consistently.
unit | the child unit |
---|
Log an error message using the current class logger, and optionally create a persistent unit notification as well.
Log an exception using the current class logger.
Log an information message using the current class logger, and optionally create a persistent unit notification as well.
Log a warning message using the current class logger, and optionally create a persistent unit notification as well.
This method is called when a project property is changed. The default implementation does nothing: Implementors may safely override. Note that project-wide properties are being tracked, not solely those defined by the current unit's identifier.
To be overridden by subclasses if necessary. The default implementation does nothing.
prj | the project to which this unit belongs |
---|
The default implementation calls processInternal()
, and makes sure that a status
string is set on error, or nullified on success. processInternal() is never called is
isProcessed()
returns true.
Plugins may decide to override this method, if they need finer control over processing (we recommend overriding processInternal(); in that case, processInternal() should be ignored.
UnitProcessed
event. If processing succeeded,
subsequent calls to isProcessed()
should return true.
Sub-classes overriding this method must override related methods consistently.
unit | the unit removed |
---|
Set the unit name.
name | the unit name |
---|
Set user-defined notes. The notes can be textual data of any sort.
notes | the notes |
---|
Set the parent unit or artifact.
parent | the parent |
---|
Mark the unit as processed and optionally notify clients by issuing a UnitChange
event. Implementors wishing to override this method must also override isProcessed()
.
Mark the unit as processed and notify the client. Same as
setProcessed(processed, true)
.
Set the optional unit's real name.
Set the plugin status. This method also takes care of notifying listeners by issuing a
UnitStatusChanged
event.
status | the new status |
---|
Set the unit processor. This method is called by the managing project or (engines) context.
processor | the unit processor |
---|