// // QueryObject.java // // WELD Java Client Persistent Object Management Package // Copyright Francis Chan (fchan@ic.eecs.berkeley.edu), 1997 // University of California, Berkeley // // // This program is in the public domain. // Permission to use, copy, modify, and distribute this software // and its documentation for NON-COMMERCIAL purposes and // without fee is hereby granted, as long as credit is given. import java.util.Vector; import java.io.StreamTokenizer; /** * * QueryObject Class * * This is a class which is used to query data at a remote server * (extends PersistentObject only to take advantage of the built-in * network capabilities. Not meant to be saved or loaded.) * * @version 1.1 February 1997 * @author Francis Chan */ public class QueryObject extends PersistentObject{ // Query Scope options public static final int GLOBAL = 0; public static final int CLASS = 1; public static final int DATABASE = 2; // or container double[] queryIdArray; private Vector objVector; /** * Constructor for QueryObject */ public QueryObject(){ } /** * Executes the query requested * */ public int execQuery(String userId, String objectClassName, int scope, String fieldName, String strId){ if (connectServer() == false) return PO.ERROR; outStreamString = comCons.prepareQueryCommandString(PO.QUERY, userId, objectClassName, scope, fieldName, strId); send(outStreamString); objVector = parse(PO.QUERY); netClient.closeConnection(netSocket); return PO.OK; } protected Vector parseQuery(StreamTokenizer strToke){ Vector infoVector = new Vector(); int token; int numContents; try { token = strToke.nextToken(); if (parseNumber(strToke, "Number (of contents) expected!") != true){ return null; } numContents = (int) strToke.nval; for (int i=0; i