001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.dsmlv2.request; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.model.message.AbandonRequest; 025import org.apache.directory.api.ldap.model.message.AbandonRequestImpl; 026import org.apache.directory.api.ldap.model.message.Control; 027import org.apache.directory.api.ldap.model.message.MessageTypeEnum; 028import org.dom4j.Element; 029 030 031/** 032 * DSML Decorator for AbandonRequest 033 * 034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 035 */ 036public class AbandonRequestDsml extends AbstractRequestDsml<AbandonRequest> 037 implements AbandonRequest 038{ 039 /** 040 * Creates a new instance of AbandonRequestDsml. 041 * 042 * @param codec The LDAP Service to use 043 */ 044 public AbandonRequestDsml( LdapApiService codec ) 045 { 046 super( codec, new AbandonRequestImpl() ); 047 } 048 049 050 /** 051 * Creates a new instance of AbandonRequestDsml. 052 * 053 * @param codec The LDAP Service to use 054 * @param ldapMessage the message to decorate 055 */ 056 public AbandonRequestDsml( LdapApiService codec, AbandonRequest ldapMessage ) 057 { 058 super( codec, ldapMessage ); 059 } 060 061 062 /** 063 * {@inheritDoc} 064 */ 065 public MessageTypeEnum getType() 066 { 067 return getDecorated().getType(); 068 } 069 070 071 /** 072 * {@inheritDoc} 073 */ 074 public Element toDsml( Element root ) 075 { 076 Element element = super.toDsml( root ); 077 078 // AbandonID 079 if ( getDecorated().getAbandoned() != 0 ) 080 { 081 element.addAttribute( "abandonID", Integer.toString( getDecorated().getAbandoned() ) ); 082 } 083 084 return element; 085 } 086 087 088 /** 089 * Get the abandoned message ID 090 * 091 * @return Returns the abandoned MessageId. 092 */ 093 public int getAbandonedMessageId() 094 { 095 return getDecorated().getAbandoned(); 096 } 097 098 099 /** 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}