Top Description Fields Constructors Methods
org.apache.hc.core5.util

public Class Timeout

extends TimeValue
Class Inheritance
Annotations
@Contract
threading:IMMUTABLE
Imports
java.text.ParseException, java.time.Duration, java.util.concurrent.TimeUnit, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior

Represents a timeout value as a non-negative long time and TimeUnit.
Since
5.0

Field Summary

Modifier and TypeField and Description
public static final Timeout
DISABLED

A disabled timeout represented as 0 MILLISECONDS.

public static final Timeout
ONE_MILLISECOND

A one milliseconds Timeout.

public static final Timeout
Inherited from org.apache.hc.core5.util.TimeValue:
INT_UNDEFINEDMAX_VALUENEG_ONE_MILLISECONDNEG_ONE_SECOND

Constructor Summary

AccessConstructor and Description
pack-priv
Timeout(final long duration, final TimeUnit timeUnit)

Method Summary

Modifier and TypeMethod and Description
public static Timeout

Returns:

timeValue or DISABLED
defaultsToDisabled
(final Timeout
may be null
timeout
)

Returns the given timeout if it is not null, if null then returns DISABLED.

public boolean

Returns:

Whether this timeout is disabled.
isDisabled
()

Whether this timeout is disabled.

public boolean

Returns:

Whether this timeout is disabled.
isEnabled
()

Whether this timeout is enabled.

public static Timeout

Returns:

a Timeout.
of
(final Duration
the time duration.
duration
)

Hides org.apache.hc.core5.util.TimeValue.of.

Creates a Timeout from a Duration.
public static Timeout

Returns:

a Timeout
of
(final long
the time duration.
duration
,
final TimeUnit
the time unit for the given duration.
timeUnit
)

Hides org.apache.hc.core5.util.TimeValue.of.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofDays
(final long
the duration in days and the given timeUnit.
days
)

Hides org.apache.hc.core5.util.TimeValue.ofDays.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofHours
(final long
the duration in hours and the given timeUnit.
hours
)

Hides org.apache.hc.core5.util.TimeValue.ofHours.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofMicroseconds
(final long
the duration in seconds and the given timeUnit.
microseconds
)

Hides org.apache.hc.core5.util.TimeValue.ofMicroseconds.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofMilliseconds
(final long
the duration in milliseconds and the given timeUnit.
milliseconds
)

Hides org.apache.hc.core5.util.TimeValue.ofMilliseconds.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofMinutes
(final long
the duration in minutes and the given timeUnit.
minutes
)

Hides org.apache.hc.core5.util.TimeValue.ofMinutes.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofNanoseconds
(final long
the duration in seconds and the given timeUnit.
nanoseconds
)

Hides org.apache.hc.core5.util.TimeValue.ofNanoseconds.

Creates a Timeout.
public static Timeout

Returns:

a Timeout
ofSeconds
(final long
the duration in seconds and the given timeUnit.
seconds
)

Hides org.apache.hc.core5.util.TimeValue.ofSeconds.

Creates a Timeout.
public static Timeout

Returns:

a new TimeValue
parse
(final String
the TimeValue to parse
value
)

Hides org.apache.hc.core5.util.TimeValue.parse.

Parses a Timeout in the format <Integer><SPACE><TimeUnit>, for example "1,200 MILLISECONDS"
Inherited from org.apache.hc.core5.util.TimeValue:
asBoundIntcompareToconvertdefaultsTodefaultsToNegativeOneMilliseconddefaultsToNegativeOneSeconddefaultsToZeroMillisecondsdividedivideequalsgetDurationgetTimeUnithashCodeisNonNegativeisPositiveminsleeptimedJointimedWaittoChronoUnittoDaystoDurationtoHourstoMicrosecondstoMillisecondstoMillisecondsIntBoundtoMinutestoNanosecondstoSecondstoSecondsIntBoundtoStringtoTimeout

Field Detail

DISABLEDback to summary
public static final Timeout DISABLED

A disabled timeout represented as 0 MILLISECONDS.

ONE_MILLISECONDback to summary
public static final Timeout ONE_MILLISECOND

A one milliseconds Timeout.

ZERO_MILLISECONDSback to summary
public static final Timeout ZERO_MILLISECONDS

Hides org.apache.hc.core5.util.TimeValue.ZERO_MILLISECONDS.

A zero milliseconds Timeout.

Constructor Detail

Timeoutback to summary
pack-priv Timeout(final long duration, final TimeUnit timeUnit)

Method Detail

defaultsToDisabledback to summary
public static Timeout defaultsToDisabled(final Timeout timeout)

Returns the given timeout if it is not null, if null then returns DISABLED.

Parameters
timeout:Timeout

may be null

Returns:Timeout

timeValue or DISABLED

isDisabledback to summary
public boolean isDisabled()

Whether this timeout is disabled.

Returns:boolean

Whether this timeout is disabled.

isEnabledback to summary
public boolean isEnabled()

Whether this timeout is enabled.

Returns:boolean

Whether this timeout is disabled.

ofback to summary
public static Timeout of(final Duration duration)

Hides org.apache.hc.core5.util.TimeValue.of.

Creates a Timeout from a Duration.

Parameters
duration:Duration

the time duration.

Returns:Timeout

a Timeout.

Since
5.2
ofback to summary
public static Timeout of(final long duration, final TimeUnit timeUnit)

Hides org.apache.hc.core5.util.TimeValue.of.

Creates a Timeout.

Parameters
duration:long

the time duration.

timeUnit:TimeUnit

the time unit for the given duration.

Returns:Timeout

a Timeout

ofDaysback to summary
public static Timeout ofDays(final long days)

Hides org.apache.hc.core5.util.TimeValue.ofDays.

Creates a Timeout.

Parameters
days:long

the duration in days and the given timeUnit.

Returns:Timeout

a Timeout

ofHoursback to summary
public static Timeout ofHours(final long hours)

Hides org.apache.hc.core5.util.TimeValue.ofHours.

Creates a Timeout.

Parameters
hours:long

the duration in hours and the given timeUnit.

Returns:Timeout

a Timeout

ofMicrosecondsback to summary
public static Timeout ofMicroseconds(final long microseconds)

Hides org.apache.hc.core5.util.TimeValue.ofMicroseconds.

Creates a Timeout.

Parameters
microseconds:long

the duration in seconds and the given timeUnit.

Returns:Timeout

a Timeout

ofMillisecondsback to summary
public static Timeout ofMilliseconds(final long milliseconds)

Hides org.apache.hc.core5.util.TimeValue.ofMilliseconds.

Creates a Timeout.

Parameters
milliseconds:long

the duration in milliseconds and the given timeUnit.

Returns:Timeout

a Timeout

ofMinutesback to summary
public static Timeout ofMinutes(final long minutes)

Hides org.apache.hc.core5.util.TimeValue.ofMinutes.

Creates a Timeout.

Parameters
minutes:long

the duration in minutes and the given timeUnit.

Returns:Timeout

a Timeout

ofNanosecondsback to summary
public static Timeout ofNanoseconds(final long nanoseconds)

Hides org.apache.hc.core5.util.TimeValue.ofNanoseconds.

Creates a Timeout.

Parameters
nanoseconds:long

the duration in seconds and the given timeUnit.

Returns:Timeout

a Timeout

ofSecondsback to summary
public static Timeout ofSeconds(final long seconds)

Hides org.apache.hc.core5.util.TimeValue.ofSeconds.

Creates a Timeout.

Parameters
seconds:long

the duration in seconds and the given timeUnit.

Returns:Timeout

a Timeout

parseback to summary
public static Timeout parse(final String value) throws ParseException

Hides org.apache.hc.core5.util.TimeValue.parse.

Parses a Timeout in the format <Integer><SPACE><TimeUnit>, for example "1,200 MILLISECONDS"

Parameters
value:String

the TimeValue to parse

Returns:Timeout

a new TimeValue

Exceptions
ParseException:
if the number cannot be parsed