开发者

How do use the Series class to set a property for Restlet?

I want to set a restlet client to follow redirects. To do this I need to make a Context, set the Client to use the Context and then run it.

However, to add the parameter:

Parameter param = new Parameter(开发者_如何学Python"followRedirects", "true");

To the Context, I need to make a Series<Parameter>. This causes a problem, as the Series class is absract and to subclass it I need to implement what looks like a copy constructor, and an addEntry method.

How do you implement the following abstract method? Since its got to return a Series<Parameter> you have to make a Series to return, but I haven't got a working Series class yet to make one to return!

public Series<Parameter> createSeries(List<Parameter> delegate) {
}

Thanks!


Call:

Series<Parameter> params = myNewContext.getParameters();
params.add("followRedirects", "true);

If you look at the source code for Context.java, you'll see that its parameters are initialized to an empty Form (a concrete subclass of Series). This is done as a convenience so you don't have to worry about creating the Series.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜