Blame | Last modification | View Log | RSS feed
/** Created on 7/04/2005*/package DMS;import java.util.HashMap;import java.util.Vector;import org.w3c.dom.Node;/*** @author mtayler*/public class highlightItem {private String FStyleClass;private Vector styleItemArray;public highlightItem(Node root) {styleItemArray = new Vector();FStyleClass = XMLParser.findNodeValue(root,"style-class");Node styleNode = XMLParser.findNode(root,"styleItem-list");parseRoot(styleNode);}private void parseRoot(Node root) {Vector dsVector = XMLParser.findNodeList(root,"styleItem");for (int i=0;i<dsVector.size();i++) {Node node=(Node)dsVector.get(i);highlightStyleItem highlight = new highlightStyleItem(node);styleItemArray.add(highlight);}}public highlightStyleItem[] getStyleItems() {return (highlightStyleItem[])styleItemArray.toArray(new highlightStyleItem[0]);}/*** @return Returns the fStyleClass.*/public String getStyleClass() {return FStyleClass;}public boolean isValidStyle(HashMap data) {for (int i=0;i<styleItemArray.size();i++) {highlightStyleItem highlightStyle = (highlightStyleItem)styleItemArray.get(i);String fieldName = highlightStyle.getFieldName();String fieldOperation = highlightStyle.getFieldName();String styleValue = highlightStyle.getFieldValue();String actualValue = DMSUtils.NVL((String)data.get(fieldName));if (highlightStyle.isEqual()&&!styleValue.equals(actualValue)) return false; //if any of the style items dont match the record data return false)else if (highlightStyle.isNotEqual()&&styleValue.equals(actualValue)) return false; //if any of the style items match the record data return false)}return true;}public String getHighlightLogic() {StringBuffer sb = new StringBuffer();for (int i=0;i<styleItemArray.size();i++) {highlightStyleItem highlightStyle = (highlightStyleItem)styleItemArray.get(i);String fieldName = highlightStyle.getFieldName().trim().toLowerCase();String styleValue = highlightStyle.getFieldValue();if (sb.length()!=0) sb.append(", ");sb.append(fieldName).append(" = ").append(styleValue);}return sb.toString();}}