?? compositecommand.java
字號:
/*
* *****************************************************
* Copyright (c) 2005 IIM Lab. All Rights Reserved.
* Created by xuehao at 2005-10-12
* Contact: zxuehao@mail.ustc.edu.cn
* *****************************************************
*/
package org.indigo.commands;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.indigo.log.FileLoggerParam;
import org.indigo.spider.Spider;
import org.indigo.spider.ThreadPool;
import org.indigo.util.*;
/**
* 復合模板對象,此對象可包含RawCommand對象。
* @author wbz
*
*/
public class CompositeCommand extends Command
{
private List itsCmds = new ArrayList();
/**
* 復合模板類構造函數(shù)。
* @param file 任務對應的文件路徑。
* @param bTableView 是否再主界面中顯示。
* @param bXmlView 是否再xml中存儲。
*/
public CompositeCommand(String file, boolean bTableView, boolean bXmlView )
{
super(file);
File theFile=null;
String taskName=null,str=null;
TaskProperties props = new TaskProperties();
props.open( itsPropertyFile );//讀取和任務對應的文件
int taskCount,i;
taskCount = Integer.parseInt( props.getProperty( "TaskCount" ) );//獲取所包含的子任務數(shù)
for( i=0; i<taskCount; i++ )//依次訪問每個子任務。
{
taskName = props.getProperty( "Task"+(i+1) );
theFile = new File( taskName );
if( !theFile.exists() )
{
str = "TaskFile: " + taskName + " doesnot exists!";
FileLoggerParam.getInstance().warning( str );
continue ;
}
TaskProperties props2 = new TaskProperties();
try
{
props2.open( taskName );
}catch( Exception e )
{
System.out.println( "TaskFile error: " + file );
System.out.println( "Task"+(i+1)+"="+taskName );
FileLoggerParam.getInstance().warning( "TaskFile error: " + file );
FileLoggerParam.getInstance().warning( "Task"+(i+1)+"="+taskName );
}
boolean bComp;
String str2 = props2.getProperty( "Nested" );
if( str2==null || str2.equals("") )
bComp = false;
else
bComp = str2.equalsIgnoreCase("true");
if( !bComp )//如果此子任務是單任務,則封裝為RawCommand,否則封裝為復合模板。
{
itsCmds.add( new RawCommand( taskName, bTableView, bXmlView ) );
}else
{
itsCmds.add( new CompositeCommand( taskName, bTableView, bXmlView ) );
}
}
}
/**
* 針對復合模板,主要執(zhí)行函數(shù)。
* 思想是:首先把存放在復合模板對象中的每個子模板取出,然后執(zhí)行。
*/
public void execute()
{
while( !itsCmds.isEmpty() )
{
Command cmd = (Command) itsCmds.get(0);
itsCmds.remove( 0 );
String str = MainConfig.getInstance().getProperty( "SerialExecute");
if( str==null || str.equals("false") )
ThreadPool.getInstance().execute( new Spider(cmd) );
else
cmd.execute();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -