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: ContentClient.java,v 1.2 2004/02/12 00:17:55 bradford Exp $
 */

import org.w3c.dom.Document;

import com.dbxml.db.core.Container;
import com.dbxml.util.dbXMLException;

/**
 * ContentClient is the standard interface for objects that are stored
 * in a Collection.  A ContentClient can either represent a Document
 * or a Value, depending on the Collection type.
 */

public interface ContentClient {
   static final int TYPE_DOCUMENT = Container.TYPE_DOCUMENT;
   static final int TYPE_VALUE = Container.TYPE_VALUE;

   /**
    * getKey returns the Content Key.
    *
    * @return The Content Key
    */
   String getKey() throws dbXMLException;

   /**
    * getContainerType returns the content type for this client.
    * This value can either be TYPE_DOCUMENT or TYPE_VALUE.
    *
    * @return The content type
    */
   int getContentType() throws dbXMLException;

   /**
    * getCanonicalName returns the canonical path for the Content.
    *
    * @return The canonical path
    */
   String getCanonicalName() throws dbXMLException;

   /**
    * getCollection returns the CollectionClient that this ContentClientImpl
    * belongs to.
    *
    * @return The CollectionClient
    */
   CollectionClient getCollection() throws dbXMLException;

   /**
    * getDocument returns the Document Content as a DOM Document.
    *
    * @return The Document content
    */
   Document getDocument() throws dbXMLException;

   /**
    * getDocumentAsText returns the Document Content as text.
    *
    * @return The Document content
    */
   String getDocumentAsText() throws dbXMLException;

   /**
    * getValue returns the Value Content as a byte array.
    *
    * @return The Value content
    */
   byte[] getValue() throws dbXMLException;

   /**
    * setDocument sets or overwrites the Document Content.
    *
    * @param document The new Document content
    */
   void setDocument(Document document) throws dbXMLException;

   /**
    * setDocumentAsText sets or overwrites the Document Content.
    *
    * @param document The new Document content
    */
   void setDocumentAsText(String document) throws dbXMLException;

   /**
    * setValue sets or overwrites the Value Content.
    *
    * @param value The new Value content
    */
   void setValue(byte[] value) throws dbXMLException;
}
