class StreamSource implements Serializable {

  public boolean validate ( ) {
    if (isValidated==true)
      return validationResult;
    windowingType = DEFAULT_WINDOW_TYPE;
    isValidated=true;
    if (samplingRate <=0 ) 
      logger.warn("The sampling rate is set to zero (or negative) which means no results. StreamSource = " + getAlias( ));
    else if(samplingRate > 1){
    	samplingRate = 1;
    	logger.warn("The provided sampling rate is greater than 1, resetting it to 1. StreamSource = " + getAlias( ));
    }
    if (getAddressing().length==0) {
      logger.warn("Validation failed because there is no addressing predicates provided for the stream source (the addressing part of the stream source is empty) stream source alias = "+getAlias());
      return validationResult=false;
    }
    if ( this.rawHistorySize != null ) {
      this.rawHistorySize = this.rawHistorySize.replace( " " , "" ).trim( ).toLowerCase( );
      if ( this.rawHistorySize.equalsIgnoreCase( "" ) ) return validationResult = true;
      final int second = 1000;
      final int minute = second * 60;
      final int hour = minute * 60;
      final int mIndex = this.rawHistorySize.indexOf( "m" );
      final int hIndex = this.rawHistorySize.indexOf( "h" );
      final int sIndex = this.rawHistorySize.indexOf( "s" );
      if ( mIndex < 0 && hIndex < 0 && sIndex < 0 ) {
        try {
          this.parsedStorageSize = Long.parseLong(this.rawHistorySize );
          this.isStorageCountBased = true;
          windowingType = WindowType.TUPLE_BASED;
        } catch ( final NumberFormatException e ) {
          logger.error( "The storage size, " + this.rawHistorySize + ", specified for the Stream Source : " + this.getAlias( ) + " is not valid.", e );
          return (validationResult= false);
        }
      } else
        try {
          final StringBuilder shs = new StringBuilder( this.rawHistorySize );
          if ( mIndex >= 0 && mIndex == shs.length() - 1) this.parsedStorageSize = Long.parseLong(shs.deleteCharAt( mIndex ).toString( ) ) * minute;
          else if ( hIndex >= 0 && hIndex == shs.length() - 1) this.parsedStorageSize = Long.parseLong( shs.deleteCharAt( hIndex ).toString( ) ) * hour;
          else if ( sIndex >= 0 && sIndex == shs.length() - 1) this.parsedStorageSize = Long.parseLong( shs.deleteCharAt( sIndex ).toString( ) ) * second;
          else Long.parseLong("");
          this.isStorageCountBased = false;
          windowingType = WindowType.TIME_BASED;
        } catch ( NumberFormatException e ) {
          logger.error("The storage size, "+rawHistorySize+", specified for the Stream Source : "+this.getAlias()+" is not valid: "+ e.getMessage());
          return (validationResult=false);
        }
    }
    //Parsing slide value
    if(this.rawSlideValue == null){
    	//If slide value was not specified by the user, consider it as 1 tuple
    	windowingType = (windowingType == WindowType.TUPLE_BASED) ? WindowType.TUPLE_BASED_SLIDE_ON_EACH_TUPLE : WindowType.TIME_BASED_SLIDE_ON_EACH_TUPLE;
    	return validationResult = true;
    } else {
    	this.rawSlideValue = this.rawSlideValue.replace( " " , "" ).trim( ).toLowerCase( );
    	//If slide value was not specified by the user, consider it as 1 tuple    	
        if ( this.rawSlideValue.equalsIgnoreCase( "" ) ){
        	windowingType = (windowingType == WindowType.TUPLE_BASED) ? WindowType.TUPLE_BASED_SLIDE_ON_EACH_TUPLE : WindowType.TIME_BASED_SLIDE_ON_EACH_TUPLE;
        	return validationResult = true;
        }
        final int second = 1000;
        final int minute = second * 60;
        final int hour = minute * 60;
        final int mIndex = this.rawSlideValue.indexOf( "m" );
        final int hIndex = this.rawSlideValue.indexOf( "h" );
        final int sIndex = this.rawSlideValue.indexOf( "s" );
        if ( mIndex < 0 && hIndex < 0 && sIndex < 0 ) {
          try {
            this.parsedSlideValue = Long.parseLong( this.rawSlideValue );
            if(parsedSlideValue == 1){//We consider this as a special case
            	windowingType = (windowingType == WindowType.TIME_BASED) ? WindowType.TIME_BASED_SLIDE_ON_EACH_TUPLE : WindowType.TUPLE_BASED_SLIDE_ON_EACH_TUPLE;
            }
            else if(windowingType == WindowType.TIME_BASED)
            	windowingType = WindowType.TIME_BASED_WIN_TUPLE_BASED_SLIDE;
          } catch ( final NumberFormatException e ) {
            logger.error("The slide value, " + rawSlideValue + ", specified for the Stream Source : " + getAlias() + " is not valid.", e );
            return (validationResult= false);
          }
        } else
          try {
            final StringBuilder shs = new StringBuilder( this.rawSlideValue );
            if ( mIndex >= 0 && mIndex == shs.length() - 1) this.parsedSlideValue = Long.parseLong( shs.deleteCharAt( mIndex ).toString( ) ) * minute;
            else if ( hIndex >= 0 && hIndex == shs.length() - 1) this.parsedSlideValue = Long.parseLong( shs.deleteCharAt( hIndex ).toString( ) ) * hour;
            else if ( sIndex >= 0 && sIndex == shs.length() - 1) this.parsedSlideValue = Long.parseLong( shs.deleteCharAt( sIndex ).toString( ) ) * second;
            else Long.parseLong("");
            if(windowingType == WindowType.TUPLE_BASED)
            	windowingType = WindowType.TUPLE_BASED_WIN_TIME_BASED_SLIDE;
          } catch ( NumberFormatException e ) {
            logger.error("The slide value, "+rawSlideValue+", specified for the Stream Source : "+getAlias()+" is not valid: "+e.getMessage());
            return (validationResult=false);
          }
    }
    return validationResult=true;
  }

  public  StreamSource();

}