codesimian
Class JavaType

java.lang.Object
  extended by codesimian.CS
      extended by codesimian.DefaultCS
          extended by codesimian.JavaType
All Implemented Interfaces:
CodeSimian, java.io.Serializable
Direct Known Subclasses:
JavaTypeConst

public class JavaType
extends DefaultCS

A fuzzy-type (thats not actually fuzzy) that determines this boolean:
if param0's Java Object is a certain Java type (or subtype).

The Java Class type is a java.lang.Class object accessed through getObject() and setObject(Object).

Exec() returns 1.0 if param0.getObject() is that Class type or a subtype of it, else returns -1.

There can be 1 or 2 params. getObject() is used when countP()==1 (param0), but if theres a second param (param1), it's Object's type is used instead of the Class object in my Object.
It would return 1 if param0 can be cast to param1.

if 1 param: fromGetObject fgo = (getObject() returns a Class object) param0;
if 2 params: param1 p1 = (param1) param0;

setP() and P() copy the Objects from getObject() to and from this CS and its param1. Param1 is optional and is an easy way to get and set the java-type.

It does not actually cast it. It returns 1 if it could be cast, and -1 if it can not. A type can always be cast to itsself. This is a way to compare java-types of Objects in CSs.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class codesimian.CS
DESCRIPTION, END, EXECPROXY, FUEL, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER
 
Constructor Summary
JavaType()
          the default type is CS.class
JavaType(java.lang.Class type)
          You should probably use this constructor so you can specify a type, or use the other constructor and (optionally) do it later
 
Method Summary
 java.lang.String description()
          a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for.
 double DForProxy()
          returns 1 (else -1) if param0 can be cast to (or is) one of these java-types:
the Class object returned by my getObject(), or
the java-type of param1.getObject().
Returns 0 if ClassCastException from (Class) getObject().
 java.lang.String keyword()
          For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
 int maxP()
          Maximum quantity of Params
 int minP()
          For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.
 CS P(int index)
          WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP().
 boolean setObject(java.lang.Object classType)
          If classType's type is java.lang.Class, then the fuzzy-type this JavaType recognizes is CSs whose getObject() returns an object with that Class type.
If classType's type is not java.lang.Class, then sets the object to classType.getClass() instead.
 boolean setP(int index, CS setTo)
          Every CS is a list of other CSs, between size minP() and maxP() inclusive.
 
Methods inherited from class codesimian.DefaultCS
B, C, countP, decrementMyFuel, deleteP, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertP, insertS, insertZ, J, javaCode, LForProxy, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, prevD, prevL, PType, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setPrevExec, setS, setZ, start, toString, V, Z
 
Methods inherited from class codesimian.CS
addP, addP, addP, addP, addP, BForProxy, CForProxy, clone, cost, D, deleteP, FForProxy, IForProxy, isIllusion, javaCode, JForProxy, L, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, setB, setC, setCost, setDescription, setF, setHeap, setI, setJ, setL, setL, setParent, setParsePriority, setProxyOf, setPType, setS, setTester, setZ, SForProxy, tester, VForProxy, voidReflect, ZForProxy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaType

public JavaType(java.lang.Class type)
You should probably use this constructor so you can specify a type, or use the other constructor and (optionally) do it later


JavaType

public JavaType()
the default type is CS.class

Method Detail

DForProxy

public double DForProxy()
returns 1 (else -1) if param0 can be cast to (or is) one of these java-types:
the Class object returned by my getObject(), or
the java-type of param1.getObject().
Returns 0 if ClassCastException from (Class) getObject().

Specified by:
DForProxy in class DefaultCS

minP

public int minP()
Description copied from class: DefaultCS
For DForProxy().
Minimum number of parameters in param[] needed to call DForProxy().
Defines which indexs of param[] DForProxy() can use.
Functions with a different number of parameters must override this.
OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS.
Default is 1.

Overrides:
minP in class DefaultCS

maxP

public int maxP()
Description copied from class: CS
Maximum quantity of Params

Overrides:
maxP in class CS

keyword

public java.lang.String keyword()
Description copied from class: DefaultCS
For the CodeSimian language as a String.
CodeSimian language keyword, like "+" "*" "max" ">" etc.

Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add.

Some CSs might never be intended to be used in the language by their keyword.
The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()".
Default: Returns class name, minus package name (and its dots), and change the first letter to lowercase.

For example, CS.MaxParams does not override keyword(), which returns "maxP".

Overrides:
keyword in class DefaultCS
See Also:
CS.parent(), CS.newInstance(), CS.name()

description

public java.lang.String description()
Description copied from class: CS
a short description of this CS, shorter than the javadoc, but long enough to tell what the params are for. Example use: in automatically generated webpages for CodeSimian. Example: "returns sum of all params" for Add.

Overrides:
description in class DefaultCS

setObject

public boolean setObject(java.lang.Object classType)
If classType's type is java.lang.Class, then the fuzzy-type this JavaType recognizes is CSs whose getObject() returns an object with that Class type.
If classType's type is not java.lang.Class, then sets the object to classType.getClass() instead.

Overrides:
setObject in class DefaultCS
See Also:
anyObject

setP

public boolean setP(int index,
                    CS setTo)
Description copied from class: CS
Every CS is a list of other CSs, between size minP() and maxP() inclusive. setP overwrites one of those CSs or adds a new one at the end, depending on the index. If index is between 0 and countP()-1, overwrites. If it equals countP(), adds at end.

Overrides:
setP in class DefaultCS

P

public CS P(int index)
Description copied from class: DefaultCS
WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP().

Overrides:
P in class DefaultCS
Parameters:
index - range 0 to countP()-1 inclusive
See Also:
CS.heap()