|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.tasklist.core.filter; import java.awt.Component; import java.lang.reflect.InvocationTargetException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.*; import org.openide.ErrorManager; import org.openide.nodes.Node; import org.openide.util.NbBundle; /** * Basic condition class for comparisons of boolean values. * * @author Tor Norbye * @author Tim Lebedkov */ public class BooleanFilterCondition extends OneOfFilterCondition { public static final int ISTRUE = 0; public static final int ISFALSE = 1; private static String[] NAME_KEYS = { "IsTrue", // NOI18N "IsFalse", // NOI18N }; /** * Creates an array of filter conditions for the specified property * * @param index index of the property */ public static BooleanFilterCondition[] createConditions() { return new BooleanFilterCondition[] { new BooleanFilterCondition(BooleanFilterCondition.ISTRUE), new BooleanFilterCondition(BooleanFilterCondition.ISFALSE) }; }; /** * Creates a condition with the given name. * * @param prop index of the property this condition uses * @param id one of the constants from this class */ public BooleanFilterCondition(int id) { super(NAME_KEYS, id); } public BooleanFilterCondition(final BooleanFilterCondition rhs) { super(rhs); } public Object clone() { return new BooleanFilterCondition(this); } private BooleanFilterCondition() { super(NAME_KEYS);}; public JComponent createConstantComponent() { return null; } public boolean isTrue(Object obj) { boolean n = ((Boolean) obj).booleanValue(); switch (getId()) { case ISTRUE: return n == true; case ISFALSE: return n == false; default: throw new InternalError("wrong id"); // NOI18N } } private static class Convertor extends OneOfFilterCondition.Convertor { private static final String ELEM_BOOLEAN_CONDITION = "BooleanCondition"; public Convertor() { super(ELEM_BOOLEAN_CONDITION, NAME_KEYS);} public static BooleanFilterCondition.Convertor create() { return new BooleanFilterCondition.Convertor(); } protected OneOfFilterCondition createCondition() { return new BooleanFilterCondition();} } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.