edu.indiana.dde.mylead.common
Class MyLeadElement

java.lang.Object
  extended byedu.indiana.dde.mylead.common.MyLeadElement

public class MyLeadElement
extends java.lang.Object

The purpose of this class is to be a container for an element within an attribute for a myLEAD query. Each attribute can consist of one or more attribute elements.

This class is used for attributes in queries for logical files, collections, experiments, and projects.

The attribute elements can be any of the valid MCS types, but the stored procedures will determine based on the element name what the data type of the element is. For purposes of this class, attribute elements are divided into the following categories:

Existence Test - this is where only the element name is specified. The query will test whether the element exists, but it does not consider what value the element has.

String Attribute Elements - Each string element has an attribute name, element name, and a boolean value that indicates whether the query should search for exact matches or just for elements that contain the specified String.

Single Value Elements - These can be any of the valid MCS data types except spatial data. The single value is passed as a String and based on the element name, the stored procedure queries will determine the actual data type and perform the necessary conversion. When a single element value is specified, the query searches for an exact match. This can be used for any of the MCS data types EXCEPT spatial data.

Range of Values for Elements - For some elements, the query may need to search for values within a specified range (e.g., temperature in the range 70 - 85). In that case there is a method for specifying a range that includes the start and end values. This can be used for any of the MCS data types EXCEPT spatial and String data.

Wrapping Up Attributes For Perform Documents:
To include the attributes in a LEAD query perform document, calling the wrapAttribute method will wrap the attributes in a tag-delimited String that validates against the leadActivity.xsd schema. The wrapElement method is called for each element in an attribute.

The valid MCS data types are:
1. Integer
2. Float
3. String
4. Spatial
5. DateTime
6. Date
7. Time


Constructor Summary
MyLeadElement()
          This default constructor will set default values for all of the variables in the element including a blank String for the name and MYLEAD_EQUAL as the default condition.
MyLeadElement(java.lang.String name, double xCoordinate, double yCoordinate)
          This overload of the constructor is used for comparisons based on spatial elements.
MyLeadElement(java.lang.String name, double xCoordinate, double yCoordinate, double attrRadius, java.lang.String attrRadiusUnits)
          This constructor is used to define a circle spatial element, but myLEAD currently does not perform comparisons based on the MYLEAD_CIRCLE_ELEMENT type.
MyLeadElement(java.lang.String name, java.lang.String attrValue, boolean exact)
          This overload of the constructor takes the name of the element, which must be defined in the lead_element_definition table.
MyLeadElement(java.lang.String name, java.lang.String attrValue, boolean exact, boolean isBlob)
          Deprecated. As of version 0.3 Alpha. This class is used to define an element for purposes of a myLEAD query. Although blob (MediumText) elements can exist for attributes, a query cannot be based on the value in a blob element.
MyLeadElement(java.lang.String name, java.lang.String attrValue, int compare)
          This overload of the constructor is used for elements that are to be compared to values in the catalog using one of the comparisons defined in LeadConstants such as MYLEAD_EQUAL or MYLEAD_GREATER_THAN_EQUAL.
MyLeadElement(java.lang.String name, java.lang.String attrStart, java.lang.String attrEnd)
          This overload of the constructor is used for comparisons based on a range of values.
 
Method Summary
 void addPoint(double xCoordinate, double yCoordinate)
          This method can only be called on elements that are already either a polygon or a point (in which case they become a polygon).
 void addPoint(MyLeadPt pt)
          This method is used to add a point to a point or polygon element where the x and y coordinates are already contained in a MyLeadPt object.
 int getCondition()
          This method returns the integer value of the comparison as set in either the constructor or the setCondition method.
 java.lang.String getEnd()
          This method returns the upper bound for a range comparison based on the value set in the constructor or using the setEnd method.
 boolean getExact()
          This method returns the boolean that indicates if a MYLEAD_STRING_ELEMENT type element needs to be an exact match.
 java.lang.String getName()
          Returns the name previously set for the element, which could be an empty String.
 double getRadius()
           
 java.lang.String getRadiusUnits()
           
 java.lang.String getStart()
          This method returns the startValue for a range comparison as set in either the constructor or the setStart method.
 int getType()
          Returns the integer code for the type of comparison.
 java.lang.String getValue()
          This method is identical to the getStart method and returns the startValue.
 void setCondition(int compare)
          This method takes an integer as a parameter for the comparison type which must match one of the comparisons defined in LeadConstants.
 void setEnd(java.lang.String endVal)
          For range comparisons the lower bound is set with the setStart method and the upper bound is set with this method.
 void setExact(boolean match)
          This method sets the exactMatch flag which is used only with the MYLEAD_STRING_ELEMENT element type to indicate if the String comparison needs to be an exact match or only needs to contain the String value set for the query.
 void setName(java.lang.String name)
          Used to set the element name - needed for use with the default constructor.
 void setRadius(double circleRadius)
           
 void setRadiusUnits(java.lang.String circleUnits)
           
 void setStart(java.lang.String startVal)
          This method can be used to set the lower bound of the range when the comparison is to a range of values.
 void setType(int elemType)
          Used to set the element type - needed for the default constructor.
 void setValue(java.lang.String startVal)
          This method has the same effect as the setStart method but it has a method name that is more sensible for the comparisons based on a single value (MYLEAD_VALUE_ELEMENT) or a String comparison (MYLEAD_STRING_ELEMENT).
 java.lang.String wrapElement()
          This routine wraps up an element and returns a string that can then be used in a query definition perform document that conforms to the leadActivity.xsd schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyLeadElement

public MyLeadElement()
This default constructor will set default values for all of the variables in the element including a blank String for the name and MYLEAD_EQUAL as the default condition. Each element also has a type which indicates the type of query - whether the element is checking for a range of values, an inexact string text match, or some other comparison. The default for the type as set in this constructor is MYLEAD_NONE_ELEMENT which indicates that no type has been set.


MyLeadElement

public MyLeadElement(java.lang.String name,
                     java.lang.String attrValue,
                     boolean exact)
This overload of the constructor takes the name of the element, which must be defined in the lead_element_definition table. The element value is taken as a string, and the boolean parameter indicates whether the element value must be an exact match or not.
This method should only be used for String elements.

Parameters:
name - String with the name of the element.
attrValue - String containing the element's value.
exact - boolean flag as to whether the element's value must match exactly - true, or just needs to contain the value specified in this method - false.

MyLeadElement

public MyLeadElement(java.lang.String name,
                     java.lang.String attrValue,
                     boolean exact,
                     boolean isBlob)
Deprecated. As of version 0.3 Alpha. This class is used to define an element for purposes of a myLEAD query. Although blob (MediumText) elements can exist for attributes, a query cannot be based on the value in a blob element.


MyLeadElement

public MyLeadElement(java.lang.String name,
                     java.lang.String attrValue,
                     int compare)
This overload of the constructor is used for elements that are to be compared to values in the catalog using one of the comparisons defined in LeadConstants such as MYLEAD_EQUAL or MYLEAD_GREATER_THAN_EQUAL.

As in the other constructor options, the element name is passed as a parameter and must be defined in the lead_element_definition table.
While String elements can be compared in this manner, generally the constructor with the boolean exact flag should be used for String elements.

Parameters:
name - String with the name of the element.
attrValue - String containing the element's value.
compare - integer with one of the comparisons defined in LeadConstants.
See Also:
LeadConstants

MyLeadElement

public MyLeadElement(java.lang.String name,
                     java.lang.String attrStart,
                     java.lang.String attrEnd)
This overload of the constructor is used for comparisons based on a range of values. As in the other constructors, the element name is passed as a parameter and must be defined in the lead_element_definition table.
The start and end values are String parameters but must match the data type for the element type. For example, an integer element should not have start and end parameters with the values "Abott" and "Costello".

Parameters:
name - String with the name of the element.
attrStart - String containing the lower limit for the element's value.
attrEnd - String containing the upper limit for the element's value.

MyLeadElement

public MyLeadElement(java.lang.String name,
                     double xCoordinate,
                     double yCoordinate)
This overload of the constructor is used for comparisons based on spatial elements. As in the other constructors, the element name is passed as a parameter and must be defined in the lead_element_definition table.
Since this constructor takes only a single pair of x/y coordinates, the element criteria created with this constructor defaults to the MYLEAD_POINT_ELEMENT type. If additional points are added later, the type will automatically bechange to the polygon type (MYLEAD_POLYGON_ELEMENT).

Parameters:
name - String with the name of the element.
xCoordinate - double containing the x-coordinate for the point.
yCoordinate - double containing the y-coordinate for the point.

MyLeadElement

public MyLeadElement(java.lang.String name,
                     double xCoordinate,
                     double yCoordinate,
                     double attrRadius,
                     java.lang.String attrRadiusUnits)
This constructor is used to define a circle spatial element, but myLEAD currently does not perform comparisons based on the MYLEAD_CIRCLE_ELEMENT type.

Parameters:
name - String with the name of the element.
xCoordinate - double containing the x-coordinate for the center of the circle
yCoordinate - double containing the y-coordinate for the center of the circle
Method Detail

setType

public void setType(int elemType)
Used to set the element type - needed for the default constructor. The type is not required for wrapping an element since an element can be empty for purposes of a query.

Parameters:
elemType - integer with the element type as defined in LeadConstants.

getType

public int getType()
Returns the integer code for the type of comparison. The comparison types are defined in LeadConstants. If the type had been set to an invalid value, then MYLEAD_NONE_ELEMENT is returned.

Returns:
integer with the comparison type.

setName

public void setName(java.lang.String name)
Used to set the element name - needed for use with the default constructor. The name is a required field for wrapping an element. The element name must be defined in the lead_element_definition table.

Parameters:
name - String with the name of the element.

getName

public java.lang.String getName()
Returns the name previously set for the element, which could be an empty String.

Returns:
String with the element name previously set.

setStart

public void setStart(java.lang.String startVal)
This method can be used to set the lower bound of the range when the comparison is to a range of values. In addition, for comparisons based on either a single value (MYLEAD_VALUE_ELEMENT) or a String comparison (MYLEAD_STRING_ELEMENT) the single value is stored in the startVal variable which is set in this method.

Parameters:
startVal - String with the value that the startValue should be set to. The start value is the lower bound for the range type or the single value for the value comparison or string comparison type.

getStart

public java.lang.String getStart()
This method returns the startValue for a range comparison as set in either the constructor or the setStart method.

Returns:
String containing the startValue.

setValue

public void setValue(java.lang.String startVal)
This method has the same effect as the setStart method but it has a method name that is more sensible for the comparisons based on a single value (MYLEAD_VALUE_ELEMENT) or a String comparison (MYLEAD_STRING_ELEMENT).

Parameters:
startVal - String with the value that the startValue should be set to. The start value is the lower bound for the range type or the single value for the value comparison or string comparison type.

getValue

public java.lang.String getValue()
This method is identical to the getStart method and returns the startValue.

Returns:
String containing the startValue.

setEnd

public void setEnd(java.lang.String endVal)
For range comparisons the lower bound is set with the setStart method and the upper bound is set with this method.

Parameters:
endVal - String containing the upper bound of a comparison range. The parameter value must match the data type of the element or the element will be ignored when running the query.

getEnd

public java.lang.String getEnd()
This method returns the upper bound for a range comparison based on the value set in the constructor or using the setEnd method.

Returns:
String with the upper bound of the comparison range.

setCondition

public void setCondition(int compare)
This method takes an integer as a parameter for the comparison type which must match one of the comparisons defined in LeadConstants. The condition set is relevant only if the element type is MYLEAD_VALUE_ELEMENT. If an invalid setting is used, the default is MYLEAD_EQUAL.

Parameters:
compare - integer with the comparison type.

getCondition

public int getCondition()
This method returns the integer value of the comparison as set in either the constructor or the setCondition method.

Returns:
integer with the value for the comparison type.

setExact

public void setExact(boolean match)
This method sets the exactMatch flag which is used only with the MYLEAD_STRING_ELEMENT element type to indicate if the String comparison needs to be an exact match or only needs to contain the String value set for the query.

Parameters:
match - boolean flag to indicate if the MYLEAD_STRING_ELEMENT element needs to be an exact match.

getExact

public boolean getExact()
This method returns the boolean that indicates if a MYLEAD_STRING_ELEMENT type element needs to be an exact match.

Returns:
boolean to indicate if an exact match is required.

setRadius

public void setRadius(double circleRadius)

getRadius

public double getRadius()

setRadiusUnits

public void setRadiusUnits(java.lang.String circleUnits)

getRadiusUnits

public java.lang.String getRadiusUnits()

addPoint

public void addPoint(double xCoordinate,
                     double yCoordinate)
This method can only be called on elements that are already either a polygon or a point (in which case they become a polygon). If called for an element that is type "none" (when the default constructor is used) then the type is set to point.

Parameters:
xCoordinate - double The x-coordinate of a point.
yCoordinate - double The y-coordinate of a point.

addPoint

public void addPoint(MyLeadPt pt)
This method is used to add a point to a point or polygon element where the x and y coordinates are already contained in a MyLeadPt object.

Parameters:
pt - A MyLeadPt object that contains the x and y coordinates of a point. The point is only added if both the x and y coordinates have already been set.

wrapElement

public java.lang.String wrapElement()
This routine wraps up an element and returns a string that can then be used in a query definition perform document that conforms to the leadActivity.xsd schema.

Returns:
Returns an XML fragment that wraps up the element.