All Packages Class Hierarchy This Package Previous Next Index
Class key.ReferenceProperty
java.lang.Object
|
+----key.Property
|
+----key.ReferenceProperty
- public class ReferenceProperty
- extends Property
- implements Referrer
When you set it (be it by loading the id or giving it
an atom, this class will attempt to use *only* that
reference for as long as possible. An actual reference
to the object has a higher priority than an id.
This means:
- You can set it directly with a reference to an object
during construction, and it will use that reference,
even if, technically, it couldn't look up that atom's
id yet. (Key needs to do this)
- You can load the id using loadFrom() before the object
exists - until you try and use the reference property
it will not try and resolve it.
There are, then, four states for this object:
- resolved == null, value == null: Nothing is set, a null reference
- resolved == something, value == null: We have a reference, but not the id
- resolved == null, value == something: An unresolved reference
- resolved == something, value == something: A fully decked out reference
Think about removing that last state in the name of storing as little as
possible. Then we only have 3 states to worry about. You'd remove it by
changing the resolve() method to clear the value. ;)
-
value
-
-
ReferenceProperty(String, Type, Atom)
-
-
ReferenceProperty(String, Type, Atom, Object)
-
-
checkType(Type)
-
-
clear()
- Make it so we're not referencing anything anymore
-
delete(Atom)
-
-
get()
- We may wish (in the future) to put in some code
that can do a rescan, or, better, notice, when
an atom moves, so that the resolved reference
isn't wrong - or the value's don't get confused
-
getId()
-
-
loadFrom(DataInput)
- You need to have the property class set up *before*
calling this command
-
resolvable()
-
-
resolve(Atom)
- This routine can be made more efficient by combining
the getSymbol and isSymbolTransit routines - possibly
by having another routine that returns a 'searchObject'
or something, which can have flags on it based on how it
was found.
-
set(Object)
- Store the resolved reference
-
setId(String)
- Just store the id of the atom
-
setId(String, Atom)
-
-
swapout(Atom)
-
-
writeTo(DataOutput)
-
value
protected Object value
ReferenceProperty
public ReferenceProperty(String name,
Type type,
Atom parent)
ReferenceProperty
public ReferenceProperty(String name,
Type type,
Atom parent,
Object theValue) throws TypeMismatchException
checkType
protected void checkType(Type type)
- Overrides:
- checkType in class Property
get
public Object get()
- We may wish (in the future) to put in some code
that can do a rescan, or, better, notice, when
an atom moves, so that the resolved reference
isn't wrong - or the value's don't get confused
resolvable
public boolean resolvable()
resolve
public Tag resolve(Atom relTo)
- This routine can be made more efficient by combining
the getSymbol and isSymbolTransit routines - possibly
by having another routine that returns a 'searchObject'
or something, which can have flags on it based on how it
was found.
clear
public void clear()
- Make it so we're not referencing anything anymore
delete
public void delete(Atom a)
set
public void set(Object o) throws TypeMismatchException
- Store the resolved reference
getId
public String getId()
setId
protected void setId(String id)
- Just store the id of the atom
setId
public void setId(String id,
Atom relTo)
writeTo
public void writeTo(DataOutput to) throws IOException
- Overrides:
- writeTo in class Property
loadFrom
public void loadFrom(DataInput from) throws IOException
- You need to have the property class set up *before*
calling this command
- Overrides:
- loadFrom in class Property
swapout
public void swapout(Atom a)
All Packages Class Hierarchy This Package Previous Next Index