| Line | Hits | Source |
|---|---|---|
| 1 | /* | |
| 2 | Chrysalis Web Framework [http://chrysalis.sourceforge.net] | |
| 3 | Copyright (c) 2002, 2003, 2004, Paul Strack | |
| 4 | ||
| 5 | All rights reserved. | |
| 6 | ||
| 7 | Redistribution and use in source and binary forms, with or without | |
| 8 | modification, are permitted provided that the following conditions are met: | |
| 9 | ||
| 10 | 1. Redistributions of source code must retain the above copyright notice, this | |
| 11 | list of conditions and the following disclaimer. | |
| 12 | ||
| 13 | 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 14 | this list of conditions and the following disclaimer in the documentation | |
| 15 | and/or other materials provided with the distribution. | |
| 16 | ||
| 17 | 3. Neither the name of the copyright holder nor the names of its contributors | |
| 18 | may be used to endorse or promote products derived from this software without | |
| 19 | specific prior written permission. | |
| 20 | ||
| 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
| 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | |
| 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
| 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 31 | */ | |
| 32 | ||
| 33 | package org.chwf.plugin; | |
| 34 | ||
| 35 | import java.util.Map; | |
| 36 | ||
| 37 | import org.chwf.converter.ConversionException; | |
| 38 | ||
| 39 | /** | |
| 40 | * An abstract superclass for custom option list retrieval for bean | |
| 41 | * filters. It is used to populate data in option lists for bean properties. | |
| 42 | * A custom <code>OptionLister</code> plugin could be defined to load | |
| 43 | * option lists from a relational database rather Chrysalis XML configuration | |
| 44 | * files. | |
| 45 | * | |
| 46 | * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a> | |
| 47 | */ | |
| 48 | 1 | public abstract class OptionLister { |
| 49 | ||
| 50 | /** Id for the option lister plugin in the config file. */ | |
| 51 | public static final String OPTION_LISTER_ID = "option-lister"; | |
| 52 | ||
| 53 | /** The default lister. */ | |
| 54 | private static final String DEFAULT_LISTER = | |
| 55 | "org.chwf.plugin.defaults.DefaultOptionLister"; | |
| 56 | ||
| 57 | /** The lister specified in the configuration. */ | |
| 58 | 1 | private static final OptionLister LISTER = init(); |
| 59 | ||
| 60 | /** | |
| 61 | * Initialize the lister. | |
| 62 | * | |
| 63 | * @return The lister. | |
| 64 | * @throws IllegalStateException If lister cannot be initialized. | |
| 65 | */ | |
| 66 | private static OptionLister init() throws IllegalStateException { | |
| 67 | 1 | Object plugin = |
| 68 | Plugin.initPlugin(OptionLister.class, OPTION_LISTER_ID, DEFAULT_LISTER); | |
| 69 | 1 | return (OptionLister) plugin; |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Returns the <code>OptionLister</code> object.<p> | |
| 74 | * | |
| 75 | * @return The lister. | |
| 76 | */ | |
| 77 | public static OptionLister getInstance() { | |
| 78 | 104 | return OptionLister.LISTER; |
| 79 | } | |
| 80 | ||
| 81 | /** No-op constructor. */ | |
| 82 | 1 | protected OptionLister() { |
| 83 | 1 | } |
| 84 | ||
| 85 | /** | |
| 86 | * Load the option list for a JavaBean's property.<p> | |
| 87 | * | |
| 88 | * @param beanClass The class in question. | |
| 89 | * @param property The property. | |
| 90 | * @return The list of options. | |
| 91 | * @throws ConversionException If type conversions fail. | |
| 92 | */ | |
| 93 | public abstract Map loadOptionList(Class beanClass, String property) | |
| 94 | throws ConversionException; | |
| 95 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |