/** * For logging and debugging the element IElementAttributes. * <p> * @return String info about the values. */ @Override public String toString() { StringBuilder dump = new StringBuilder(); dump.append( "[ IS_LATERAL = " ).append( IS_LATERAL ); dump.append( ", IS_SPOOL = " ).append( IS_SPOOL ); dump.append( ", IS_REMOTE = " ).append( IS_REMOTE ); dump.append( ", IS_ETERNAL = " ).append( IS_ETERNAL ); dump.append( ", MaxLifeSeconds = " ).append( this.getMaxLife() ); dump.append( ", IdleTime = " ).append( this.getIdleTime() ); dump.append( ", CreateTime = " ).append( this.getCreateTime() ); dump.append( ", LastAccessTime = " ).append( this.getLastAccessTime() ); dump.append( ", getTimeToLiveSeconds() = " ).append( String.valueOf( getTimeToLiveSeconds() ) ); dump.append( ", createTime = " ).append( String.valueOf( createTime ) ).append( " ]" ); return dump.toString(); }
/** * Gets the time left to live of the IAttributes object. * <p> * This is the (max life + create time) - current time. * @return The TimeToLiveSeconds value */ @Override public long getTimeToLiveSeconds() { final long now = System.currentTimeMillis(); final long timeFactorForMilliseconds = getTimeFactorForMilliseconds(); return ( this.getCreateTime() + this.getMaxLife() * timeFactorForMilliseconds - now ) / 1000; }
/** * Gets the time left to live of the IAttributes object. * <p> * This is the (max life + create time) - current time. * @return The TimeToLiveSeconds value */ @Override public long getTimeToLiveSeconds() { final long now = System.currentTimeMillis(); final long timeFactorForMilliseconds = getTimeFactorForMilliseconds(); return ( this.getCreateTime() + this.getMaxLife() * timeFactorForMilliseconds - now ) / 1000; }
/** * For logging and debugging the element IElementAttributes. * <p> * @return String info about the values. */ @Override public String toString() { StringBuilder dump = new StringBuilder(); dump.append( "[ IS_LATERAL = " ).append( IS_LATERAL ); dump.append( ", IS_SPOOL = " ).append( IS_SPOOL ); dump.append( ", IS_REMOTE = " ).append( IS_REMOTE ); dump.append( ", IS_ETERNAL = " ).append( IS_ETERNAL ); dump.append( ", MaxLifeSeconds = " ).append( this.getMaxLife() ); dump.append( ", IdleTime = " ).append( this.getIdleTime() ); dump.append( ", CreateTime = " ).append( this.getCreateTime() ); dump.append( ", LastAccessTime = " ).append( this.getLastAccessTime() ); dump.append( ", getTimeToLiveSeconds() = " ).append( String.valueOf( getTimeToLiveSeconds() ) ); dump.append( ", createTime = " ).append( String.valueOf( createTime ) ).append( " ]" ); return dump.toString(); } }
/** * Test that cloned ElementAttributes have different creation times. * @throws Exception */ public void testElementAttributesCreationTime() throws Exception { ElementAttributes elem1 = new ElementAttributes(); long ctime1 = elem1.getCreateTime(); Thread.sleep(10); IElementAttributes elem2 = elem1.clone(); long ctime2 = elem2.getCreateTime(); assertFalse("Creation times should be different", ctime1 == ctime2); }