【发布时间】:2016-02-06 10:15:01
【问题描述】:
我已经创建了一个类并导入了我的接口,但剩下的怎么办,我该怎么办?
我有任何东西,但它不起作用我的意思是 ClassCastExeption 不起作用
代码示例:
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);
}
}
这里有一些可能会有所帮助的细节。
Revmetrix Linkify 队列编码问题使用转换的字符串数据的输入和输出。这个队列必须
以合理的性能正确处理并发操作。从 JAR 实现 ProcessingQueue 和 ProcessingQueueFactory。
您的 ProcessingQueue 实现将通过其offer 方法从多个并发生产者接收未处理的文本数据。你的队列
必须通过其poll 方法提供数据的转换版本。作为队列,从poll收到的数据
对于对 offer 的调用,必须是 FIFO(先进先出);
【问题讨论】:
-
我需要帮助,一点帮助,而不是警告,不,它不是重复的,因为我专注于两个接口,我从一个 jar 文件中导入它们,但是如何填充后者?
-
您在上述情况下遇到的具体问题是什么?
标签: java eclipse jar interface