KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > dsmlv2 > reponse > SearchResponseDsml


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.dsmlv2.reponse;
21
22
23 import java.util.List JavaDoc;
24
25 import org.apache.directory.ldapstudio.dsmlv2.DsmlDecorator;
26 import org.apache.directory.shared.ldap.codec.LdapMessage;
27 import org.dom4j.Element;
28
29
30 /**
31  * This class represents the Search Response Dsml Container.
32  * It is used to store Search Responses (Search Result Entry,
33  * Search Result Reference and SearchResultDone).
34  *
35  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
36  * @version $Rev$, $Date$
37  */

38 public class SearchResponseDsml extends LdapResponseDecorator implements DsmlDecorator
39 {
40     /** The responses */
41     private List JavaDoc<DsmlDecorator> responses;
42
43
44     /**
45      * Creates a new instance of SearchResponseDsml.
46      */

47     public SearchResponseDsml()
48     {
49         super( new LdapMessage() );
50     }
51
52
53     /**
54      * Adds a response.
55      *
56      * @param response
57      * the response to add
58      * @return
59      * true (as per the general contract of the Collection.add method).
60      */

61     public boolean addResponse( DsmlDecorator response )
62     {
63         return responses.add( response );
64     }
65
66
67     /**
68      * Removes a response.
69      *
70      * @param response
71      * the response to remove
72      * @return
73      * true if this list contained the specified element.
74      */

75     public boolean removeResponse( DsmlDecorator response )
76     {
77         return responses.remove( response );
78     }
79
80
81     /* (non-Javadoc)
82      * @see org.apache.directory.ldapstudio.dsmlv2.DsmlDecorator#toDsml(org.dom4j.Element)
83      */

84     public Element toDsml( Element root )
85     {
86         Element element = root.addElement( "searchResponse" );
87
88         // RequestID
89
int requestID = instance.getMessageId();
90         if ( requestID != 0 )
91         {
92             element.addAttribute( "requestID", "" + requestID );
93         }
94
95         for ( DsmlDecorator response : responses )
96         {
97             response.toDsml( element );
98         }
99
100         return element;
101     }
102 }
103
Popular Tags