# Class: com.pnfsoftware.jeb.core.units.AbstractUnit

Skeleton implementation for an [IUnit](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: 
 
- By default, [#canBePersisted()](#canBePersisted()) returns true.
-  
- This class persist the non\-transient children units only.
-  
- The formatter allows storing of persisted and transient presentation. Refer to [IUnitFormatter](IUnitFormatter) for more information.
-  
- Derived classes that wish to implement custom persistence should implement a custom serialization methods.
-

## Protected Constructor: AbstractUnit
- parameter: `formatType`, type: `java.lang.String`
- parameter: `name`, type: `java.lang.String`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.units.IUnit`

Description: Build a new child from parent [IUnit](IUnit)
parameter: formatType: the mandatory format type, normally one provided by the identifier
parameter: name: the unit name
parameter: parent: the parent unit

## Protected Constructor: AbstractUnit
- parameter: `formatType`, type: `java.lang.String`
- parameter: `name`, type: `java.lang.String`
- parameter: `unitProcessor`, type: `com.pnfsoftware.jeb.core.units.IUnitProcessor`
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.IUnitCreator`
- parameter: `pdm`, type: `com.pnfsoftware.jeb.core.properties.IPropertyDefinitionManager`

Description: 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.
parameter: formatType: the mandatory format type, normally one provided by the identifier
parameter: name: the desired unit name; if null or blank, a name will be auto\-generated; slashes            and back\-slashes will be replaced by underscores; leading and trailing WSP            characters will be removed
parameter: unitProcessor: the unit processor
parameter: parent: the parent unit or artifact; if null, this unit cannot be attached to a            project; practically, this field should never be null
parameter: pdm: optional an optional property definition manager

## Method: addChild
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.IUnit`

Description: Sub\-classes overriding this method must override related methods consistently.

## Method: addChild
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- parameter: `persisted`, type: `boolean`

Description: Sub\-classes overriding this method must override related methods consistently.

## Protected Method: addChild
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- parameter: `persisted`, type: `boolean`
- parameter: `notify`, type: `boolean`

Description: Add a child unit and optionally notify listeners.
parameter: unit: child unit
parameter: persisted: true if the child should be persisted
parameter: notify: true to notify listeners

## Method: addNotification
- parameter: `notification`, type: `com.pnfsoftware.jeb.core.units.IUnitNotification`

Description: Add a persistent unit notification.
parameter: notification: notification to add

## Method: canBePersisted
- return type: `boolean`


## Method: clearAllData
- parameter: `key`, type: `java.lang.Object`


## Method: dispose

Description: Sub\-classes overriding this method must call the `super` implementation last.

## Protected Method: finalize


## Method: generateQuickState
- return type: `com.pnfsoftware.jeb.core.units.IQuickStateObject`

Description: The default implementation returns null.

## Method: getAllData
- return type: `java.util.Map<java.lang.Object,java.lang.Object>`


## Method: getChildren
- return type: `java.util.List<? extends com.pnfsoftware.jeb.core.units.IUnit>`

Description: Sub\-classes overriding this method must override related methods consistently.

## Method: getContributions
- return type: `java.util.List<com.pnfsoftware.jeb.core.IUnitContribution>`


## Method: getCreationTimestamp
- return type: `long`


## Method: getData
- parameter: `key`, type: `java.lang.Object`
- return type: `java.lang.Object`


## Method: getDescription
- return type: `java.lang.String`


## Method: getFormatType
- return type: `java.lang.String`


## Method: getFormatter
- return type: `com.pnfsoftware.jeb.core.output.IUnitFormatter`


## Method: getIconData
- return type: `byte[]`


## Method: getInterpreters
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.IUnitInterpreter>`


## Method: getLock
- return type: `com.pnfsoftware.jeb.core.units.IUnitLock`

Description: The default implementation returns a pass\-through lock that never locks.

## Method: getName
- return type: `java.lang.String`


## Method: getNotes
- return type: `java.lang.String`


## Method: getNotificationManager
- return type: `com.pnfsoftware.jeb.core.units.IUnitNotificationManager`


## Method: getParent
- return type: `com.pnfsoftware.jeb.core.IUnitCreator`


## Method: getPropertyDefinitionManager
- return type: `com.pnfsoftware.jeb.core.properties.IPropertyDefinitionManager`


## Method: getPropertyManager
- return type: `com.pnfsoftware.jeb.core.properties.IPropertyManager`


## Method: getRealName
- return type: `java.lang.String`


## Method: getStatus
- return type: `java.lang.String`


## Method: getUid
- return type: `long`


## Method: getUnitProcessor
- return type: `com.pnfsoftware.jeb.core.units.IUnitProcessor`


## Method: hasChildren
- return type: `boolean`

Description: Determine whether this unit has children.
return: true if this unit has at least one child

## Method: initializePropertyObjects
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.IUnitCreator`
- parameter: `processor`, type: `com.pnfsoftware.jeb.core.units.IUnitProcessor`
- parameter: `pdm`, type: `com.pnfsoftware.jeb.core.properties.IPropertyDefinitionManager`

Description: Overrides are allowed. If so, `super.initializePropertyObjects()` must be called first.

## Method: internalSwapChildren

Description: RESERVED FOR INTERNAL USE.

## Method: isDeserialized
- return type: `boolean`

Description: Determine whether this unit was restored from a serialized project.
return: true if this unit was deserialized

## Method: isDisposed
- return type: `boolean`


## Method: isProcessed
- return type: `boolean`


## Method: isStale
- return type: `boolean`

Description: The default implementation returns `false`.

## Method: isTransientChild
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- return type: `boolean`

Description: Sub\-classes overriding this method must override related methods consistently.

## Method: logError
- parameter: `recordNotification`, type: `boolean`
- parameter: `format`, type: `java.lang.String`
- parameter: `params`, type: `java.lang.Object[]`

Description: Log an error message using the current class logger, and optionally create a persistent unit notification as well.
parameter: recordNotification: true to create a persistent unit notification
parameter: format: message format
parameter: params: format parameters

## Method: logException
- parameter: `e`, type: `java.lang.Exception`

Description: Log an exception using the current class logger.
parameter: e: exception to log

## Method: logInfo
- parameter: `recordNotification`, type: `boolean`
- parameter: `format`, type: `java.lang.String`
- parameter: `params`, type: `java.lang.Object[]`

Description: Log an information message using the current class logger, and optionally create a persistent unit notification as well.
parameter: recordNotification: true to create a persistent unit notification
parameter: format: message format
parameter: params: format parameters

## Method: logTrace
- parameter: `format`, type: `java.lang.String`
- parameter: `params`, type: `java.lang.Object[]`

Description: Log a trace message using the current class logger.
parameter: format: message format
parameter: params: format parameters

## Method: logWarn
- parameter: `recordNotification`, type: `boolean`
- parameter: `format`, type: `java.lang.String`
- parameter: `params`, type: `java.lang.Object[]`

Description: Log a warning message using the current class logger, and optionally create a persistent unit notification as well.
parameter: recordNotification: true to create a persistent unit notification
parameter: format: message format
parameter: params: format parameters

## Method: onPropertyChange
- parameter: `fqPropertyName`, type: `java.lang.String`

Description: 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.
parameter: fqPropertyName: fully\-qualified property name

## Method: postDeserialization
- parameter: `prj`, type: `com.pnfsoftware.jeb.core.IRuntimeProject`

Description: To be overridden by subclasses if necessary. The default implementation does nothing.

## Method: process
- return type: `boolean`

Description: The default implementation calls [#processInternal()](#processInternal()), and makes sure that a status string is set on error, or nullified on success. processInternal\(\) is never called is [#isProcessed()](#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.

## Protected Method: processInternal
- return type: `boolean`

Description: Plugins may override this method instead of the traditional [#process()](#process()). \(If this method is overridden, implementors must NOT override [#process()](#process()).\) This method is called only if [#isProcessed()](#isProcessed()) returned `false`.
return: success indicator

## Method: removeChild
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.IUnit`

Description: Sub\-classes overriding this method must override related methods consistently.

## Protected Method: removeChild
- parameter: `unit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- parameter: `notify`, type: `boolean`

Description: Remove a child unit and optionally notify listeners.
parameter: unit: child unit
parameter: notify: true to notify listeners

## Method: setChild
- parameter: `oldUnit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- parameter: `newUnit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- return type: `boolean`

Description: Replace a child unit and notify listeners.
parameter: oldUnit: child unit to replace
parameter: newUnit: replacement child unit
return: success indicator

## Protected Method: setChild
- parameter: `oldUnit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- parameter: `newUnit`, type: `com.pnfsoftware.jeb.core.units.IUnit`
- parameter: `notify`, type: `boolean`
- return type: `boolean`

Description: Replace a child unit and optionally notify listeners.
parameter: oldUnit: child unit to replace
parameter: newUnit: replacement child unit
parameter: notify: true to notify listeners
return: success indicator

## Method: setData
- parameter: `key`, type: `java.lang.Object`
- parameter: `value`, type: `java.lang.Object`
- parameter: `persist`, type: `boolean`


## Method: setName
- parameter: `newName`, type: `java.lang.String`


## Method: setNotes
- parameter: `notes`, type: `java.lang.String`


## Method: setParent
- parameter: `parent`, type: `com.pnfsoftware.jeb.core.IUnitCreator`


## Method: setProcessed
- parameter: `processed`, type: `boolean`

Description: Mark the unit as processed and, if processed, notify the client. Same as [setProcessed\(processed, true\)](#setProcessed(boolean, boolean)).
parameter: processed: true if the unit was processed successfully

## Method: setProcessed
- parameter: `processed`, type: `boolean`
- parameter: `notify`, type: `boolean`

Description: Mark the unit as processed and, if processed, optionally notify clients by issuing a [J#UnitChange](J#UnitChange) event. Implementors wishing to override this method must also override [#isProcessed()](#isProcessed()).
parameter: processed: true if the unit was processed successfully
parameter: notify: true to notify listeners when marking the unit as processed

## Method: setRealName
- parameter: `name`, type: `java.lang.String`


## Method: setStatus
- parameter: `status`, type: `java.lang.String`

Description: Set the plugin status. This method also takes care of notifying listeners by issuing a [J#UnitStatusChanged](J#UnitStatusChanged) event.
parameter: status: the new status

## Method: setStatus
- parameter: `status`, type: `java.lang.String`
- parameter: `notify`, type: `boolean`

Description: Set the plugin status and optionally notify listeners.
parameter: status: the new status
parameter: notify: true to notify listeners

## Method: setUnitProcessor
- parameter: `processor`, type: `com.pnfsoftware.jeb.core.units.IUnitProcessor`


## Method: toString
- return type: `java.lang.String`


