📄 baseportletinfoentry.java
字号:
Parameter param = (Parameter)i.next();
if (param.getName().equals(name))
{
i.remove();
}
}
buildNameIndex();
}
}
/**
* Returns a list of the supported media type names
*
* @return an iterator on the supported media type names
*/
public Iterator listMediaTypes()
{
if (mediasIdx == null)
{
synchronized( medias )
{
buildMediasIndex();
}
}
return mediasIdx.keySet().iterator();
}
/**
* Test if a given media type is supported by this entry.
* The test is done by a case sensitive name comparison
*
* @param name the media type name to test for.
* @return true is the media type is supported false otherwise
*/
public boolean hasMediaType(String name)
{
if (mediasIdx == null)
{
synchronized( medias )
{
buildMediasIndex();
}
}
return ((name!=null)&&(mediasIdx.get(name)!=null));
}
/**
* Add a new supported media type
*
* @param name the media type name to add.
*/
public void addMediaType(String name)
{
if (name!=null)
{
synchronized (medias)
{
if (mediasIdx == null)
{
buildMediasIndex();
}
BaseMediaType m = new BaseMediaType();
m.setRef(name);
mediasIdx.put(name,new Integer(medias.size()));
medias.add(m);
}
}
}
/**
* Remove support for a given media type
*
* @param name the media type name to remove.
*/
public void removeMediaType(String name)
{
if (name != null)
{
synchronized (medias)
{
mediasIdx.remove(name);
BaseMediaType m = new BaseMediaType();
m.setRef(name);
Iterator i = medias.iterator();
while (i.hasNext())
{
if (i.next().equals(m))
{
i.remove();
return;
}
}
}
}
}
// Castor serialization accessor methods
/** Needed for Castor 0.8.11 XML serialization for retrieving the
* parameters objects associated to this object
*/
public Vector getParameters()
{
return this.parameter;
}
public void setParameters(Vector parameters)
{
this.parameter = parameters;
}
public void setMediaTypes(Vector mediaTypes)
{
this.medias = mediaTypes;
}
/** Needed for Castor 0.8.11 XML serialization for retrieving the
* media type names associated to this object
*/
public Vector getMediaTypes()
{
return this.medias;
}
public Vector getTools()
{
return this.tools;
}
public void setTools(Vector tools)
{
this.tools = tools;
}
/** This method recreates the paramter name index for quick retrieval
* of parameters by name. Shoule be called whenever a complete index
* of parameter should be rebuilt (eg removing a parameter or setting
* a parameters vector)
*/
protected void buildNameIndex()
{
Hashtable idx = new Hashtable();
Iterator i = parameter.iterator();
int count = 0;
while( i.hasNext() )
{
Parameter p = (Parameter)i.next();
idx.put( p.getName(), new Integer(count) );
count++;
}
this.nameIdx = idx;
}
/** This method recreates the media name index for quick retrieval
* by name.
*/
private void buildMediasIndex()
{
Hashtable idx = new Hashtable();
Iterator i = medias.iterator();
int count = 0;
while( i.hasNext() )
{
BaseMediaType b = (BaseMediaType)i.next();
idx.put( b.getRef(), new Integer(count) );
count++;
}
this.mediasIdx = idx;
}
/** @return an enumeration of this entry parameter names */
public Iterator getToolNames()
{
synchronized (tools)
{
if (toolsIdx == null)
{
buildToolsIndex();
}
}
return toolsIdx.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 ToolDescriptor getTool( String name )
{
synchronized (tools)
{
if (toolsIdx == null)
{
buildToolsIndex();
}
}
if (name != null)
{
Integer pos = (Integer)toolsIdx.get(name);
if (pos != null)
{
return (ToolDescriptor)tools.elementAt(pos.intValue());
}
}
return null;
}
/** Returns a map of parameter values keyed on the parameter names
* @return the parameter values map
*/
public Map getToolMap()
{
Hashtable map = new Hashtable();
Enumeration en = tools.elements();
while(en.hasMoreElements())
{
ToolDescriptor desc = (ToolDescriptor)en.nextElement();
map.put(desc.getName(),desc);
}
return map;
}
/** Adds a new parameter for this entry
* @param parameter the new parameter to add
*/
public void addTool( ToolDescriptor tool )
{
synchronized (tools)
{
if (tools == null)
tools = new Vector();
if (toolsIdx == null)
buildToolsIndex();
tools.addElement( tool );
toolsIdx.put( tool.getName(), new Integer( tools.size()-1 ) );
}
}
/** Removes all parameter values associated with the
* name
*
* @param name the parameter name to remove
*/
public void removeTool( String name )
{
if (name == null) return;
synchronized (tools)
{
Iterator i = tools.iterator();
while(i.hasNext())
{
ToolDescriptor tool = (ToolDescriptor)i.next();
if (tool.getName().equals(name))
{
i.remove();
}
}
buildToolsIndex();
}
}
/** This method recreates the media name index for quick retrieval
* by name.
*/
private void buildToolsIndex()
{
Hashtable idx = new Hashtable();
Iterator i = tools.iterator();
int count = 0;
while( i.hasNext() )
{
ToolDescriptor b = (ToolDescriptor)i.next();
idx.put( b.getName(), new Integer(count) );
count++;
}
this.toolsIdx = idx;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -