bloritsch 02/03/13 06:41:00
Added: src/scratchpad/org/apache/avalon/excalibur/system/util
OverridableContext.java
Log:
add overridable context
Revision Changes Path
1.1
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/OverridableContext.java
Index: OverridableContext.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.txt file.
*/
package org.apache.avalon.excalibur.system.util;
import org.apache.avalon.framework.context.*;
/**
* The OverridableContext allows you to "null" out entries, even if they are
* in a parent context.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/03/13 14:41:00 $
* @since 4.1
*/
public final class OverridableContext extends DefaultContext
{
private final Null m_null = new Null();
public OverridableContext()
{
super();
}
public OverridableContext( Context parent )
{
super( parent );
}
public Object get( String key )
throws ContextException
{
Object value = super.get( key );
if ( m_null.equals( value ) )
{
throw new ContextException("Could not return value for " + key);
}
return value;
}
public void put( String key, Object value )
{
super.put( key, (value == null) ? new Null() : value );
}
private final static class Null
{
public boolean equals( Object other )
{
return other instanceof Null;
}
public int hashcode()
{
return 0;
}
public String toString()
{
return "null";
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>