KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > search > results > ChildAssocRefResultSet


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 /*
18  * Created on 07-Jun-2005
19  *
20  * TODO Comment this class
21  *
22  *
23  */

24 package org.alfresco.repo.search.results;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.alfresco.repo.search.AbstractResultSet;
31 import org.alfresco.repo.search.SimpleResultSetMetaData;
32 import org.alfresco.service.cmr.repository.ChildAssociationRef;
33 import org.alfresco.service.cmr.repository.NodeRef;
34 import org.alfresco.service.cmr.repository.NodeService;
35 import org.alfresco.service.cmr.repository.Path;
36 import org.alfresco.service.cmr.search.LimitBy;
37 import org.alfresco.service.cmr.search.PermissionEvaluationMode;
38 import org.alfresco.service.cmr.search.ResultSetMetaData;
39 import org.alfresco.service.cmr.search.ResultSetRow;
40 import org.alfresco.service.cmr.search.SearchParameters;
41
42 public class ChildAssocRefResultSet extends AbstractResultSet
43 {
44     private List JavaDoc<ChildAssociationRef> cars;
45     NodeService nodeService;
46     
47     public ChildAssocRefResultSet(NodeService nodeService, List JavaDoc<ChildAssociationRef> cars, Path[] propertyPaths)
48     {
49         super(propertyPaths);
50         this.nodeService = nodeService;
51         this.cars = cars;
52     }
53     
54     public ChildAssocRefResultSet(NodeService nodeService, List JavaDoc<NodeRef> nodeRefs, Path[] propertyPaths, boolean resolveAllParents)
55     {
56         super(propertyPaths);
57         this.nodeService = nodeService;
58         List JavaDoc<ChildAssociationRef> cars = new ArrayList JavaDoc<ChildAssociationRef>(nodeRefs.size());
59         for(NodeRef nodeRef : nodeRefs)
60         {
61             if(resolveAllParents)
62             {
63                 cars.addAll(nodeService.getParentAssocs(nodeRef));
64             }
65             else
66             {
67                 cars.add(nodeService.getPrimaryParent(nodeRef));
68             }
69         }
70         this.cars = cars;
71     }
72
73     public int length()
74     {
75         return cars.size();
76     }
77
78     public NodeRef getNodeRef(int n)
79     {
80         return cars.get(n).getChildRef();
81     }
82     
83     public ChildAssociationRef getChildAssocRef(int n)
84     {
85         return cars.get(n);
86     }
87
88     public ResultSetRow getRow(int i)
89     {
90         return new ChildAssocRefResultSetRow(this, i);
91     }
92
93     public Iterator JavaDoc<ResultSetRow> iterator()
94     {
95         return new ChildAssocRefResultSetRowIterator(this);
96     }
97     
98     public NodeService getNodeService()
99     {
100         return nodeService;
101     }
102
103     public ResultSetMetaData getResultSetMetaData()
104     {
105         return new SimpleResultSetMetaData(LimitBy.UNLIMITED, PermissionEvaluationMode.EAGER, new SearchParameters());
106     }
107 }
108
Popular Tags