📄 memorynamingenumeration.java
字号:
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.avalon.excalibur.naming.memory;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.NoSuchElementException;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.NameClassPair;
import javax.naming.NamingException;
import org.apache.avalon.excalibur.naming.AbstractNamingEnumeration;
import org.apache.avalon.excalibur.naming.Namespace;
/**
* Class for building NamingEnumerations.
*
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @version $Revision: 1.2 $
*/
final class MemoryNamingEnumeration
extends AbstractNamingEnumeration
{
protected Hashtable m_bindings;
protected Iterator m_names;
protected boolean m_returnBindings;
public MemoryNamingEnumeration( final Context owner,
final Namespace namespace,
final Hashtable bindings,
final boolean returnBindings )
{
super( owner, namespace );
m_returnBindings = returnBindings;
m_bindings = bindings;
m_names = m_bindings.keySet().iterator();
}
public boolean hasMoreElements()
{
return m_names.hasNext();
}
public Object next()
throws NamingException
{
if( !hasMore() ) throw new NoSuchElementException();
final String name = (String)m_names.next();
Object object = m_bindings.get( name );
if( !m_returnBindings )
{
return new NameClassPair( name, object.getClass().getName() );
}
else
{
return new Binding( name, resolve( name, object ) );
}
}
public void close()
{
super.close();
m_bindings = null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -