001    /**
002     * Copyright (c) 2000-present 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.search.facet.util;
016    
017    import com.liferay.portal.kernel.util.CharPool;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.kernel.util.StringUtil;
020    
021    /**
022     * @author Raymond Aug??
023     */
024    public class RangeParserUtil {
025    
026            public static String[] parserRange(String range) {
027                    range = StringUtil.replace(
028                            range,
029                            new char[] {CharPool.OPEN_CURLY_BRACE, CharPool.CLOSE_CURLY_BRACE},
030                            new char[] {CharPool.OPEN_BRACKET, CharPool.CLOSE_BRACKET});
031    
032                    int x = range.indexOf(StringPool.OPEN_BRACKET);
033                    int y = range.indexOf(" TO ");
034                    int z = range.indexOf(StringPool.CLOSE_BRACKET);
035    
036                    String lower = range.substring(x + 1, y).trim();
037                    String upper = range.substring(y + 4, z).trim();
038    
039                    return new String[] {lower, upper};
040            }
041    
042    }