home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
sybase
/
starbuck
/
template.z
/
Document.java
< prev
next >
Wrap
Text File
|
1996-12-09
|
7KB
|
234 lines
/*
* Document.java
*
*
* Copyright 1996 Sybase, Inc. All rights reserved.
*/
import java.io.*;
/**
* <P>The Document class provides an interface to the Dynamo document
* object, for a single request from the NetImpact Dynamo web server.
* The current document corresponds to the template that originated this request
*
* <P>Lifetime: created from DynamoConnection.getDocument()
* Note that a public variable called document will be predefined for
* each Java servlet, in the runtime startup.
* When the Java servlet is done, the document object become garbage
*
* <P>See SQL Anywhere documentation on NetImpact Dynamo for a description
* of the methods, but be aware that, in Java, the first character
* of a method name is always in lower case.
*/
public class Document extends DynamoConnection
//********************************************
{
//-------------------------------------------------------------
// Constructor
//-------------------------------------------------------------
/**
* Constructs a new Document object with the specified handle
* @param handle handle to Dynamo client
*/
Document(int handle)
//******************
{
super();
setHandle(handle);
}
//-------------------------------------------------------------
// Properties
//-------------------------------------------------------------
/**
* Returns the document's full path and filename
* @exception DynamoException If an error has occured
*/
public String getLocation() throws DynamoException
//************************************************
{
return getDocumentValue(false, "location");
}
/**
* Returns the document's name, including extension, if any
* @exception DynamoException If an error has occured
*/
public String getName() throws DynamoException
//********************************************
{
return getDocumentValue(false, "name");
}
/**
* Returns the document's internal object ID
* @exception DynamoException If an error has occured
*/
public int getId() throws DynamoException
//***************************************
{
return getIntProperty(DOCUMENT, "id");
}
/**
* Returns the ID of the associated connnection object
* @exception DynamoException If an error has occured
*/
public int getConnectionId() throws DynamoException
//*************************************************
{
return getIntProperty(DOCUMENT, "connectionId");
}
/**
* Returns the name of the associated connection object
* @exception DynamoException If an error has occured
*/
public String getConnectionName() throws DynamoException
//******************************************************
{
return getDocumentValue(false, "connectionName");
}
/**
* Returns a comment / description of the document
* @exception DynamoException If an error has occured
*/
public String getDescription() throws DynamoException
//***************************************************
{
return getDocumentValue(false, "description");
}
/**
* Returns a field in document.value[variable].
* These are usually arguments from an HTML form
* @param variable argument name
* @exception DynamoException If an error has occured
*/
public String getArgument(String variable) throws DynamoException
//***************************************************************
{
return getDocumentValue(true, variable);
}
/**
* Sets a field in document.value[variable].
* These are usually arguments from an HTML form
* @param variable argument name
* @param value argument value
* @return true if success; false otherwise
* @exception DynamoException If an error has occured
*/
public boolean setArgument(String variable, String value)
throws DynamoException
//*******************************************************
{
return setDocumentValue(true, variable, value);
}
/**
* Returns the value of a document."variable" field
* @param variable name of the variable
* @exception DynamoException If an error has occured
*/
public String getValue(String variable) throws DynamoException
//************************************************************
{
return getDocumentValue(false, variable);
}
/**
* Sets the value of a document."variable" field.
* document."variable" is created when set
* @param variable name of the variable
* @param value value of the variable
* @return true if success; false otherwise
* @exception DynamoException If an error has occured
*/
public boolean setValue(String variable, String value)
throws DynamoException
//****************************************************
{
return setDocumentValue(false, variable, value);
}
/**
* Returns a new stream for output to Dynamo client
* @exception IOException If an I/O error has occured
*/
public PrintStream getStream() throws IOException
//***********************************************
{
return new PrintStream( new BaseServletStream( this ) );
}
//-------------------------------------------------------------
// Public Methods
//-------------------------------------------------------------
/**
* Writes a String to Dynamo client
* @exception DynamoException If an error has occured
*/
public void write(String s) throws DynamoException
//************************************************
{
writeOutput(s, false);
}
/**
* Writes a String, followed by a newline, to Dynamo client
* @exception DynamoException If an error has occured
*/
public void writeln(String s) throws DynamoException
//**************************************************
{
writeOutput(s, true);
}
/**
* Writes a String, followed by a newline, to Dynamo client
* @exception DynamoException If an error has occured
*/
public void writeLn(String s) throws DynamoException
//**************************************************
{
writeOutput(s, true);
}
//-------------------------------------------------------------
// Protected Methods
//-------------------------------------------------------------
protected native void writeOutput(String s, boolean addNewline)
throws DynamoException;
protected native String getDocumentValue(boolean isValue, String name)
throws DynamoException;
protected native boolean setDocumentValue(boolean isValue, String name, String value)
throws DynamoException;
};