⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java

📁 数据挖掘的工具代码(包含fp-tree,appriory
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
  {    Vector result;    try       {	out.reset();	out.writeObject("BENCHMARK");	out.writeObject(benchInput);	out.flush();	// Get the Server Response.	String response = (String)in.readObject();	result = new Vector();	result.add(response);	result.add((Vector)in.readObject());      }     catch (IOException f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    catch (ClassNotFoundException f)      {	//System.err.println("Client: Benchmark " + f);	throw new ClientErrorException(f.toString());      }    return result;  }  /**   * Reset the DBConfig object in the class.   *   * @exception ClientException   All the Exception happened in client side   */  public static void setDBConfig()     throws ClientException  {    Vector feedback = getDBConfig();    try      {	if (feedback.size() > 0)	  {	    String response = (String)feedback.get(0);	    if (!response.equals(strOK))	      {		throw new ClientException("Cannot get DBConfig from server in Client.setDBConfig():\n " 					  + feedback.get(1));	      }	    else	      {		DBConfig dbConfig = (DBConfig)feedback.get(1);	      }	  }      }    catch (Exception e)      {	throw new ClientException("Error in Client.setDBConfig():\n " + e);      }  }  /**   * Get Database object from server side.   *   */  public static Vector getDBConfig()  {    Vector result;    try      {	out.reset();	out.writeObject("GETDBCONFIG");	out.flush();	//Get the server response.	String response = (String)in.readObject();	//System.err.println("got back: " + response);	result = new Vector();	result.add(response);	if (response.equals(strOK))	  result.add((DBConfig)in.readObject());	else	  result.add((Vector)in.readObject());      }    catch (Exception f)      {	//System.err.println(f);	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * Get a recent DBConfig instance object   * @exception ClientErrorException   The operation can not be completed,   * the error message from the server will be thrown.   * @return   Returns the unique instance of this class.   */  public static DBConfig getDBConfig1()    throws ClientErrorException  {    try       {	out.reset();	out.writeObject("GETDBCONFIG");	out.flush();	status = (String)in.readObject();	//System.out.println("getDBConfig1: status: " + status);    	if (!status.equals(strOK))	  {	    response = (Vector)in.readObject();	    throw new ClientErrorException((String)response.get(0));	  }    	dbConfig = (DBConfig)in.readObject();	return dbConfig;      }    catch (IOException e)      {	//System.err.println("Client: getDBConfig1 " + e);	throw new ClientErrorException(e.toString());      }    catch (ClassNotFoundException e)      {	//System.err.println("Client: getDBConfig1 " + e);	throw new ClientErrorException(e.toString());      }  }  /**   * Get database column names from server side.   *   * @param db  Vector of database name   */  public static Vector getColumns(Vector db)  {    Vector result;    try      {	out.reset();	out.writeObject("GETCOLS");	out.writeObject(db);	out.flush();	//Get the server response.	String response = (String)in.readObject();	result = new Vector();	result.add(response);	result.add((Vector)in.readObject());      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * send a mining request to the server   *   * @param action      String of mining type which includes    * "MINE" and "MINEADV"   * @param mineInput   Vector of mining input.   */  public static Vector mine(String action, Vector mineInput)  {    Vector result;    try      {	out.reset();	out.writeObject(action);	out.writeObject(mineInput);	out.flush();	String response = (String)in.readObject();	result = new Vector();	result.add(response);	result.add((Vector)in.readObject());      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * Get next page of mining results.   *   */  public static Vector getNext()  {    Vector result;    try      {	out.reset();	out.writeObject("GETNEXT");	out.flush();	String response = (String)in.readObject();	result = new Vector();	result.add(response);	result.add((Vector)in.readObject());      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * request a sort of the mining results   *   * @param sortString   */  public static Vector sort(String action, String sortBy, String order)  {    Vector result;    try      {	out.reset();	out.writeObject(action);	out.flush();	out.writeObject(sortBy);	out.flush();	out.writeObject(order);	out.flush();	//Get the server response.	String response = (String)in.readObject();	result = new Vector();	result.add(response);	result.add((Vector)in.readObject());      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * add a database to server   *   * @param inFile    DBReader to read the file from file source   * @param DBName    Database name   * @param group    The group who is going to use this database   */  public static Vector addDB(DBReader inFile, String dbName, String group)  {    Vector result;    try      {	Vector db = new Vector();	db.add(dbName);	db.add(group);	db.add(inFile.getColumnNames());	db.add(inFile.getDescription());	out.writeObject("ADDDB");	out.writeObject(db);	out.flush();	String response = (String)in.readObject();	if (response.equals(strOK))	  {	    while (inFile.hasMoreRows())	      {		// we send 100 rows at a time		// NOTE: the communication is not prefect here, we		// should normally require an answer from the server for each 		// batch sent		Vector aVector = new Vector(100);		for (int i = 0 ; i < 100 && inFile.hasMoreRows(); i++)		  {		    aVector.add(inFile.getNextRow());		  }		out.reset();		out.writeObject(aVector);		out.flush();	      }	    // we signal termination with an empty vector	    out.writeObject(new Vector());	    out.flush();	    // get response from server to see if operation succeeded	    response = (String)in.readObject();	    result = new Vector();	    result.add(response);	    if (!response.equals(strOK))	      result.add((Vector)in.readObject());	  }	else // response must have been ERROR	  {	    result = new Vector();	    result.add(response);	    result.add((Vector)in.readObject());	  }      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * delete a database   *   * @param db    Vector of database name to be deleted   */  public static Vector delDB(Vector db)  {    Vector result;    try      {	out.reset();	out.writeObject("DELDB");	out.writeObject(db);	out.flush();	//Get the server response.	String response = (String)in.readObject();	result = new Vector();	result.add(response);	if (!response.equals(strOK))	  {	    result.add((Vector)in.readObject());	  }      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  public static Vector  fsynthetic (Vector vsynthetic)    throws ClientErrorException  {    Vector result;    String response;    try       {	out.writeObject("GENDB");	out.writeObject(vsynthetic);	out.flush();	response = (String)in.readObject();	result = new Vector();	result.add(response);	if (!response.equals(strOK))	  result.add((Vector)in.readObject());       }     catch (Exception f)      {   	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }  /**   * Change the database's user group.   *   * @param modificationInfo    Vector of input information for modifying a database,   * it includes database name and new user group name   */  public static Vector modDB(Vector modificationInfo)  {    Vector result;    try      {	out.reset();	out.writeObject("CHGDBGRP");	out.writeObject(modificationInfo);	out.flush();	//Get the server response.	String response = (String)in.readObject();	result = new Vector();	result.add(response);	if (!response.equals(strOK))	  {	    result.add((Vector)in.readObject());	  }      }    catch (Exception f)      {	result = new Vector();	result.add(strERROR);	Vector msg = new Vector();	msg.add(f.toString());	result.add(msg);      }    return result;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -