|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| MVCClassFinder.java | - | 71.4% | 60% | 66.7% |
|
||||||||||||||
| 1 | // | |
| 2 | // Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. | |
| 3 | // All rights reserved. | |
| 4 | // | |
| 5 | // Redistribution and use in source and binary forms, with or without modification, | |
| 6 | // are permitted provided that the following conditions are met: | |
| 7 | // | |
| 8 | // * Redistributions of source code must retain the above copyright notice, | |
| 9 | // this list of conditions and the following disclaimer. | |
| 10 | // * Redistributions in binary form must reproduce the above copyright notice, | |
| 11 | // this list of conditions and the following disclaimer in the documentation | |
| 12 | // and/or other materials provided with the distribution. | |
| 13 | // * Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. | |
| 14 | // nor the names of its contributors may be used to endorse or promote products | |
| 15 | // derived from this software without specific prior written permission. | |
| 16 | // | |
| 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 19 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
| 20 | // IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
| 21 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 22 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | |
| 23 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 24 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 25 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 26 | // POSSIBILITY OF SUCH DAMAGE. | |
| 27 | // | |
| 28 | package org.objectledge.web.mvc.finders; | |
| 29 | ||
| 30 | import org.objectledge.pipeline.Valve; | |
| 31 | import org.objectledge.web.mvc.builders.Builder; | |
| 32 | import org.objectledge.web.mvc.components.Component; | |
| 33 | ||
| 34 | /** | |
| 35 | * A class finder for finding MVC model classes. | |
| 36 | * | |
| 37 | * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a> | |
| 38 | * @version $Id: MVCClassFinder.java,v 1.17 2005/07/22 17:25:53 pablo Exp $ | |
| 39 | */ | |
| 40 | public interface MVCClassFinder | |
| 41 | { | |
| 42 | // actions ////////////////////////////////////////////////////////////////////////////////// | |
| 43 | ||
| 44 | /** | |
| 45 | * Returns a runnable action instance based on a given name. If no runnable exists, a | |
| 46 | * <code>null</code> is returned. | |
| 47 | * | |
| 48 | * @param actionName name of an action class | |
| 49 | * @return found runnable action instance | |
| 50 | */ | |
| 51 | public Valve getAction(String actionName); | |
| 52 | ||
| 53 | // builders ///////////////////////////////////////////////////////////////////////////////// | |
| 54 | ||
| 55 | /** | |
| 56 | * Returns a result object containing reference to the found builder for a given view | |
| 57 | * name. If no builder is found, a <code>null</code> builder is returned in the result object. | |
| 58 | * | |
| 59 | * @param builderName part of a name of a builder class to be instantiated | |
| 60 | * @return found builder instance with accompanying info. | |
| 61 | */ | |
| 62 | public Result findBuilder(String builderName); | |
| 63 | ||
| 64 | /** | |
| 65 | * Returns an enclosing view name for a given view name. If no name is found, a | |
| 66 | * <code>null</code> is returned. | |
| 67 | * | |
| 68 | * @param viewName name of a view for which an enclosing view must be found | |
| 69 | * @return found view name | |
| 70 | */ | |
| 71 | public String findEnclosingViewName(String viewName); | |
| 72 | ||
| 73 | // components ///////////////////////////////////////////////////////////////////////////////// | |
| 74 | ||
| 75 | /** | |
| 76 | * Returns a component instance based on a given name. If no component exists, a | |
| 77 | * <code>null</code> is returned. | |
| 78 | * | |
| 79 | * @param componentName part of a name of a component class to be found/instantiated | |
| 80 | * @return found component instance | |
| 81 | */ | |
| 82 | public Component getComponent(String componentName); | |
| 83 | ||
| 84 | /** | |
| 85 | * The search result for builder find method. | |
| 86 | * | |
| 87 | * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a> | |
| 88 | */ | |
| 89 | public static class Result | |
| 90 | { | |
| 91 | private final String originalView; | |
| 92 | private final Builder builder; | |
| 93 | private final String actualView; | |
| 94 | ||
| 95 | /** | |
| 96 | * Creates a new Result instance. | |
| 97 | * | |
| 98 | * @param originalView originally requested builder. | |
| 99 | * @param builder resolved builder. | |
| 100 | * @param actualView the actual view associated with the resolved builder. | |
| 101 | */ | |
| 102 | 1656 | public Result(String originalView, Builder builder, String actualView) |
| 103 | { | |
| 104 | 1656 | this.originalView = originalView; |
| 105 | 1656 | this.builder = builder; |
| 106 | 1656 | this.actualView = actualView; |
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * @return Returns the original view used to search for the builder. | |
| 111 | */ | |
| 112 | 0 | public String getOriginalView() |
| 113 | { | |
| 114 | 0 | return originalView; |
| 115 | } | |
| 116 | ||
| 117 | /** | |
| 118 | * @return Returns the actual view name computed during search. | |
| 119 | */ | |
| 120 | 0 | public String getActualView() |
| 121 | { | |
| 122 | 0 | return actualView; |
| 123 | } | |
| 124 | ||
| 125 | /** | |
| 126 | * @return Returns the found builder. | |
| 127 | */ | |
| 128 | 1656 | public Builder getBuilder() |
| 129 | { | |
| 130 | 1656 | return builder; |
| 131 | } | |
| 132 | ||
| 133 | /** | |
| 134 | * @return Tells whether fallback on view name was preformed during builder search. | |
| 135 | */ | |
| 136 | 230 | public boolean fallbackPerformed() |
| 137 | { | |
| 138 | 230 | return !originalView.equals(actualView); |
| 139 | } | |
| 140 | } | |
| 141 | } |
|
||||||||||