"restriction_value_" + i,
str("restrictionValue", (i+1)),
str("helpRestrictionValue")));
}
requestList.add(new UIRequest_Output(helpString));
UIRequest[] requestArray = new UIRequest[requestList.size()];
requestArray = requestList.toArray(requestArray);
NamedDataSet reply = uiForRequests.request(requestArray);
if (reply == null) { return null; } //cancelled - #### !! return-point !! ####
try { //catch MalformedURLException and NamedDataNotAvailableException
createBot(conf_wikiURLs[reply.<Integer>get("url")]);
Integer type = reply.get("type");
String name = reply.get("name");
if ( type == 0 /*article*/ ){
result = readArticle(name);
}
else { //one of the iterator-generating types
try { //catch JWBFExceptions
/* get the appropriate iterator */
switch (type) {
case 1: /*articles from*/
titleIterator = new AllPageTitles(bot, name,null,nonredirects).iterator();
break;
case 2: /*articles starting with*/
titleIterator = new AllPageTitles(bot,null,name,nonredirects).iterator();
break;
case 3: /*category*/
titleIterator = new CategoryMembersSimple(bot, name).iterator();
break;
case 4: /*backlinks*/
titleIterator = new BacklinkTitles(bot, name).iterator();
break;
case 5: /*imagelinks*/
if (!imagePrefix.equals("")) {
name = imagePrefix + name;
}
titleIterator = new ImageUsageTitles(bot, name).iterator();
break;
case 6: /*template users*/
if (!templatePrefix.equals("")) {
name = templatePrefix + name;
}
titleIterator = new TemplateUserTitles(bot, name).iterator();
break;
}
/* apply the restrictions */
for (int i = 0; i < restrictionsInArticleSelection;
i ++) {
Integer restrictionType =
reply.get("restriction_type_" + i);
String restrictionValue =
reply.get("restriction_value_" + i);
if (restrictionType > 0 &&
restrictionValue != null) {
switch (restrictionType) {
case 1: /* articles from */
titleIterator =
new RestrictedIterator_StartFrom(
titleIterator,
restrictionValue);
break;
case 2: /* articles starting with */
titleIterator =
new RestrictedIterator_Prefix(
titleIterator,
restrictionValue);
break;
}
}
}
} catch (VersionException ve) {
String error = str("errorReceivingInfoWithExceptionName", "VersionException", ve.getMessage());
uiForRequests.request(new UIRequest_Output(error));
} catch (CookieException ce) {
String error = str("errorReceivingInfoWithExceptionName", "CookieException", ce.getMessage());
uiForRequests.request(new UIRequest_Output(error));
} catch (JwbfException je) {
String error = str("errorReceivingInfo", je.getMessage());
uiForRequests.request(new UIRequest_Output(error));
}
//return the first article
if (titleIterator.hasNext()) {
result = readArticle(titleIterator.next());
} else {
result = null;
}
}
} catch (MalformedURLException e) {
uiForRequests.request(
new UIRequest_Output(
str("errorMalformedURL") + e.getMessage() ));
} catch (NamedDataNotAvailableException e) {
uiForRequests.request(new UIRequest_Output(str("errorUserInput")));
}
}
/* optionally show read article in browser, then return text */