001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.databinding.datagrid.api;
020:
021: import java.util.Map;
022:
023: /**
024: * <p>
025: * This abstract class provides methods that are used to build maps of URL parameters
026: * containing current ahd future data grid state. These are useful for building
027: * anchors and other kinds of requests that when clicked / submitted can move to
028: * the next or previous page of data or change the state of sorts or filters for
029: * a data grid.
030: * </p>
031: * <p>
032: * Subclasses are free to implement the contents of the parameter map with whatever
033: * parameter key / values that make sense for a particular data grid. For example,
034: * some data grids may encode sort, filter, and paging information in the URL. Others
035: * may add information about row selection and not add sort / filter parameters. Be
036: * sure to check the documentation for a specific DataGridURLBuilder subclass to
037: * find out what specific parameters are available in the parameter maps.
038: * </p>
039: * <p>
040: * Parameter maps produced by methods on this class should contain key / value pairs
041: * where the key is of type <code>String</code> and the values are of type
042: * <code>String[]</code>. The parameter maps should also include all of the
043: * additional "current" URL parameters in order to maintain the "current" view
044: * state and modifying only state associated with a single data grid. Subclasses are
045: * free to change this behavior.
046: * </p>
047: */
048: public abstract class DataGridURLBuilder {
049:
050: /**
051: * Get a {@link Map} containing the current state of the data grid.
052: * @return the parameter map
053: */
054: public abstract Map getQueryParams();
055:
056: /**
057: * Get a parameter map that contains the grid's current state with a
058: * value that will set the current to the first page.
059: *
060: * @return the parameter map
061: */
062: public abstract Map getQueryParamsForFirstPage();
063:
064: /**
065: * Get a parameter map that contains the grid's current state with a
066: * value that will set the current page to the previous page.
067: *
068: * @return the parameter map
069: */
070: public abstract Map getQueryParamsForPreviousPage();
071:
072: /**
073: * Get a parameter map that contains the grid's current state with a
074: * value that will set the current page to the next page.
075: *
076: * @return the parameter map
077: */
078: public abstract Map getQueryParamsForNextPage();
079:
080: /**
081: * Get a parameter map that contains the grid's current state with a
082: * value that will set the current page to the last page.
083: *
084: * @return the parameter map
085: */
086: public abstract Map getQueryParamsForLastPage();
087:
088: /**
089: * Get a String array that contains the values which can be used to
090: * reach any page in the data grid.
091: *
092: * @return an array of the query parameter values for each page
093: */
094: public abstract String[] getPagerParamValues();
095:
096: /**
097: * Get the String for the pager query parameter key.
098: *
099: * @return the query parameter key for accessing the current page from the URL
100: */
101: public abstract String getPagerRowQueryParamKey();
102:
103: /**
104: * Get a parameter map that contains the grid's current state with the
105: * sort matching the given <code>sortExpression</code> switched to the
106: * next available sort direction.
107: *
108: * @param sortExpression the sort expression whose sort value to change
109: * @return the parameter map
110: */
111: public abstract Map buildSortQueryParamsMap(String sortExpression);
112: }
|