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 */ 020 package org.apache.directory.shared.dsmlv2.request; 021 022 023 import org.apache.directory.shared.ldap.codec.MessageTypeEnum; 024 import org.apache.directory.shared.ldap.codec.compare.CompareRequestCodec; 025 import org.apache.directory.shared.ldap.name.DN; 026 import org.dom4j.Element; 027 028 029 /** 030 * DSML Decorator for CompareRequest 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 * @version $Rev$, $Date$ 034 */ 035 public class CompareRequestDsml extends AbstractRequestDsml 036 { 037 /** 038 * Creates a new instance of CompareRequestDsml. 039 */ 040 public CompareRequestDsml() 041 { 042 super( new CompareRequestCodec() ); 043 } 044 045 046 /** 047 * Creates a new instance of CompareRequestDsml. 048 * 049 * @param ldapMessage 050 * the message to decorate 051 */ 052 public CompareRequestDsml( CompareRequestCodec ldapMessage ) 053 { 054 super( ldapMessage ); 055 } 056 057 058 /** 059 * {@inheritDoc} 060 */ 061 public MessageTypeEnum getMessageType() 062 { 063 return instance.getMessageType(); 064 } 065 066 067 /** 068 * {@inheritDoc} 069 */ 070 public Element toDsml( Element root ) 071 { 072 Element element = super.toDsml( root ); 073 074 CompareRequestCodec request = ( CompareRequestCodec ) instance; 075 076 // DN 077 if ( request.getEntry() != null ) 078 { 079 element.addAttribute( "dn", request.getEntry().getName() ); 080 } 081 082 // Assertion 083 Element assertionElement = element.addElement( "assertion" ); 084 if ( request.getAttributeDesc() != null ) 085 { 086 assertionElement.addAttribute( "name", request.getAttributeDesc() ); 087 } 088 if ( request.getAssertionValue() != null ) 089 { 090 assertionElement.addElement( "value" ).setText( ( String ) request.getAssertionValue() ); 091 } 092 093 return element; 094 } 095 096 097 /** 098 * Get the entry to be compared 099 * 100 * @return Returns the entry. 101 */ 102 public DN getEntry() 103 { 104 return ( ( CompareRequestCodec ) instance ).getEntry(); 105 } 106 107 108 /** 109 * Set the entry to be compared 110 * 111 * @param entry The entry to set. 112 */ 113 public void setEntry( DN entry ) 114 { 115 ( ( CompareRequestCodec ) instance ).setEntry( entry ); 116 } 117 118 119 /** 120 * Get the assertion value 121 * 122 * @return Returns the assertionValue. 123 */ 124 public Object getAssertionValue() 125 { 126 return ( ( CompareRequestCodec ) instance ).getAssertionValue(); 127 } 128 129 130 /** 131 * Set the assertion value 132 * 133 * @param assertionValue The assertionValue to set. 134 */ 135 public void setAssertionValue( Object assertionValue ) 136 { 137 ( ( CompareRequestCodec ) instance ).setAssertionValue( assertionValue ); 138 } 139 140 141 /** 142 * Get the attribute description 143 * 144 * @return Returns the attributeDesc. 145 */ 146 public String getAttributeDesc() 147 { 148 return ( ( CompareRequestCodec ) instance ).getAttributeDesc(); 149 } 150 151 152 /** 153 * Set the attribute description 154 * 155 * @param attributeDesc The attributeDesc to set. 156 */ 157 public void setAttributeDesc( String attributeDesc ) 158 { 159 ( ( CompareRequestCodec ) instance ).setAttributeDesc( attributeDesc ); 160 } 161 }