ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess DemuxProperties.java
Date Fri, 26 Apr 2002 02:43:14 GMT
donaldp     02/04/25 19:43:14

  Added:       aut/src/java/org/apache/aut/jprocess DemuxProperties.java
  Log:
  Add in a properties object that fowards
  requests to a thread specific proeprties
  object.
  
  Revision  Changes    Path
  1.1                  jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess/DemuxProperties.java
  
  Index: DemuxProperties.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.aut.jprocess;
  
  import java.io.PrintStream;
  import java.io.PrintWriter;
  import java.util.Enumeration;
  import java.util.Properties;
  
  /**
   * Access to this Properties object is forwarded to a
   * properties that has been associated with this thread.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/04/26 02:43:14 $
   */
  final class DemuxProperties
      extends Properties
  {
      /**
       * The properties objects associated with each thread.
       */
      private final InheritableThreadLocal m_properties =
          new InheritableThreadLocal();
  
      public DemuxProperties( final Properties defaults )
      {
          super( defaults );
      }
  
      /**
       * Bind the specified Properties object to the current thread.
       *
       * @param properties the Properties object to bind
       */
      public void bindProperties( final Properties properties )
      {
          m_properties.set( properties );
      }
  
      public Object get( final Object key )
      {
          final Properties properties = getProperties();
          return properties.get( key );
      }
  
      public Object put( final Object key,
                         final Object value )
      {
          final Properties properties = getProperties();
          return properties.put( key, value );
      }
  
      public Object remove( final Object key )
      {
          final Properties properties = getProperties();
          return properties.remove( key );
      }
  
      public final int size()
      {
          final Properties properties = getProperties();
          return properties.size();
      }
  
      public final boolean isEmpty()
      {
          final Properties properties = getProperties();
          return properties.isEmpty();
      }
  
      public Enumeration keys()
      {
          final Properties properties = getProperties();
          return properties.keys();
      }
  
      public Enumeration elements()
      {
          final Properties properties = getProperties();
          return properties.keys();
      }
  
      public boolean contains( final Object value )
      {
          final Properties properties = getProperties();
          return properties.contains( value );
      }
  
      public boolean containsKey( final Object key )
      {
          final Properties properties = getProperties();
          return properties.containsKey( key );
      }
  
      public void clear()
      {
          final Properties properties = getProperties();
          properties.clear();
      }
  
      public Object clone()
      {
          final Properties properties = getProperties();
          return properties.clone();
      }
  
      public String toString()
      {
          final Properties properties = getProperties();
          return properties.toString();
      }
  
      public final String getProperty( final String key )
      {
          final Properties properties = getProperties();
          return properties.getProperty( key );
      }
  
      public final Enumeration propertyNames()
      {
          final Properties properties = getProperties();
          return properties.propertyNames();
      }
  
      public final void list( final PrintStream out )
      {
          final Properties properties = getProperties();
          properties.list( out );
      }
  
      public final void list( final PrintWriter out )
      {
          final Properties properties = getProperties();
          properties.list( out );
      }
  
      /**
       * Utility method to retrieve properties bound to current thread (if any).
       */
      private Properties getProperties()
      {
          final Properties properties = (Properties)m_properties.get();
          if( null != properties )
          {
              return properties;
          }
          else
          {
              return defaults;
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message