net.jini.constraint
Class BasicMethodConstraints.MethodDesc

java.lang.Object
  extended by net.jini.constraint.BasicMethodConstraints.MethodDesc
All Implemented Interfaces:
Serializable
Enclosing class:
BasicMethodConstraints

public static final class BasicMethodConstraints.MethodDesc
extends Object
implements Serializable

Descriptor for specifying the constraints associated with one or more methods allowing limited wildcard matching on method names and parameter types. Methods can be specified by exact name and parameter types (matching a single method), by exact name (matching all methods with that name), by name prefix (matching all methods with names that start with that prefix), by name suffix (matching all methods with names that end with that suffix), and by a default that matches all methods.

Since:
2.0
See Also:
Serialized Form

Field Summary
(package private)  InvocationConstraints constraints
          The non-empty constraints for the specified method or methods, or null if there are no constraints.
(package private)  String name
          The name of the method, with prefix or suffix '*' permitted if types is null, or null for a descriptor that matches all methods (in which case types must also be null.
private static ObjectStreamField[] serialPersistentFields
           
private static long serialVersionUID
           
(package private)  Class[] types
          The formal parameter types of the method, in declared order, or null for wildcard parameter types.
 
Constructor Summary
BasicMethodConstraints.MethodDesc(InvocationConstraints constraints)
          Creates a default descriptor that matches all methods.
BasicMethodConstraints.MethodDesc(String name, Class[] types, InvocationConstraints constraints)
          Creates a descriptor that only matches methods with exactly the specified name and parameter types.
BasicMethodConstraints.MethodDesc(String name, InvocationConstraints constraints)
          Creates a descriptor that matches all methods with names that equal the specified name or that match the specified pattern, regardless of their parameter types.
 
Method Summary
private  void check()
          Verifies that the name is a syntactically valid method name, or (if types is null) if the name is a syntactically valid method name with a '*' appended or could be constructed from some syntactically valid method name containing more than two characters by replacing the first character of that name with '*', and verifies that none of the elements of types are null.
 boolean equals(Object obj)
          Two instances of this class are equal if they have the same name, the same parameter types, and the same constraints.
 InvocationConstraints getConstraints()
          Returns the constraints as a non-null value.
 String getName()
          Returns the name of the method, with a prefix or suffix '*' if the name is a pattern, or null if this descriptor matches all methods.
 Class[] getParameterTypes()
          Returns the parameter types, or null if this descriptor matches all parameter types or all methods.
 int hashCode()
          Returns a hash code value for this object.
private  void readObject(ObjectInputStream s)
          Verifies that the method name, parameter types, and constraints are valid.
 String toString()
          Returns a string representation of this object.
(package private)  void toString(StringBuffer buf, boolean includeConstraints)
          Appends a string representation of this object to the buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

serialPersistentFields

private static final ObjectStreamField[] serialPersistentFields

name

final String name
The name of the method, with prefix or suffix '*' permitted if types is null, or null for a descriptor that matches all methods (in which case types must also be null.


types

final Class[] types
The formal parameter types of the method, in declared order, or null for wildcard parameter types.


constraints

final InvocationConstraints constraints
The non-empty constraints for the specified method or methods, or null if there are no constraints.

Constructor Detail

BasicMethodConstraints.MethodDesc

public BasicMethodConstraints.MethodDesc(String name,
                                         Class[] types,
                                         InvocationConstraints constraints)
Creates a descriptor that only matches methods with exactly the specified name and parameter types. The constraints can be null, which is treated the same as an empty instance. The array passed to the constructor is neither modified nor retained; subsequent changes to that array have no effect on the instance created.

Parameters:
name - the name of the method
types - the formal parameter types of the method, in declared order
constraints - the constraints, or null
Throws:
NullPointerException - if name or types is null or any element of types is null
IllegalArgumentException - if name is not a syntactically valid method name

BasicMethodConstraints.MethodDesc

public BasicMethodConstraints.MethodDesc(String name,
                                         InvocationConstraints constraints)
Creates a descriptor that matches all methods with names that equal the specified name or that match the specified pattern, regardless of their parameter types. If the specified name starts with the character '*', then this descriptor matches all methods with names that end with the rest of the specified name. If the specified name ends with the character '*', then this descriptor matches all methods with names that start with the rest of the specified name. Otherwise, this descriptor matches all methods with names that equal the specified name. The constraints can be null, which is treated the same as an empty instance.

Parameters:
name - the name of the method, with a prefix or suffix '*' permitted for pattern matching
constraints - the constraints, or null
Throws:
NullPointerException - if name is null
IllegalArgumentException - if name does not match any syntactically valid method name

BasicMethodConstraints.MethodDesc

public BasicMethodConstraints.MethodDesc(InvocationConstraints constraints)
Creates a default descriptor that matches all methods. The constraints can be null, which is treated the same as an empty instance.

Parameters:
constraints - the constraints, or null
Method Detail

check

private void check()
Verifies that the name is a syntactically valid method name, or (if types is null) if the name is a syntactically valid method name with a '*' appended or could be constructed from some syntactically valid method name containing more than two characters by replacing the first character of that name with '*', and verifies that none of the elements of types are null.


getName

public String getName()
Returns the name of the method, with a prefix or suffix '*' if the name is a pattern, or null if this descriptor matches all methods.

Returns:
the name of the method, with a prefix or suffix '*' if the name is a pattern, or null if this descriptor matches all methods

getParameterTypes

public Class[] getParameterTypes()
Returns the parameter types, or null if this descriptor matches all parameter types or all methods. Returns a new non-null array every time it is called.

Returns:
the parameter types, or null if this descriptor matches all parameter types or all methods

getConstraints

public InvocationConstraints getConstraints()
Returns the constraints as a non-null value.

Returns:
the constraints as a non-null value

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Two instances of this class are equal if they have the same name, the same parameter types, and the same constraints.

Overrides:
equals in class Object

toString

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

Overrides:
toString in class Object

toString

void toString(StringBuffer buf,
              boolean includeConstraints)
Appends a string representation of this object to the buffer.


readObject

private void readObject(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
Verifies that the method name, parameter types, and constraints are valid.

Throws:
InvalidObjectException - if types is non-null and name is either null or is not a syntactically valid method name; or if types is null and name is neither a syntactically valid method name, a syntactically valid method name with a '*' appended, nor a name constructed from some syntactically valid method name containing more than two characters by replacing the first character of that name with '*'; or if any element of types is null; or if constraints is non-null but empty
IOException
ClassNotFoundException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.