KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > arp > RDFCollection


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP,
3   all rights reserved.
4   [See end of file]
5   $Id: RDFCollection.java,v 1.7 2005/02/21 12:09:15 andy_seaborne Exp $
6 */

7 package com.hp.hpl.jena.rdf.arp;
8
9 /**
10  * @author Jeremy J. Carroll
11  *
12  */

13 class RDFCollection extends CollectionAction {
14
15     
16
17     static URIReference first = null;
18     static URIReference rest = null;
19     static URIReference nil = null;
20     
21     RDFCollection(ParserSupport x){
22         super(x);
23     }
24     RDFCollection(ParserSupport x, AResourceInternal r[]){
25         super(x);
26         rslt = r;
27     }
28     private AResourceInternal rslt[];
29     static {
30         try {
31             nil = new URIReference(XMLHandler.rdfns+"nil");
32             
33             first = new URIReference(XMLHandler.rdfns+"first");
34             rest = new URIReference(XMLHandler.rdfns+"rest");
35         }
36         catch (MalformedURIException e) {
37             System.err.println("Internal error: " + e.toString());
38             e.printStackTrace();
39         }
40     }
41     /* (non-Javadoc)
42      * @see com.hp.hpl.jena.rdf.arp.CollectionAction#terminate()
43      */

44     void terminate() {
45         rslt[0] = nil;
46     }
47     public void cleanUp() {
48         if (rslt[0]!=null) {
49             X.arp.endLocalScope(rslt[0]);
50             rslt[0] = null;
51         }
52     }
53     /* (non-Javadoc)
54      * @see com.hp.hpl.jena.rdf.arp.CollectionAction#next(com.hp.hpl.jena.rdf.arp.AResource)
55      */

56     CollectionAction next(AResourceInternal head) {
57         ARPResource cell= new ARPResource(X.arp);
58         try {
59             cell.setPredicateObject( first,head, null );
60         }
61         finally {
62             X.arp.endLocalScope(head);
63             rslt[0] = cell;
64         }
65         //cell.setPredicateObject( rest, tail, null );
66
//cell.setType(DAML.List);
67

68         return new RDFTailCollection(X,cell);
69         
70     }
71
72 }
73
74 /*
75     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
76     All rights reserved.
77
78     Redistribution and use in source and binary forms, with or without
79     modification, are permitted provided that the following conditions
80     are met:
81
82     1. Redistributions of source code must retain the above copyright
83        notice, this list of conditions and the following disclaimer.
84
85     2. Redistributions in binary form must reproduce the above copyright
86        notice, this list of conditions and the following disclaimer in the
87        documentation and/or other materials provided with the distribution.
88
89     3. The name of the author may not be used to endorse or promote products
90        derived from this software without specific prior written permission.
91
92     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
93     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
94     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
95     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
96     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
97     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
98     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
99     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
100     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
101     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 */
Popular Tags