directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject [2/3] directory-kerby git commit: o Added Javadoc o Some slight modifications
Date Wed, 30 Dec 2015 11:28:47 GMT
o Added Javadoc
o Some slight modifications

Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/f8884fa8
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/f8884fa8
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/f8884fa8

Branch: refs/heads/trunk
Commit: f8884fa84735ed2975fd03c67d69847bd76033eb
Parents: 4d7f1cd
Author: Emmanuel L├ęcharny <elecharny@symas.com>
Authored: Wed Dec 30 12:23:39 2015 +0100
Committer: Emmanuel L├ęcharny <elecharny@symas.com>
Committed: Wed Dec 30 12:23:39 2015 +0100

----------------------------------------------------------------------
 .../kerby/kerberos/kerb/type/KerberosTime.java  | 82 ++++++++++++++------
 1 file changed, 57 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f8884fa8/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosTime.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosTime.java
b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosTime.java
index 3a78bf0..844efb9 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosTime.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/type/KerberosTime.java
@@ -19,10 +19,10 @@
  */
 package org.apache.kerby.kerberos.kerb.type;
 
-import org.apache.kerby.asn1.type.Asn1GeneralizedTime;
-
 import java.util.Date;
 
+import org.apache.kerby.asn1.type.Asn1GeneralizedTime;
+
 /**
  * A specialization of the ASN.1 GeneralTime. The Kerberos time contains date and
  * time up to the seconds, but with no fractional seconds. It's also always
@@ -67,6 +67,7 @@ public class KerberosTime extends Asn1GeneralizedTime {
     }
 
     /**
+     * Set the Kerberos time
      * @param time set time in milliseconds
      */
     public void setTime(long time) {
@@ -74,35 +75,50 @@ public class KerberosTime extends Asn1GeneralizedTime {
     }
 
     /**
-     * get the time in seconds
+     * Gets the time in seconds
+     * 
      * @return The time
      */
     public long getTimeInSeconds() {
         return getTime() / 1000;
     }
 
+    /**
+     * Compare the KerberosTime with another one, and return <tt>true</tt>
+     * if it's lesser than the provided one
+     * 
+     * @param time in milliseconds
+     * @return <tt>true</tt> if less
+     */
     public boolean lessThan(KerberosTime ktime) {
         return getValue().compareTo(ktime.getValue()) < 0;
     }
 
     /**
+     * Compare the KerberosTime with a time, and return <tt>true</tt>
+     * if it's lesser than the provided one
+     * 
      * @param time in milliseconds
-     * @return true if less
+     * @return <tt>true</tt> if less
      */
     public boolean lessThan(long time) {
         return getValue().getTime() < time;
     }
 
     /**
+     * Compare the KerberosTime with another one, and return <tt>true</tt>
+     * if it's greater than the provided one
+     * 
      * @param ktime compare with milliseconds
-     * @return true if greater
+     * @return <tt>true</tt> if greater
      */
     public boolean greaterThan(KerberosTime ktime) {
         return getValue().compareTo(ktime.getValue()) > 0;
     }
 
     /**
-     * time in milliseconds
+     * Check if the KerberosTime is within the provided clock skew
+     * 
      * @param clockSkew The clock skew
      * @return true if in clock skew
      */
@@ -112,49 +128,65 @@ public class KerberosTime extends Asn1GeneralizedTime {
         return delta < clockSkew;
     }
 
+    /**
+     * @return A copy of the KerbeorsTime
+     */
     public KerberosTime copy() {
         long time = getTime();
+        
         return new KerberosTime(time);
     }
 
     /**
-     * time in milliseconds.
+     * Create a KerberosTime based on a time in milliseconds.
+     * 
      * @param duration The duration
-     * @return The kerberos time
+     * @return The created kerberos time
      */
     public KerberosTime extend(long duration) {
         long result = getTime() + duration;
+        
         return new KerberosTime(result);
     }
 
     /**
-     * Return diff time in milliseconds
-     * @param other The kerberos time
-     * @return The diff time
+     * Return the difference between the currentKerberosTime and the provided one
+     * 
+     * @param kerberosTime The kerberos time
+     * @return The difference between the two KerberosTime
      */
-    public long diff(KerberosTime other) {
-        return getTime() - other.getTime();
+    public long diff(KerberosTime kerberosTime) {
+        return getTime() - kerberosTime.getTime();
     }
 
+    /**
+     * @return The current KerberosTime
+     */
     public static KerberosTime now() {
-        return new KerberosTime(new Date().getTime());
+        return new KerberosTime(System.currentTimeMillis());
     }
 
+    /**
+     * @see Object#hashCode()
+     */
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public int hashCode() {
+        return getValue().hashCode();
+    }
+    
+    /**
+     * @see Object#equals()
+     */
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
             return true;
         }
-        if (o == null || getClass() != o.getClass()) {
+        
+        if (!(that instanceof KerberosTime)) {
             return false;
         }
-
-        KerberosTime time = (KerberosTime) o;
-        return this.getValue().equals(time.getValue());
-    }
-
-    @Override
-    public int hashCode() {
-        return getValue().hashCode();
+        
+        return this.getValue().equals(((KerberosTime) that).getValue());
     }
 }
\ No newline at end of file


Mime
View raw message