001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.repository.cmis.search;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    
020    import java.util.List;
021    
022    /**
023     * @author Mika Koivisto
024     */
025    public class CMISConjunction extends CMISJunction {
026    
027            @Override
028            public String toQueryFragment() {
029                    if (isEmpty()) {
030                            return StringPool.BLANK;
031                    }
032    
033                    List<CMISCriterion> cmisCriterions = list();
034    
035                    StringBundler sb = new StringBundler(cmisCriterions.size() * 2 - 1);
036    
037                    for (int i = 0; i < cmisCriterions.size(); i++) {
038                            CMISCriterion cmisCriterion = cmisCriterions.get(i);
039    
040                            if (i != 0) {
041                                    sb.append(" AND ");
042                            }
043    
044                            sb.append(cmisCriterion.toQueryFragment());
045                    }
046    
047                    return sb.toString();
048            }
049    
050    }