org.melati.poem
Class Field

Package class diagram package Field
java.lang.Object
  extended by org.melati.poem.Field
All Implemented Interfaces:
Cloneable, FieldAttributes

public class Field
extends Object
implements FieldAttributes, Cloneable

A Field. A field is a value (the raw) with its metadata (a set of attributes) and possibly an access violation if the current user is not allowed to access it.


Constructor Summary
Field(AccessPoemException accessException, FieldAttributes attrs)
          Constructor for a Field with an access violation.
Field(Object raw, FieldAttributes attrs)
          Constructor.
 
Method Summary
static Field basic(Object value, String name, PoemType type)
          A convenience method to create a Field.
 Object clone()
          
 void dump(PrintStream p)
          Dump to a PrintStream.
 Object getCooked()
           
 String getCookedString()
           
 String getCookedString(PoemLocale locale, int style)
           
 String getDescription()
          
 String getDisplayName()
          
 Enumeration getFirst1000Possibilities()
          Return a limited enumeration of possibilities.
 int getHeight()
          
 boolean getIndexed()
          
 String getName()
          
 Enumeration getPossibilities()
          Might be a bit big for some Reference types.
 Object getRaw()
          Get the value of the Field.
 Object getRawString()
          Get the value as a String.
 String getRenderInfo()
          
 PoemType getType()
          
 boolean getUserCreateable()
          
 boolean getUserEditable()
          
 int getWidth()
          
static Field integer(Integer value, String name)
          A convenience method to create nullable Integer Field.
static Field reference(Persistent value, String name)
          A convenience method to create a populated, nullable, Reference Field.
static Field reference(Table table, String name)
          A convenience method to create new unpopulated, nullable Reference Field.
 boolean sameRawAs(Field other)
          Compare raws.
static Field string(String value, String name)
          A convenience method to create nullable String Field.
 String toString()
          Dump to a string.
 Field withDescription(String description)
          Clone with a new description.
 Field withName(String name)
          Clone with a new name.
 Field withNullable(boolean nullable)
          Clone with a different nullability.
 Field withRaw(Object rawP)
          Clone this Field with a new value but same metadata.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Field

public Field(Object raw,
             FieldAttributes attrs)
Constructor.

Parameters:
raw - the object value, integer for reference types
attrs - the metadata attributes to set

Field

public Field(AccessPoemException accessException,
             FieldAttributes attrs)
Constructor for a Field with an access violation.

Parameters:
accessException - the access violation
attrs - the metadata attributes to set
Method Detail

clone

public Object clone()

Overrides:
clone in class Object
See Also:
Object.clone()

getName

public String getName()

Specified by:
getName in interface FieldAttributes
Returns:
the machine name of the field
See Also:
FieldAttributes.getName()

getDisplayName

public String getDisplayName()

Specified by:
getDisplayName in interface FieldAttributes
Returns:
the human readable name of the field
See Also:
FieldAttributes.getDisplayName()

getDescription

public String getDescription()

Specified by:
getDescription in interface FieldAttributes
Returns:
the longer description of the field
See Also:
FieldAttributes.getDescription()

getType

public PoemType getType()

Specified by:
getType in interface FieldAttributes
Returns:
the PoemType of the field
See Also:
FieldAttributes.getType()

getIndexed

public boolean getIndexed()

Specified by:
getIndexed in interface FieldAttributes
Returns:
whether the field is indexed
See Also:
FieldAttributes.getIndexed()

getUserEditable

public boolean getUserEditable()

Specified by:
getUserEditable in interface FieldAttributes
Returns:
whether a user may change the field value
See Also:
FieldAttributes.getUserEditable()

getUserCreateable

public boolean getUserCreateable()

Specified by:
getUserCreateable in interface FieldAttributes
Returns:
whether a user may create a field
See Also:
FieldAttributes.getUserCreateable()

getWidth

public int getWidth()

Specified by:
getWidth in interface FieldAttributes
Returns:
the width of widget required to display this field
See Also:
FieldAttributes.getWidth()

getHeight

public int getHeight()

Specified by:
getHeight in interface FieldAttributes
Returns:
the height of widget to display this field
See Also:
FieldAttributes.getHeight()

getRenderInfo

public String getRenderInfo()

Specified by:
getRenderInfo in interface FieldAttributes
Returns:
the name of a special widget templet to display this field
See Also:
FieldAttributes.getRenderInfo()

getRaw

public final Object getRaw()
                    throws AccessPoemException
Get the value of the Field.

Returns:
the Object value, Integer for reference types
Throws:
AccessPoemException

getRawString

public final Object getRawString()
                          throws AccessPoemException
Get the value as a String.

Returns:
the String representation of this Field.
Throws:
AccessPoemException - if the current AccessToken does not permit reading

getCooked

public final Object getCooked()
                       throws AccessPoemException
Returns:
the object represented by the raw
Throws:
AccessPoemException - if the current AccessToken does not permit reading

getCookedString

public final String getCookedString()
                             throws AccessPoemException
Returns:
cooked value as a String with defaulted Locale and DateFormat
Throws:
AccessPoemException

getCookedString

public final String getCookedString(PoemLocale locale,
                                    int style)
                             throws AccessPoemException
Parameters:
locale -
style -
Returns:
a String representation of the Object represented by the raw
Throws:
AccessPoemException - if the current AccessToken does not permit reading

withRaw

public Field withRaw(Object rawP)
Clone this Field with a new value but same metadata.

Parameters:
rawP - new value to set
Returns:
a clone with the raw value set to new value

withNullable

public Field withNullable(boolean nullable)
Clone with a different nullability.

Parameters:
nullable - the new nullability
Returns:
a new Field with a new, presumably different, nullability

withName

public Field withName(String name)
Clone with a new name.

Parameters:
name - the new name
Returns:
a new Field with a new name

withDescription

public Field withDescription(String description)
Clone with a new description.

Parameters:
description - the new description
Returns:
a new Field with a new description

getPossibilities

public Enumeration getPossibilities()
Might be a bit big for some Reference types. Returns null for String or Integer Types.

Returns:
All possible values or null.

getFirst1000Possibilities

public Enumeration getFirst1000Possibilities()
Return a limited enumeration of possibilities. A bit of a hack?

Returns:
the first 100 possibilities or null

sameRawAs

public boolean sameRawAs(Field other)
                  throws AccessPoemException
Compare raws.

Parameters:
other - another field to check
Returns:
whether the other field has the same raw value as this one
Throws:
AccessPoemException - if it is already set

dump

public void dump(PrintStream p)
Dump to a PrintStream.

Parameters:
p - the PRintStream to write to

toString

public String toString()
Dump to a string.

Overrides:
toString in class Object
See Also:
Object.toString()

basic

public static Field basic(Object value,
                          String name,
                          PoemType type)
A convenience method to create a Field.

Parameters:
value - the Object to set the value to
name - the name of the new Field, also used as description
type - the PoemType of the Field
Returns:
a newly created Field

string

public static Field string(String value,
                           String name)
A convenience method to create nullable String Field.

Parameters:
value - the String to set the value to
name - the name of the new Field, also used as description
Returns:
a newly created nullable Field of type StringPoemType

integer

public static Field integer(Integer value,
                            String name)
A convenience method to create nullable Integer Field.

Parameters:
value - the Integer to set the value to
name - the name of the new Field, also used as description
Returns:
a newly created nullable Field of type IntegerPoemType

reference

public static Field reference(Persistent value,
                              String name)
A convenience method to create a populated, nullable, Reference Field.

Parameters:
value - the Persistent to set the value to
name - the name of the new Field, also used as description
Returns:
a newly created nullable Field of type ReferencePoemType

reference

public static Field reference(Table table,
                              String name)
A convenience method to create new unpopulated, nullable Reference Field.

Parameters:
table - the Table to refer to
name - the name of the new Field, also used as description
Returns:
a newly created nullable Field of type ReferencePoemType


Copyright © 2000-2010 PanEris. All Rights Reserved.