All Downloads are FREE. Search and download functionalities are using the official Maven repository.

juzu.request.Dispatch Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
/*
 * Copyright 2013 eXo Platform SAS
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package juzu.request;

import juzu.PropertyMap;
import juzu.PropertyType;
import juzu.impl.common.MimeType;
import juzu.io.Encoding;

/**
 * 

The Dispatch object represents the dispatch to a controller method. It can be used for generating * URL or as a {@link juzu.Response.View} objects. A dispatch object can be obtained from a {@link juzu.request.RequestContext} * object for building controller methods, however the best way to obtain a builder is to use a controller companion * that provides a type safe way for creating fully configured dispatch.

* *

Type safe Dispatch factory method are generated for each view, action or resource controller methods. The * signature of a dispatch factory is the same as the original method.

*

*

 *    public void MyController {
 *
 *       @Action
 *       public Response.View myAction(String param) {
 *          return MyController_.myRender();
 *       }
 *
 *       @View
 *       public void myRender() {
 *          String url = MyController_.myAction("hello");
 *       }
 *    }
 * 
* * @author Julien Viet */ public interface Dispatch { Dispatch with(MimeType mimeType); Dispatch with(PropertyMap properties); Dispatch escapeXML(Boolean escapeXML); /** * Set or clear a property of the URL. * * @param propertyType the property type * @param propertyValue the property value * @param the property generic type * @return this URL builder * @throws IllegalArgumentException if the property is not valid */ Dispatch setProperty(PropertyType propertyType, T propertyValue) throws IllegalArgumentException; /** *

Set a parameter on the URL that will be built by this builder. This method replaces the parameter with the * given name . A parameter value of null indicates that this parameter should be removed.

* * @param name the parameter name * @param value the parameter value * @throws NullPointerException if the name parameter is null */ Dispatch setParameter(String name, String value) throws NullPointerException; /** *

Set a parameter on the URL that will be built by this builder. This method replaces the parameter with the * given name . A parameter value of null indicates that this parameter should be removed.

* * @param encoding the character encoding * @param name the parameter name * @param value the parameter value * @throws NullPointerException if the name parameter is null * @throws IllegalArgumentException if the encoding is not allowed */ Dispatch setParameter(Encoding encoding, String name, String value) throws NullPointerException; /** * Set a parameter. This method replaces the parameter with the given name . An zero length parameter value indicates * that this parameter should be removed. *

* The inserted value is cloned before its insertion in the map. * * @param name the parameter name * @param value the parameter value * @throws NullPointerException if the name parameter or the value parameter is null * @throws IllegalArgumentException if any component of the value is null */ Dispatch setParameter(String name, String[] value) throws NullPointerException, IllegalArgumentException; /** *

Set a parameter on the URL that will be built by this builder. This method replaces the parameter with the * given name . A parameter value of null indicates that this parameter should be removed.

* * @param encoding the character encoding * @param name the parameter name * @param value the parameter value * @throws NullPointerException if the name parameter is null * @throws IllegalArgumentException if the encoding is not allowed, if any component of the value is null */ Dispatch setParameter(Encoding encoding, String name, String[] value) throws IllegalArgumentException, NullPointerException; String toString(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy