public final class ConnectionRelativeTime extends Object implements RelativeTimeConstraint, Serializable
Socket
-based communication, the intention is that this
constraint controls the timeout parameter of the
connect
method.
The duration is translated into an absolute end time at the point of a remote call by adding the caller's current time.
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID |
private long |
time
The maximum connection duration in milliseconds.
|
Constructor and Description |
---|
ConnectionRelativeTime(long time)
Creates a constraint with the specified duration.
|
Modifier and Type | Method and Description |
---|---|
private static long |
add(long dur,
long time) |
boolean |
equals(Object obj)
Two instances of this class are equal if both have the same duration.
|
long |
getTime()
Returns the maximum connection duration in milliseconds.
|
int |
hashCode()
Returns a hash code value for this object.
|
InvocationConstraint |
makeAbsolute(long baseTime)
Returns a
ConnectionAbsoluteTime instance with time obtained
by adding the specified base time argument to the duration value
from this instance. |
private void |
readObject(ObjectInputStream s)
Verifies that
time is greater than or equal to zero. |
String |
toString()
Returns a string representation of this object.
|
private static final long serialVersionUID
private final long time
public ConnectionRelativeTime(long time)
time
- the maximum connection duration in millisecondsIllegalArgumentException
- if the argument is less than zeropublic long getTime()
public InvocationConstraint makeAbsolute(long baseTime)
ConnectionAbsoluteTime
instance with time obtained
by adding the specified base time argument to the duration value
from this instance. If the addition results in overflow, a time value
of Long.MAX_VALUE
is used.makeAbsolute
in interface RelativeTimeConstraint
baseTime
- an absolute time, specified in milliseconds from
midnight, January 1, 1970 UTCprivate static long add(long dur, long time)
public int hashCode()
public boolean equals(Object obj)
public String toString()
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
time
is greater than or equal to zero.InvalidObjectException
- if time
is less than zeroIOException
ClassNotFoundException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.