2010-05-26 17:40:08 -04:00
|
|
|
/*
|
|
|
|
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
|
|
|
* Copyright (C) 2010 Mickael Guessant
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
package davmail.exchange.ews;
|
|
|
|
|
2010-06-07 17:17:07 -04:00
|
|
|
import davmail.util.StringUtil;
|
|
|
|
|
2010-05-26 17:40:08 -04:00
|
|
|
/**
|
|
|
|
* Two operand expression.
|
|
|
|
*/
|
2010-06-07 12:01:20 -04:00
|
|
|
public class TwoOperandExpression implements SearchExpression {
|
2010-07-25 07:34:37 -04:00
|
|
|
@SuppressWarnings({"UnusedDeclaration"})
|
2010-05-26 17:40:08 -04:00
|
|
|
protected enum Operator {
|
|
|
|
IsEqualTo, IsNotEqualTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsLessThan, IsLessThanOrEqualTo
|
|
|
|
}
|
|
|
|
|
2010-07-19 05:22:42 -04:00
|
|
|
protected final Operator operator;
|
|
|
|
protected final FieldURI fieldURI;
|
|
|
|
protected final String value;
|
2010-05-26 17:40:08 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create two operand expression.
|
|
|
|
*
|
|
|
|
* @param operator operator
|
|
|
|
* @param fieldURI field operand
|
|
|
|
* @param value value operand
|
|
|
|
*/
|
|
|
|
public TwoOperandExpression(Operator operator, FieldURI fieldURI, String value) {
|
|
|
|
this.operator = operator;
|
|
|
|
this.fieldURI = fieldURI;
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
2010-06-07 17:17:07 -04:00
|
|
|
public void appendTo(StringBuilder buffer) {
|
|
|
|
buffer.append("<t:").append(operator.toString()).append('>');
|
|
|
|
fieldURI.appendTo(buffer);
|
2010-05-26 17:40:08 -04:00
|
|
|
|
2010-06-07 17:17:07 -04:00
|
|
|
buffer.append("<t:FieldURIOrConstant><t:Constant Value=\"");
|
2010-07-25 10:36:27 -04:00
|
|
|
// encode urlcompname
|
|
|
|
if (fieldURI instanceof ExtendedFieldURI && "0x10f3".equals(((ExtendedFieldURI) fieldURI).propertyTag)) {
|
|
|
|
buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
|
|
|
|
} else {
|
|
|
|
buffer.append(StringUtil.xmlEncode(value));
|
|
|
|
}
|
2010-06-07 17:17:07 -04:00
|
|
|
buffer.append("\"/></t:FieldURIOrConstant>");
|
2010-05-26 17:40:08 -04:00
|
|
|
|
2010-06-07 17:17:07 -04:00
|
|
|
buffer.append("</t:").append(operator.toString()).append('>');
|
2010-05-26 17:40:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|