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

📄 jsourcecodewizardabstract.java

📁 用免疫遗传算法解决TSP问题
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺ResultSet夝愅<BR>
	 * 
	 *   @param ResultSet 慡崁栚偺専嶕寢壥
	 *   @throws SQLException
	 */
	public void parse(java.sql.ResultSet resultSet)
		throws java.sql.SQLException
	{
		int iColumn=1;
		setCurrentDirectory(trimRight(resultSet.getString(iColumn++)));
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞嶌惉<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @throws SQLException
	 */
	public static void sqlCreateTable(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		java.sql.Statement stmt=conn.createStatement();
		try{
			stmt.executeUpdate("CREATE TABLE JSourceCodeWizard (currentDirectory CHAR(-1))");
		}finally{
			stmt.close();
		}
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞嶍彍<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @throws SQLException
	 */
	public static void sqlDropTable(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		java.sql.Statement stmt=conn.createStatement();
		try{
			stmt.executeUpdate("DROP TABLE JSourceCodeWizard");
		}finally{
			stmt.close();
		}
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞憓擖<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @return 僥乕僽儖憓擖偵惉岟偟偨審悢
	 *   @throws SQLException
	 */
	public int sqlInsertInto(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		java.sql.PreparedStatement stmt=conn.prepareStatement("INSERT INTO JSourceCodeWizard VALUES (?)");
		try{
			int iColumn=1;
			stmt.setString(iColumn++,getCurrentDirectory());
			return stmt.executeUpdate();
		}finally{
			stmt.close();
		}
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞慡専嶕<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @return 専嶕寢壥
	 *   @throws SQLException
	 */
	public static java.sql.PreparedStatement sqlSelect(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		java.sql.PreparedStatement stmt=conn.prepareStatement("SELECT currentDirectory FROM JSourceCodeWizard ORDER BY ");
		return stmt;
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞慡専嶕 List栠傝抣斉<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @return ArrayList 専嶕寢壥
	 *   @throws SQLException
	 */
	public static ArrayList sqlSelectList(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		ArrayList vecResult=new ArrayList();
		java.sql.PreparedStatement stmt=sqlSelect(conn);
		try{
			java.sql.ResultSet resultSet=stmt.executeQuery();
			for(;resultSet.next();)
			{
				JSourceCodeWizardAbstract dataJSourceCodeWizard=new JSourceCodeWizardAbstract();
				dataJSourceCodeWizard.parse(resultSet);
				vecResult.add(dataJSourceCodeWizard);
			}
			return vecResult;
		}finally{
			stmt.close();
		}
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞専嶕 WHERE斉<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @param String 忦審. null側傜僷儔儊乕僞柍偟
	 *   @param Object[] 僷儔儊乕僞. null側傜僷儔儊乕僞柍偟
	 *   @param String 僜乕僩弴. null側傜僜乕僩柍偟
	 *   @return 専嶕寢壥
	 *   @throws SQLException
	 */
	public static java.sql.PreparedStatement sqlSelectWhereOrderBy(java.sql.Connection conn,String strWhere,Object[] params,String strOrderBy)
		throws java.sql.SQLException
	{
		StringBuffer strbufSql=new StringBuffer();
		strbufSql.append("SELECT currentDirectory FROM JSourceCodeWizard");
		if(strWhere!=null && strWhere.length()>0)strbufSql.append(" WHERE "+strWhere);
		if(strOrderBy!=null && strOrderBy.length()>0)strbufSql.append(" ORDER BY "+strOrderBy);
		java.sql.PreparedStatement stmt=conn.prepareStatement(strbufSql.toString());
		try{
			if(params!=null)for(int iColumn=0;iColumn<params.length;iColumn++)
			{
				if(params[iColumn] instanceof String)
				{
					stmt.setString(iColumn+1,(String)params[iColumn]);
				}
				else if(params[iColumn] instanceof Integer)
				{
					stmt.setInt(iColumn+1,((Integer)params[iColumn]).intValue());
				}
				else if(params[iColumn] instanceof java.math.BigDecimal)
				{
					stmt.setBigDecimal(iColumn+1,((java.math.BigDecimal)params[iColumn]));
				}
			}
		}catch(java.sql.SQLException ex){
			stmt.close();
			throw ex;
		}
		return stmt;
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞峴嶍彍<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @return int 嶍彍幚峴寢壥審悢
	 *   @throws SQLException
	 */
	public int sqlDelete(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		java.sql.PreparedStatement stmt=conn.prepareStatement("DELETE FROM JSourceCodeWizard WHERE ");
		int iColumn=1;
		try{
			return stmt.executeUpdate();
		}finally{
			stmt.close();
		}
	}

	/**
	 * JSourceCodeWizard(abstract class of wizard) 偺DB昞峴峏怴<BR>
	 * 
	 *   @param Connection 愙懕僐僱僋僔儑儞
	 *   @return int 峏怴幚峴寢壥審悢
	 *   @throws SQLException
	 */
	public int sqlUpdate(java.sql.Connection conn)
		throws java.sql.SQLException
	{
		java.sql.PreparedStatement stmt=conn.prepareStatement("UPDATE JSourceCodeWizard SET currentDirectory=? WHERE ");
		try{
			int iColumn=1;
			stmt.setString(iColumn++,getCurrentDirectory());
			return stmt.executeUpdate();
		}finally{
			stmt.close();
		}
	}

	/**
	 * 梌偊傜傟偨暥帤楍傪壜擻側尷傝悢帤壔偟傑偡丅<BR>
	 * 偙偺儊僜僢僪偼敿妏悢帤偺傒桳岠偱偡丅
	 * 偨偩偟扨懱僥僗僩偟偰傒偨偲偙傠丄Integer.parseInt()偼慡妏暥帤傕
	 * 埖偊偰偟傑偊傞 (偮傑傝 偙偺傔偦偭偳偱傕棙梡壜擻側) 柾條偱偡丅(at JDK1.3.1)
	 * 
	 *   @param String strInput 擖椡暥帤楍
	 *   @return int 拪弌偝傟偨悢帤
	 */
	public static final int toInteger(String strInput)
	{
		if(strInput==null
		|| strInput.length()==0)
		{
			return 0;
		}
		try{
			return Integer.parseInt(strInput);
		}catch(java.lang.NumberFormatException ex){
			return 0;
		}
	}

	/**
	 * 梌偊傜傟偨暥帤楍傪巜掕挿偝偵傄偭偨傝偵廂傑傞傛偆壛岺偡傞儊僜僢僪<BR>
	 * 2僶僀僩1暥帤偺暥帤偼2暥帤偲偟偰僇僂儞僩偟傑偡丅<BR>
	 * 亂拲堄亃偙偺儊僜僢僪偵偮偄偰偼 JSourceCodeWizard僋儔僗偑嶌惉偡傞傂側宍僜乕僗僐乕僪
	 * 偺堦晹偲偟偰棙梡偝傟傑偡丅偛棟夝偲偛嫤椡偺傎偳 偳偆偧傛傠偟偔偍婅偄偄偨偟傑偡丅<BR>
	 * <BR>
	 * 側偍丄尰嵼偺幚憰偱偼 EUC偵偍偄偰敿妏僇僞僇僫偑2僶僀僩偵側傞審偵偮偄偰懳墳偟偰偄傑偣傫<BR>
	 * 
	 *   @param String strInput 擖椡暥帤楍
	 *   @param int iLength 惗惉偟偨偄挿偝
	 *   @param char cFill 杽傔傞暥帤
	 *   @return String 晹暘暥帤楍
	 */
	public static final String fitRight(String strInput,int iLength,char cFill)
	{
		try{
			StringReader reader=new StringReader(strInput);
			StringWriter writer=new StringWriter();
			for(int iCurrentLength=0;;)
			{
				int iRead=reader.read();
				if(iRead<0)break;
				if(iRead>0xff)
				{
					iCurrentLength+=2;
				}
				else
				{
					iCurrentLength+=1;
				}
				if(iCurrentLength<=iLength)
				{
					writer.write(iRead);
				}
				else
				{
					break;
				}
			}
			reader.close();
			writer.flush();
			writer.close();
			return padRight(writer.toString(),iLength,cFill);
		}catch(IOException ex){
			System.out.println(ex.toString());
			ex.printStackTrace();
			return null;
		}
	}

	/**
	 * 梌偊傜傟偨暥帤楍傪巜掕挿偝傑偱塃懁偵巜掕暥帤傪杽傔傞儊僜僢僪<BR>
	 * 2僶僀僩1暥帤偺暥帤偼2暥帤偲偟偰僇僂儞僩偟傑偡丅<BR>
	 * 亂拲堄亃偙偺儊僜僢僪偵偮偄偰偼 JSourceCodeWizard僋儔僗偑嶌惉偡傞傂側宍僜乕僗僐乕僪
	 * 偺堦晹偲偟偰棙梡偝傟傑偡丅偛棟夝偲偛嫤椡偺傎偳 偳偆偧傛傠偟偔偍婅偄偄偨偟傑偡丅<BR>
	 * 
	 *   @param String strInput 擖椡暥帤楍
	 *   @param int iLength 惗惉偟偨偄挿偝
	 *   @param char cFill 杽傔傞暥帤丅
	 *   @return String 晹暘暥帤楍
	 */
	public static final String padRight(String strInput,int iLength,char cFill)
	{
		try{
			int iInputLength=strInput.getBytes().length;

			StringWriter writer=new StringWriter();
			writer.write(strInput);

			for(int iCurrentLength=iInputLength;;)
			{
				if(cFill>0xff)
				{
					iCurrentLength+=2;
					if(iCurrentLength>iLength)
					{
						if(iCurrentLength==(iLength+1))
						{
							writer.write(' ');
						}
						break;
					}
				}
				else
				{
					iCurrentLength+=1;
				}

				if(iCurrentLength<=iLength)
				{
					writer.write(cFill);
				}
				else
				{
					break;
				}
			}

			writer.flush();
			writer.close();

			return writer.toString();
		}catch(IOException ex){
			System.out.println(ex.toString());
			ex.printStackTrace();
			return null;
		}
	}

	/**
	 * 梌偊傜傟偨暥帤楍偺塃懁傪愗傝偮傔傞儊僜僢僪
	 * 敿妏嬻敀偲慡妏嬻敀傪愗傝偮傔傑偡
	 * 亂拲堄亃偙偺儊僜僢僪偵偮偄偰偼 JSourceCodeWizard僋儔僗偑嶌惉偡傞傂側宍僜乕僗僐乕僪
	 * 偺堦晹偲偟偰棙梡偝傟傑偡丅偛棟夝偲偛嫤椡偺傎偳 偳偆偧傛傠偟偔偍婅偄偄偨偟傑偡丅<BR>
	 * 
	 *   @param String strInput 擖椡暥帤楍
	 *   @return String 愗傝偮傔屻暥帤楍
	 */
	public static final String trimRight(String strInput)
	{
		try{
			StringReader reader=new StringReader(strInput);
			StringWriter writer=new StringWriter();
			StringBuffer strbufWhiteSpace=new StringBuffer();

			for(;;)
			{
				int iRead=reader.read();
				if(iRead<0)break;
				if(iRead==' '
				|| iRead=='丂')
				{
					strbufWhiteSpace.append((char)iRead);
				}
				else
				{
					writer.write(strbufWhiteSpace.toString());
					strbufWhiteSpace=new StringBuffer();
					writer.write(iRead);
				}
			}

			reader.close();
			writer.flush();
			writer.close();

			return writer.toString();
		}catch(IOException ex){
			System.out.println(ex.toString());
			ex.printStackTrace();
			return null;
		}
	}

⌨️ 快捷键说明

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