public abstract class DynamicObjectImpl extends java.lang.Object implements DynamicObject, java.lang.Cloneable
DynamicObject.FlagsFunction
Modifier and Type | Field and Description |
---|---|
static DebugCounter |
reshapeCount |
Constructor and Description |
---|
DynamicObjectImpl(Shape shape) |
Modifier and Type | Method and Description |
---|---|
boolean |
changeFlags(java.lang.Object id,
DynamicObject.FlagsFunction updateFunction)
Change property flags.
|
boolean |
changeFlags(java.lang.Object id,
int newFlags)
Change property flags.
|
protected abstract boolean |
checkExtensionArrayInvariants(Shape newShape)
Check whether the extension arrays are in accordance with the description in the shape.
|
protected DynamicObject |
clone() |
protected abstract DynamicObject |
cloneWithShape(Shape currentShape) |
void |
copyProperties(DynamicObject fromObject,
Shape ancestor) |
java.lang.String |
debugDump(int level) |
java.lang.String |
debugDump(int level,
int levelStop) |
void |
define(java.lang.Object id,
java.lang.Object value,
int flags)
Define new property or redefine existing property.
|
void |
define(java.lang.Object id,
java.lang.Object value,
int flags,
LocationFactory locationFactory)
Define new property with a static location or change existing property.
|
boolean |
delete(java.lang.Object id)
Delete property.
|
boolean |
equals(java.lang.Object obj) |
java.lang.Object |
get(java.lang.Object id,
java.lang.Object defaultValue)
Get property value.
|
ShapeImpl |
getShape()
Get the object's current shape.
|
java.lang.Object |
getTypeIdentifier() |
protected abstract void |
growObjectStore(Shape oldShape,
Shape newShape) |
protected abstract void |
growPrimitiveStore(Shape oldShape,
Shape newShape) |
int |
hashCode() |
protected abstract void |
initialize(Shape initialShape) |
boolean |
isEmpty()
Returns
true if this object contains no properties. |
protected abstract void |
resizeObjectStore(Shape oldShape,
Shape newShape) |
protected abstract void |
resizePrimitiveStore(Shape oldShape,
Shape newShape) |
boolean |
set(java.lang.Object id,
java.lang.Object value)
Set value of existing property.
|
protected void |
setShape(Shape shape) |
void |
setShapeAndGrow(Shape oldShape,
Shape newShape)
Set shape to an immediate child of the current shape, optionally growing the extension array.
|
void |
setShapeAndResize(Shape newShape) |
void |
setShapeAndResize(Shape oldShape,
Shape newShape)
Set object shape and resize storage if necessary.
|
int |
size()
Returns the number of properties in this object.
|
java.lang.String |
toString() |
boolean |
updateShape()
Ensure object shape is up-to-date.
|
public static final DebugCounter reshapeCount
public DynamicObjectImpl(Shape shape)
public java.lang.Object getTypeIdentifier()
getTypeIdentifier
in interface TypedObject
public ShapeImpl getShape()
DynamicObject
getShape
in interface DynamicObject
protected void setShape(Shape shape)
protected abstract void initialize(Shape initialShape)
public final void setShapeAndResize(Shape newShape)
public final void setShapeAndResize(Shape oldShape, Shape newShape)
DynamicObject
setShapeAndResize
in interface DynamicObject
oldShape
- the object's current shape (must equal DynamicObject.getShape()
)newShape
- the new shape to be setpublic final void setShapeAndGrow(Shape oldShape, Shape newShape)
setShapeAndGrow
in interface DynamicObject
oldShape
- the object's current shape (must equal DynamicObject.getShape()
)newShape
- the new shape to be setsetShapeAndResize(Shape, Shape)
protected abstract boolean checkExtensionArrayInvariants(Shape newShape)
protected final DynamicObject clone()
clone
in class java.lang.Object
protected abstract DynamicObject cloneWithShape(Shape currentShape)
public final void copyProperties(DynamicObject fromObject, Shape ancestor)
public boolean changeFlags(java.lang.Object id, int newFlags)
DynamicObject
changeFlags
in interface DynamicObject
id
- property identifiernewFlags
- flags to be settrue
if successful or false
if property not foundpublic boolean changeFlags(java.lang.Object id, DynamicObject.FlagsFunction updateFunction)
DynamicObject
changeFlags
in interface DynamicObject
id
- property identifierupdateFunction
- function updating old flags to new flagstrue
if successful or false
if property not foundpublic java.lang.String debugDump(int level)
public java.lang.String debugDump(int level, int levelStop)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object get(java.lang.Object id, java.lang.Object defaultValue)
DynamicObject
get
in interface DynamicObject
id
- property identifierdefaultValue
- return value if property is not foundpublic boolean set(java.lang.Object id, java.lang.Object value)
DynamicObject
set
in interface DynamicObject
id
- property identifiervalue
- value to be settrue
if successful or false
if property not foundpublic void define(java.lang.Object id, java.lang.Object value, int flags)
DynamicObject
define
in interface DynamicObject
id
- property identifiervalue
- value to be setflags
- flags to be setpublic void define(java.lang.Object id, java.lang.Object value, int flags, LocationFactory locationFactory)
DynamicObject
define
in interface DynamicObject
id
- property identifiervalue
- value to be setflags
- flags to be setlocationFactory
- factory function that creates a location for a given shape and valuepublic boolean delete(java.lang.Object id)
DynamicObject
delete
in interface DynamicObject
id
- property identifiertrue
if successful or false
if property not foundpublic int size()
DynamicObject
size
in interface DynamicObject
public boolean isEmpty()
DynamicObject
true
if this object contains no properties.isEmpty
in interface DynamicObject
public final boolean updateShape()
DynamicObject
updateShape
in interface DynamicObject
true
if shape has changed