?? baseportletinfoentry.java
字號:
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed 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.
*/
package org.apache.jetspeed.om.registry.base;
import org.apache.jetspeed.om.registry.*;
import java.util.Vector;
import java.util.Map;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Enumeration;
/**
* The BasePortletInfoEntry is a bean like implementation of the PortletInfoEntry
* interface suitable for Castor XML serialization
*
* @see org.apache.jetspeed.om.registry.PortletInfoEntry
* @author <a href="mailto:raphael@apache.org">Rapha雔 Luta</a>
* @version $Id: BasePortletInfoEntry.java,v 1.9 2004/03/29 19:28:24 jford Exp $
*/
public abstract class BasePortletInfoEntry extends BaseRegistryEntry
{
protected String classname;
protected Vector parameter = new Vector();
protected transient Map nameIdx = null;
protected Vector medias = new Vector();
protected transient Map mediasIdx = null;
protected Vector tools = new Vector();
protected transient Map toolsIdx = null;
/**
* Implements the equals operation so that 2 elements are equal if
* all their member values are equal.
*/
public boolean equals(Object object)
{
if (object==null)
{
return false;
}
BasePortletInfoEntry obj = (BasePortletInfoEntry)object;
if (classname!=null)
{
if (!classname.equals(obj.getClassname()))
{
return false;
}
}
else
{
if (obj.getClassname()!=null)
{
return false;
}
}
Iterator i = parameter.iterator();
Iterator i2 = obj.getParameters().iterator();
while(i.hasNext())
{
BaseParameter p1 = (BaseParameter)i.next();
BaseParameter p2 = null;
if (i2.hasNext())
{
p2 = (BaseParameter)i2.next();
}
else
{
return false;
}
if (!p1.equals(p2))
{
return false;
}
}
if (i2.hasNext())
{
return false;
}
i = medias.iterator();
i2 = obj.getMediaTypes().iterator();
while(i.hasNext())
{
BaseMediaType m1 = (BaseMediaType)i.next();
BaseMediaType m2 = null;
if (i2.hasNext())
{
m2 = (BaseMediaType)i2.next();
}
else
{
return false;
}
if (!m1.equals(m2))
{
return false;
}
}
if (i2.hasNext())
{
return false;
}
i = tools.iterator();
i2 = obj.getTools().iterator();
while(i.hasNext())
{
BaseToolDescriptor t1 = (BaseToolDescriptor)i.next();
BaseToolDescriptor t2 = null;
if (i2.hasNext())
{
t2 = (BaseToolDescriptor)i2.next();
}
else
{
return false;
}
if (!t1.equals(t2))
{
return false;
}
}
if (i2.hasNext())
{
return false;
}
return super.equals(object);
}
/** @return the classname associated to this entry */
public String getClassname()
{
return this.classname;
}
/** Sets the classname for this entry. This classname is used for instanciating
* the associated element
*
* @param classname the classname used for instanciating the component associated with
* this entry
*/
public void setClassname( String classname )
{
this.classname = classname;
}
/** @return an enumeration of this entry parameter names */
public Iterator getParameterNames()
{
synchronized (parameter)
{
if (nameIdx == null)
{
buildNameIndex();
}
}
return nameIdx.keySet().iterator();
}
/** Search for a named parameter and return the associated
* parameter object. The search is case sensitive.
*
* @return the parameter object for a given parameter name
* @param name the parameter name to look for
*/
public Parameter getParameter( String name )
{
synchronized (parameter)
{
if (nameIdx == null)
{
buildNameIndex();
}
}
if (name != null)
{
Integer pos = (Integer)nameIdx.get(name);
if (pos != null)
{
return (Parameter)parameter.elementAt(pos.intValue());
}
}
return null;
}
/** Returns a map of parameter values keyed on the parameter names
* @return the parameter values map
*/
public Map getParameterMap()
{
Hashtable params = new Hashtable();
Enumeration en = parameter.elements();
while(en.hasMoreElements())
{
Parameter param = (Parameter)en.nextElement();
String key = param.getName();
String value = param.getValue();
if(key != null && value != null)
{
params.put(key, value);
}
}
return params;
}
/** Adds a new parameter for this entry
* @param name the new parameter name
* @param value the new parameter value
*/
public void addParameter( String name, String value )
{
if (name != null)
{
Parameter p = getParameter(name);
if (p == null)
{
if (this instanceof PortletEntry)
p = new BaseCachedParameter();
else
p = new BaseParameter();
p.setName(name);
}
p.setValue(value);
addParameter(p);
}
}
/** Adds a new parameter for this entry
* @param parameter the new parameter to add
*/
public void addParameter( Parameter param )
{
synchronized (parameter)
{
if (parameter == null)
parameter = new Vector();
if (nameIdx == null)
buildNameIndex();
parameter.addElement( param );
nameIdx.put( param.getName(), new Integer( parameter.size()-1 ) );
}
}
/** Removes all parameter values associated with the
* name
*
* @param name the parameter name to remove
*/
public void removeParameter( String name )
{
if (name == null) return;
synchronized (parameter)
{
Iterator i = parameter.iterator();
while(i.hasNext())
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -