java.lang.Object | ||
↳ | com.pnfsoftware.jeb.core.events.JebEventSource | |
↳ | com.pnfsoftware.jeb.core.units.AbstractUnit |
Known Direct Subclasses |
Known Indirect Subclasses |
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.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.pnfsoftware.jeb.core.events.JebEventSource
|
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 |
clearAllData(Object key)
Remove all pieces of custom unit data.
| ||||||||||
void |
dispose()
Sub-classes overriding this method must call the
super implementation last. | ||||||||||
IQuickStateObject |
generateQuickState()
The default implementation returns null.
| ||||||||||
Map<Object, Object> |
getAllData()
Retrieve a map containing all key-value pairs of of custom unit data.
| ||||||||||
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.
| ||||||||||
Object |
getData(Object key)
Retrieve a piece of custom unit data.
| ||||||||||
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.
| ||||||||||
long |
getUid()
Retrieve an identifier that uniquely identifies the unit within its
project . | ||||||||||
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() | ||||||||||
final boolean |
isDisposed()
Indicate if the unit has been disposed
| ||||||||||
boolean |
isProcessed()
Verify if the unit was successfully processed.
| ||||||||||
boolean |
isStale()
The default implementation returns
false . | ||||||||||
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 |
logTrace(String format, Object... params)
Log a trace message using the current class logger.
| ||||||||||
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. | ||||||||||
final void |
removeChild(IUnit unit)
Sub-classes overriding this method must override related methods consistently.
| ||||||||||
boolean | setChild(IUnit oldUnit, IUnit newUnit) | ||||||||||
void |
setData(Object key, Object value, boolean persist)
Store a piece of custom unit data.
| ||||||||||
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, if processed, optionally notify clients by issuing a
UnitChange event. | ||||||||||
final void |
setProcessed(boolean processed)
Mark the unit as processed and, if processed, notify the client.
| ||||||||||
void |
setRealName(String name)
Set the optional unit's real name.
| ||||||||||
void | setStatus(String status, boolean notify) | ||||||||||
final 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) | ||||||||||
void | finalize() | ||||||||||
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.pnfsoftware.jeb.core.events.JebEventSource
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
com.pnfsoftware.jeb.core.IUnitCreator
| |||||||||||
From interface
com.pnfsoftware.jeb.core.IUserDataSupport
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.IUnit
| |||||||||||
From interface
com.pnfsoftware.jeb.util.events.IEventSource
|
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.
Remove all pieces of custom unit data.
Sub-classes overriding this method must call the super
implementation last.
The default implementation returns null.
Retrieve a map containing all key-value pairs of of custom unit data.
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.
Retrieve a piece of custom unit data.
key | non-null key |
---|
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 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 an identifier that uniquely identifies the unit within its project
.
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.
The default implementation returns false
.
stale
; this method should return false if
isProcessed()
returns false
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 trace message using the current class logger.
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 |
---|
Store a piece of custom unit data.
key | non-null key |
---|---|
value | optional value (may be null) |
persist | if false, the piece of data is transient and will not be persisted to disk
when saving the project to a JEB database; if true, the piece of data will be
persisted, in which case, user of this method must ensure that both key and value
are serializable ; if unsure, it is recommended to either not persist
the data, or if persistence is a requirement, use only key/value types that are
guaranteed to be persisted, such as any basic types (String, boxed primitive
types, primitive types, arrays or lists of those, etc.)
|
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, if processed, optionally notify clients by issuing a
UnitChange
event. Implementors wishing to override this method must also override
isProcessed()
.
Mark the unit as processed and, if processed, 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 |
---|
Throwable |
---|
Plugins may override this method instead of the traditional process()
. (If this
method is overridden, implementors must NOT override process()
.) This method is
called only if isProcessed()
returned false
.