⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functionismatchpart.java

📁 High performance DB query
💻 JAVA
字号:
/* * @(#)$Id: FunctionIsmatchpart.java,v 1.1 2004/12/17 20:15:09 huebsch Exp $ * * Copyright (c) 2001-2004 Regents of the University of California. * All rights reserved. * * This file is distributed under the terms in the attached BERKELEY-LICENSE * file. If you do not find these files, copies can be found by writing to: * Computer Science Division, Database Group, Universite of California, * 617 Soda Hall #1776, Berkeley, CA 94720-1776. Attention: Berkeley License * * Copyright (c) 2003-2004 Intel Corporation. All rights reserved. * * This file is distributed under the terms in the attached INTEL-LICENSE file. * If you do not find these files, copies can be found by writing to: * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, * Berkeley, CA, 94704.  Attention:  Intel License Inquiry. */package pier.helpers.functions;import java.util.Collection;import java.util.Iterator;import java.util.StringTokenizer;import java.util.TreeSet;/** * Class FunctionConcat * */public class FunctionIsmatchpart implements Function {    /**     * Method evaluate     *     * @param parameters     * @return     */    public Object evaluate(Object[] parameters) {        int params = parameters.length;        if ((params == 3) || (params == 4)) {            String delim1 = parameters[2].toString();            String delim2 = (params == 4)                            ? delim2 = parameters[3].toString()                            : delim1;            TreeSet set1 = (TreeSet) getParts(new TreeSet(),                                              parameters[0].toString(), delim1);            TreeSet set2 = (TreeSet) getParts(new TreeSet(),                                              parameters[1].toString(), delim2);            return new Boolean(haveMatch(set1, set2));        } else {            return null;        }    }    /**     * Method getParts     *     *     * @param parts     * @param string     * @param delim     * @return     */    protected Collection getParts(Collection parts, String string, String delim) {        StringTokenizer strTokenizer = new StringTokenizer(string, delim);        int count = strTokenizer.countTokens();        for (int i = 0; i < count; i++) {            parts.add(strTokenizer.nextToken());        }        return parts;    }    /**     * Method haveMatch     *     * @param set1     * @param set2     * @return     */    protected boolean haveMatch(Collection set1, Collection set2) {        Iterator iterator1 = set1.iterator();        Iterator iterator2 = set2.iterator();        if ((iterator1.hasNext() == false) || (iterator2.hasNext() == false)) {            return false;        }        String head1 = (String) iterator1.next();        String head2 = (String) iterator2.next();        while (true) {            int compareResult = head1.compareTo(head2);            if (compareResult == 0) {                return true;            }            if (compareResult < 0) {                if (iterator1.hasNext()) {                    head1 = (String) iterator1.next();                } else {                    return false;                }            } else {                if (iterator2.hasNext()) {                    head2 = (String) iterator2.next();                } else {                    return false;                }            }        }    }    /**     * Method cacheable     * @return     */    public boolean cacheable() {        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -