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.ldap.codec.actions.request.search.filter; 021 022 023import org.apache.directory.api.asn1.ber.grammar.GrammarAction; 024import org.apache.directory.api.asn1.ber.tlv.TLV; 025import org.apache.directory.api.i18n.I18n; 026import org.apache.directory.api.ldap.codec.api.LdapMessageContainer; 027import org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter; 028import org.apache.directory.api.ldap.model.entry.Value; 029import org.apache.directory.api.ldap.model.message.SearchRequest; 030import org.slf4j.Logger; 031import org.slf4j.LoggerFactory; 032 033 034/** 035 * The action used to store a match value 036 * <pre> 037 * Filter ::= CHOICE { 038 * ... 039 * extensibleMatch [9] MatchingRuleAssertion } 040 * 041 * MatchingRuleAssertion ::= SEQUENCE { 042 * ... 043 * matchValue [3] AssertionValue, 044 * ... 045 * </pre> 046 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 047 */ 048public class StoreMatchValue extends GrammarAction<LdapMessageContainer<SearchRequest>> 049{ 050 /** The logger */ 051 private static final Logger LOG = LoggerFactory.getLogger( StoreMatchValue.class ); 052 053 /** 054 * Instantiates a new store match value action. 055 */ 056 public StoreMatchValue() 057 { 058 super( "Store match Value" ); 059 } 060 061 062 /** 063 * {@inheritDoc} 064 */ 065 public void action( LdapMessageContainer<SearchRequest> container ) 066 { 067 TLV tlv = container.getCurrentTLV(); 068 069 // Store the value. 070 ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) container.getTerminalFilter(); 071 072 byte[] value = tlv.getValue().getData(); 073 extensibleMatchFilter.setMatchValue( new Value( value ) ); 074 075 // unstack the filters if needed 076 container.unstackFilters(); 077 078 if ( LOG.isDebugEnabled() ) 079 { 080 LOG.debug( I18n.msg( I18n.MSG_05156_STORED_MATCH_VALUE, value ) ); 081 } 082 } 083}