SilentQ

 Making
computing
a little
easier.



The SilentQ QVector library allows Java developers to incorporate primitive types into Vectors without having to wrap or cast them. The package contains two kinds of classes -- the primitive type specific classes (QIntVector, QByteVector, etc.) and one general class (QVector) that can handle any combination of Objects and primitives.

The QVector class will accept all the primitive types, as well as Objects, and will return the contents of any slot in the QVector as the requested type, as far as it can determine. For example, you could say:

qvector.addElement(1);
float f = qvector.lastAsFloat();
Integer i = qvector.lastElement();

and get the values you expect (1.0, new Integer(1)) for f and i.

These classes are JavaBeans, and are compatible with JDK version 1.1 and above, though this version only overrides the methods for the JDK 1.1 java.util.Vector class (QVectors are not Collections, and do not implement the new JDK 1.2 classes, though the 1.2 version will be coming soon). These libraries can be installed on any platform that has a JDK 1.1 (or above) port and an unzip utility, but instructions are only given for the two most common - Windows and Unix.


Windows Installation

This library is provided in JavaBeans format (a jar file), which can be installed as-is in a beans directory, or included in your classpath as a standard library. Once you have downloaded the library, choose a location for it (the example is c:\silentq). Move the zip file to that location and unzip it (if you don't have an unzip utility available, you can get one from the Info-ZIP Home Page):

move qvector.zip c:\silentq
cd c:\silentq
unzip qvector.zip

Then, add the jar file to your classpath:

set classpath=%classpath%;c:\silentq\QVector.jar

The library is now installed, and can be incorporated into your code.


Unix Installation

This library is provided in JavaBeans format (a jar file), which can be installed as-is in a beans directory, or included in your classpath as a standard library. Once you have downloaded the library, choose a location for it (the example is /usr/local/silentq). Move the zip file to that location and unzip it (if you don't have an unzip utility available, you can get one from the Info-ZIP Home Page):

move qvector.zip /usr/local/silentq
cd /usr/local/silentq
unzip qvector.zip:

Then, add the jar file to your classpath:

CLASSPATH=$CLASSPATH:/usr/local/silentq/QVector.jar;
export CLASSPATH

or

setenv CLASSPATH \ $CLASSPATH:/usr/local/silentq/QVector.jar

The library is now installed, and can be incorporated into your code.


Using QVector Classes

Using the QVector classes is very much like using the java.util.Vector class, with some minor differences. The primitive type classes (QIntVector, etc.) can be used directly as Vector classes, with the obvious change that instead of storing and retrieving Objects, they will store and retrieve the type they're named after. So, for example:

import com.silentq.util.QIntVector;

...

QIntVector qintv = new QIntVector();
qintv.addElement(1);
qintv.setElementAt(0,0);
int i = qintv.firstElement();

The only thing to be careful of is the elements() method -- there is no primitive Enumeration class (though we hope to release one at a later date) so elements() will return the primitive type wrapped in the appropriate object (Integer, in the above example).

The QVector class is the general class that handles any combination of primitives and Objects. It has some specialized methods that allow you to choose the return type of the object you're getting: firstAs, lastAs, and At. To get the float versions of the elements of a vector, use firstAsFloat(), lastAsFloat(), and floatAt().

One final word about conversions. When you request a return type that doesn't match the type it was entered as, it will either throw an exception, or do the best it can to convert it, based on the value of the throwException variable (set by setThrowException()). It tries to do intelligent conversions (for example, "1", when returned as an int, will be 1, as expected). If it tries to do the conversion and fails, it will return a 0 if it's a number, '?' for char, and false for boolean.


Support

Please send any questions, comments, or bugs to support@silentq.com. Priority will go to those with support contracts, but all mail will be read, and all bugs will be recorded.


Copyright 2000, SilentQ Software Company

    

.