Class WrapperUnit<T extends IUnit>
java.lang.Object
com.pnfsoftware.jeb.core.units.impl.WrapperUnit<T>
- All Implemented Interfaces:
IUnitCreator,IUserDataSupport,IUnit,com.pnfsoftware.jeb.corei.IWrap<T>,IEventSource
- Direct Known Subclasses:
BinaryWrapperUnit,InteractiveWrapperUnit
@Ser
public class WrapperUnit<T extends IUnit>
extends Object
implements IUnit, com.pnfsoftware.jeb.corei.IWrap<T>
Simple wrapper (decorator) unit that delegates its job to the provided
IUnit. This
decorator allows the additions of output documents as well as a customization of the unit's
format type using the IUnitProvider. For other changes in the IUnit, it is
required to extend this class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister a child unit to this unit.voidAdd a child unit to this unit.voidaddListener(IEventListener listener) Register a listener.booleanDetermine if this unit can be persisted.voidclearAllData(Object key) Remove all pieces of custom unit data.intGet the numbers of objects listening to this event source.voiddispose()Dispose of the resources used by this unit.Save the state of this unit (it may be a partial state).Retrieve a map containing all key-value pairs of of custom unit data.Retrieve a read-only list of all direct children units.Get the list of contributions attached to the unit.longGet the date of creation of this unit.Retrieve a piece of custom unit data.Get a description string for that unit.Retrieve a fresh formatter for that unit.Mandatory unit type.byte[]The icon bytes representing units of such type.Get the list of command interpreters attached to the unit.List<? extends IEventListener>Get a copy of the list of listeners.getLock()Get the unit lock.getName()Get the unit name.getNotes()Get user-defined notes.Get a reference to the notification manager.Retrieve the creator (or parent) of this unit.Get the parent source.Retrieve the PDM used by this unit.Retrieve the PM used by this unit.Retrieve the optional real unit name.Get the status for the unit.longgetUid()Retrieve an identifier that uniquely identifies the unit within itsproject.Retrieve the unit processor used by this unit.getWrap()Return the wrappedIUnitvoidinitializePropertyObjects(IUnitCreator parent, IUnitProcessor processor, IPropertyDefinitionManager pdm) Initialize the property manager and property definition manager used by this unit.voidinsertListener(int index, IEventListener listener) Register a listener.booleanIndicate if the unit has been disposedbooleanVerify if the unit was successfully processed.booleanisStale()Determine whether the unit was successfully processed, but is now considered to be stale (outdated content).booleanisTransientChild(IUnit unit) Check if a child unit is transient.voidNotify listeners that an event has occurred.voidThis method is called by the engines after a unit has been fully deserialized.booleanprocess()Process the unit.voidremoveChild(IUnit unit) Remove a direct child of the current unit.voidremoveListener(IEventListener listener) Unregister a listener.voidStore a piece of custom unit data.voidSet the unit name.voidSet user-defined notes.voidsetParent(IUnitCreator parent) Set the parent unit or artifact.voidsetParentSource(IEventSource parentSource) Set a parent source.voidsetRealName(String name) Set the optional unit's real name.voidsetUnitProcessor(IUnitProcessor unitProcessor) Set the unit processor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.core.units.IUnit
execprvfunc, getExtraInputs, getInput, getParentArtifact, getParentProject, notifyGenericChange
-
Constructor Details
-
WrapperUnit
- Parameters:
unit-IUnitto be delegatedprovider- provider that extends the unit behavior
-
-
Method Details
-
getWrap
Return the wrappedIUnit -
addListener
Description copied from interface:IEventSourceRegister a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.- Specified by:
addListenerin interfaceIEventSource- Parameters:
listener- a listener of events generated by this source
-
insertListener
Description copied from interface:IEventSourceRegister a listener. The implementor may allow duplicates.- Specified by:
insertListenerin interfaceIEventSource- Parameters:
index- insertion pointlistener- a listener of events generated by this source
-
countListeners
public int countListeners()Description copied from interface:IEventSourceGet the numbers of objects listening to this event source.- Specified by:
countListenersin interfaceIEventSource- Returns:
- the number of listeners
-
getListeners
Description copied from interface:IEventSourceGet a copy of the list of listeners.- Specified by:
getListenersin interfaceIEventSource- Returns:
-
getParentSource
Description copied from interface:IEventSourceGet the parent source.- Specified by:
getParentSourcein interfaceIEventSource- Returns:
- the parent source, or null if none
-
notifyListeners
Description copied from interface:IEventSourceNotify listeners that an event has occurred.- Specified by:
notifyListenersin interfaceIEventSource- Parameters:
e- the event to be propagated
-
canBePersisted
public boolean canBePersisted()Description copied from interface:IUnitDetermine 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.- Specified by:
canBePersistedin interfaceIUnit- Returns:
- true if the unit can be persisted, false if the unit must not be persisted
-
getChildren
Description copied from interface:IUnitRetrieve a read-only list of all direct children units.- Specified by:
getChildrenin interfaceIUnit- Returns:
- the children or an empty list, never null
-
getLock
Description copied from interface:IUnitGet the unit lock. -
getCreationTimestamp
public long getCreationTimestamp()Description copied from interface:IUnitGet the date of creation of this unit.- Specified by:
getCreationTimestampin interfaceIUnit- Returns:
- the creation timestamp in milliseconds since the unix epoch
-
getDescription
Description copied from interface:IUnitGet a description string for that unit.The unit must be processed before calling this method.
- Specified by:
getDescriptionin interfaceIUnit- Returns:
- a description string
-
getFormatType
Description copied from interface:IUnitMandatory unit type. The type should be unique across all units. It should be the same as theidentifier'stype.- Specified by:
getFormatTypein interfaceIUnit- Returns:
- the non-null unit type
-
getFormatter
Description copied from interface:IUnitRetrieve 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.
- Specified by:
getFormatterin interfaceIUnit- Returns:
- a new formatter, never null
-
getIconData
public byte[] getIconData()Description copied from interface:IUnitThe 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.- Specified by:
getIconDatain interfaceIUnit- Returns:
- the BMP or PNG bytes of an icon
-
getUid
public long getUid()Description copied from interface:IUnitRetrieve an identifier that uniquely identifies the unit within itsproject. -
getName
Description copied from interface:IUnitGet the unit name.- Specified by:
getNamein interfaceIUnit- Specified by:
getNamein interfaceIUnitCreator- Returns:
- the unit name
-
getRealName
Description copied from interface:IUnitRetrieve the optional real unit name.- Specified by:
getRealNamein interfaceIUnit- Returns:
- potentially null
-
setRealName
Description copied from interface:IUnitSet the optional unit's real name.- Specified by:
setRealNamein interfaceIUnit
-
getNotes
Description copied from interface:IUnitGet user-defined notes. The notes can be textual data of any sort. -
getNotificationManager
Description copied from interface:IUnitGet a reference to the notification manager.- Specified by:
getNotificationManagerin interfaceIUnit- Returns:
- the notification manager, never null
-
getParent
Description copied from interface:IUnitRetrieve the creator (or parent) of this unit. It can be a parentIUnitor anIArtifact, for top-level units.- Specified by:
getParentin interfaceIUnit- Specified by:
getParentin interfaceIUnitCreator- Returns:
- the parent
-
getPropertyDefinitionManager
Description copied from interface:IUnitRetrieve the PDM used by this unit. For consistency, it is recommend that all units of a given type return equivalent PDMs.- Specified by:
getPropertyDefinitionManagerin interfaceIUnit- Returns:
- the property definition manager
-
getPropertyManager
Description copied from interface:IUnitRetrieve the PM used by this unit.- Specified by:
getPropertyManagerin interfaceIUnit- Returns:
- the property manager
-
getStatus
Description copied from interface:IUnitGet the status for the unit. Plugins should set a status if processing failed. Implementors must notify their listeners by issuing aJ.UnitStatusChangedevent. -
getUnitProcessor
Description copied from interface:IUnitRetrieve the unit processor used by this unit.- Specified by:
getUnitProcessorin interfaceIUnit- Returns:
- the processor
-
isProcessed
public boolean isProcessed()Description copied from interface:IUnitVerify if the unit was successfully processed.- Specified by:
isProcessedin interfaceIUnit- Returns:
- true if the unit was successfully processed
-
isStale
public boolean isStale()Description copied from interface:IUnitDetermine whether the unit was successfully processed, but is now considered to be stale (outdated content).Re-processingis encouraged but not mandatory.The result is irrelevant if
IUnit.isProcessed()isfalse.- Specified by:
isStalein interfaceIUnit- Returns:
- whether the unit
stale; this method should return false ifIUnit.isProcessed()returns false
-
process
public boolean process()Description copied from interface:IUnitProcess the unit. Processing almost always involves parsing, eg, for a code disassembler unit, processing could mean disassembling machine code. This method is called by the unit producer, typically, those are:- a unit identifier who successfully identified input data, and who was later called by a processor
- a parent unit doing the identification itself, and calling a child unit process() directly
- Specified by:
processin interfaceIUnit- Returns:
- true if processing is or was successful (in the latter case, process() should do
nothing but return true), or false is processing failed. The unit should also notify
clients by issuing a
J.UnitProcessedevent. If processing succeeded, subsequent calls toIUnit.isProcessed()should return true.
-
removeListener
Description copied from interface:IEventSourceUnregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.- Specified by:
removeListenerin interfaceIEventSource- Parameters:
listener- the listener to be removed
-
setName
Description copied from interface:IUnitSet the unit name. -
setNotes
Description copied from interface:IUnitSet user-defined notes. The notes can be textual data of any sort. -
setParent
Description copied from interface:IUnitSet the parent unit or artifact. -
setParentSource
Description copied from interface:IEventSourceSet a parent source.- Specified by:
setParentSourcein interfaceIEventSource- Parameters:
parentSource- the optional parent source
-
initializePropertyObjects
public void initializePropertyObjects(IUnitCreator parent, IUnitProcessor processor, IPropertyDefinitionManager pdm) Description copied from interface:IUnitInitialize the property manager and property definition manager used by this unit.Code that needs access to the unit's property manager right after deserialization can safely do so after execution of this method.
- Specified by:
initializePropertyObjectsin interfaceIUnit- Parameters:
parent- the parent unit or artifactprocessor- the processorpdm- the property definition manager for units of this type
-
postDeserialization
Description copied from interface:IUnitThis method is called by the engines after a unit has been fully deserialized. Final repairs (eg, retrieving and re-connecting global objects that were not serialized) may be done by this method. The unit's project and engines are now accessible.- Specified by:
postDeserializationin interfaceIUnit- Parameters:
prj- the project to which this unit belongs
-
setUnitProcessor
Description copied from interface:IUnitSet the unit processor. This method is called by the managing project or (engines) context.- Specified by:
setUnitProcessorin interfaceIUnit- Parameters:
unitProcessor- the unit processor
-
getContributions
Description copied from interface:IUnitGet the list of contributions attached to the unit.- Specified by:
getContributionsin interfaceIUnit- Returns:
-
getInterpreters
Description copied from interface:IUnitGet the list of command interpreters attached to the unit.- Specified by:
getInterpretersin interfaceIUnit- Returns:
- the interpreter, null if none
-
dispose
public void dispose()Description copied from interface:IUnitDispose of the resources used by this unit. -
isDisposed
public boolean isDisposed()Description copied from interface:IUnitIndicate if the unit has been disposed- Specified by:
isDisposedin interfaceIUnit- Returns:
- disposal status
- See Also:
-
removeChild
Description copied from interface:IUnitRemove a direct child of the current unit.- Specified by:
removeChildin interfaceIUnit- Parameters:
unit- the unit removed
-
addChild
Description copied from interface:IUnitAdd a child unit to this unit. Implementations must check for duplicate and also notify clients by emitting the right event. -
isTransientChild
Description copied from interface:IUnitCheck if a child unit is transient. By default, children units are persisted.- Specified by:
isTransientChildin interfaceIUnit- Parameters:
unit- the child unit- Returns:
- true if the child is non-persisted
-
addChild
Description copied from interface:IUnitRegister a child unit to this unit. The child unit is persisted. Same asaddChild(child, true). -
generateQuickState
Description copied from interface:IUnitSave the state of this unit (it may be a partial state). Implementation of this method is optional.- Specified by:
generateQuickStatein interfaceIUnit- Returns:
- a state object or null if unsupported
-
setData
Description copied from interface:IUserDataSupportStore a piece of custom unit data.- Specified by:
setDatain interfaceIUserDataSupport- Parameters:
key- non-null keyvalue- 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 areserializable; 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.)
-
getData
Description copied from interface:IUserDataSupportRetrieve a piece of custom unit data.- Specified by:
getDatain interfaceIUserDataSupport- Parameters:
key- non-null key- Returns:
- value (null may indicate that the key-value pair is not present or that the stored value is null)
-
clearAllData
Description copied from interface:IUserDataSupportRemove all pieces of custom unit data.- Specified by:
clearAllDatain interfaceIUserDataSupport
-
getAllData
Description copied from interface:IUserDataSupportRetrieve a map containing all key-value pairs of of custom unit data.- Specified by:
getAllDatain interfaceIUserDataSupport- Returns:
- a map
-