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

org.apache.turbine.services.pull.util.SessionData Maven / Gradle / Ivy

Go to download

Turbine is a servlet based framework that allows experienced Java developers to quickly build secure web applications. Parts of Turbine can also be used independently of the web portion of Turbine as well. In other words, we strive to make portions of Turbine easily available for use in other applications.

There is a newer version: 6.0
Show newest version
package org.apache.turbine.services.pull.util;


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */


import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.turbine.services.pull.ApplicationTool;

/**
 * Pull tool designed to be used in the session scope for storage of
 * temporary data.  This tool should eliminate the need for the
 * {@link org.apache.turbine.om.security.User#setTemp} and
 * {@link org.apache.turbine.om.security.User#getTemp} methods.
 *
 * @author Quinton McCombs
 * @version $Id: SessionData.java 1706239 2015-10-01 13:18:35Z tv $
 */
public class SessionData implements ApplicationTool
{
    /** Storage of user defined data */
    private Map dataStorage;

    /**
     * Initialize the application tool.
     *
     * @param data initialization data
     */
    @Override
    public void init(Object data)
    {
        dataStorage = new HashMap();
    }

    /**
     * Refresh the application tool.
     */
    @Override
    public void refresh()
    {
        // do nothing
    }

    /**
     * Gets the data stored under the key.  Null will be returned if the
     * key does not exist or if null was stored under the key.
     * 

* To check for a key with a null value use {@link #containsKey}. * * @param key key under which the data is stored. * @return Object stored under the key. */ public Object get(String key) { return dataStorage.get(key); } /** * Determines is a given key is stored. * * @param key the key to check for * @return true if the key was found */ public boolean containsKey(String key) { return dataStorage.containsKey(key); } /** * Stores the data. If the key already exists, the value will be * overwritten. * * @param key key under which the data will be stored. * @param value data to store under the key. Null values are allowed. */ public void put(String key, Object value) { dataStorage.put(key, value); } /** * Clears all data */ public void clear() { dataStorage.clear(); } /** * Gets a iterator for the keys. * * @return Iterator for the keys */ public Iterator iterator() { return dataStorage.keySet().iterator(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy