001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.repository.cmis.search;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    
020    /**
021     * @author Mika Koivisto
022     */
023    public class CMISSimpleExpression implements CMISCriterion {
024    
025            public CMISSimpleExpression(
026                    String field, String value,
027                    CMISSimpleExpressionOperator cmisSimpleExpressionOperator) {
028    
029                    _field = field;
030                    _value = value;
031                    _cmisSimpleExpressionOperator = cmisSimpleExpressionOperator;
032            }
033    
034            @Override
035            public String toQueryFragment() {
036                    StringBundler sb = new StringBundler(7);
037    
038                    sb.append(_field);
039                    sb.append(StringPool.SPACE);
040                    sb.append(_cmisSimpleExpressionOperator);
041                    sb.append(StringPool.SPACE);
042                    sb.append(StringPool.APOSTROPHE);
043                    sb.append(_value);
044                    sb.append(StringPool.APOSTROPHE);
045    
046                    return sb.toString();
047            }
048    
049            private CMISSimpleExpressionOperator _cmisSimpleExpressionOperator;
050            private String _field;
051            private String _value;
052    
053    }