WepsTableEnum.java [src/usda/weru/util/table] Revision: default Date:
/*
* WepsTableEnum.java
*
* Created on June 19, 2006, 11:22 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package usda.weru.util.table;
/**
* A collection of constants used by WepsTable. Constants begining with "XML_" are tags or attributes found within the XML configuration files used to specify the look and feel of the table. Other constants are possible configuration values for the table.
* @note this originally referenced package com.klg.jclass.table.JCTableEnum, which is no longer used.
* @author Joseph Levin
*/
public class WepsTableEnum {
public static final int NOT_FOUND = -666;
public static final int NO_VALUE = -999;
public static final String DEFAULT_ID = "DEFAULT_ID";
public static final String NO_UNITS_SYSTEM = "NO_UNITS_SYSTEM";
//Attributes available to XML tags
public static final String XML_id = "id";
public static final String XML_parent = "parent";
//Meta
public static final String XML_table = "table";
public static final String XML_cellstyles = "cellstyles";
public static final String XML_columnstyles = "columnstyles";
public static final String XML_columns = "columns";
public static final String XML_columngroup = "columngroup";
public static final String XML_defaultcellstyle = "defaultcellstyle";
public static final String XML_defaultlabelstyle = "defaultlabelstyle";
public static final String XML_rowlabeldisplay = "rowlabeldisplay";
public static final String XML_columnlabeldisplay = "columnlabeldisplay";
public static final String XML_frozenrows = "frozenrows";
public static final String XML_frozencolumns = "frozencolumns";
//Cellstyles
public static final String XML_style = "style";
public static final String XML_background = "background";
public static final String XML_border = "border";
public static final String XML_left = "left";
public static final String XML_right = "right";
public static final String XML_top = "top";
public static final String XML_bottom = "bottom";
public static final String XML_all = "all";
public static final String XML_none = "none";
public static final String XML_color = "color";
public static final String XML_cliphints = "cliphints";
//TODO: Fix editable, not applying.
public static final String XML_editable = "editable";
public static final String XML_editor = "editor";
public static final String XML_foreground = "foreground";
public static final String XML_font = "font";
public static final String XML_horizontalalignment = "horizontalalignment";
public static final String XML_renderer = "renderer";
public static final String XML_repeatbackground = "repeatbackground";
public static final String XML_repeatforeground = "repeatforeground";
public static final String XML_traversable= "traversable";
public static final String XML_verticalalignment = "verticalalignment";
public static final String XML_conditional = "conditional";
public static final String XML_expression = "expression";
public static final String XML_size = "size";
public static final String XML_bold = "bold";
public static final String XML_italic = "italic";
//column
public static final String XML_column = "column";
public static final String XML_name = "name";
public static final String XML_data = "data";
public static final String XML_type = "type";
public static final String XML_units = "units";
public static final String XML_displayunits = "displayunits";
public static final String XML_system = "system";
public static final String XML_format = "format";
public static final String XML_visible = "visible";
public static final String XML_hidden = "hidden";
//Sizes
public static final String XML_width = "width";
public static final String XML_height = "height";
public static final String XML_min = "min";
public static final String XML_max = "max";
//Adjustment
public static final String XML_adjust = "adjust";
public static final String XML_operation = "operation";
//Limit
public static final String XML_limit = "limit";
public static final String XML_lower = "lower";
public static final String XML_upper = "upper";
public static final String XML_allowzero = "allowzero";
public static final String XML_inclusive = "inclusive";
//Filter
public static final String XML_filterset = "filterset";
public static final String XML_rowfilter = "rowfilter";
public static final String XML_columnfilter = "columnfilter";
public static final String XML_class = "class";
//label
public static final String XML_label = "label";
public static final String XML_text = "text";
public static final String XML_spanrows = "spanrows";
public static final String XML_spancolumns = "spancolumns";
public static final String XML_image = "image";
public static final String XML_angle = "angle";
//quickplot
public static final String XML_quickplot = "quickplot";
//Parsing fields
public static final String PARSE_value = "value";
public static final String PARSE_units = "units";
public static final String PARSE_displayunits = "displayunits";
public static final String PARSE_displayunitsabbreviation = "displayunitsabbreviation";
//Data Types
public static final int DATA_text = 1;
public static final int DATA_date = 2;
public static final int DATA_numeric = 4;
public static final int DATA_boolean = 8;
public static final int DATA_list = 16;
public static final int DATA_image = 32;
//Adjustments
public static final int OPERATION_add = 1;
public static final int OPERATION_subtract = 2;
public static final int OPERATION_multiply = 4;
public static final int OPERATION_divide = 8;
public static final int OPERATION_abs = 16;
//Prepare Flags
public static final int PREPARE_adjustments = 1;
public static final int PREPARE_displayunits = 2;
public static final int PREPARE_limits = 4;
public static final int PREPARE_formats = 8;
public static final int PREPARE_all = PREPARE_adjustments | PREPARE_displayunits | PREPARE_limits | PREPARE_formats;
/**
* Return the value of the constant specified.
* @param constant The name of the constant.
* @return The value of the constant.
*/
public static int getEnumFromTag(String constant){
return getEnumFromTag(constant, NOT_FOUND);
}
/**
* Return the value of the constant specified or the default value specified if the constant can't be found.
* @param constant The name of the constant.
* @param defaultValue The value to be returned if the constant can't be found.
* @return The value of the constant.
*/
public static int getEnumFromTag(String constant, int defaultValue){
if (constant == null) return defaultValue;
constant = constant.toLowerCase().trim();
// //JCTableEnums
// if (constant.equals("all")) return JCTableEnum.ALL;
// else if (constant.equals("allcells")) return JCTableEnum.ALLCELLS;
//
// else if (constant.equals("border_etched_in")) return JCTableEnum.BORDER_ETCHED_IN;
// else if (constant.equals("border_etched_out")) return JCTableEnum.BORDER_ETCHED_OUT;
// else if (constant.equals("border_frame_in")) return JCTableEnum.BORDER_FRAME_IN;
// else if (constant.equals("border_frame_out")) return JCTableEnum.BORDER_FRAME_OUT;
// else if (constant.equals("border_in")) return JCTableEnum.BORDER_IN;
// else if (constant.equals("border_none")) return JCTableEnum.BORDER_NONE;
// else if (constant.equals("border_out")) return JCTableEnum.BORDER_OUT;
// else if (constant.equals("border_plain")) return JCTableEnum.BORDER_PLAIN;
// else if (constant.equals("border_thin")) return JCTableEnum.BORDER_THIN;
//
// else if (constant.equals("bottom")) return JCTableEnum.BOTTOM;
//
//
// else if (constant.equals("center")) return JCTableEnum.CENTER;
//
// else if (constant.equals("left")) return JCTableEnum.LEFT;
//
// else if (constant.equals("middle")) return JCTableEnum.CENTER;
// else if (constant.equals("middlecenter")) return JCTableEnum.MIDDLECENTER;
// else if (constant.equals("middleleft")) return JCTableEnum.MIDDLELEFT;
// else if (constant.equals("middleright")) return JCTableEnum.MIDDLERIGHT;
//
// else if (constant.equals("repeat_column")) return JCTableEnum.REPEAT_COLUMN;
// else if (constant.equals("repeat_none")) return JCTableEnum.REPEAT_NONE;
// else if (constant.equals("repeat_row")) return JCTableEnum.REPEAT_ROW;
// else if (constant.equals("repeat_right")) return JCTableEnum.RIGHT;
//
// else if (constant.equals("right")) return JCTableEnum.RIGHT;
//
// else if (constant.equals("top")) return JCTableEnum.TOP;
//
//Data Types
/*else*/ if (constant.equals("text")) return DATA_text;
else if (constant.equals("date")) return DATA_date;
else if (constant.equals("numeric")) return DATA_numeric;
else if (constant.equals("boolean")) return DATA_boolean;
else if (constant.equals("list")) return DATA_list;
else if (constant.equals("image")) return DATA_image;
//adjustment operations
else if (constant.equals("add")) return OPERATION_add;
else if (constant.equals("subtract")) return OPERATION_subtract;
else if (constant.equals("multiply")) return OPERATION_multiply;
else if (constant.equals("divide")) return OPERATION_divide;
else if (constant.equals("abs")) return OPERATION_abs;
// //cliphints
// else if (constant.equals("show_all")) return JCTableEnum.SHOW_ALL;
// else if (constant.equals("show_none")) return JCTableEnum.SHOW_NONE;
// else if (constant.equals("show_vertical")) return JCTableEnum.SHOW_VERTICAL;
// else if (constant.equals("show_horizontal")) return JCTableEnum.SHOW_HORIZONTAL;
//
// //columnwidth
// else if (constant.equals("variable")) return JCTableEnum.VARIABLE;
//
else return defaultValue;
}
}