Top Description Fields Constructors Methods
org.apache.sshd.common.random

public Class SingletonRandomFactory

extends AbstractRandom
implements RandomFactory
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.random.RandomFactory, org.apache.sshd.common.BuiltinFactory, org.apache.sshd.common.OptionalFeature, org.apache.sshd.common.NamedFactory, org.apache.sshd.common.NamedResource, org.apache.sshd.common.Factory, java.util.function.Supplier
Imports
java.util.Objects, org.apache.sshd.common.NamedFactory, .OptionalFeature

A random factory wrapper that uses a single random instance. The underlying random instance has to be thread safe.
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final NamedFactory<Random>
private final Random

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Random
public void
fill(byte[]
byte array to be filled.
bytes
,
int
index to start filling at.
start
,
int
length of segment to fill.
len
)

Implements org.apache.sshd.common.random.Random.fill.

Fill part of bytes with random values.

public String
public boolean
public int
random(int
The range upper limit
max
)

Implements org.apache.sshd.common.random.Random.random.

Returns a pseudo-random uniformly distributed int in the half-open range [0, n).

Inherited from org.apache.sshd.common.random.AbstractRandom:
toString

Field Detail

factoryback to summary
private final NamedFactory<Random> factory
randomback to summary
private final Random random

Constructor Detail

SingletonRandomFactoryback to summary
public SingletonRandomFactory(NamedFactory<Random> factory)

Method Detail

createback to summary
public Random create()

Implements org.apache.sshd.common.Factory.create.

Returns:Random

Doc from org.apache.sshd.common.Factory.create.

A new instance

Annotations
@Override
fillback to summary
public void fill(byte[] bytes, int start, int len)

Implements org.apache.sshd.common.random.Random.fill.

Doc from org.apache.sshd.common.random.Random.fill.

Fill part of bytes with random values.

Parameters
bytes:byte[]

byte array to be filled.

start:int

index to start filling at.

len:int

length of segment to fill.

Annotations
@Override
getNameback to summary
public String getName()

Implements org.apache.sshd.common.NamedResource.getName.

Returns:String

Doc from org.apache.sshd.common.NamedResource.getName.

The resource name

Annotations
@Override
isSupportedback to summary
public boolean isSupported()

Implements org.apache.sshd.common.OptionalFeature.isSupported.

Annotations
@Override
randomback to summary
public int random(int max)

Implements org.apache.sshd.common.random.Random.random.

Doc from org.apache.sshd.common.random.Random.random.

Returns a pseudo-random uniformly distributed int in the half-open range [0, n).

Parameters
max:int

The range upper limit

Returns:int

The randomly selected value in the range

Annotations
@Override