| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| EONotQualifier |
|
| 1.6666666666666667;1.667 |
| 1 | /* |
|
| 2 | Wotonomy: OpenStep design patterns for pure Java applications. |
|
| 3 | Copyright (C) 2001 Intersect Software Corporation |
|
| 4 | ||
| 5 | This library is free software; you can redistribute it and/or |
|
| 6 | modify it under the terms of the GNU Lesser General Public |
|
| 7 | License as published by the Free Software Foundation; either |
|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|
| 9 | ||
| 10 | This library is distributed in the hope that it will be useful, |
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 | Lesser General Public License for more details. |
|
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public |
|
| 16 | License along with this library; if not, see http://www.gnu.org |
|
| 17 | */ |
|
| 18 | ||
| 19 | package net.wotonomy.control; |
|
| 20 | ||
| 21 | import net.wotonomy.foundation.internal.WotonomyException; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * EONotQualifiier negates a specified qualifier, |
|
| 25 | * evaluating to the opposite of the specified qualifier. |
|
| 26 | * |
|
| 27 | * @author michael@mpowers.net |
|
| 28 | * @author yjcheung@intersectsoft.com |
|
| 29 | * @author $Author: cgruber $ |
|
| 30 | * @version $Revision: 894 $ |
|
| 31 | */ |
|
| 32 | public class EONotQualifier extends EOQualifier |
|
| 33 | implements EOKeyValueArchiving, EOQualifierEvaluation |
|
| 34 | { |
|
| 35 | private EOQualifier qualifier; |
|
| 36 | ||
| 37 | 0 | public EONotQualifier( |
| 38 | EOQualifier aQualifier ) |
|
| 39 | 0 | { |
| 40 | 0 | qualifier = aQualifier; |
| 41 | 0 | } |
| 42 | ||
| 43 | /** |
|
| 44 | * Returns the qualifier that this qualifier negates. |
|
| 45 | */ |
|
| 46 | public EOQualifier qualifier() |
|
| 47 | { |
|
| 48 | 0 | return qualifier; |
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Evaluates this qualifier for the specified object, |
|
| 53 | * and returns whether the object is qualified. |
|
| 54 | * evaluateWithObject is invoked on qualifier |
|
| 55 | * and the result is negated and returned. |
|
| 56 | */ |
|
| 57 | public boolean evaluateWithObject( Object anObject ) |
|
| 58 | { |
|
| 59 | 0 | return !(qualifier.evaluateWithObject(anObject)); |
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Returns a string representation of this qualifier. |
|
| 64 | */ |
|
| 65 | public String toString() |
|
| 66 | { |
|
| 67 | 0 | return (new StringBuffer("Not ").append(qualifier.toString()).toString()); |
| 68 | } |
|
| 69 | ||
| 70 | public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver arch) { |
|
| 71 | 0 | EOQualifier q = (EOQualifier)arch.decodeObjectForKey("qualifier"); |
| 72 | 0 | if (q == null) |
| 73 | 0 | return null; |
| 74 | 0 | return new EONotQualifier(q); |
| 75 | } |
|
| 76 | ||
| 77 | public void encodeWithKeyValueArchiver(EOKeyValueArchiver arch) { |
|
| 78 | 0 | arch.encodeObject("EONotQualifier", "class"); |
| 79 | 0 | if (qualifier instanceof EOKeyValueArchiving) { |
| 80 | 0 | EOKeyValueArchiver ar2 = new EOKeyValueArchiver(); |
| 81 | 0 | ((EOKeyValueArchiving)qualifier).encodeWithKeyValueArchiver(ar2); |
| 82 | 0 | arch.encodeObject(ar2.dictionary(), "qualifiers"); |
| 83 | 0 | } else |
| 84 | 0 | throw new WotonomyException("Cannot archive instance of " + qualifier.getClass().getName()); |
| 85 | 0 | } |
| 86 | ||
| 87 | } |
|
| 88 | ||
| 89 | /* |
|
| 90 | * $Log$ |
|
| 91 | * Revision 1.2 2006/02/16 16:47:14 cgruber |
|
| 92 | * Move some classes in to "internal" packages and re-work imports, etc. |
|
| 93 | * |
|
| 94 | * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions. |
|
| 95 | * |
|
| 96 | * Revision 1.1 2006/02/16 13:19:57 cgruber |
|
| 97 | * Check in all sources in eclipse-friendly maven-enabled packages. |
|
| 98 | * |
|
| 99 | * Revision 1.9 2003/08/12 01:43:04 chochos |
|
| 100 | * formally implement EOQualifierEvaluation |
|
| 101 | * |
|
| 102 | * Revision 1.8 2003/08/11 19:39:30 chochos |
|
| 103 | * special conditions for NSKeyValueCoding.NullValue -> EONull |
|
| 104 | * |
|
| 105 | * Revision 1.7 2003/08/09 01:24:19 chochos |
|
| 106 | * implements EOKeyValueArchiving |
|
| 107 | * |
|
| 108 | * Revision 1.6 2003/08/06 23:07:52 chochos |
|
| 109 | * general code cleanup (mostly, removing unused imports) |
|
| 110 | * |
|
| 111 | * Revision 1.5 2001/10/31 15:25:14 mpowers |
|
| 112 | * Cleanup of qualifiers. |
|
| 113 | * |
|
| 114 | * Revision 1.4 2001/10/30 22:57:28 mpowers |
|
| 115 | * EOQualifier framework is now working. |
|
| 116 | * |
|
| 117 | * Revision 1.3 2001/09/13 15:42:20 mpowers |
|
| 118 | * Fixed another cut/paste typo. |
|
| 119 | * |
|
| 120 | * Revision 1.2 2001/09/13 15:41:34 mpowers |
|
| 121 | * Fixed typo. |
|
| 122 | * |
|
| 123 | * Revision 1.1 2001/09/13 15:38:19 mpowers |
|
| 124 | * Started implementation of the EOQualifier framework. |
|
| 125 | * |
|
| 126 | * |
|
| 127 | */ |
|
| 128 | ||
| 129 |