Coverage Report - org.apache.tapestry.IScriptProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
IScriptProcessor
N/A
N/A
1
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry;
 16  
 
 17  
 import org.apache.hivemind.Resource;
 18  
 
 19  
 /**
 20  
  * Defines methods needed by a {@link org.apache.tapestry.IScript}to execute.
 21  
  * 
 22  
  * @author Howard Lewis Ship
 23  
  * @since 3.0
 24  
  * @see org.apache.tapestry.html.Body
 25  
  */
 26  
 
 27  
 public interface IScriptProcessor
 28  
 {
 29  
     /**
 30  
      * Adds scripting code to the main body. During the render, multiple scripts may render multiple
 31  
      * bodies; all are concatinated together to form a single block. The
 32  
      * {@link org.apache.tapestry.html.Body} component will write the body script contents
 33  
      * just inside the <code>&lt;body&gt;</code> tag.
 34  
      * 
 35  
      * @deprecated To be removed sometime after 4.1.
 36  
      * @see {@link #addBodyScript(IComponent, String)}
 37  
      */
 38  
 
 39  
     void addBodyScript(String script);
 40  
 
 41  
     /**
 42  
      * Adds scripting code to the main body. During the render, multiple scripts may render multiple
 43  
      * bodies; all are concatinated together to form a single block. The
 44  
      * {@link org.apache.tapestry.html.Body}&nbsp;component will write the body script contents
 45  
      * just inside the <code>&lt;body&gt;</code> tag.
 46  
      * 
 47  
      * @param target
 48  
      *          The component this script is being added for.
 49  
      * @param script
 50  
      *          The script to add to the body response.
 51  
      */
 52  
     void addBodyScript(IComponent target, String script);
 53  
     
 54  
     /**
 55  
      * Adds initialization script. Initialization script is executed once, when the containing page
 56  
      * loads. Initialization script content is written only after all HTML content that could be
 57  
      * referenced from the script (in effect, just before the <code>&lt/body&gt;</code> tag).
 58  
      * 
 59  
      * @deprecated To be removed sometime after 4.1.
 60  
      * @see {@link #addInitializationScript(IComponent, String)}
 61  
      */
 62  
     void addInitializationScript(String script);
 63  
 
 64  
     /**
 65  
      * Adds initialization script. Initialization script is executed once, when the containing page
 66  
      * loads. Initialization script content is written only after all HTML content that could be
 67  
      * referenced from the script (in effect, just before the <code>&lt/body&gt;</code> tag).
 68  
      * 
 69  
      * @param target
 70  
      *          The component the script is being added for.
 71  
      * @param script
 72  
      *          The script to add.
 73  
      */
 74  
     void addInitializationScript(IComponent target, String script);
 75  
 
 76  
     /**
 77  
      * Works in the same way as {@link #addInitializationScript(IComponent, String)} - except this
 78  
      * method causes the script being added to appear <em>after</em> all of the script content written out
 79  
      * from the normal initialization script processing happens.  This is useful if you have some initialization
 80  
      * script logic that absolutely must happen at the very end of the rest of things.
 81  
      *
 82  
      * @see {@link #addInitializationScript(IComponent, String)}.
 83  
      * 
 84  
      * @param target
 85  
      *          The component the script is being added for.
 86  
      * @param script
 87  
      *          The script to add.
 88  
      */
 89  
     void addScriptAfterInitialization(IComponent target, String script);
 90  
 
 91  
     /**
 92  
      * Adds an external script. The processor is expected to ensure that external scripts are only
 93  
      * loaded a single time per page.
 94  
      * 
 95  
      * @deprecated To be removed sometime after 4.1
 96  
      * @see {@link #addExternalScript(IComponent, Resource)}
 97  
      */
 98  
 
 99  
     void addExternalScript(Resource resource);
 100  
 
 101  
     /**
 102  
      * Adds an external script. The processor is expected to ensure that external scripts are only
 103  
      * loaded a single time per page. The target will be checked to filter the scripts
 104  
      * added for those types of responses that require them.
 105  
      * 
 106  
      * @param target
 107  
      *          The component the script is being added for.
 108  
      * @param resource
 109  
      *          The external script to add.
 110  
      */
 111  
     void addExternalScript(IComponent target, Resource resource);
 112  
     
 113  
     /**
 114  
      * Determines if the specified component should have its javascript 
 115  
      * body added to the response.
 116  
      * 
 117  
      * @param target
 118  
      *          The component to allow/disallow body script content from.
 119  
      * @return True if the component script should be allowed.
 120  
      */
 121  
     boolean isBodyScriptAllowed(IComponent target);
 122  
     
 123  
     /**
 124  
      * Determines if the specified component should have its javascript 
 125  
      * initialization added to the response.
 126  
      * 
 127  
      * @param target
 128  
      *          The component to allow/disallow initialization script content from.
 129  
      * @return True if the component script should be allowed.
 130  
      */
 131  
     boolean isInitializationScriptAllowed(IComponent target);
 132  
     
 133  
     /**
 134  
      * Determines if the specified component should have its javascript 
 135  
      * external resource scripts added to the response.
 136  
      * 
 137  
      * @param target
 138  
      *          The component to check for inclusion/exclusion.
 139  
      * @return True if external scripts from this component should be added to
 140  
      *          the response.
 141  
      */
 142  
     boolean isExternalScriptAllowed(IComponent target);
 143  
     
 144  
     /**
 145  
      * Ensures that the given string is unique. The string is either returned unchanged, or a suffix
 146  
      * is appended to ensure uniqueness.
 147  
      */
 148  
 
 149  
     String getUniqueString(String baseValue);
 150  
 }