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      public AbandonRequestDsml( LdapApiService codec )
43      {
44          super( codec, new AbandonRequestImpl() );
45      }
46  
47  
48      /**
49       * Creates a new instance of AbandonRequestDsml.
50       *
51       * @param ldapMessage the message to decorate
52       */
53      public AbandonRequestDsml( LdapApiService codec, AbandonRequest ldapMessage )
54      {
55          super( codec, ldapMessage );
56      }
57  
58  
59      /**
60       * {@inheritDoc}
61       */
62      public MessageTypeEnum getType()
63      {
64          return getDecorated().getType();
65      }
66  
67  
68      /**
69       * {@inheritDoc}
70       */
71      public Element toDsml( Element root )
72      {
73          Element element = super.toDsml( root );
74  
75          // AbandonID
76          if ( getDecorated().getAbandoned() != 0 )
77          {
78              element.addAttribute( "abandonID", "" + getDecorated().getAbandoned() );
79          }
80  
81          return element;
82      }
83  
84  
85      /**
86       * Get the abandoned message ID
87       * 
88       * @return Returns the abandoned MessageId.
89       */
90      public int getAbandonedMessageId()
91      {
92          return getDecorated().getAbandoned();
93      }
94  
95  
96      /**
97       * Set the abandoned message ID
98       * 
99       * @param abandonedMessageId The abandoned messageID to set.
100      */
101     public AbandonRequest setAbandonedMessageId( int abandonedMessageId )
102     {
103         getDecorated().setAbandoned( abandonedMessageId );
104 
105         return this;
106     }
107 
108 
109     /**
110      * {@inheritDoc}
111      */
112     public int getAbandoned()
113     {
114         return getDecorated().getAbandoned();
115     }
116 
117 
118     /**
119      * {@inheritDoc}
120      */
121     public AbandonRequest setAbandoned( int requestId )
122     {
123         getDecorated().setAbandoned( requestId );
124 
125         return this;
126     }
127 
128 
129     /**
130      * {@inheritDoc}
131      */
132     public AbandonRequest setMessageId( int messageId )
133     {
134         super.setMessageId( messageId );
135 
136         return this;
137     }
138 
139 
140     /**
141      * {@inheritDoc}
142      */
143     public AbandonRequest addControl( Control control )
144     {
145         return ( AbandonRequest ) super.addControl( control );
146     }
147 
148 
149     /**
150      * {@inheritDoc}
151      */
152     public AbandonRequest addAllControls( Control[] controls )
153     {
154         return ( AbandonRequest ) super.addAllControls( controls );
155     }
156 
157 
158     /**
159      * {@inheritDoc}
160      */
161     public AbandonRequest removeControl( Control control )
162     {
163         return ( AbandonRequest ) super.removeControl( control );
164     }
165 }