Package org.apache.hc.core5.util
Class Timeout
java.lang.Object
org.apache.hc.core5.util.TimeValue
org.apache.hc.core5.util.Timeout
- All Implemented Interfaces:
Comparable<TimeValue>
Represents a timeout value as a non-negative
long time and TimeUnit.- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimeoutA disabled timeout represented as 0MILLISECONDS.static final TimeoutA one millisecondsTimeout.static final TimeoutA zero millisecondsTimeout.Fields inherited from class org.apache.hc.core5.util.TimeValue
INT_UNDEFINED, MAX_VALUE, NEG_ONE_MILLISECOND, NEG_ONE_SECOND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeoutdefaultsToDisabled(Timeout timeout) booleanWhether this timeout is disabled.booleanWhether this timeout is enabled.static TimeoutCreates a Timeout.static TimeoutCreates a Timeout from a Duration.static TimeoutofDays(long days) Creates a Timeout.static TimeoutofHours(long hours) Creates a Timeout.static TimeoutofMicroseconds(long microseconds) Creates a Timeout.static TimeoutofMilliseconds(long milliseconds) Creates a Timeout.static TimeoutofMinutes(long minutes) Creates a Timeout.static TimeoutofNanoseconds(long nanoseconds) Creates a Timeout.static TimeoutofSeconds(long seconds) Creates a Timeout.static TimeoutParses a Timeout in the format<Integer><SPACE><TimeUnit>, for example"1,200 MILLISECONDS"Methods inherited from class org.apache.hc.core5.util.TimeValue
asBoundInt, compareTo, convert, defaultsTo, defaultsToNegativeOneMillisecond, defaultsToNegativeOneSecond, defaultsToZeroMilliseconds, divide, divide, equals, getDuration, getTimeUnit, hashCode, isNonNegative, isPositive, min, sleep, timedJoin, timedWait, toChronoUnit, toDays, toDuration, toHours, toMicroseconds, toMilliseconds, toMillisecondsIntBound, toMinutes, toNanoseconds, toSeconds, toSecondsIntBound, toString, toTimeout
-
Field Details
-
Constructor Details
-
Timeout
Timeout(long duration, TimeUnit timeUnit)
-
-
Method Details
-
defaultsToDisabled
- Parameters:
timeout- may benull- Returns:
timeValueorDISABLED
-
of
Creates a Timeout from a Duration.- Parameters:
duration- the time duration.- Returns:
- a Timeout.
- Since:
- 5.2
-
of
Creates a Timeout.- Parameters:
duration- the time duration.timeUnit- the time unit for the given duration.- Returns:
- a Timeout
-
ofDays
Creates a Timeout.- Parameters:
days- the duration in days and the giventimeUnit.- Returns:
- a Timeout
-
ofHours
Creates a Timeout.- Parameters:
hours- the duration in hours and the giventimeUnit.- Returns:
- a Timeout
-
ofMicroseconds
Creates a Timeout.- Parameters:
microseconds- the duration in seconds and the giventimeUnit.- Returns:
- a Timeout
-
ofMilliseconds
Creates a Timeout.- Parameters:
milliseconds- the duration in milliseconds and the giventimeUnit.- Returns:
- a Timeout
-
ofMinutes
Creates a Timeout.- Parameters:
minutes- the duration in minutes and the giventimeUnit.- Returns:
- a Timeout
-
ofNanoseconds
Creates a Timeout.- Parameters:
nanoseconds- the duration in seconds and the giventimeUnit.- Returns:
- a Timeout
-
ofSeconds
Creates a Timeout.- Parameters:
seconds- the duration in seconds and the giventimeUnit.- Returns:
- a Timeout
-
parse
Parses a Timeout in the format<Integer><SPACE><TimeUnit>, for example"1,200 MILLISECONDS"- Parameters:
value- the TimeValue to parse- Returns:
- a new TimeValue
- Throws:
ParseException- if the number cannot be parsed
-
isDisabled
public boolean isDisabled()Whether this timeout is disabled.- Returns:
- Whether this timeout is disabled.
-
isEnabled
public boolean isEnabled()Whether this timeout is enabled.- Returns:
- Whether this timeout is disabled.
-