public interface NameGenerator
URLFactory
while it is in the process of producing a new unique
URL
.Modifier and Type | Method and Description |
---|---|
java.lang.String |
nextName()
This method is called by
URLFactory from one of its
newUniqueURL(...) methods to obtain a relative
file name, which is usually just a simple file name without any
preceeding directory names, that will be used in the process of
generating a unique URL . |
java.lang.String nextName()
URLFactory
from one of its
newUniqueURL(...)
methods to obtain a relative
file name, which is usually just a simple file name without any
preceeding directory names, that will be used in the process of
generating a unique URL
.
The URLFactory
is responsible for assembling a complete
URL
by combining a base URL
with the
relative file name returned by nextName()
. The
URLFactory
is also responsible for checking that the
newly created URL
is unique among files on disk
and within the IDE's caches. If the new URL
is not
unique, then URLFactory
will issue another call to
nextName()
to get a new name. This process is
repeated until either a unique URL
is produced, or
the URLFactory
"times out" on the
NameGenerator
implementation after a very large
number of iterations fails to produce a unique URL
.
Therefore to interact properly with URLFactory
, the
nextName()
implementation must return a different
name each time it is invoked. More specifically, a particular
instance of NameGenerator
should not return any
name more than once from its nextName()
method.
Of course, this restriction does not apply across different
instances of NameGenerator
.
The exact means by which a new name is produced is not specified
and is left to the specific NameGenerator
classes.
However, the nextName()
method should not attempt to
create an URL
and check for its uniqueness, as this
may lead to problems in the future when the URLFactory
and
URLFileSystem
classes are enhanced. For example, if
individual NameGenerator
implementations are
attempting to determine uniqueness, bugs may surface later if the
IDE's algorithm for determining uniqueness changes. How the IDE
determines URL
uniqueness is not documented and should
be considered an implementation detail of the IDE framework.
For an example of a NameGenerator
implementation,
see DefaultNameGenerator
.