wyvern.kernel.properties
Class ArchetypeImpl
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.properties.ArchetypeImpl
- All Implemented Interfaces:
- Archetype, PropertyList
- public class ArchetypeImpl
- extends PList
- implements Archetype
This class is a list of properties that a game object can inherit
from. Archetypes generally have names, although they can be
anonymous.
- Version:
- 1.0, Jan 25, 1998
- Author:
- Steve Yegge
Method Summary |
java.lang.String |
getName()
Returns the name of the archetype file, e.g. |
java.lang.String |
getPythonPath()
Returns the "path" attribute of the Archetype |
GameObject |
instantiate()
Creates an instance of this archetype. |
boolean |
isPythonArch()
Returns true if this is a Jython archetype. |
java.lang.Class |
loadClass()
Loads an Archetype's class. |
java.lang.String |
provideName()
Returns a name for the archetype suitable for writing it to
a map file. |
void |
setName(java.lang.String name)
Sets the name of the archetype file. |
java.lang.String |
toString()
Returns the archetype formatted as a property list, for debugging. |
java.lang.String |
toString(boolean inherit)
Returns a string representation of this archetype. |
Methods inherited from class wyvern.kernel.properties.PList |
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, transientlyRemoveProperty |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface wyvern.lib.PropertyList |
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, transientlyRemoveProperty |
ArchetypeImpl
public ArchetypeImpl()
ArchetypeImpl
public ArchetypeImpl(Archetype parent)
- Constructs a new ArchetypeImpl with the specified parent archetype.
- Parameters:
parent
- the parent archetype to inherit from. Sets
the parent link on this archetype to the new parent.
toString
public java.lang.String toString()
- Description copied from interface:
Archetype
- Returns the archetype formatted as a property list, for debugging.
- Specified by:
toString
in interface Archetype
- Overrides:
toString
in class PList
- Returns:
- a debugging string
toString
public java.lang.String toString(boolean inherit)
- Returns a string representation of this archetype. Includes
inherited properties.
- Specified by:
toString
in interface Archetype
- Overrides:
toString
in class PList
- Parameters:
inherit
- true to include inherited properties, false
to include only ones in the local list.
- Returns:
- the formatted property list
instantiate
public GameObject instantiate()
throws java.lang.Exception
- Description copied from interface:
Archetype
- Creates an instance of this archetype. Looks for a "class"
property to load and instantiate, and adds a pointer to this
archetype on the new object.
- Specified by:
instantiate
in interface Archetype
- Returns:
- a GameObject that inherits from this archetype. The
GameObject does not get copies of the archetype's properties;
it inherits them via the archetype parent pointer.
- Throws:
java.lang.Exception
loadClass
public java.lang.Class loadClass()
throws java.lang.Exception
- Description copied from interface:
Archetype
- Loads an Archetype's class. Don't call this method if the
class is a python class - use the PythonInterpreter to
instantiate python objects.
- Specified by:
loadClass
in interface Archetype
- Returns:
- the class specified in the "class" property, if found
- Throws:
java.lang.Exception
getName
public java.lang.String getName()
- Description copied from interface:
Archetype
- Returns the name of the archetype file, e.g. "terrain/water".
- Specified by:
getName
in interface Archetype
- Returns:
- the local or relative path to the archetype file
setName
public void setName(java.lang.String name)
- Description copied from interface:
Archetype
- Sets the name of the archetype file. Should only be called
by the MapLoader.
- Specified by:
setName
in interface Archetype
- Parameters:
name
- the local or relative path to the archetype file
provideName
public java.lang.String provideName()
- Description copied from interface:
Archetype
- Returns a name for the archetype suitable for writing it to
a map file. (It's what goes in the "path" attribute).
This will be one of several possibilities:
a) if name returned by getName() returns non-null, then:
- if name starts with "local/", returns the local
archetype's parent's name.
- if the name doesn't start with "local/", returns
that name as the path.
b) the parent archetype's name, if there's a parent archetype
c) the class to instantiate
(b) and (c) are the possible options for an anonymous archetype.
- Specified by:
provideName
in interface Archetype
isPythonArch
public boolean isPythonArch()
- Returns true if this is a Jython archetype.
- Specified by:
isPythonArch
in interface Archetype
- Returns:
- true if it was defined as ...
getPythonPath
public java.lang.String getPythonPath()
- Returns the "path" attribute of the Archetype
- Specified by:
getPythonPath
in interface Archetype
- Returns:
- the relative python path that the archetype inherits
from, or null if it's not a jython archetype