Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

oracle.ide.net
Class DefaultNameGenerator

java.lang.Object
  extended by oracle.ide.net.DefaultNameGenerator
All Implemented Interfaces:
NameGenerator

public class DefaultNameGenerator
extends java.lang.Object
implements NameGenerator

Default implementation of the NameGenerator interface used when generating new unique URLs from URLFactory. This implementation supports producing a name by incrementing a counter that is appended to the name before its suffix.


Constructor Summary
DefaultNameGenerator(java.lang.String name, java.lang.String suffix)
          Creates a new DefaultNameGenerator that generates names by inserting a numerical index between the specified name and suffix.
DefaultNameGenerator(java.lang.String name, java.lang.String suffix, int initialIndex)
          Creates a new DefaultNameGenerator that generates names by inserting a numerical index between the specified name and suffix.
 
Method Summary
protected  java.lang.String getName()
          Called by nextName() to get the starting fixed portion of the name.
protected  java.lang.String getSuffix()
          Called by nextName() to get the ending fixed portion of the name.
protected  int nextIndex()
          Returns the next index.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNameGenerator

public DefaultNameGenerator(java.lang.String name,
                            java.lang.String suffix)
Creates a new DefaultNameGenerator that generates names by inserting a numerical index between the specified name and suffix. The starting index is 1.


DefaultNameGenerator

public DefaultNameGenerator(java.lang.String name,
                            java.lang.String suffix,
                            int initialIndex)
Creates a new DefaultNameGenerator that generates names by inserting a numerical index between the specified name and suffix. The starting index is the specified initialIndex. The initial index is allowed to be 0. If the initial index is less than 0, then the first name is generated without an index, and the next name is generated with index 1 (not 0).

Method Detail

nextName

public java.lang.String nextName()
Description copied from interface: NameGenerator
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.

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 URLuniqueness is not documented and should be considered an implementation detail of the IDE framework. For an example of a NameGenerator implementation, see DefaultNameGenerator.

Specified by:
nextName in interface NameGenerator

getName

protected java.lang.String getName()
Called by nextName() to get the starting fixed portion of the name.


getSuffix

protected java.lang.String getSuffix()
Called by nextName() to get the ending fixed portion of the name.


nextIndex

protected int nextIndex()
Returns the next index. This method does not repeat an index unless all integers are exhausted. If the current index is less than 0, then -1 is returned and the next index is set to 1. Otherwise, the current index is returned, and the index is incremented.


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

Copyright © 1997, 2010, Oracle. All rights reserved.