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 javax.servlet.ServletRequest;
022:
023: /**
024: * <p>
025: * This abstract base class acts as a service that exposes state information to a
026: * data grid.
027: * </p>
028: * <p>
029: * Implementations of the DataGridStateCodec should be request scoped and are not
030: * meant to be serialized. Implementations can hold references to the {@link ServletRequest}.
031: * In order to maintain a data grid's state across a request in a Java object,
032: * the {@link DataGridState} object should be used.
033: * </p>
034: */
035: public abstract class DataGridStateCodec {
036:
037: private ServletRequest _request;
038: private String _gridName;
039:
040: /**
041: * Set the {@link ServletRequest}. The ServletRequest can be used by implementations to
042: * discover information contained in request URL or searched for request attributes.
043: *
044: * @param request the current request
045: */
046: public void setServletRequest(ServletRequest request) {
047: _request = request;
048: }
049:
050: /**
051: * Get the current servlet request with which this DataGridStateCodec is associated.
052: *
053: * @return the {@link ServletRequest}
054: */
055: public ServletRequest getServletRequest() {
056: return _request;
057: }
058:
059: /**
060: * Set the data grid name with which this DataGridStateCodec is associated.
061: *
062: * @param gridName the data grid's name
063: */
064: public void setGridName(String gridName) {
065: _gridName = gridName;
066: }
067:
068: /**
069: * Get the data grid name with which this DataGridStateCodec is associated.
070: *
071: * @return the data grid's name
072: */
073: public String getGridName() {
074: return _gridName;
075: }
076:
077: /**
078: * Get the {@link DataGridState} for a data grid. This object contains the state
079: * which the data grid will use during rendering.
080: *
081: * @return the current {@link DataGridState} object
082: */
083: public abstract DataGridState getDataGridState();
084:
085: /**
086: * Set the @{link DataGridState} object. This allows a client to apply a prior
087: * {@link DataGridState} object in order to explicitly set the data grid's state
088: * to a previously create set of objects.
089: *
090: * @param state the new {@link DataGridState}
091: */
092: public abstract void setDataGridState(DataGridState state);
093:
094: /**
095: * Get a {@link DataGridURLBuilder} which can build be used to build URLs for
096: * a data grid's current state.
097: *
098: * @return the {@link DataGridURLBuilder} for the data grid's state
099: */
100: public abstract DataGridURLBuilder getDataGridURLBuilder();
101: }
|