Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java中从jar文件实现多接口?_Java_Eclipse_Jar_Interface - Fatal编程技术网

如何在java中从jar文件实现多接口?

如何在java中从jar文件实现多接口?,java,eclipse,jar,interface,Java,Eclipse,Jar,Interface,我已经创建了一个类并导入了我的接口,但是如何完成其余的工作,我应该怎么做 在这里,我有任何东西,但它不工作,我的意思是ClassCastXeption不工作 代码示例: import java.util.LinkedList; import java.util.Queue; import com.revmetrix.code_test.linkify_queue.ProcessingQueue; import com.revmetrix.code_test.linkify_queue.Proc

我已经创建了一个类并导入了我的接口,但是如何完成其余的工作,我应该怎么做

在这里,我有任何东西,但它不工作,我的意思是ClassCastXeption不工作

代码示例:

import java.util.LinkedList;
import java.util.Queue;

import com.revmetrix.code_test.linkify_queue.ProcessingQueue;
import com.revmetrix.code_test.linkify_queue.ProcessingQueueFactory;

public class Solution {

    ProcessingQueue newQueue;
    ProcessingQueueFactory runFactory;

    Solution() {
        ProcessingQueueFactoryClass runFactory = new ProcessingQueueFactoryClass();

        ProcessingQueue newQueue = runFactory.createQueue();

    }

    /**Your ProcessingQueueFactory must contain two methods: one for creating new
     * queues and one for cleaning up after them. In `createQueue`, just create a
     * new ProcessingQueue, performing any necessary initialization of the queue
     * before it is returned. `createQueue` will be called multiple times during our
     * automated tests. In `stopQueue`, perform any cleanup required for a queue
     * created by your `createQueue` method. (E.g., stop threads, if necessary for
     * your solution.) `stopQueue` will be called once for each queue created with
     * `createQueue`.
     */
    class ProcessingQueueFactoryClass implements ProcessingQueueFactory {

        public void stopQueue(ProcessingQueue p) {

        }


        // TODO encok burda sikinti var, queue yaratacam ama Proccesing Queue donderiyor bu
        // asil eleman ekleyecegim queue yi ProcessingQueue nin icinde mi yaratcam?
        // ProcessingQueue bi interface bu arada, bunu implement eden class ProcessingQueueClass yazdim 
        // onun icinde queue olsun dedim yine gormuyor zalim queue olarak 
        //bi loop var ProcessingQueue ile ProcessingQueueFactory arasinda, anlamadim!
        public ProcessingQueue createQueue() {



            Queue<String> newQueue = new LinkedList<String>();

            return (ProcessingQueue) newQueue;
        }

    }

    /**
     * Your ProcessingQueue implementation will receive unprocessed textual data
     * from multiple concurrent producers through its `offer` method. Your queue
     * must provide a transformed version of the data via its `poll` method. The
     * transformation is described below. As a queue, the data received from
     * `poll` must be FIFO (first-in, first-out) with respect to calls to
     * `offer`; i.e., the first items in should also be the first items out. If
     * data is available, `poll` must remove it from queue and return it. If no
     * data is available, then `poll` must return null.
     */
    class ProcessingQueueClass implements ProcessingQueue {

        ProcessingQueueFactoryClass openFactory = new ProcessingQueueFactoryClass();
        ProcessingQueue newQueue = openFactory.createQueue();

        /**The linkify transformation should find raw URLs prefixed with "http(s)://" in
         * the input text and convert them to HTML links. For example,
         * http://www.example.com becomes <a href="http://www.example.com">www.example.com</a>. Do not include the scheme
         * (http(s)://) in the anchor text. Any URLs that are already within HTML links
         * should not be modified. You can assume the input text contains multiple words
         * separated by white space (i.e. spaces, new lines) or punctuations (commas,
         * periods, etc.)
         */
        public String linkifyTransformation(String s){
            // System.out.println(s);
            String[] splitArray = s.split(" ");
            String transformedString = "";

            for (int i = 0; i < splitArray.length; ++i) {
                if (splitArray[i].startsWith("https://")) {
                    transformedString += "<a href=\"" + splitArray[i] + "\">"
                            + splitArray[i].substring(8) + "</a> ";
                } else if (splitArray[i].startsWith("http://")) {
                    transformedString += "<a href=\"" + splitArray[i] + "\">"
                            + splitArray[i].substring(7) + "</a> ";
                } else {
                    transformedString += splitArray[i] + " ";
                }
            }

            //System.out.println(transformedString);            
            return transformedString;
        }

        public boolean offer(String s) {

            //returns transformedString 
            linkifyTransformation(s);
            // we need to add the transformedString to our Queue, Where should we create?;

            //how to return true or false?
            return false;
        }

        public String poll() {

            return "";
        }

    }

    public static void main(String[] args) {
//      String s = "The quick http://www.brown.com/fox 
//                 jumps https://over.com the lazy dog foo www.bar.com 
//                 is <a href=\"http://myfavorite.com\">my favorite</a> "
//                 + "These aren't the droids you're looking for.";

        //Solution sol = new Solution();
        //ProcessingQueueClass pqs = sol.new ProcessingQueueClass();
        //pqs.linkifyTransformation(s);


}

}
import java.util.LinkedList;
导入java.util.Queue;
导入com.revmetrix.code\u test.linkify\u queue.ProcessingQueue;
导入com.revmetrix.code_test.linkify_queue.ProcessingQueueFactory;
公共类解决方案{
处理队列新建队列;
处理队列工厂运行工厂;
解决方案(){
ProcessingQueueFactoryClass runFactory=新ProcessingQueueFactoryClass();
ProcessingQueue newQueue=runFactory.createQueue();
}
/**ProcessingQueueFactory必须包含两个方法:一个用于创建新的
*队列和一个用于在它们之后清理的队列。在“createQueue”中,只需创建一个
*新建ProcessingQueue,执行队列的任何必要初始化
*在返回之前。`createQueue`将在我们的
*自动测试。在“stopQueue”中,执行队列所需的任何清理
*通过“createQueue”方法创建。(例如,如果需要,停止线程)
*您的解决方案。)`stopQueue`将为使用创建的每个队列调用一次
*`createQueue`。
*/
类ProcessingQueueFactoryClass实现ProcessingQueueFactory{
公共无效停止队列(处理队列p){
}
//TODO encok burda sikinti var,队列yaratacam ama处理队列donderiyor bu
//是否在icinde mi yaratcam中处理队列?
//ProcessingQueue bi接口bu arada,bunu实现eden类ProcessingQueueClass yazdim
//奥伦-伊辛德队列olsun dedim yine gormuyor zalim队列olarak
//双循环变量处理队列ile处理队列工厂arasinda,anlamadim!
公共处理队列createQueue(){
Queue newQueue=newlinkedlist();
return(ProcessingQueue)newQueue;
}
}
/**
*ProcessingQueue实现将接收未处理的文本数据
*通过其'offer'方法从多个并发生产者获取。您的队列
*必须通过其“poll”方法提供数据的转换版本
*转换描述如下。作为队列,从
*对于调用,poll必须是FIFO(先进先出)
*`offer`;即,输入的第一项也应该是输出的第一项。如果
*数据可用,`poll`必须将其从队列中删除并返回。如果否
*数据可用,则“poll”必须返回null。
*/
类ProcessingQueueClass实现ProcessingQueue{
ProcessingQueueFactoryClass openFactory=新ProcessingQueueFactoryClass();
ProcessingQueue newQueue=openFactory.createQueue();
/**linkify转换应在中找到前缀为“http(s):/”的原始URL
*输入文本并将其转换为HTML链接。例如,
* http://www.example.com 成为。不包括该方案
*(http://)在锚文本中。任何已经在HTML链接中的URL
*不应修改。您可以假定输入文本包含多个单词
*由空格(即空格、新行)或标点(逗号)分隔,
*期间等)
*/
公共字符串链接化转换(字符串s){
//系统输出打印项次;
字符串[]splitArray=s.split(“”);
字符串transformedString=“”;
对于(int i=0;i
以下是一些可能会有所帮助的细节。

Revmetrix Linkify队列编码问题通过转换输入和输出字符串数据。此队列必须 以合理的性能正确处理并发操作。从JAR实现ProcessingQueue和ProcessingQueueFactory。 ProcessingQueue实现将通过其
offer
方法从多个并发生产者接收未经处理的文本数据。你的队列 必须通过其
poll
方法提供数据的转换版本。作为队列,从
poll

对于调用
报价
,必须是FIFO(先进先出)

一般来说,当您在java中
实现
接口时,您需要实现它的方法,并为该接口中定义的方法定义主体

如果不想实现该接口的所有方法体,可以将类更改为
abstract
类,并将该方法标记为
abstract

我不知道有多熟悉
return (ProcessingQueue) newQueue;
ProcessingQueueFactoryClass openFactory = new ProcessingQueueFactoryClass();
ProcessingQueue newQueue = openFactory.createQueue();
Queue<String> newQueue = new LinkedList<String>();
class ProcessingQueueClass implements ProcessingQueue {
    Queue<String> newQueue = new LinkedList<String>();
    ...
}