evolution
Class KnowledgeCatalog

Direct Known Subclasses:
ActionKnowledgeCatalog, ConstructionKnowledgeCatalog, EvolutionKnowledgeCatalog, LandKnowledgeCatalog, ResourceKnowledgeCatalog

public abstract class KnowledgeCatalog

Abstract class of knowledgecatalogs.


Constructor Summary
 protected KnowledgeCatalog(String fileName)
          Create a new KnowledgeCatalog from the given file.

Method Summary
 protected static ClassdlClassForName(String packageName, String className)
          Dynamically load a class by name.
 static StringextractArgument(String spec)
          Extract the argument of a name(argument) list.
 static StringextractName(String spec)
          Extract the name of a name(value) or name(argument) list.
 static DoubleextractValue(String spec)
          Extract the value of a name(value) list.
 StringgetFileName()
          Return the filename from which this catalog was loaded.
 StringgetProperty(String name)
          Get a property.
 StringgetProperty(String name, String def)
          Get a property.
 static StringgetResourcePath()
          The resource path.
 booleanisInitialized()
          Is this catalog initialized.
 MapmakeStringDoubleMap(String propertyName, String def)
          Parse a string of name(value) pairs into a map from the property list.
 protected voidsetResourcePath(String fileName)
          Set the resource path from a fileName of a KnowledgeCatalog.
 static Listsplit(String delim, String str)
          Split a given string in parts.
 static StringstripPathFromClassName(String name)
          Strip the path from a string representation of a class name.
 static StringstripPathFromClassName(Class c)
          Strip the path from the class name of this class.
 static StringstripPathFromClassName(Object o)
          Strip the path from the class name of this object.

Constructor Detail

KnowledgeCatalog

protected KnowledgeCatalog(String fileName)
throws java.io.FileNotFoundException,
java.io.IOException
Create a new KnowledgeCatalog from the given file.
Method Detail

dlClassForName

protected static Class dlClassForName(String packageName, String className)
throws java.lang.ClassNotFoundException
Dynamically load a class by name. The class will first be searched in the evolution package and if not found in the resources package.
Parameters:
packageName - The subpackage name, e.g. actions
className - The class name, e.g. Fishing

extractArgument

public static String extractArgument(String spec)
Extract the argument of a name(argument) list. e.g. Cherries(BlueBerries) => BlueBerries

extractName

public static String extractName(String spec)
Extract the name of a name(value) or name(argument) list. e.g. Cherries(50) => Cherries

extractValue

public static Double extractValue(String spec)
Extract the value of a name(value) list. e.g. Cherries(50) => 50

getFileName

public String getFileName()
Return the filename from which this catalog was loaded.

getProperty

public String getProperty(String name)
Get a property. If not found returns null.

getProperty

public String getProperty(String name, String def)
Get a property. If the property is not found returns def.

getResourcePath

public static String getResourcePath()
The resource path. If not set returns an empty string "".

isInitialized

public boolean isInitialized()
Is this catalog initialized.

makeStringDoubleMap

public Map makeStringDoubleMap(String propertyName, String def)
Parse a string of name(value) pairs into a map from the property list.
Parameters:
propertyName - The string to parse, e.g. "Bananas(50) Cocos(13.4)"
def - If the property is not found, use def as string to parse.
result For the example: {"Bananas" => Double(50), "Cocos" => Double(13.4)}

setResourcePath

protected void setResourcePath(String fileName)
Set the resource path from a fileName of a KnowledgeCatalog. If the resource path is already set, this method does nothing.
Parameters:
fileName - A relative path + filename (e.g. resources/evolution.prop). The directory separator is the one used in URL's and UNIX paths (a '/' thus).

split

public static List split(String delim, String str)
Split a given string in parts.

stripPathFromClassName

public static String stripPathFromClassName(String name)
Strip the path from a string representation of a class name. e.g. evolution.lands.Water => Water

stripPathFromClassName

public static String stripPathFromClassName(Class c)
Strip the path from the class name of this class.

stripPathFromClassName

public static String stripPathFromClassName(Object o)
Strip the path from the class name of this object.

Association Links

to Class java.util.Properties

Defines the behavior.

to Class java.net.URL

The url from where this catalog is loaded.

to Class java.lang.String

The resource path. This is stripped from the first filename used to load a KnowledgeCatalog.

a gvijf production