flatscape.util
Class UFormUtils

java.lang.Object
  |
  +--flatscape.util.UFormUtils

public final class UFormUtils
extends java.lang.Object

The UFormUtils class contains static utility methods related to accessing properties of UForm's. The method which all of the other convenience methods are built around is the getProperty(Element, String, String) method. The failure cases for this method apply to all others.

Copyright (c) 2001,2002 Rutgers, The State University of New Jersey

Version:
%Revision%

Field Summary
static java.lang.String NAME
           
 
Method Summary
static Command createDocument(java.lang.String name, org.w3c.dom.Node root, Controller controller)
          Create a command to add a document to the repository.
static Command createSetPropertyCommand(java.lang.String docName, org.w3c.dom.Element model, java.lang.String key, java.lang.Object value)
          Creates a command to add or change a property of a model element.
static Transform2D get2DTransform(org.w3c.dom.Element model)
           
static org.w3c.dom.Element getParent(org.w3c.dom.Node node, java.lang.String[] validTypes)
           
static boolean getProperty(org.w3c.dom.Element model, java.lang.String key, boolean defaultValue)
          Returns the specified Boolean property of the model element if possible, otherwise the default value is returned.
static byte getProperty(org.w3c.dom.Element model, java.lang.String key, byte defaultValue)
          Returns the specified Byte property of the model element if possible, otherwise the default value is returned.
static char getProperty(org.w3c.dom.Element model, java.lang.String key, char defaultValue)
          Returns the specified Char property of the model element if possible, otherwise the default value is returned.
static double getProperty(org.w3c.dom.Element model, java.lang.String key, double defaultValue)
          Returns the specified Double property of the model element if possible, otherwise the default value is returned.
static float getProperty(org.w3c.dom.Element model, java.lang.String key, float defaultValue)
          Returns the specified Float property of the model element if possible, otherwise the default value is returned.
static int getProperty(org.w3c.dom.Element model, java.lang.String key, int defaultValue)
          Returns the specified Integer property of the model element if possible, otherwise the default value is returned.
static long getProperty(org.w3c.dom.Element model, java.lang.String key, long defaultValue)
          Returns the specified Long property of the model element if possible, otherwise the default value is returned.
static java.lang.Object getProperty(org.w3c.dom.Element model, java.lang.String key, java.lang.Object defaultValue)
          Returns the specified property of the model element if it exists and is an instance of the default value's class, otherwise the default value is returned.
static short getProperty(org.w3c.dom.Element model, java.lang.String key, short defaultValue)
          Returns the specified Short property of the model element if possible, otherwise the default value is returned.
static java.lang.String getProperty(org.w3c.dom.Element model, java.lang.String key, java.lang.String defaultValue)
          Returns the specified String property of the model element if possible, otherwise the default value is returned.
static void setProperty(org.w3c.dom.Element model, java.lang.String key, java.lang.Object value)
          Adds or changes a property of a model element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values
Method Detail

get2DTransform

public static Transform2D get2DTransform(org.w3c.dom.Element model)

createDocument

public static Command createDocument(java.lang.String name,
                                     org.w3c.dom.Node root,
                                     Controller controller)
Create a command to add a document to the repository.

Parameters:
name - the name of the document
root - the root node of the document
controller - the controller

createSetPropertyCommand

public static Command createSetPropertyCommand(java.lang.String docName,
                                               org.w3c.dom.Element model,
                                               java.lang.String key,
                                               java.lang.Object value)
Creates a command to add or change a property of a model element.

Returns:
a SetNodeValueCommand if the property already exsists, else a AddSubtreeCommand to add the property
See Also:
setProperty(org.w3c.dom.Element, java.lang.String, java.lang.Object), SetNodeValueCommand, AddSubtreeCommand

setProperty

public static void setProperty(org.w3c.dom.Element model,
                               java.lang.String key,
                               java.lang.Object value)
Adds or changes a property of a model element. WARNING - this method should only be used when creating new model elements before they are sent to the repository. Adding or setting properties for already created model elements should be done using the createSetPropertyCommand method and send the created command using the Controller

See Also:
createSetPropertyCommand(java.lang.String, org.w3c.dom.Element, java.lang.String, java.lang.Object), SetNodeValueCommand

getProperty

public static java.lang.String getProperty(org.w3c.dom.Element model,
                                           java.lang.String key,
                                           java.lang.String defaultValue)
Returns the specified String property of the model element if possible, otherwise the default value is returned.


getProperty

public static java.lang.Object getProperty(org.w3c.dom.Element model,
                                           java.lang.String key,
                                           java.lang.Object defaultValue)
Returns the specified property of the model element if it exists and is an instance of the default value's class, otherwise the default value is returned. If the default value is null, the model's property is returned regaurdless. This function prevents ClassCastExceptions while providing a convienient way to have default property values.


getProperty

public static boolean getProperty(org.w3c.dom.Element model,
                                  java.lang.String key,
                                  boolean defaultValue)
Returns the specified Boolean property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static byte getProperty(org.w3c.dom.Element model,
                               java.lang.String key,
                               byte defaultValue)
Returns the specified Byte property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static short getProperty(org.w3c.dom.Element model,
                                java.lang.String key,
                                short defaultValue)
Returns the specified Short property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static int getProperty(org.w3c.dom.Element model,
                              java.lang.String key,
                              int defaultValue)
Returns the specified Integer property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static long getProperty(org.w3c.dom.Element model,
                               java.lang.String key,
                               long defaultValue)
Returns the specified Long property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static char getProperty(org.w3c.dom.Element model,
                               java.lang.String key,
                               char defaultValue)
Returns the specified Char property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static float getProperty(org.w3c.dom.Element model,
                                java.lang.String key,
                                float defaultValue)
Returns the specified Float property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getProperty

public static double getProperty(org.w3c.dom.Element model,
                                 java.lang.String key,
                                 double defaultValue)
Returns the specified Double property of the model element if possible, otherwise the default value is returned. A primitive is returned.


getParent

public static org.w3c.dom.Element getParent(org.w3c.dom.Node node,
                                            java.lang.String[] validTypes)
Returns:
the first parent element matching one of the validTypes, when traversing the tree from the node towards the root,


Copyright (c) 2003 Rutgers, The State University of New Jersey