com.cometway.props
Class PropsSchema

java.lang.Object
  extended by com.cometway.props.PropsSchema

public class PropsSchema
extends java.lang.Object

This class contains static methods for parsing a Props Schema into a Vector of Props.


Field Summary
protected static int DEFAULT_SIZE
           
protected static java.lang.String EOL
           
protected  java.util.List schema
           
 
Constructor Summary
PropsSchema()
          Constructs an empty schema.
PropsSchema(java.util.List l)
          Constructs a schema based on the specified List containing Props.
PropsSchema(java.lang.String s)
          Constructs a schema containing the parsed Props from the string.
 
Method Summary
 void add(Props p)
          Adds the specified Props to the schema.
 Props addBoolean(java.lang.String label, java.lang.String key)
          Adds a boolean type to the schema.
 Props addButton(java.lang.String key, java.lang.String title, java.lang.String description)
          Adds a button type to the schema.
 Props addCaption(java.lang.String caption)
          Adds a caption type to the schema.
 Props addChoice(java.lang.String label, java.lang.String key, java.lang.String options)
          Adds a choice type to the schema.
 Props addInteger(java.lang.String label, java.lang.String key)
          Adds an integer type to the schema.
 Props addSpace()
          Adds a space type to the schema.
 Props addString(java.lang.String label, java.lang.String key)
          Adds a string type to the schema.
 Props addString(java.lang.String label, java.lang.String key, int lines)
          Adds a string type to the schema.
 Props getFieldSchema(java.lang.String key)
          Returns the schema for the specified field.
 java.util.List getListSchema()
          Returns a list of schema types that contain a list:true; property.
 java.lang.String getPrimaryKey()
          Returns the name of the key that contains a primary:true; property.
 java.util.List getSchema()
          Return a list of Props that define the schema.
static java.util.List parse(java.lang.String schema)
          Parses the formatted schema string and returns it as a List of Props.
 void setSchema(java.lang.String s)
          Uses a schema containing the parsed Props from the string.
 java.lang.String toString()
          Returns the schema as a parseable string.
static java.lang.String toString(java.util.List schema)
          Returns the specified List of Props as a formatted schema string.
 void writeForm(HTMLFormWriter w)
          Writes the schema using the specified HTMLFormWriter.
 void writeForm(HTMLFormWriter w, Props p)
          Writes the schema using the specified HTMLFormWriter and Props values.
 void writeForm(HTMLFormWriter w, Props p, int defaultSize)
          Writes the schema using the specified HTMLFormWriter and Props values.
 void writeFormElement(HTMLFormWriter w, Props fieldProps, Props p, int defaultSize)
          Writes the schema element using the specified HTMLFormWriter and Props values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EOL

protected static final java.lang.String EOL

DEFAULT_SIZE

protected static final int DEFAULT_SIZE
See Also:
Constant Field Values

schema

protected java.util.List schema
Constructor Detail

PropsSchema

public PropsSchema()
Constructs an empty schema. Use the add methods to fill in this schema.


PropsSchema

public PropsSchema(java.util.List l)
Constructs a schema based on the specified List containing Props.


PropsSchema

public PropsSchema(java.lang.String s)
            throws PropsException
Constructs a schema containing the parsed Props from the string.

Throws:
PropsException
Method Detail

add

public void add(Props p)
Adds the specified Props to the schema.


addBoolean

public Props addBoolean(java.lang.String label,
                        java.lang.String key)
Adds a boolean type to the schema.


addButton

public Props addButton(java.lang.String key,
                       java.lang.String title,
                       java.lang.String description)
Adds a button type to the schema.


addCaption

public Props addCaption(java.lang.String caption)
Adds a caption type to the schema.


addChoice

public Props addChoice(java.lang.String label,
                       java.lang.String key,
                       java.lang.String options)
Adds a choice type to the schema.


addInteger

public Props addInteger(java.lang.String label,
                        java.lang.String key)
Adds an integer type to the schema.


addString

public Props addString(java.lang.String label,
                       java.lang.String key)
Adds a string type to the schema. Use for single lines.


addString

public Props addString(java.lang.String label,
                       java.lang.String key,
                       int lines)
Adds a string type to the schema. Use for multiple lines.


addSpace

public Props addSpace()
Adds a space type to the schema.


getFieldSchema

public Props getFieldSchema(java.lang.String key)
Returns the schema for the specified field. If more than one schema exists, the first one is returned.


getListSchema

public java.util.List getListSchema()
Returns a list of schema types that contain a list:true; property.


getPrimaryKey

public java.lang.String getPrimaryKey()
Returns the name of the key that contains a primary:true; property.


getSchema

public java.util.List getSchema()
Return a list of Props that define the schema.


setSchema

public void setSchema(java.lang.String s)
               throws PropsException
Uses a schema containing the parsed Props from the string.

Throws:
PropsException

toString

public java.lang.String toString()
Returns the schema as a parseable string.

Overrides:
toString in class java.lang.Object

writeForm

public void writeForm(HTMLFormWriter w)
               throws java.io.IOException
Writes the schema using the specified HTMLFormWriter.

Throws:
java.io.IOException

writeForm

public void writeForm(HTMLFormWriter w,
                      Props p)
               throws java.io.IOException
Writes the schema using the specified HTMLFormWriter and Props values.

Throws:
java.io.IOException

writeForm

public void writeForm(HTMLFormWriter w,
                      Props p,
                      int defaultSize)
               throws java.io.IOException
Writes the schema using the specified HTMLFormWriter and Props values. The size of fields will not exceed the specified default size.

Throws:
java.io.IOException

writeFormElement

public void writeFormElement(HTMLFormWriter w,
                             Props fieldProps,
                             Props p,
                             int defaultSize)
                      throws java.io.IOException
Writes the schema element using the specified HTMLFormWriter and Props values. The size of fields will not exceed the specified default size.

Throws:
java.io.IOException

parse

public static java.util.List parse(java.lang.String schema)
                            throws PropsException
Parses the formatted schema string and returns it as a List of Props.

Throws:
PropsException

toString

public static java.lang.String toString(java.util.List schema)
Returns the specified List of Props as a formatted schema string.