package edu.vt.marian.Document;

import java.io.*;
import java.net.*;
import java.util.*;

import edu.vt.marian.common.*;


/**
	Sort of the natural solution to the interface:  a Document that 
	can do all and only the interface methods with the minimum of
	overhead.

	@author	Robert France
*/

public class SimpleDocument extends FullID implements Document
{
	private String shortDesc = null;
	private String longDesc = null;
	private String fullDesc = null;

	/** This document has <I>no</I> analyzable parts.
	*/
	private static Vector attributes = new Vector();
	
	/**
		Create a SimpleDocument object.
		@param	shDesc	short description.
		@param	lgDesc	long description.
		@param	flDesc	full description.
	*/      
	public SimpleDocument(Debug dbg, String shDesc, String lgDesc, String flDesc)
	{
		super(dbg);
		if (shDesc == null)
                   shortDesc = new String();
                else
			shortDesc = new String(shDesc);
		longDesc = new String(lgDesc);
		fullDesc = new String(flDesc);
	}


	/**
		Create a SimpleDocument object from just a short and a long
			description.
		@param	shDesc	short description.
		@param	lgDesc	long description.
	*/      
	public SimpleDocument(Debug dbg, String shDesc, String lgDesc)
	{
		super(dbg);
		if (shDesc == null)
                   shortDesc = new String();
                else
			shortDesc = new String(shDesc);
		longDesc = new String(lgDesc);
		fullDesc = longDesc;
	}


	/**
		Create a SimpleDocument object.
		@param	shDesc	short description.
	*/      
	public SimpleDocument(Debug dbg, String shDesc)
	{
		super(dbg);
		if (shDesc == null)
                   shortDesc = new String();
                else
			shortDesc = new String(shDesc);
		longDesc = shortDesc;
		fullDesc = shortDesc;
	}



	/**
		Create a null SimpleDocument object.
	*/      
	public SimpleDocument(Debug dbg)
	{
		super(dbg);
        shortDesc = new String();
		longDesc = shortDesc;
		fullDesc = shortDesc;
	}


	/**
		Is this object ready to rock?  Yes.
	*/      
	public boolean isValid()
	{
		return( true );
	}


	/**
		An attempt to get around declaring public clone() methods.
	*/
	public DigInfObj copy()
	{
		return( (DigInfObj) new SimpleDocument(debug, shortDesc, longDesc, fullDesc) );
	}


	/**
		return the short description of this document in one line.
		@param	markupType	how to mark up the string returned (e.g., HTML or ASCII).
		@return	the short description String.
	*/
	public String presentShort(int markupType)
	{
		return shortDesc;
	}

	public int presentShort(int markupType, BufferedWriter out) throws IOException
	{
		out.write(shortDesc);
		return( ReturnCodes.OK );
	}
	

	/**
		return the long description of this document.
		@param	markupType	how to mark up the string returned (e.g., HTML or ASCII).
		@return	a (potentially very long) String.
	*/
	public String presentLong(int markupType)
	{
		return( longDesc );
	}

	public int presentLong(int markupType, BufferedWriter out) throws IOException
	{
		out.write(longDesc);
		return( ReturnCodes.OK );
	}
	

	/**
		return the full description of this document.
		@param	markupType	how to mark up the string returned (e.g., HTML or ASCII).
		@return	a (potentially very long) String.
	*/
	public String presentFull(int markupType)
	{
		return( fullDesc );
	}
	
	public int presentFull(int markupType, BufferedWriter out) throws IOException
	{
		out.write(fullDesc);
		return( ReturnCodes.OK );
	}

	
	/**
		return a Vector of metadata attributes for this document.
		@param	markupType	how to mark up the string returned (e.g., HTML or ASCII).
		@return	a Vector of triples [attrName, attrType, attrValue].
	*/
	public Vector presentAttributes(int markupType)
	{
		return attributes;
	}
		

	/**
		Return an Object (almost certainly a String) in some markupType for the given
			attribute.
		@param	markupType	how to mark up the string returned (e.g., HTML or ASCII).
		@return	a Vector of triples [attrName, attrType, attrValue].
	*/
	public Object presentAttribute(int attrID, int markupType)
	{
		return null;
	}


	/**
		return a Vector of metadata attributes for this document.
		@param	markupType	how to mark up the string returned (e.g., HTML or ASCII).
		@return	a Vector of triples [attrName, attrType, attrValue].
	*/
	public Vector attributes()
	{
		return attributes;
	}

}
