org.basex.core.cmd
Class CreateDB

java.lang.Object
  extended by org.basex.core.Progress
      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
 
Fields inherited from class org.basex.core.Progress
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.
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.
 void setParser(Parser p)
          Attaches a parser.
 
Methods inherited from class org.basex.core.cmd.ACreate
newData, stoppable, supportsProg
 
Methods inherited from class org.basex.core.Command
execute, execute, info, result, run, run, setInput, setInput, toString, updated, updating
 
Methods inherited from class org.basex.core.Progress
checkStop, detail, listen, progress, startTimeout, stop, stopTimeout, title
 
Methods inherited from class java.lang.Object
equals, 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

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.

Parameters:
cb - command builder