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.response; 021 022 023import org.apache.directory.api.ldap.codec.api.LdapApiService; 024import org.apache.directory.api.ldap.model.message.MessageTypeEnum; 025import org.apache.directory.api.ldap.model.message.SearchResultDone; 026import org.apache.directory.api.ldap.model.message.SearchResultDoneImpl; 027import org.dom4j.Element; 028import org.dom4j.tree.DefaultElement; 029 030 031/** 032 * DSML Decorator for SearchResultDone 033 * 034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 035 */ 036public class SearchResultDoneDsml extends AbstractResultResponseDsml<SearchResultDone> 037 implements SearchResultDone 038{ 039 private static final String SEARCH_RESULT_DONE_TAG = "searchResultDone"; 040 041 042 /** 043 * Creates a new getDecoratedMessage() of SearchResultDoneDsml. 044 * 045 * @param codec The LDAP Service to use 046 */ 047 public SearchResultDoneDsml( LdapApiService codec ) 048 { 049 super( codec, new SearchResultDoneImpl() ); 050 } 051 052 053 /** 054 * Creates a new getDecoratedMessage() of SearchResultDoneDsml. 055 * 056 * @param codec The LDAP Service to use 057 * @param ldapMessage the message to decorate 058 */ 059 public SearchResultDoneDsml( LdapApiService codec, SearchResultDone ldapMessage ) 060 { 061 super( codec, ldapMessage ); 062 } 063 064 065 /** 066 * {@inheritDoc} 067 */ 068 public MessageTypeEnum getType() 069 { 070 return getDecorated().getType(); 071 } 072 073 074 /** 075 * {@inheritDoc} 076 */ 077 public Element toDsml( Element root ) 078 { 079 Element element = null; 080 081 if ( root != null ) 082 { 083 element = root.addElement( SEARCH_RESULT_DONE_TAG ); 084 } 085 else 086 { 087 element = new DefaultElement( SEARCH_RESULT_DONE_TAG ); 088 } 089 090 LdapResultDsml ldapResultDsml = 091 new LdapResultDsml( getCodecService(), getDecorated().getLdapResult(), getDecorated() ); 092 if ( ldapResultDsml != null ) 093 { 094 ldapResultDsml.toDsml( element ); 095 } 096 097 return element; 098 } 099}