162 lines
4.5 KiB
Java
162 lines
4.5 KiB
Java
/*
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
|
* (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.mozilla.org/MPL/>.
|
|
*
|
|
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
|
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
|
* language governing rights and limitations under the License.
|
|
*
|
|
* The Original Code is the Venice Web Communities System.
|
|
*
|
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
|
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
*/
|
|
package com.silverwrist.venice.servlets;
|
|
|
|
import java.util.*;
|
|
import javax.servlet.*;
|
|
import javax.servlet.http.*;
|
|
import com.silverwrist.venice.core.ConferenceContext;
|
|
|
|
public class TopicSortHolder
|
|
{
|
|
/*--------------------------------------------------------------------------------
|
|
* Internal class for holding view and sort options
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
static class SortHolderItem
|
|
{
|
|
int view_opt;
|
|
int sort_opt;
|
|
|
|
SortHolderItem(int view_opt, int sort_opt)
|
|
{
|
|
this.view_opt = view_opt;
|
|
this.sort_opt = sort_opt;
|
|
|
|
} // end constructor
|
|
|
|
int getViewOption()
|
|
{
|
|
return view_opt;
|
|
|
|
} // end getViewOption
|
|
|
|
void setViewOption(int val)
|
|
{
|
|
view_opt = val;
|
|
|
|
} // end setViewOption
|
|
|
|
int getSortOption()
|
|
{
|
|
return sort_opt;
|
|
|
|
} // end getSortOption
|
|
|
|
void setSortOption(int val)
|
|
{
|
|
sort_opt = val;
|
|
|
|
} // end setSortOption
|
|
|
|
} // end class SortHolderItem
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Static data members
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
protected static final String ATTRIBUTE = "conf.display.topic.sort";
|
|
protected static final int DEFAULT_VIEW = ConferenceContext.DISPLAY_ACTIVE;
|
|
protected static final int DEFAULT_SORT = ConferenceContext.SORT_NUMBER;
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Attributes
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
private Hashtable hash = new Hashtable();
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Constructor
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
protected TopicSortHolder()
|
|
{ // this does nothing
|
|
} // end constructor
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* Internal functions
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
private SortHolderItem getItem(int confid)
|
|
{
|
|
Integer the_confid = new Integer(confid);
|
|
SortHolderItem item = (SortHolderItem)(hash.get(the_confid));
|
|
if (item==null)
|
|
{ // create a new item...
|
|
item = new SortHolderItem(DEFAULT_VIEW,DEFAULT_SORT);
|
|
hash.put(the_confid,item);
|
|
|
|
} // end if
|
|
|
|
return item;
|
|
|
|
} // end getItem
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* External static operations
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public static TopicSortHolder retrieve(HttpSession session)
|
|
{
|
|
Object tmp = session.getAttribute(ATTRIBUTE);
|
|
if (tmp!=null)
|
|
return (TopicSortHolder)tmp;
|
|
|
|
TopicSortHolder rc = new TopicSortHolder();
|
|
session.setAttribute(ATTRIBUTE,rc);
|
|
return rc;
|
|
|
|
} // end retrieve
|
|
|
|
/*--------------------------------------------------------------------------------
|
|
* External operations
|
|
*--------------------------------------------------------------------------------
|
|
*/
|
|
|
|
public int getViewOption(int confid)
|
|
{
|
|
return getItem(confid).getViewOption();
|
|
|
|
} // end getViewOption
|
|
|
|
public void setViewOption(int confid, int opt)
|
|
{
|
|
getItem(confid).setViewOption(opt);
|
|
|
|
} // end setViewOption
|
|
|
|
public int getSortOption(int confid)
|
|
{
|
|
return getItem(confid).getSortOption();
|
|
|
|
} // end getSortOption
|
|
|
|
public void setSortOption(int confid, int opt)
|
|
{
|
|
getItem(confid).setSortOption(opt);
|
|
|
|
} // end setSortOption
|
|
|
|
} // end class TopicSortHolder
|