KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

13 class DAMLCollection extends CollectionAction {
14
15     
16
17     static URIReference first = null;
18     static URIReference rest = null;
19     static URIReference nil = null;
20     static URIReference List = null;
21     static private String JavaDoc damlns = "http://www.daml.org/2001/03/daml+oil#";
22     
23
24     DAMLCollection(ParserSupport x){
25         super(x);
26     }
27     DAMLCollection(ParserSupport x,AResourceInternal r[]){
28         super(x);
29         rslt = r;
30     }
31     private AResourceInternal rslt[];
32     static {
33         try {
34             nil = new URIReference(damlns+"nil");
35             
36             first = new URIReference(damlns+"first");
37             rest = new URIReference(damlns+"rest");
38             List = new URIReference(damlns+"List");
39         }
40         catch (MalformedURIException e) {
41             System.err.println("Internal error: " + e.toString());
42             e.printStackTrace();
43         }
44     }
45     
46     public void cleanUp() {
47         if (rslt[0]!=null) {
48             X.arp.endLocalScope(rslt[0]);
49             rslt[0] = null;
50         }
51     }
52     /* (non-Javadoc)
53      * @see com.hp.hpl.jena.rdf.arp.CollectionAction#terminate()
54      */

55     void terminate() {
56         rslt[0] = nil;
57     }
58
59     /* (non-Javadoc)
60      * @see com.hp.hpl.jena.rdf.arp.CollectionAction#next(com.hp.hpl.jena.rdf.arp.AResource)
61      */

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