Smart CODE
Your on-line guide to the generated code

NAME
Internet Data - The data object controlling the data input stream

INTRODUCTION
Data coming in from the internet is handled through its own data structure/class. This allows data to be processed in a variety of ways under user control once a URL connection has been established, data has been sent, and content headers retrieved.

This Internet Data object is processed automatically by Thin-Client smart code - it contains private code to load the data and deserialize it and update the contents of the group data object. This sequence is detailed in the section on the generated client-server callout/method

Where the MIME type of the incoming data does not correspond with the expected Thin-Client private MIME type, (or where the user has provided an alternative Recieve handler), the data is passed to stub routines for processing. Generated stubs do contain commented examples of how to access the data InputStream and how to load/process the data.

Internet connection and stream handling in C and C++ is handled using classes/objects that work to the same API as the java.net and java.io URL URLConnection, InputStream OutputStream etc classes. This is to provide a common API that allows code written with one toolkit/language to migrate easily to another - or for alternative thin-client implementations to work in exactly the same way.

The data structures below define the Internet Data interface. They are abstract, as the data objects that are passed into the handler routines are implementations of the interface for a particular transport mechanism (here HTTP).

SYNOPSIS

C


typedef struct sc_idata_s
{
	/* public: */
		string_f        getMimeType;      /* pure virtual */
		InputStream_f   getInputStream;   /* pv */
		int_f           getContentLength; /* pv */
		int_f           load;             /* pv */
} sc_idata_t;
C++


class sc_idata_c
{
	public:
		virtual char * getMimeType() = 0;
		virtual InputStream * getInputStream() = 0;
		virtual int getContentLength() = 0;
		virtual int load( sc_stdcs_c* data) = 0;
};
Java


package utils_java;

public abstract class SCIData
{
	public abstract String getMimeType();
	public abstract InputStream getInputStream() throws IOException;
	public abstract int getContentLength();
	public abstract boolean load( SCStdCS csdata) throws IOException;
}

DESCRIPTION
getMimeType()
- this getter returns the MIME type of the URL, taken from the content header returned by the web server. For successful Thin-Client transactions it will be the private MIME type:

x-application/sc-GROUPNAME
which is used both by the client and by the server to ensure the integrity of the connection.

If you are providing your own processing routine you may wish to provide alternative processing mechanisms for different incoming MIME types.

getContentLength()
- this returns the expected length of the data as advised by the web server that is sending it. Where firewalls/proxes intervene, this cannot always be relied on - and a length of -1 (unspecified) is not uncommon.
getInputStream()
- this getter gives you access to the URL's returning InputStream. Incoming data can be processed
  • as a stream, buffering as required
  • after downloading all the data (using the InputData methods)
  • by passing it through to a handler - for example the SGML/HTML parsing engine.
  • load()
    will read the InputStream and load its content into the group object. This is used by Thin Client code and expects data that conforms to the group's private MIME type.

    USAGE

    EXAMPLES

    SEE ALSO