📄 simpleclient.java
字号:
package dli2fe.sample;
import dli2fe.DLI2FEException;
/* holder for integer values */
import dli2fe.helpers.*;
/* following packages are imported only if DOM-aware XMLObjects are used */
/* DLI2FE XML element names */
import dli2fe.DLI2FE;
import org.omg.CORBA.IntHolder;
/**
* This is the SimpleClient application described in the DLI2FE Java tutorial.
*/
public class SimpleClient {
public static void main(String args[]) {
if(args.length != 2) {
System.err.println("Usage: java dli2fe.sample.SimpleClient <URL_or_IOR> <query text>");
System.exit(1);
}
try {
/* extract command line parameters */
String searchServerURI = args[0]; //"dli2fens:http://localhost:9524/";
String queryStr = args[1];
/* an DLI2FE/CORBA or DLI2FE/DASL transport module is created
* depending on whether a URL or an IOR is supplied */
ClientTransportModule tm = ClientTransportModule.create(searchServerURI);
/* the result will be held in a DOM-enabled dli2fe.xml.dom.XMLObject */
SimpleXMLObject result = new SimpleXMLObject();
/* total expected number of results for this query */
IntHolder expectedTotal = new IntHolder();
tm.search(12345, /* some client SID */
null, /* search the default subcollection */
new SimpleXMLObject("<basicsearch xmlns='DAV:'>" +
" <where><contains>" + queryStr + "</contains></where>" +
"</basicsearch>"),
10, /* return 10 results only */
null, /* retrieve all properties */
null, /* no query options */
expectedTotal, /* place to return expectedTotal */
new IntHolder(), /* place to return serverSID - don't care */
result /* place to return search result */
);
System.out.println("Document: \n" + result.getString() );
System.out.println("EXPECTED TOTAL: " + expectedTotal.value);
} catch (DLI2FEException dli2fe) {
System.err.println("DLI2FE exception (" + dli2fe.getCode() + "): " + dli2fe.getReason());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -