Application Techniques



Using Utility-Class Methods

How to write methods in utility classes that you can then call from any other class.

About this technique

Details

Category

Core Programming Techniques> General

Description

You'll learn about:

You can run this technique code from:

NOTE   First make sure that database is running on your localhost SilverStream Server

Related reading

See the chapter on Utility classes, JAR files, and JAVA beans in the Programmer's Guide

Creating a utility class   Top of page

To create a class whose methods can be called by all classes:

  1. From the SilverStream Designer, select Objects in one of the databases.

  2. Click the New icon (at the lower part of the Window) and select New Object.

  3. Follow each step in the Wizard to create the class you want. That is, you specify which class it extends, which interface(s) it implements, and so on.

  4. Once you have created the class, write the methods for the class.

Calling a method of the utility class   Top of page

As with all external methods, you must import the BOLoanCalculator class to be able to call its methods. The following code calls the BOLoanCalculator's calculateLoanPayment() to compute the loan payment, given the following information, which is provided by the user:

Notes about the code






Copyright © 2000, SilverStream Software, Inc. All rights reserved.