View Javadoc
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.api.dsmlv2.request;
21  
22  
23  import org.apache.directory.api.ldap.codec.api.LdapApiService;
24  import org.apache.directory.api.ldap.model.message.AbandonRequest;
25  import org.apache.directory.api.ldap.model.message.AbandonRequestImpl;
26  import org.apache.directory.api.ldap.model.message.Control;
27  import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
28  import org.dom4j.Element;
29  
30  
31  /**
32   * DSML Decorator for AbandonRequest
33   *
34   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
35   */
36  public class AbandonRequestDsml extends AbstractRequestDsml<AbandonRequest>
37      implements AbandonRequest
38  {
39      /**
40       * Creates a new instance of AbandonRequestDsml.
41       * 
42       * @param codec The LDAP Service to use
43       */
44      public AbandonRequestDsml( LdapApiService codec )
45      {
46          super( codec, new AbandonRequestImpl() );
47      }
48  
49  
50      /**
51       * Creates a new instance of AbandonRequestDsml.
52       *
53       * @param codec The LDAP Service to use
54       * @param ldapMessage the message to decorate
55       */
56      public AbandonRequestDsml( LdapApiService codec, AbandonRequest ldapMessage )
57      {
58          super( codec, ldapMessage );
59      }
60  
61  
62      /**
63       * {@inheritDoc}
64       */
65      public MessageTypeEnum getType()
66      {
67          return getDecorated().getType();
68      }
69  
70  
71      /**
72       * {@inheritDoc}
73       */
74      public Element toDsml( Element root )
75      {
76          Element element = super.toDsml( root );
77  
78          // AbandonID
79          if ( getDecorated().getAbandoned() != 0 )
80          {
81              element.addAttribute( "abandonID", Integer.toString( getDecorated().getAbandoned() ) );
82          }
83  
84          return element;
85      }
86  
87  
88      /**
89       * Get the abandoned message ID
90       * 
91       * @return Returns the abandoned MessageId.
92       */
93      public int getAbandonedMessageId()
94      {
95          return getDecorated().getAbandoned();
96      }
97  
98  
99      /**
100      * Set the abandoned message ID
101      * 
102      * @param abandonedMessageId The abandoned messageID to set.
103      * @return The modified AbandonRequest instance
104      */
105     public AbandonRequest setAbandonedMessageId( int abandonedMessageId )
106     {
107         getDecorated().setAbandoned( abandonedMessageId );
108 
109         return this;
110     }
111 
112 
113     /**
114      * {@inheritDoc}
115      */
116     public int getAbandoned()
117     {
118         return getDecorated().getAbandoned();
119     }
120 
121 
122     /**
123      * {@inheritDoc}
124      */
125     public AbandonRequest setAbandoned( int requestId )
126     {
127         getDecorated().setAbandoned( requestId );
128 
129         return this;
130     }
131 
132 
133     /**
134      * {@inheritDoc}
135      */
136     public AbandonRequest setMessageId( int messageId )
137     {
138         super.setMessageId( messageId );
139 
140         return this;
141     }
142 
143 
144     /**
145      * {@inheritDoc}
146      */
147     public AbandonRequest addControl( Control control )
148     {
149         return ( AbandonRequest ) super.addControl( control );
150     }
151 
152 
153     /**
154      * {@inheritDoc}
155      */
156     public AbandonRequest addAllControls( Control[] controls )
157     {
158         return ( AbandonRequest ) super.addAllControls( controls );
159     }
160 
161 
162     /**
163      * {@inheritDoc}
164      */
165     public AbandonRequest removeControl( Control control )
166     {
167         return ( AbandonRequest ) super.removeControl( control );
168     }
169 }