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/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs Sleep.java
Date Thu, 14 Feb 2002 11:17:25 GMT
donaldp     02/02/14 03:17:25

  Added:       proposal/myrmidon/src/java/org/apache/antlib/build
                        SleepTask.java Resources.properties
  Removed:     proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
                        Sleep.java
  Log:
  Moved sleep task into antlib hierarchy and i18n'ed task
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/build/SleepTask.java
  
  Index: SleepTask.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.antlib.build;
  
  import org.apache.avalon.excalibur.i18n.ResourceManager;
  import org.apache.avalon.excalibur.i18n.Resources;
  import org.apache.myrmidon.api.AbstractTask;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   * A task to sleep for a period of time
   *
   * @author steve_l@iseran.com steve loughran
   * @created 01 May 2001
   */
  public class SleepTask
      extends AbstractTask
  {
      private final static Resources REZ =
          ResourceManager.getPackageResources( SleepTask.class );
  
      private int m_seconds;
      private int m_hours;
      private int m_minutes;
      private int m_milliseconds;
  
      /**
       * Sets the Hours attribute of the Sleep object
       */
      public void setHours( final int hours )
      {
          m_hours = hours;
      }
  
      /**
       * Sets the Milliseconds attribute of the Sleep object
       */
      public void setMilliseconds( final int milliseconds )
      {
          m_milliseconds = milliseconds;
      }
  
      /**
       * Sets the Minutes attribute of the Sleep object
       */
      public void setMinutes( final int minutes )
      {
          m_minutes = minutes;
      }
  
      /**
       * Sets the Seconds attribute of the Sleep object
       */
      public void setSeconds( final int seconds )
      {
          m_seconds = seconds;
      }
  
      /**
       * sleep for a period of time
       *
       * @param millis time to sleep
       */
      private void doSleep( final long millis )
      {
          try
          {
              Thread.currentThread().sleep( millis );
          }
          catch( InterruptedException ie )
          {
          }
      }
  
      /**
       * Executes this build task. throws org.apache.tools.ant.TaskException if
       * there is an error during task execution.
       *
       * @exception TaskException Description of Exception
       */
      public void execute()
          throws TaskException
      {
          validate();
          final long sleepTime = getSleepTime();
  
          final String message = REZ.getString( "sleep.duration.notice", new Long( sleepTime
) );
          getLogger().debug( message );
  
          doSleep( sleepTime );
      }
  
      /**
       * verify parameters
       *
       * @throws TaskException if something is invalid
       */
      private void validate()
          throws TaskException
      {
          if( getSleepTime() < 0 )
          {
              final String message = REZ.getString( "sleep.neg-time.error" );
              throw new TaskException( message );
          }
      }
  
      /**
       * return time to sleep
       *
       * @return sleep time. if below 0 then there is an error
       */
      private long getSleepTime()
      {
          return ( ( ( (long)m_hours * 60 ) + m_minutes ) * 60 + m_seconds ) * 1000 + m_milliseconds;
      }
  }
  
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/build/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  sleep.duration.notice=Sleeping for {0} milliseconds.
  sleep.neg-time.error=Negative sleep periods are not supported.
  
  patch.missing-file.error=Patchfile argument is required.
  patch.file-noexist.error=Patchfile "{0}" doesn\'t exist.
  patch.neg-strip.error=Strip has to be >= 0
  
  
  

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