org.exist.fluent
Class Name

java.lang.Object
  extended by org.exist.fluent.Name

public abstract class Name
extends Object

An actual or virtual name for a document, augmented with instructions for processing in case of duplication.

Author:
Piotr Kaminski

Method Summary
static Name adjust(String name)
          Try to use the given name but, if it conflicts with anything in the destination folder, add a random component that will make it unique.
static Name create(String name)
          Use the given name that is believed to be unique.
static Name generate()
          Generate a random name that will not conflict with anything else in the destination folder.
static Name generate(String suffix)
          Generate a random name with the given suffix that will not conflict with anything else in the destination folder.
 String get()
          Get the computed value of this name.
static Name keepAdjust()
          Keep the existing name of the source item if it is unique in the destination folder, otherwise adjust it as per the rules of adjust(String).
static Name keepCreate()
          Keep the existing name of the source item, believed to be unique in the destination folder.
static Name keepOverwrite()
          Keep the existing name of the source item, overwriting any document with the same name in the destination folder as per the rules for overwrite(String).
static Name overwrite(String name)
          Use the given name whether it is unique or not.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public String get()
Get the computed value of this name. Once computed, the value is cached.

Returns:
the value of this name

toString

public String toString()
Overrides:
toString in class Object

generate

public static Name generate()
Generate a random name that will not conflict with anything else in the destination folder.

Returns:
a random name unique within the target folder

generate

public static Name generate(String suffix)
Generate a random name with the given suffix that will not conflict with anything else in the destination folder.

Parameters:
suffix - the string to append to the random name, e.g. ".xml"
Returns:
a random name unique within the target folder and ending with the given suffix

keepAdjust

public static Name keepAdjust()
Keep the existing name of the source item if it is unique in the destination folder, otherwise adjust it as per the rules of adjust(String).

Returns:
the existing name if unique, otherwise a unique variation of the existing name

adjust

public static Name adjust(String name)
Try to use the given name but, if it conflicts with anything in the destination folder, add a random component that will make it unique. If a random component needs to be added, it is inserted between the main part of the name and its dotted suffix, separated by a '$' sign. (If the name has no suffix, the random component is simply appended to the name.) If the given name already has a random component in the format described (perhaps resulting from a previous 'adjustment'), it is first removed before a new one is selected.

Parameters:
name - the desired name
Returns:
if the given name is unique, the name; otherwise, a unique variation on the given name

keepOverwrite

public static Name keepOverwrite()
Keep the existing name of the source item, overwriting any document with the same name in the destination folder as per the rules for overwrite(String).

Returns:
the existing name that will be used whether it's unique or not

overwrite

public static Name overwrite(String name)
Use the given name whether it is unique or not. If the name is already used for another document in the destination folder, that document will be overwritten. If the name is already used for a child folder of the destination folder, the folder will not be affected and the operation will throw an exception.

Parameters:
name - the desired name
Returns:
the desired name that will be used whether it's unique or not

keepCreate

public static Name keepCreate()
Keep the existing name of the source item, believed to be unique in the destination folder. The name follows the rules given in create(String).

Returns:
the existing name, with a stipulation that any operation using it will fail if it's a duplicate

create

public static Name create(String name)
Use the given name that is believed to be unique. If the given name is already used in the destination folder, the existing owner of the name will not be affected and the operation will throw an exception.

Parameters:
name - the desired name believed to be unique
Returns:
the desired name, with a stipulation that any operation using it will fail if it's a duplicate


Copyright (C) All rights reserved.