kawigi.template
Class MethodInfo

java.lang.Object
  |
  +--kawigi.template.MethodInfo
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class MethodInfo
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Represents a tag in a tag library. The typical format of this object is that it is composed of a name (which should be absolutely unique), calling code which gets inserted where the tag is placed, and method code that gets inserted later, outside of the primary method. In some cases the method code is inherited, or a MethodInfo object may not even literally represent a method call. In these cases, the method code should be an empty array. This class is bean compliant :-)

See Also:
Serialized Form

Field Summary
protected  java.lang.String[] callingCode
          A template for the code inserted where this tag is invoked.
protected  java.lang.String[] methodCode
          The code of the method being called.
protected  java.lang.String methodName
          The unique name of the tag associated with this object.
 
Constructor Summary
MethodInfo()
          Creates a new instance of MethodInfo with null fields.
MethodInfo(java.lang.String methodName, java.lang.String[] methodCode, java.lang.String[] callingCode)
          Constructs a new MethodInfo with the given name, method code, and calling code.
 
Method Summary
 int compareTo(java.lang.Object o)
          Returns whether this MethodInfo is greater than, equal to, or less than another object, by comparing method names lexically.
 boolean equals(java.lang.Object o)
          Returns true if o is a MethodInfo with the same name as this object.
 java.lang.String[] getCallingCode(java.lang.String[] params)
          Translates the callingCode template to use the parameter list given.
 java.lang.String[] getCallingCodeTemplate()
          Accessor for callingCode.
 java.lang.String[] getMethodCode()
          Accessor for methodCode.
 java.lang.String getMethodName()
          Accessor for methodName.
 int hashCode()
          Returns a hash code appropriate for hashing this object, so that it can be stored dependably in a HashSet or used as a key in a HashMap.
static kawigi.template.MethodInfo read(java.io.BufferedReader in)
          Reads this MethodInfo from a stream.
 void setCallingCodeTemplate(java.lang.String[] code)
          Mutator for callingCode.
 void setMethodCode(java.lang.String[] code)
          Mutator for methodCode.
 void setMethodName(java.lang.String name)
          Mutator for methodName.
 java.lang.String toString()
          Returns a string representation of this object.
 void write(java.io.PrintWriter out)
          Writes this MethodInfo to a stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

methodName

protected java.lang.String methodName
The unique name of the tag associated with this object. Usually it will be the name of the method implemented, if this tag represents a method.


methodCode

protected java.lang.String[] methodCode
The code of the method being called. For library tags that actually represent a method call, this is where the method is defined, with one element in the array for each "line" of code.


callingCode

protected java.lang.String[] callingCode
A template for the code inserted where this tag is invoked. If this tag represents a fairly simple method call, it will probably be of the format:
		methodName($1,$2,$3);
	
There should be one element in the array for each "line" of code that should be inserted (in the above example, there is only one line).

Constructor Detail

MethodInfo

public MethodInfo(java.lang.String methodName,
                  java.lang.String[] methodCode,
                  java.lang.String[] callingCode)
Constructs a new MethodInfo with the given name, method code, and calling code.


MethodInfo

public MethodInfo()
Creates a new instance of MethodInfo with null fields.

Method Detail

getCallingCode

public java.lang.String[] getCallingCode(java.lang.String[] params)
Translates the callingCode template to use the parameter list given. All it does is replace $1 with the first parameter, $2 with the second, etc. It would actually make a good div-2 easy problem some day :-)


getCallingCodeTemplate

public java.lang.String[] getCallingCodeTemplate()
Accessor for callingCode.


setCallingCodeTemplate

public void setCallingCodeTemplate(java.lang.String[] code)
Mutator for callingCode.


getMethodCode

public java.lang.String[] getMethodCode()
Accessor for methodCode.


setMethodCode

public void setMethodCode(java.lang.String[] code)
Mutator for methodCode.


getMethodName

public java.lang.String getMethodName()
Accessor for methodName.


setMethodName

public void setMethodName(java.lang.String name)
Mutator for methodName.


hashCode

public int hashCode()
Returns a hash code appropriate for hashing this object, so that it can be stored dependably in a HashSet or used as a key in a HashMap.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Returns true if o is a MethodInfo with the same name as this object.

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Returns whether this MethodInfo is greater than, equal to, or less than another object, by comparing method names lexically.

Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object

write

public void write(java.io.PrintWriter out)
Writes this MethodInfo to a stream.


read

public static kawigi.template.MethodInfo read(java.io.BufferedReader in)
Reads this MethodInfo from a stream.