01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.minilang.operation;
19:
20: import java.util.*;
21:
22: import org.w3c.dom.*;
23: import org.ofbiz.base.util.*;
24:
25: /**
26: * Abstract class providing functionality for the compare SimpleMapOperations
27: */
28: public abstract class BaseCompare extends SimpleMapOperation {
29: String operator;
30: String type;
31: String format;
32:
33: public BaseCompare(Element element,
34: SimpleMapProcess simpleMapProcess) {
35: super (element, simpleMapProcess);
36: this .operator = element.getAttribute("operator");
37: this .type = element.getAttribute("type");
38: this .format = element.getAttribute("format");
39:
40: /* -- Let ObjectType handle the default --
41: if (this.format == null || this.format.length() == 0) {
42: if ("Date".equals(type)) {
43: this.format = "yyyy-MM-dd";
44: } else if ("Time".equals(type)) {
45: this.format = "HH:mm:ss";
46: } else if ("Timestamp".equals(type)) {
47: this.format = "yyyy-MM-dd HH:mm:ss";
48: }
49: }
50: */
51: }
52:
53: public void doCompare(Object value1, Object value2, List messages,
54: Locale locale, ClassLoader loader,
55: boolean value2InlineConstant) {
56: Boolean success = BaseCompare.doRealCompare(value1, value2,
57: this .operator, this .type, this .format, messages,
58: locale, loader, value2InlineConstant);
59:
60: if (success != null && success.booleanValue() == false) {
61: addMessage(messages, loader, locale);
62: }
63: }
64:
65: public void exec(Map inMap, Map results, List messages,
66: Locale locale, ClassLoader loader) {
67: }
68:
69: public static Boolean doRealCompare(Object value1, Object value2,
70: String operator, String type, String format, List messages,
71: Locale locale, ClassLoader loader,
72: boolean value2InlineConstant) {
73: return ObjectType.doRealCompare(value1, value2, operator, type,
74: format, messages, locale, loader, value2InlineConstant);
75: }
76: }
|