/* * 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 . * * 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 , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.menu; import java.util.*; public class MenuDefinition { /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ private int m_id; private String m_namespace; private String m_name; private String m_title; private String m_subtitle; private HashSet m_vars = new HashSet(); private HashMap m_defaults = new HashMap(); private ArrayList m_items = new ArrayList(); /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- */ MenuDefinition(int id, String namespace, String name, String title, String subtitle) { m_id = id; m_namespace = namespace; m_name = name; m_title = title; m_subtitle = subtitle; } // end constructor /*-------------------------------------------------------------------------------- * Internal operations *-------------------------------------------------------------------------------- */ void addVariableDef(String name, String default_val) { m_vars.add(name); if (default_val!=null) m_defaults.put(name,default_val); } // end addVariableDef void addItemDef(MenuItemDefinition item) { m_items.add(item); } // end addItemDef Map getVarDefaults() { return Collections.unmodifiableMap(m_defaults); } // end getVarDefaults /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- */ public String getNamespace() { return m_namespace; } // end getNamespace public String getName() { return m_name; } // end getName public String getTitle() { return m_title; } // end getTitle public String getSubtitle() { return m_subtitle; } // end getSubtitle public boolean isVariable(String name) { return m_vars.contains(name); } // end isVariable public int getItemCount() { return m_items.size(); } // end getItemCount public MenuItemDefinition getItem(int ndx) { return (MenuItemDefinition)(m_items.get(ndx)); } // end getItem } // end class MenuDefinition