package edu.vt.marian.WebGate; import java.net.*; import java.util.*; import java.io.*; import edu.vt.marian.common.*; import edu.vt.marian.uip.*; /** Class name: query_data_for_one_server Class description: this class represent the query data corresponds to a server it's a component of the class query_data Author: Jianxin Zhao Finished time: ????, 1998 Known bugs: none Platform: jdk1.1.5 under UNIX */ public class query_data_for_one_server { /** this is just for debugging */ Debug debug; /** this is the uip server this object is corresponds to */ private uip_server us; /** this is the query data of this object */ private general_query_data gqd; /** this constructor will create a query data for one server object, the object is empty upon creation */ public query_data_for_one_server(Debug debug) { // first initialize data members init(); this.debug = debug; gqd = new general_query_data(debug); } /** this constructor will create a query data for one server object from the specified directory */ public query_data_for_one_server(String dir, Debug debug) { // first initialize data members init(); this.debug = debug; gqd = new general_query_data(debug); // read out uip server set_server(new uip_server(dir + System.getProperty("file.separator") + "uip_server", debug)); // read out query data gqd = new general_query_data(dir + System.getProperty("file.separator") + "query_data", debug); } /** this constructor will create a query data for one server object from the specified directory */ public query_data_for_one_server(BufferedReader br, Debug debug) { // first initialize data members init(); this.debug = debug; // read out uip server set_server(new uip_server(br, debug)); // read out query data gqd = new general_query_data(br, debug); } /** this constructor will create a query data for one server object from a stream, this might be helpful for remote manage in the future (not implemented yet) */ public query_data_for_one_server(DataInputStream dis) { } /** this method will set the uip server of this object */ public String set_server(uip_server us) { if (us == null) { this.us = null; return null; } this.us = new uip_server(us.get_hostname(), us.get_port(), us.get_short_description(), us.get_long_description(), debug); return "OK"; } /** this method will return the server this object is corresponds to */ public uip_server get_server() { if (us == null) { return null; } uip_server server = new uip_server(us.get_hostname(), us.get_port(), us.get_short_description(), us.get_long_description(), debug); return server; } /** this method will return all the field names of this object */ public Vector get_field_names() { return gqd.get_field_names(); } /** this method will add the field with the specified value to this object */ public String add_field(String name, String value) { return gqd.add_field(name, value); } /** this method will set the specified field to the specified value for this object */ public String set_field(String name, String value) { return gqd.set_field(name, value); } /** this method will delete the specified field from this object */ public String delete_field(String name) { return gqd.delete_field(name); } /** this method will return the value of the specified field of this object */ public String get_value(String field_name) { return gqd.get_value(field_name); } /** this method will set the relation between the fields of this object */ public String set_relation(String relation) { return gqd.set_relation(relation); } /** this method will return the relationship between fields of this object */ public String get_relation() { return gqd.get_relation(); } /** this method will return all the preference names of this object */ public Vector get_preference_names() { return gqd.get_preference_names(); } /** this method will return the value of the specified preference of this object */ public String get_preference_value(String name) { return gqd.get_preference_value(name); } /** this method will add the specified preference with the specified value to this object */ public String add_preference(String name, String value) { return gqd.add_preference(name, value); } /** this method will set the specified preference with the specified value */ public String set_preference(String name, String value) { return gqd.set_preference(name, value); } /** this method will delete the specified preference from this object */ public String delete_preference(String name) { return gqd.delete_preference(name); } /** this method will print the content of this object to a stream, this might be helpful for remote management in the future */ public String to_stream(DataOutputStream dos) { return null; // not implemented yet } /** this method will save the content of this object to the specified directory or file */ public String save(String dir) { File file = new File(dir); try { file.mkdir(); } catch (SecurityException e) { debug.dumpTrace("class qdfos: can not create directory"); } // save the uip server us.save(dir + System.getProperty("file.separator") + "uip_server"); // save the query data gqd.save(dir + System.getProperty("file.separator") + "query_data"); return "OK"; } /** this method will save the content of this object to the specified directory or file */ public String save(PrintWriter pw) { // save the uip server us.to_stream(pw); // save the query data gqd.save(pw); return "OK"; } /** this method will initialize the data members of this object */ private void init() { debug = null; us = null; gqd = null; } }