package com.dbxml.db.client;

/*
 * dbXML - Native XML Database
 * Copyright (C) 1999-2004  The dbXML Group, L.L.C.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Id: dbXMLClient.java,v 1.2 2004/02/12 00:17:55 bradford Exp $
 */

import java.util.Map;

import com.dbxml.util.dbXMLException;

/**
 * dbXMLClient is the standard interface for working with dbXML in
 * a client/server fashion.
 */

public interface dbXMLClient {
   // Standardized property names
   static final String HOST = "host";
   static final String ALT_HOST = "hostname";

   static final String PORT = "port";
   static final String ALT_PORT = "portnum";

   static final String USER = "user";
   static final String ALT_USER = "username";

   static final String PASS = "pass";
   static final String ALT_PASS = "password";

   /**
    * setProperty sets a connection property for the client.
    * Properties should be set before calling the connect
    * method.
    *
    * @param name The property name
    * @param value The property value
    */
   void setProperty(String name, String value);

   /**
    * getProperty returns a connection property from the client.
    *
    * @param name The property name
    * @return The property value
    */
   String getProperty(String name);

   /**
    * listProperties returns a list of the connection property
    * names for the client.
    *
    * @return The property list
    */
   String[] listProperties();

   /**
    * getProperties returns the entire set of client properties.
    *
    * @return The properties
    */
   Map getProperties();

   /**
    * connect instructs the client to connect to the server.
    */
   void connect() throws dbXMLException;

   /**
    * disconnect instructs the client to disconnect from the server.
    */
   void disconnect() throws dbXMLException;

   /**
    * getServerVersion returns a string that includes the name and
    * current version of the server that is currently connected.
    *
    * @return The server version
    */
   String getServerVersion() throws dbXMLException;

   /**
    * shutdown shuts down the server with the specified exit code.
    *
    * @param exitCode The exit code to use
    */
   void shutdown(int exitCode) throws dbXMLException;

   /**
    * getDatabase returns the Database instance as a CollectionClient.
    *
    * @return The CollectionClient
    */
   CollectionClient getDatabase() throws dbXMLException;

   /**
    * getCollection returns the CollectionClient defined by the
    * specified path.
    *
    * @param path The Collection path
    * @return The CollectionClient
    */
   CollectionClient getCollection(String path) throws dbXMLException;

   /**
    * getContent returns the ContentClient defined by the
    * specified path.
    *
    * @param path The Document path
    * @return The ContentClient
    */
   ContentClient getContent(String path) throws dbXMLException;
}
