codesimian
Class CSFactory

java.lang.Object
  extended by codesimian.CSFactory

public class CSFactory
extends java.lang.Object

Contains all the standard subclasses of CS. CSs might change their index (dont know why they would, but be ready for it).

CSFactory should eventually be replaced by CS.newInstance() and some new function in CS to contain or list the types of CS available to instantiate.

CSFactory needs to become a subclass of NothingList. It should be a list of default code objects. Call newInstance() on those code objects to create a new object of that type.


Field Summary
static java.lang.Class[] classes
           
static java.util.Map classToString
          error: can have more keyword() Strings than CLASSES!!!
static CSFactory defaultFactory
          The default CSFactory.
static java.lang.String[] name
           
static java.util.Map stringToClass
          big-O(1) time to get Class from CS String, or the reverse.
static java.util.Map<java.lang.String,CS> stringToCS
          Key is the String returned by the CS's keyword().
static CS[] trees
           
 
Constructor Summary
CSFactory()
           
 
Method Summary
static void add(CS newClass)
          Adds a new subclass of CS that can be instantiated by newCS().
static void addDefaultClasses()
           
static int classCount()
           
static java.lang.Class CSClass(java.lang.String CSName)
           
static java.lang.String CSName(java.lang.Class CSClass)
          error: can have more keyword() Strings than CLASSES!!!
static CS hardCodedNewInstance(java.lang.String instanceOfWhat)
          Deprecated.  
static void init()
           
static CS newCS(int index)
          returns a new instance of a subclass of CS index is the order the class was added
static CS newInstance(java.lang.String instanceOfWhat)
          Returns a new instance of the type of CS with specified CS.keyword(): instanceOfWhat.
static boolean newInstanceWouldWork(java.lang.String instanceOfWhat)
          Returns true if newInstance(instanceOfWhat) would return what you asked for, instead of an Err (unless you asked for an Err).
static CSFactory popFactory()
          Pops a CSFactory off the stack and returns it.
static void pushFactory(CSFactory pushMe)
          Pushes pushMe onto the CSFactory stack
 int stackSize()
           
static CSFactory topFactory()
          Returns the top CSFactory or null if none are on the stack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

trees

public static CS[] trees

classes

public static java.lang.Class[] classes

name

public static java.lang.String[] name

stringToClass

public static java.util.Map stringToClass
big-O(1) time to get Class from CS String, or the reverse. Example keys of stringToClass (CS Strings): "add" "divide" "sin" stringToClass.get("add") returns a Class Object. Call newInstance() on the class to get the CS.


stringToCS

public static java.util.Map<java.lang.String,CS> stringToCS
Key is the String returned by the CS's keyword(). Value is that CS.

This should eventually replace stringToClass because each instance of that class might have multiple Strings returned from keyword().

Example: Layout contains any type of LayoutManager, therefore needs a different name for each.


classToString

public static java.util.Map classToString
error: can have more keyword() Strings than CLASSES!!!


defaultFactory

public static CSFactory defaultFactory
The default CSFactory. Contains many default CSs.

Constructor Detail

CSFactory

public CSFactory()
Method Detail

newInstance

public static CS newInstance(java.lang.String instanceOfWhat)
Returns a new instance of the type of CS with specified CS.keyword(): instanceOfWhat. Calls newInstance() on one of the CSs that was added with add(CS).


hardCodedNewInstance

public static final CS hardCodedNewInstance(java.lang.String instanceOfWhat)
Deprecated. 

Try to avoid using this function because all instantiations should instead be based on DYNAMIC names. This is a hack. For lack of a better way to do it right now, I've hard-coded the reflected symbols in CodeSimian language, including these symbols: # ( ) ;# ;( ;) ;;# ;;( ;;) ;;;#...
Those symbols are hard to include in CSFactory the normal way because each symbol varies its keyword() (has more or less ;s) by the value of that object at the time.

Returns:
a new instance of some CS, or null if none exists with that name

newInstanceWouldWork

public static boolean newInstanceWouldWork(java.lang.String instanceOfWhat)
Returns true if newInstance(instanceOfWhat) would return what you asked for, instead of an Err (unless you asked for an Err).


addDefaultClasses

public static void addDefaultClasses()

topFactory

public static CSFactory topFactory()
Returns the top CSFactory or null if none are on the stack


pushFactory

public static void pushFactory(CSFactory pushMe)
Pushes pushMe onto the CSFactory stack


stackSize

public int stackSize()

popFactory

public static CSFactory popFactory()
Pops a CSFactory off the stack and returns it. Returns null if the stack is empty.


CSClass

public static final java.lang.Class CSClass(java.lang.String CSName)

CSName

public static final java.lang.String CSName(java.lang.Class CSClass)
error: can have more keyword() Strings than CLASSES!!!


classCount

public static final int classCount()

init

public static void init()

newCS

public static CS newCS(int index)
returns a new instance of a subclass of CS index is the order the class was added


add

public static void add(CS newClass)
Adds a new subclass of CS that can be instantiated by newCS(). If newClass or CSName already exists in CSFactory, neither will be added. Name is the command used to convert a string to a tree of CSs. Name can not contain: whitespace ( ) # $