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

📄 addservicetorelevanceset.java

📁 实现对owl-s描述服务的检索
💻 JAVA
字号:
/*
 * Created on 21.11.2005
 * OWL-S Matchmaker
 * 
 * COPYRIGHT NOTICE
 * 
 * Copyright (C) 2005 DFKI GmbH, Germany
 * Developed by Benedikt Fries, Matthias Klusch
 * 
 * The code is free for non-commercial use only.
 * You can redistribute it and/or modify it under the terms
 * of the Mozilla Public License version 1.1  as
 * published by the Mozilla Foundation at
 * http://www.mozilla.org/MPL/MPL-1.1.txt
 */

package owlsmx.gui.util.tasks;

import java.io.File;
import java.io.FileNotFoundException;
import owlsmx.analysis.MemoryContainer;
import owlsmx.gui.data.Query;
import owlsmx.gui.data.ServiceItem;
import owlsmx.gui.data.TestCollection;
import owlsmx.gui.util.GUIState;
import owlsmx.gui.util.SwingWorker;


public class AddServiceToRelevanceset {


	    private int lengthOfTask;
	    private int current = 0;
	    private boolean done = false;
	    private boolean canceled = false;
	    private Query query;
	    File[] files;

	    public AddServiceToRelevanceset(File[] files, Query query) {
	    	if (files == null)
	    		return;
	        lengthOfTask = files.length-1;
	        this.query = query;
	        this.files = files; 
	    }

	    /**
	     * Called from ProgressBarDemo to start the task.
	     */
	    public void go() {
	    	MemoryContainer.getInstance().setGUIMemory();
	        final SwingWorker worker = new SwingWorker() {
	            public Object construct() {
	                current = 0;
	                done = false;
	                canceled = false;
//	                statMessage = "Adding service to relevance set of query " + query.getName();
	                return new ActualTask(files, query);
	            }
	        };
	        worker.start();
	    }

	    /**
	     * Called from ProgressBarDemo to find out how much work needs
	     * to be done.
	     */
	    public int getLengthOfTask() {
	        return lengthOfTask;
	    }

	    /**
	     * Called from ProgressBarDemo to find out how much has been done.
	     */
	    public int getCurrent() {
	        return current;
	    }

	    public void stop() {
	        canceled = true;
//	        statMessage = null;
	    }

	    /**
	     * Called from ProgressBarDemo to find out if the task has completed.
	     */
	    public boolean isDone() {
	        return done;
	    }

	    /**
	     * Returns the most recent status message, or null
	     * if there is no current status message.
	     */
	    public String getMessage() {
	        return "Processing service " + current + "/" + lengthOfTask;
	    }

	    /**
	     * The actual long running task.  This runs in a SwingWorker thread.
	     */
	    class ActualTask {
	        ActualTask(File[] files, Query query) {
	            while ( (!canceled) && (!done) ) {
	            	ServiceItem tmpService;
	            	for(int i = 0; i<files.length;i++) {
	            		current = i;
	                	if ( (files[i].isFile()) && 
	 					   ( (files[i].getAbsolutePath().endsWith(".owl")) || 
	 					     (files[i].getAbsolutePath().endsWith(".owls") )) ) {
							try {
									tmpService = TestCollection.getInstance().addService(files[i].toURI());
									if (query==null)
										owlsmx.io.ErrorLog.instanceOf().report("Query was empty and I don't know why");
									if (tmpService==null)
										owlsmx.io.ErrorLog.instanceOf().report("Service was not found for file" + files[i] + " and query " + query);
									TestCollection.getInstance().addServiceToAnswerset(query.getURI(),tmpService.getURI());
								if (canceled)
									break;
							} catch (FileNotFoundException e) {
								GUIState.displayWarning(e.getClass().toString(), e.getMessage());
								e.printStackTrace();
							}
	                	 }                    
//	                    statMessage = "Completed " + i + "/" + lengthOfTask + ".";
	            	}                
	                done = true;
	            }
	        }
	    }
	}

⌨️ 快捷键说明

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