de.hunsicker.jalopy.language
Class MethodType

java.lang.Object
  |
  +--de.hunsicker.jalopy.language.MethodType
All Implemented Interfaces:
java.lang.Comparable, Type

public class MethodType
extends java.lang.Object
implements java.lang.Comparable, Type

Represents a method type to distinguish between ordinary method names and those which adhere to the Java Bean naming conventions.

The default order for comparing is: ordinary Java method names, mutator, accessor/tester. This can be changed via setOrder(java.lang.String).

Version:
$Revision: 1.2.2.1 $
Author:
Marco Hunsicker

Field Summary
static MethodType GETTER
          Represents a Java Bean accessor.
static MethodType OTHER
          Represents an ordinary Java method.
static MethodType SETTER
          Represents a Java Bean mutator.
static MethodType TESTER
          Represents a Java Bean accessor/tester.
 
Method Summary
 int compareTo(java.lang.Object other)
          Compares this object with the specified object for order.
static java.lang.String getOrder()
          Returns a string representation of the current sort order.
 boolean isBean()
          Indicates whether this type represents a Java Bean method.
static void setOrder(java.lang.String str)
          Sets the order to use as the natural order.
 java.lang.String toString()
          Returns a string representation of this method type.
static MethodType valueOf(java.lang.String name)
          Returns the method type of the given method name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GETTER

public static final MethodType GETTER
Represents a Java Bean accessor.


SETTER

public static final MethodType SETTER
Represents a Java Bean mutator.


TESTER

public static final MethodType TESTER
Represents a Java Bean accessor/tester.


OTHER

public static final MethodType OTHER
Represents an ordinary Java method.

Method Detail

setOrder

public static void setOrder(java.lang.String str)
Sets the order to use as the natural order.

Parameters:
str - a string representing the new order. The string must consist of exactly four different, comma delimited strings which represents a method type (e.g. isFoo,getFoo,setFoo,foo)
Throws:
java.lang.IllegalArgumentException - if the given string is invalid.

getOrder

public static java.lang.String getOrder()
Returns a string representation of the current sort order. To encode the different method types, the common foo abreviation is used:
      
isFoo,getFoo,setFoo,foo or foo,getFoo,isFoo,setFoo or ...

Returns:
a string representation of the current sort order.

compareTo

public int compareTo(java.lang.Object other)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - the object to be compared.
Returns:
DOCUMENT ME!
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this object.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this type.

valueOf

public static MethodType valueOf(java.lang.String name)
Returns the method type of the given method name.

Parameters:
name - a method name.
Returns:
the method type of the given name.
Throws:
java.lang.IllegalArgumentException - if no valid method name is given.

isBean

public boolean isBean()
Indicates whether this type represents a Java Bean method.

Returns:
true if this method type adheres to the Java Bean naming conventions.


Copyright © 1997-2005 Jalopy. All Rights Reserved.