001 package org.apache.myfaces.tobago.context; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020 021 import javax.faces.component.StateHolder; 022 import javax.faces.context.FacesContext; 023 import java.io.Serializable; 024 025 /* 026 * Date: May 3, 2007 027 * Time: 5:44:04 PM 028 */ 029 public class TransientStateHolder implements StateHolder, Serializable { 030 private static final long serialVersionUID = -5260593843885016768L; 031 private transient Object object; 032 033 034 public TransientStateHolder(Object object) { 035 this.object = object; 036 } 037 038 public Object saveState(FacesContext context) { 039 // do nothing 040 return null; 041 } 042 043 public void put(Object object) { 044 this.object = object; 045 } 046 047 public boolean isEmpty() { 048 return object == null; 049 } 050 051 public Object get() { 052 return object; 053 } 054 055 public void restoreState(FacesContext context, Object state) { 056 // do nothing 057 } 058 059 060 public boolean isTransient() { 061 return true; 062 } 063 064 public void setTransient(boolean newTransientValue) { 065 // do nothing 066 } 067 }