Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: Status.java 130 2009-06-05 17:01:24Z karianna $
   * $URL: https://ikasaneip.svn.sourceforge.net/svnroot/ikasaneip/tags/ikasan-0.7.3/common/src/main/java/org/ikasan/common/component/Status.java $
   * 
   * ====================================================================
   * Ikasan Enterprise Integration Platform
   * Copyright (c) 2003-2008 Mizuho International plc. and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the 
  * Free Software Foundation Europe e.V. Talstrasse 110, 40217 Dusseldorf, Germany 
  * or see the FSF site: http://www.fsfeurope.org/.
  * ====================================================================
  */
 package org.ikasan.common.component;
 
 import java.util.Date;

Status class for setting and getting the component status at runtime.

Author(s):
Ikasan Development Team
 
 public class Status
     implements Serializable
 {
    
Serial ID
 
     private static final long serialVersionUID = -327855826132075594L;
    
    
componentState enum
 
     private final ComponentState componentState;
    
    
status last update time
 
     private final Long lastUpdateTime;

    
Creates a new instance of Spec with the specified component status and last updated time.

Parameters:
componentState
lastUpdateTime
 
     public Status(final ComponentState componentState,
                   final Long lastUpdateTime)
     {
         this. = componentState;
         this. = lastUpdateTime;
     }

    
Getter for component state

Returns:
componentState enum instance
 
     public ComponentState getComponentState()
     {
         return this.;
     }

    
Getter for status last update time

Returns:
long last update time in millis
 
     public Long getLastUpdateTime()
     {
         return this.;
     }

    
Compare instances of Status

Parameters:
status
Returns:
boolean
 
     public boolean equals(Status status)
     {
         if (status == nullreturn false;
         
         if (this..equals(status.componentState) &&
            this..equals(status.lastUpdateTime) )
             return true;
         
         return false;
     }

    
Utility method for diffing status update times.

Parameters:
status
Returns:
Long
    public Long diffLastUpdateTime(Status status)
    {
        return this. - status.lastUpdateTime
    }

    
Runs this class for test.

Parameters:
args
    public static void main(String args[])
    {
        Status currentStatus = new Status(.,
                                          new Date().getTime());
        try
        {
            Thread.sleep(1000);
        }
        catch (InterruptedException e)
        {
            ..println("Thread was woken early");
            e.printStackTrace();
        }
        
        Status futureStatus = new Status(.,
                                         new Date().getTime());
        if(currentStatus.equals(futureStatus))
            ..println("currentCS"
                             + currentStatus.toString()
                             + " EQUALS futureCS"
                             + futureStatus.toString());
        else
            ..println("CurrentCS"
                    + currentStatus.toString()
                    + " DOES NOT EQUAL futureCS"
                    + futureStatus.toString());
        ..println(futureStatus.diffLastUpdateTime(currentStatus));
        
    }
New to GrepCode? Check out our FAQ X