com.lonniepryor.blues.util
Class Fields

java.lang.Object
  |
  +--com.lonniepryor.blues.util.Fields

public abstract class Fields
extends java.lang.Object

Specification interface for identifying Fields. Instances of this class may be logically combined using the AND, OR, and NOT operations. Many common use-cases are supplied via static accessor methods.

Version:
$Revision: 1.1 $
Author:
Lonnie Pryor

Constructor Summary
protected Fields()
          Creates a new Fields object.
 
Method Summary
 Fields and(Fields specification)
          Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.
static Fields declaredFinal()
          Returns a specification matching final fields.
static Fields declaredOn(Types specification)
          Creates a new specification satisfied only by Fields declared on the Types that satisfy the supplied specification.
static Fields declaredPackageProtected()
          Returns a specification matching package protected fields.
static Fields declaredPrivate()
          Returns a specification matching private fields.
static Fields declaredProtected()
          Returns a specification matching protected fields.
static Fields declaredPublic()
          Returns a specification matching public fields.
static Fields declaredStatic()
          Returns a specification matching static fields.
static Fields declaredTransient()
          Returns a specification matching transient fields.
static Fields declaredVolatile()
          Returns a specification matching volatile fields.
static Fields equalTo(java.lang.reflect.Field toTest)
          Creates a new specification satisfied by Fields equal to the supplied Field.
abstract  boolean evaluate(java.lang.reflect.Field field)
          Returns true if the supplied Field satisfies this specification.
 boolean isSatisfiedBy(java.lang.reflect.Field field)
          Returns true if the supplied Field is not null and satisfies this specification.
 boolean isSatisifiedByAll(java.lang.reflect.Field[] all)
          Returns true if all of the supplied Fields satisfy this specification.
 boolean isSatisifiedByAny(java.lang.reflect.Field[] any)
          Returns true if any of the supplied Fields satisfy this specification.
static Fields named(java.lang.String namePattern)
          Creates a new specification satisfied by Fields whose names match the supplied pattern.
static Fields named(Strings specification)
          Creates a new specification satisfied by Fields whose names match the supplied specification.
 Fields not()
          Returns a specification representing a logical NOT of this specification.
static Fields ofType(Types specification)
          Creates a new specification satisfied by Fields whose type satisfy the supplied specification.
 Fields or(Fields specification)
          Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.
static Fields parse(java.lang.String fieldsPattern)
          Parses a pattern string into a complete Fields specification.
 java.lang.reflect.Field[] selectAll(java.lang.reflect.Field[] from)
          Selects all the Fields that satisfy this specification from the supplied array.
 java.lang.reflect.Field selectFirst(java.lang.reflect.Field[] from)
          Selects the first Field that satisfies this specification from the supplied array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fields

protected Fields()
Creates a new Fields object.

Method Detail

declaredPublic

public static Fields declaredPublic()
Returns a specification matching public fields.

Returns:
A specification matching public fields.

declaredProtected

public static Fields declaredProtected()
Returns a specification matching protected fields.

Returns:
A specification matching protected fields.

declaredPrivate

public static Fields declaredPrivate()
Returns a specification matching private fields.

Returns:
A specification matching private fields.

declaredPackageProtected

public static Fields declaredPackageProtected()
Returns a specification matching package protected fields.

Returns:
A specification matching package protected fields.

declaredFinal

public static Fields declaredFinal()
Returns a specification matching final fields.

Returns:
A specification matching final fields.

declaredStatic

public static Fields declaredStatic()
Returns a specification matching static fields.

Returns:
A specification matching static fields.

declaredTransient

public static Fields declaredTransient()
Returns a specification matching transient fields.

Returns:
A specification matching transient fields.

declaredVolatile

public static Fields declaredVolatile()
Returns a specification matching volatile fields.

Returns:
A specification matching volatile fields.

equalTo

public static Fields equalTo(java.lang.reflect.Field toTest)
Creates a new specification satisfied by Fields equal to the supplied Field.

Parameters:
toTest - The Field to be equal to.
Returns:
A new specification satisfied by Fields equal to the supplied Field.

declaredOn

public static Fields declaredOn(Types specification)
Creates a new specification satisfied only by Fields declared on the Types that satisfy the supplied specification.

Parameters:
specification - The specification that Types must match.
Returns:
A new specification satisfied only by Fields declared on the Types that satisfy the supplied specification.

named

public static Fields named(java.lang.String namePattern)
Creates a new specification satisfied by Fields whose names match the supplied pattern.

Parameters:
namePattern - The pattern names must match.
Returns:
A new specification satisfied by Fields whose names match the supplied pattern.
Throws:
ParseException - if the name pattern is invalid.

named

public static Fields named(Strings specification)
Creates a new specification satisfied by Fields whose names match the supplied specification.

Parameters:
specification - The specification names must match.
Returns:
A new specification satisfied by Fields whose names match the supplied specification.

ofType

public static Fields ofType(Types specification)
Creates a new specification satisfied by Fields whose type satisfy the supplied specification.

Parameters:
specification - The specification types must match.
Returns:
A new specification satisfied by Fields whose type satisfy the supplied specification.

parse

public static Fields parse(java.lang.String fieldsPattern)
Parses a pattern string into a complete Fields specification. Format:
   fields      ::=   name
   name        ::=  [ field-type ] [ types | "(" types-expr ")" "." ]
                            ( strings | "(" strings-expr ")" )
   field-type  ::=  [ modifiers ] ( types | "(" types-expr ")" )
   modifiers   ::=  ( [ "!" ]
                      ( "public" | "protected" | "package" | "private"
                        | "static" | "abstract" | "final" ) )...
 
Example:
   (int | float) com.lonniepryor..*.foo
 
The above matches any int or float field named 'foo', declared on any class in the 'com.lonniepryor' namespace.

Parameters:
fieldsPattern - The pattern definition string.
Returns:
A specification matching the pattern.
Throws:
ParseException - if the pattern is invalid.

isSatisfiedBy

public final boolean isSatisfiedBy(java.lang.reflect.Field field)
Returns true if the supplied Field is not null and satisfies this specification.

Parameters:
field - The Field to test.
Returns:
True if the supplied Field is not null and satisfies this specification.

evaluate

public abstract boolean evaluate(java.lang.reflect.Field field)
Returns true if the supplied Field satisfies this specification.

Returns:
True if the supplied Field satisfies this specification.

isSatisifiedByAll

public final boolean isSatisifiedByAll(java.lang.reflect.Field[] all)
Returns true if all of the supplied Fields satisfy this specification.

Parameters:
all - The array of Fields to test.
Returns:
True if all of the supplied Fields satisfy this specification.

isSatisifiedByAny

public final boolean isSatisifiedByAny(java.lang.reflect.Field[] any)
Returns true if any of the supplied Fields satisfy this specification.

Parameters:
any - The array of Fields to test.
Returns:
True if any of the supplied Fields satisfy this specification.

selectFirst

public final java.lang.reflect.Field selectFirst(java.lang.reflect.Field[] from)
Selects the first Field that satisfies this specification from the supplied array.

Parameters:
from - The array to select from.
Returns:
The first Field that satisfies this specification from the supplied array.

selectAll

public final java.lang.reflect.Field[] selectAll(java.lang.reflect.Field[] from)
Selects all the Fields that satisfy this specification from the supplied array.

Parameters:
from - The array to select from.
Returns:
All the Fields that satisfy this specification from the supplied array.

and

public final Fields and(Fields specification)
Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.

Parameters:
specification - The specification to AND with.
Returns:
A specification representing a logical AND of this specification on the left and the supplied specification on the right.

or

public final Fields or(Fields specification)
Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.

Parameters:
specification - The specification to OR with.
Returns:
A specification representing a logical OR of this specification on the left and the supplied specification on the right.

not

public final Fields not()
Returns a specification representing a logical NOT of this specification.

Returns:
A specification representing a logical NOT of this specification.


Copyright © 2003 Blues Framework. All Rights Reserved.