Mandarax's judgment is a repicate in a collection of Object

xiaoxiao2021-03-06  102

/ * * Copyright (c) 1999-2004 aaron tang * this library is free software; you can redistribute it and / or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation;. either * version 2 of the License, or (at your option) any later version * * This library 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 * Lesser General Public License for more details * * You should have received a copy of the GNU Lesser General Public * License along With this library; if not, Write to The Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 0211-1307 USA * /

Package org.mandarax.lib.collection;

Import org.mandarax.kernel. *; import java.util.AbstractCollection;

/ ** * Predicates Associating one Object and a collection may contact the object. * * @Author aaron tang * @version 3.3 <18 Oct. 2004> * @since 1.4 * / public class CollectionPredicate extends org.mandarax.lib.AbstractPredicate {private static final long serialVersionUID = -1234619399185521391L; private static class [] structure = {Object.class, AbstractCollection.class};

/ ** * get the structure of the predicate. * * @Return the structure of the predicate * / public class [] getStructure () {Return structure;}

/ ** * Perform the function or predicate using an array of terms as parameters. * * @Return an object * @param parameter * an array of terms * @param session * a session object * @throws java.lang.UnsupportedOperationException * @ throws java.lang.IllegalArgumentException * / public Object perform (Term [] parameter, Session session) throws IllegalArgumentException, UnsupportedOperationException {Object s1; AbstractCollection s2; try {s1 = (parameter [0] .resolve (session)); s2 = ( AbstractCollection) (parameter [1] .resolve (session));} catch (exception x) {throw new illegalgumentException ();

IF (S1 == Null) {throw new illegalgumentException ();

RETURN (EVALUATE (S1, S2))? Boolean.true: Boolean.false;}

/ ** * Evaluate the two values ​​using the predicate. * * @Return true or false * @param s1 * value 1 * @param s2 * value 2 * / protected boolean evaluate (Object s1, AbstractCollection s2) {return s2.contains (S1);

/ * (non-javadoc) * @see org.mandarax.kernel.constructor # getName () * / public string getName () {return "contained in";}}

转载请注明原文地址:https://www.9cbs.com/read-103329.html

New Post(0)