org.basex.core
Class Context

java.lang.Object
  extended by org.basex.core.Context

public final class Context
extends java.lang.Object

This class serves as a central database context. It references the currently opened database, properties, client sessions, users and other meta data. Next, the instance of this class will be passed on to all operations, as it organizes concurrent data access, ensuring that no process will concurrently write to the same data instances.

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

Field Summary
 ClientBlocker blocker
          Blocked clients.
 Nodes copied
          Copied nodes.
 Databases databases
          Databases list.
 Datas dbs
          Opened databases.
 Events events
          Event pool.
 int focused
          Focused node.
 ClientListener listener
          Client listener.
 Log log
          Log.
 Nodes marked
          Marked nodes.
 MainProp mprop
          Main properties.
 Prop prop
          Client-related properties.
 Repo repo
          Package repository.
 Sessions sessions
          Client connections.
 User user
          User reference.
 Users users
          Users.
 
Constructor Summary
Context()
          Default constructor, which is usually called once in the lifetime of a project.
Context(boolean file)
          Default constructor, which is usually called once in the lifetime of a project.
Context(Context ctx, ClientListener cl)
          Constructor, called by clients, and adopting the variables of the main process.
 
Method Summary
 void close()
          Closes the database context.
 void closeDB()
          Closes the current database context.
 Nodes current()
          Returns the current node context.
 void current(Nodes curr)
          Sets the current node context.
 Data data()
          Returns the current data reference.
 void downgrade(Proc pr, StringList write)
          Downgrades locks.
 void openDB(Data d)
          Sets the specified data instance as current database.
 boolean perm(Perm p, MetaData md)
          Checks if the current user has the specified permission.
 boolean pinned(java.lang.String db)
          Checks if the specified database is pinned.
 void register(Proc pr)
          Locks the specified process and starts a timeout thread.
 boolean root()
          Returns true if a data reference exists and if the current node set contains all documents.
 void set(Nodes curr, Nodes mark)
          Sets the current context and marked node set and resets the focus.
 void unregister(Proc pr)
          Unlocks the process and stops the timeout.
 void update()
          Invalidates the current node set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

public final ClientListener listener
Client listener. Set to null in standalone/server mode.


blocker

public final ClientBlocker blocker
Blocked clients.


prop

public final Prop prop
Client-related properties.


mprop

public final MainProp mprop
Main properties.


sessions

public final Sessions sessions
Client connections.


events

public final Events events
Event pool.


dbs

public final Datas dbs
Opened databases.


users

public final Users users
Users.


repo

public final Repo repo
Package repository.


databases

public final Databases databases
Databases list.


user

public User user
User reference.


log

public final Log log
Log.


marked

public Nodes marked
Marked nodes.


copied

public Nodes copied
Copied nodes.


focused

public int focused
Focused node.

Constructor Detail

Context

public Context()
Default constructor, which is usually called once in the lifetime of a project.


Context

public Context(boolean file)
Default constructor, which is usually called once in the lifetime of a project.

Parameters:
file - retrieve properties from disk

Context

public Context(Context ctx,
               ClientListener cl)
Constructor, called by clients, and adopting the variables of the main process. The user reference must be set after calling this method.

Parameters:
ctx - context of the main process
cl - client listener
Method Detail

close

public void close()
Closes the database context. Should only be called from the main context instance.


root

public boolean root()
Returns true if a data reference exists and if the current node set contains all documents.

Returns:
result of check

data

public Data data()
Returns the current data reference.

Returns:
data reference

current

public Nodes current()
Returns the current node context.

Returns:
node set

current

public void current(Nodes curr)
Sets the current node context. Discards the input if it contains all document nodes of the currently opened database.

Parameters:
curr - node set

openDB

public void openDB(Data d)
Sets the specified data instance as current database.

Parameters:
d - data reference

closeDB

public void closeDB()
Closes the current database context.


set

public void set(Nodes curr,
                Nodes mark)
Sets the current context and marked node set and resets the focus.

Parameters:
curr - context set
mark - marked nodes

update

public void update()
Invalidates the current node set.


pinned

public boolean pinned(java.lang.String db)
Checks if the specified database is pinned.

Parameters:
db - name of database
Returns:
result of check

perm

public boolean perm(Perm p,
                    MetaData md)
Checks if the current user has the specified permission.

Parameters:
p - requested permission
md - optional meta data reference
Returns:
result of check

register

public void register(Proc pr)
Locks the specified process and starts a timeout thread.

Parameters:
pr - process

downgrade

public void downgrade(Proc pr,
                      StringList write)
Downgrades locks.

Parameters:
pr - process
write - write locks to keep

unregister

public void unregister(Proc pr)
Unlocks the process and stops the timeout.

Parameters:
pr - process