001 // Copyright 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.record; 016 017 import org.apache.tapestry.IRequestCycle; 018 import org.apache.tapestry.engine.ServiceEncoding; 019 020 /** 021 * Service tapestry.persist.ClientPropertyPersistenceScope. Determines whether a particular property 022 * needs to be persisted or not. 023 * 024 * @author Mindbridge 025 * @since 4.0 026 * @see org.apache.tapestry.record.ClientPropertyPersistenceStrategy 027 */ 028 public interface ClientPropertyPersistenceScope 029 { 030 /** 031 * Determines whether state should be encoded for the request. 032 * 033 * @param encoding 034 * identifies the service, URL and base set of parameters 035 * @param cycle 036 * current request 037 * @param pageName 038 * the page for which data is potentially to be encoded 039 * @param data 040 * @return true if state should be encoded into the encoding, false otherwise 041 */ 042 043 public boolean shouldEncodeState(ServiceEncoding encoding, IRequestCycle cycle, 044 String pageName, PersistentPropertyData data); 045 046 /** 047 * Constructs a parameter name for a particular page name. The parameter name can be recognized 048 * (in a later request) by the {@link #isParameterForScope(String)} method. 049 * 050 * @param pageName 051 * the name of the page for which a corresponding parameter name should be generated. 052 * @returns a query parameter name that identifies the page and this client persistence scope. 053 */ 054 055 public String constructParameterName(String pageName); 056 057 /** 058 * Checks a parameter to see if it was the result of {@link #constructParameterName(String)} for 059 * this persistence scope. 060 * 061 * @param parameterName 062 * a query parameter name 063 * @return true if the parameterName was genereted (i.e., is properly prefixed) by this scope, 064 * false otherwise. 065 */ 066 067 public boolean isParameterForScope(String parameterName); 068 069 /** 070 * Extracts a page name from a query parameter name. 071 * 072 * @param parameterName 073 * the paramter name, for which {@link #isParameterForScope(String) must return true 074 * @return the name of the page 075 */ 076 public String extractPageName(String parameterName); 077 }