Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2308 mtayler 1
/*
2
 * Created on 7/04/2005
3
 */
4
package DMS;
5
 
6
import java.util.HashMap;
7
import java.util.Vector;
8
 
9
import org.w3c.dom.Node;
10
 
11
/**
12
 * @author mtayler
13
 */
14
public class highlightItem {
15
 
16
	private String FStyleClass;
17
	private Vector styleItemArray;
18
 
19
	public highlightItem(Node root) {
20
		styleItemArray = new Vector();
21
		FStyleClass = XMLParser.findNodeValue(root,"style-class");		
22
 
23
		Node styleNode = XMLParser.findNode(root,"styleItem-list");
24
 
25
		parseRoot(styleNode);
26
	}
27
 
28
	private void parseRoot(Node root) {
29
		Vector dsVector = XMLParser.findNodeList(root,"styleItem");
30
 
31
		for (int i=0;i<dsVector.size();i++) {
32
			Node node=(Node)dsVector.get(i);			
33
			highlightStyleItem highlight = new highlightStyleItem(node);
34
			styleItemArray.add(highlight);			
35
		}
36
 
37
	}
38
 
39
	public highlightStyleItem[] getStyleItems() {		
40
		return (highlightStyleItem[])styleItemArray.toArray(new highlightStyleItem[0]);		
41
	}
42
 
43
	/**
44
	 * @return Returns the fStyleClass.
45
	 */
46
	public String getStyleClass() {
47
		return FStyleClass;
48
	}	
49
 
50
 
51
	public boolean isValidStyle(HashMap data) {
52
		for (int i=0;i<styleItemArray.size();i++) {
53
			highlightStyleItem highlightStyle = (highlightStyleItem)styleItemArray.get(i);
54
			String fieldName = highlightStyle.getFieldName();
55
			String fieldOperation = highlightStyle.getFieldName();
56
			String styleValue = highlightStyle.getFieldValue();
57
			String actualValue = DMSUtils.NVL((String)data.get(fieldName));
58
 
59
			if (highlightStyle.isEqual()&&!styleValue.equals(actualValue)) return false; //if any of the style items dont match the record data return false)
60
			else if (highlightStyle.isNotEqual()&&styleValue.equals(actualValue)) return false; //if any of the style items match the record data return false)			
61
		}
62
		return true;
63
	}	
64
 
65
	public String getHighlightLogic() {
66
		StringBuffer sb = new StringBuffer();
67
		for (int i=0;i<styleItemArray.size();i++) {
68
			highlightStyleItem highlightStyle = (highlightStyleItem)styleItemArray.get(i);
69
			String fieldName = highlightStyle.getFieldName().trim().toLowerCase();
70
			String styleValue = highlightStyle.getFieldValue();
71
			if (sb.length()!=0) sb.append(", ");
72
			sb.append(fieldName).append(" = ").append(styleValue);
73
		}		
74
		return sb.toString();
75
	}
76
}