org.basex.core.cmd
Class CreateDB

java.lang.Object
  extended by org.basex.core.Proc
      extended by org.basex.core.Command
          extended by org.basex.core.cmd.ACreate
              extended by org.basex.core.cmd.CreateDB

public final class CreateDB
extends ACreate

Evaluates the 'create db' command and creates a new database.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Field Summary
 
Fields inherited from class org.basex.core.Command
args, context, in, mprop, out, perf, prop
 
Fields inherited from class org.basex.core.Proc
listen, updating
 
Constructor Summary
CreateDB(java.lang.String name)
          Default constructor.
CreateDB(java.lang.String name, java.lang.String input)
          Constructor, specifying an initial database input.
 
Method Summary
 void build(CmdBuilder cb)
          Builds a string representation from the command.
static Data create(IO source, boolean single, Context ctx)
          Creates a new database if a valid path was specified.
static Data create(java.lang.String name, Parser parser, Context ctx)
          Returns a database instance from the specified parser.
 void databases(LockResult lr)
          Adds the names of the databases that may be touched by the process.
static MemData mainMem(IO source, Context ctx)
          Returns a main memory database instance for the specified input reference.
static MemData mainMem(Parser parser, Context ctx)
          Returns a main memory database instance from the specified parser.
protected  boolean run()
          Executes the command and serializes the result (internal call).
 void setParser(Parser p)
          Attaches a parser.
 
Methods inherited from class org.basex.core.cmd.ACreate
create, drop, newData, sourceToIO, stoppable, supportsProg
 
Methods inherited from class org.basex.core.Command
close, databases, error, execute, execute, getOption, getOption, info, info, result, run, run, setInput, setInput, toString, updated, updating
 
Methods inherited from class org.basex.core.Proc
abort, checkStop, det, detail, listen, proc, prog, progress, registered, registered, startTimeout, stop, stopTimeout, tit, title
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CreateDB

public CreateDB(java.lang.String name)
Default constructor. Input can be set via Command.setInput(InputStream).

Parameters:
name - name of database

CreateDB

public CreateDB(java.lang.String name,
                java.lang.String input)
Constructor, specifying an initial database input.

Parameters:
name - name of database
input - input reference (local/remote file or XML string)
Method Detail

setParser

public void setParser(Parser p)
Attaches a parser.

Parameters:
p - input parser

run

protected boolean run()
Description copied from class: Command
Executes the command and serializes the result (internal call).

Specified by:
run in class Command
Returns:
success of operation

databases

public void databases(LockResult lr)
Description copied from class: Proc
Adds the names of the databases that may be touched by the process.

Overrides:
databases in class ACreate
Parameters:
lr - Container for lock result to pass around

create

public static Data create(java.lang.String name,
                          Parser parser,
                          Context ctx)
                   throws java.io.IOException
Returns a database instance from the specified parser.

Parameters:
name - name of the database
parser - input parser
ctx - database context
Returns:
new database instance
Throws:
java.io.IOException - I/O exception

mainMem

public static MemData mainMem(Parser parser,
                              Context ctx)
                       throws java.io.IOException
Returns a main memory database instance from the specified parser.

Parameters:
parser - input parser
ctx - database context
Returns:
new database instance
Throws:
java.io.IOException - I/O exception

mainMem

public static MemData mainMem(IO source,
                              Context ctx)
                       throws java.io.IOException
Returns a main memory database instance for the specified input reference.

Parameters:
source - document source
ctx - database context
Returns:
new database instance
Throws:
java.io.IOException - I/O exception

create

public static Data create(IO source,
                          boolean single,
                          Context ctx)
                   throws java.io.IOException
Creates a new database if a valid path was specified.

Parameters:
source - document source
single - expect single document
ctx - database context
Returns:
data reference
Throws:
java.io.IOException - I/O exception

build

public void build(CmdBuilder cb)
Description copied from class: Command
Builds a string representation from the command. This string must be correctly built, as commands are sent to the server as strings.

Overrides:
build in class Command
Parameters:
cb - command builder