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/container/src/java/org/apache/myrmidon/interfaces/property Resolvable.java
Date Thu, 11 Jul 2002 05:37:43 GMT
donaldp     2002/07/10 22:37:43

  Added:       container/src/java/org/apache/myrmidon/components/property
                        ResolvingMap.java
               container/src/java/org/apache/myrmidon/interfaces/property
                        Resolvable.java
  Log:
  Add in start of support for resolving values prior to moving computers ...
  
  Revision  Changes    Path
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/property/ResolvingMap.java
  
  Index: ResolvingMap.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.myrmidon.components.property;
  
  import java.util.Map;
  import java.util.Set;
  import java.util.Collection;
  import java.util.Collections;
  import org.apache.myrmidon.interfaces.property.Resolvable;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.api.TaskContext;
  
  /**
   * An adapting map that is read only and resolves values
   * that come out of it.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/07/11 05:37:43 $
   */
  class ResolvingMap
      implements Map
  {
      private final Map m_data;
  
      private Set m_keySet;
      private Collection m_values;
      private Set m_entrySet;
  
      ResolvingMap( final Map data )
      {
          m_data = data;
      }
  
      public int size()
      {
          return m_data.size();
      }
  
      public boolean isEmpty()
      {
          return m_data.isEmpty();
      }
  
      public boolean containsKey( final Object key )
      {
          return m_data.containsKey( key );
      }
  
      public boolean containsValue( final Object value )
      {
          return m_data.containsValue( value );
      }
  
      public Object get( final Object key )
      {
          final Object value = m_data.get( key );
          if( value instanceof Resolvable )
          {
              try
              {
                  ( (Resolvable)value ).resolve();
              }
              catch( final TaskException te )
              {
                  //TODO: we should be logging here
                  return null;
              }
          }
          return value;
      }
  
      public Object put( final Object key, final Object value )
      {
          throw new UnsupportedOperationException();
      }
  
      public Object remove( final Object key )
      {
          throw new UnsupportedOperationException();
      }
  
      public void putAll( final Map t )
      {
          throw new UnsupportedOperationException();
      }
  
      public void clear()
      {
          throw new UnsupportedOperationException();
      }
  
      public Set keySet()
      {
          if( null == m_keySet )
          {
              m_keySet = Collections.unmodifiableSet( m_data.keySet() );
          }
          return m_keySet;
      }
  
      public Collection values()
      {
          if( null == m_values )
          {
              m_values = Collections.unmodifiableCollection( m_data.values() );
          }
          return m_values;
      }
  
      public Set entrySet()
      {
          if( null == m_entrySet )
          {
              m_entrySet = Collections.unmodifiableSet( m_data.entrySet() );
          }
          return m_entrySet;
      }
  }
  
  
  
  1.1                  jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/interfaces/property/Resolvable.java
  
  Index: Resolvable.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.myrmidon.interfaces.property;
  
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * The interface which data items implement if they need to be
   * "resolved" prior to being returned from PropertyStore.
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/07/11 05:37:43 $
   */
  public interface Resolvable
  {
      /**
       * Resolve a value.
       *
       * @throws TaskException if an error occurs
       */
      void resolve()
          throws TaskException;
  }
  
  
  

--
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