1 |
import estraier.*; |
2 |
|
3 |
public class NodeExample001 { |
4 |
public static void main(String[] args){ |
5 |
// create the creator object |
6 |
Creator creator = new CreatorImpl(); |
7 |
// create and configure the node connecton object |
8 |
Node node = creator.create_node(); |
9 |
node.set_url("http://localhost:1978/node/test1"); |
10 |
node.set_auth("admin", "admin"); |
11 |
// create a document object |
12 |
Document doc = creator.create_document(); |
13 |
// add attributes to the document object |
14 |
doc.add_attr("@uri", "http://estraier.gov/example.txt"); |
15 |
doc.add_attr("@title", "Over the Rainbow"); |
16 |
// add the body text to the document object |
17 |
doc.add_text("Somewhere over the rainbow. Way up high."); |
18 |
doc.add_text("There's a land that I heard of once in a lullaby."); |
19 |
// register the document object to the node |
20 |
if(!node.put_doc(doc)) |
21 |
System.err.println("error: " + node.status()); |
22 |
} |
23 |
} |