org.intermine.metadata
Class FieldDescriptor

java.lang.Object
  extended by org.intermine.metadata.FieldDescriptor
Direct Known Subclasses:
AttributeDescriptor, ReferenceDescriptor

public abstract class FieldDescriptor
extends java.lang.Object

Abstract representation of a field within a class - could be an attribute, an object reference or a collection.


Field Summary
protected  ClassDescriptor cld
           
static int M_N_RELATION
          A M:N relationship.
static int N_ONE_RELATION
          A N:1 relationship.
protected  java.lang.String name
           
static int NOT_RELATION
          Not a relationship between objects
static int ONE_N_RELATION
          A 1:N relationship.
static int ONE_ONE_RELATION
          A 1:1 relationship
 
Constructor Summary
FieldDescriptor(java.lang.String name)
          Construct, name of field must not be null and must be a valid Java variable name.
 
Method Summary
 ClassDescriptor getClassDescriptor()
          Get the ClassDescriptor for this field's class.
 java.lang.String getName()
          Get the name of the described field.
 boolean isAttribute()
          Is this FieldDescriptor an attribute?
 boolean isCollection()
          Is this FieldDescriptor a collection?
 boolean isReference()
          Is this FieldDescriptor a reference?
abstract  int relationType()
          Return an integer describing the type of relationship this field represents, where relationship types are 1:1, 1:N, N:1, M:N and "not a relationship".
protected  void setClassDescriptor(ClassDescriptor cld)
          Set the parent ClassDescriptor - should be called when this is added to a ClassDescriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_RELATION

public static final int NOT_RELATION
Not a relationship between objects

See Also:
Constant Field Values

ONE_ONE_RELATION

public static final int ONE_ONE_RELATION
A 1:1 relationship

See Also:
Constant Field Values

ONE_N_RELATION

public static final int ONE_N_RELATION
A 1:N relationship.

See Also:
Constant Field Values

N_ONE_RELATION

public static final int N_ONE_RELATION
A N:1 relationship.

See Also:
Constant Field Values

M_N_RELATION

public static final int M_N_RELATION
A M:N relationship.

See Also:
Constant Field Values

name

protected final java.lang.String name

cld

protected ClassDescriptor cld
Constructor Detail

FieldDescriptor

public FieldDescriptor(java.lang.String name)
Construct, name of field must not be null and must be a valid Java variable name.

Parameters:
name - name of field in class
Throws:
java.lang.IllegalArgumentException - if name argument is null
Method Detail

getClassDescriptor

public ClassDescriptor getClassDescriptor()
Get the ClassDescriptor for this field's class.

Returns:
a the ClassDescriptor for this field's class

getName

public java.lang.String getName()
Get the name of the described field.

Returns:
name of the field

setClassDescriptor

protected void setClassDescriptor(ClassDescriptor cld)
Set the parent ClassDescriptor - should be called when this is added to a ClassDescriptor. ClassDescriptor in this class is final so a MetadataException is thrown if method called again.

Parameters:
cld - the parent ClassDescriptor
Throws:
java.lang.IllegalStateException - if the parent ClassDescriptor is not set

relationType

public abstract int relationType()
Return an integer describing the type of relationship this field represents, where relationship types are 1:1, 1:N, N:1, M:N and "not a relationship".

Returns:
int to describe the relationship type

isAttribute

public boolean isAttribute()
Is this FieldDescriptor an attribute?

Returns:
true if this FieldDescriptor describes an attribute

isReference

public boolean isReference()
Is this FieldDescriptor a reference?

Returns:
true if this FieldDescriptor describes a reference

isCollection

public boolean isCollection()
Is this FieldDescriptor a collection?

Returns:
true if this FieldDescriptor describes a collection