[Javamatch-cvs] javamatch/src/net/sourceforge/javamatch/query NotQuery.java,NONE,1.1
Status: Pre-Alpha
Brought to you by:
iterson
From: Walter v. I. <it...@us...> - 2004-09-09 14:19:10
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24523/query Added Files: NotQuery.java Log Message: Added NotQuery, fix javadoc --- NEW FILE: NotQuery.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * 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.1 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 02111-1307 USA */ package net.sourceforge.javamatch.query; import net.sourceforge.javamatch.engine.*; /** * Class NotQuery is a query that negates the match result of the underlying * query */ public class NotQuery extends MatchQuery { /** The nested query */ private MatchQuery nestedQuery; /** * Creates a new NotQuery-query, that negates the given nested query * @param nestedQuery the query of which the result is negated */ public NotQuery(MatchQuery nestedQuery) { if (nestedQuery == null) { throw new NullPointerException("Can't create NotQuery with null " + "nested query"); } this.nestedQuery = nestedQuery; } /** * Returns the match value of this match query, when executed on the given * object. * @param targetObject the object agains which the query is executed * @return A value between 0 and 1, both inclusive, that indicates how good * the object matches this query. 0 means a mismatch, 1 means a full * match * @throws MatchException when the value could not be retrieved */ public float getMatchValue(Object targetObject) throws MatchException { float nestedValue = nestedQuery.getMatchValue(targetObject); return 1 - nestedValue; } } |