<commit_before>/*
 *   Copyright 2005 The Apache Software Foundation
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package org.apache.ldap.common.codec;

import java.util.HashSet;
import java.util.Set;

import org.apache.ldap.common.util.StringTools;
import org.apache.ldap.common.codec.abandon.AbandonRequestGrammar;
import org.apache.ldap.common.codec.add.AddRequestGrammar;
import org.apache.ldap.common.codec.add.AddResponseGrammar;
import org.apache.ldap.common.codec.bind.BindRequestGrammar;
import org.apache.ldap.common.codec.bind.BindResponseGrammar;
import org.apache.ldap.common.codec.compare.CompareRequestGrammar;
import org.apache.ldap.common.codec.compare.CompareResponseGrammar;
import org.apache.ldap.common.codec.del.DelRequestGrammar;
import org.apache.ldap.common.codec.del.DelResponseGrammar;
import org.apache.ldap.common.codec.extended.ExtendedRequestGrammar;
import org.apache.ldap.common.codec.extended.ExtendedResponseGrammar;
import org.apache.ldap.common.codec.modify.ModifyRequestGrammar;
import org.apache.ldap.common.codec.modify.ModifyResponseGrammar;
import org.apache.ldap.common.codec.modifyDn.ModifyDNRequestGrammar;
import org.apache.ldap.common.codec.modifyDn.ModifyDNResponseGrammar;
import org.apache.ldap.common.codec.search.FilterGrammar;
import org.apache.ldap.common.codec.search.SearchRequestGrammar;
import org.apache.ldap.common.codec.search.SearchResultDoneGrammar;
import org.apache.ldap.common.codec.search.SearchResultEntryGrammar;
import org.apache.ldap.common.codec.search.SearchResultReferenceGrammar;
import org.apache.ldap.common.codec.unbind.UnBindRequestGrammar;
import org.apache.asn1.ber.AbstractContainer;
import org.apache.asn1.ber.IAsn1Container;
import org.apache.asn1.ber.grammar.IGrammar;


/**
 * The LdapMessage container stores all the messages decoded by the
 * Asn1Decoder. When dealing whith an incoding PDU, we will obtain
 * a LdapMessage in the ILdapContainer.
 *  
 * @author <a href="mailto:<EMAIL>">Apache Directory Project</a>
 */
public class LdapMessageContainer extends AbstractContainer implements IAsn1Container //extends AbstractLdapContainer
{
    //~ Instance fields ----------------------------------------------------------------------------

    /** The ldap message */
    private LdapMessage ldapMessage;

    /** A HashSet which contaons the binary attributes */
    private Set binaries;

    //~ Constructors -------------------------------------------------------------------------------

    /**
     * Creates a new LdapMessageContainer object.
     * We will store ten grammars, it's enough ...
     */
    public LdapMessageContainer()
    {
        this( new HashSet() );
    }

    /**
     * Creates a new LdapMessageContainer object.
     * We will store ten grammars, it's enough ...
     */
    public LdapMessageContainer( Set binaries )
    {
        super( );
        currentGrammar = 0;
        grammars = new IGrammar[LdapStatesEnum.NB_GRAMMARS];
        grammarStack = new IGrammar[10];
        stateStack = new int[10];
        nbGrammars = 0;

        grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR] = LdapMessageGrammar.getInstance();
        grammars[LdapStatesEnum.LDAP_CONTROL_GRAMMAR] = LdapControlGrammar.getInstance();
        grammars[LdapStatesEnum.BIND_REQUEST_GRAMMAR] = BindRequestGrammar.getInstance();
        grammars[LdapStatesEnum.LDAP_RESULT_GRAMMAR]  = LdapResultGrammar.getInstance();
        grammars[LdapStatesEnum.BIND_RESPONSE_GRAMMAR] = BindResponseGrammar.getInstance();
        grammars[LdapStatesEnum.UNBIND_REQUEST_GRAMMAR] = UnBindRequestGrammar.getInstance();
        grammars[LdapStatesEnum.ABANDON_REQUEST_GRAMMAR] = AbandonRequestGrammar.getInstance();
        grammars[LdapStatesEnum.ADD_RESPONSE_GRAMMAR] = AddResponseGrammar.getInstance();
        grammars[LdapStatesEnum.COMPARE_RESPONSE_GRAMMAR] = CompareResponseGrammar.getInstance();
        grammars[LdapStatesEnum.DEL_RESPONSE_GRAMMAR] = DelResponseGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_RESPONSE_GRAMMAR] = ModifyResponseGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_DN_RESPONSE_GRAMMAR] = ModifyDNResponseGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_RESULT_DONE_GRAMMAR] = SearchResultDoneGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_REQUEST_GRAMMAR] = SearchRequestGrammar.getInstance();
        grammars[LdapStatesEnum.FILTER_GRAMMAR] = FilterGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_RESULT_ENTRY_GRAMMAR] = SearchResultEntryGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_REQUEST_GRAMMAR] = ModifyRequestGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_RESULT_REFERENCE_GRAMMAR] = SearchResultReferenceGrammar.getInstance();
        grammars[LdapStatesEnum.ADD_REQUEST_GRAMMAR] = AddRequestGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_DN_REQUEST_GRAMMAR] = ModifyDNRequestGrammar.getInstance();
        grammars[LdapStatesEnum.DEL_REQUEST_GRAMMAR] = DelRequestGrammar.getInstance();
        grammars[LdapStatesEnum.COMPARE_REQUEST_GRAMMAR] = CompareRequestGrammar.getInstance();
        grammars[LdapStatesEnum.EXTENDED_REQUEST_GRAMMAR] = ExtendedRequestGrammar.getInstance();
        grammars[LdapStatesEnum.EXTENDED_RESPONSE_GRAMMAR] = ExtendedResponseGrammar.getInstance();

        grammarStack[currentGrammar] = grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR];

        states = LdapStatesEnum.getInstance();

        this.binaries = binaries;
    }

    //~ Methods ------------------------------------------------------------------------------------
    /**
     * @return Returns the ldapMessage.
     */
    public LdapMessage getLdapMessage()
    {

        return ldapMessage;<commit_msg>Added two more grammars in the container : SubstringsFilter Grammar and MatchingRuleAssertion Grammar<commit_after>/*
 *   Copyright 2005 The Apache Software Foundation
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package org.apache.ldap.common.codec;

import java.util.HashSet;
import java.util.Set;

import org.apache.ldap.common.util.StringTools;
import org.apache.ldap.common.codec.abandon.AbandonRequestGrammar;
import org.apache.ldap.common.codec.add.AddRequestGrammar;
import org.apache.ldap.common.codec.add.AddResponseGrammar;
import org.apache.ldap.common.codec.bind.BindRequestGrammar;
import org.apache.ldap.common.codec.bind.BindResponseGrammar;
import org.apache.ldap.common.codec.compare.CompareRequestGrammar;
import org.apache.ldap.common.codec.compare.CompareResponseGrammar;
import org.apache.ldap.common.codec.del.DelRequestGrammar;
import org.apache.ldap.common.codec.del.DelResponseGrammar;
import org.apache.ldap.common.codec.extended.ExtendedRequestGrammar;
import org.apache.ldap.common.codec.extended.ExtendedResponseGrammar;
import org.apache.ldap.common.codec.modify.ModifyRequestGrammar;
import org.apache.ldap.common.codec.modify.ModifyResponseGrammar;
import org.apache.ldap.common.codec.modifyDn.ModifyDNRequestGrammar;
import org.apache.ldap.common.codec.modifyDn.ModifyDNResponseGrammar;
import org.apache.ldap.common.codec.search.FilterGrammar;
import org.apache.ldap.common.codec.search.MatchingRuleAssertionGrammar;
import org.apache.ldap.common.codec.search.SearchRequestGrammar;
import org.apache.ldap.common.codec.search.SearchResultDoneGrammar;
import org.apache.ldap.common.codec.search.SearchResultEntryGrammar;
import org.apache.ldap.common.codec.search.SearchResultReferenceGrammar;
import org.apache.ldap.common.codec.search.SubstringFilterGrammar;
import org.apache.ldap.common.codec.unbind.UnBindRequestGrammar;
import org.apache.asn1.ber.AbstractContainer;
import org.apache.asn1.ber.IAsn1Container;
import org.apache.asn1.ber.grammar.IGrammar;


/**
 * The LdapMessage container stores all the messages decoded by the
 * Asn1Decoder. When dealing whith an incoding PDU, we will obtain
 * a LdapMessage in the ILdapContainer.
 *  
 * @author <a href="mailto:<EMAIL>">Apache Directory Project</a>
 */
public class LdapMessageContainer extends AbstractContainer implements IAsn1Container //extends AbstractLdapContainer
{
    //~ Instance fields ----------------------------------------------------------------------------

    /** The ldap message */
    private LdapMessage ldapMessage;

    /** A HashSet which contaons the binary attributes */
    private Set binaries;

    //~ Constructors -------------------------------------------------------------------------------

    /**
     * Creates a new LdapMessageContainer object.
     * We will store ten grammars, it's enough ...
     */
    public LdapMessageContainer()
    {
        this( new HashSet() );
    }

    /**
     * Creates a new LdapMessageContainer object.
     * We will store ten grammars, it's enough ...
     */
    public LdapMessageContainer( Set binaries )
    {
        super( );
        currentGrammar = 0;
        grammars = new IGrammar[LdapStatesEnum.NB_GRAMMARS];
        grammarStack = new IGrammar[10];
        stateStack = new int[10];
        nbGrammars = 0;

        grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR] = LdapMessageGrammar.getInstance();
        grammars[LdapStatesEnum.LDAP_CONTROL_GRAMMAR] = LdapControlGrammar.getInstance();
        grammars[LdapStatesEnum.BIND_REQUEST_GRAMMAR] = BindRequestGrammar.getInstance();
        grammars[LdapStatesEnum.LDAP_RESULT_GRAMMAR]  = LdapResultGrammar.getInstance();
        grammars[LdapStatesEnum.BIND_RESPONSE_GRAMMAR] = BindResponseGrammar.getInstance();
        grammars[LdapStatesEnum.UNBIND_REQUEST_GRAMMAR] = UnBindRequestGrammar.getInstance();
        grammars[LdapStatesEnum.ABANDON_REQUEST_GRAMMAR] = AbandonRequestGrammar.getInstance();
        grammars[LdapStatesEnum.ADD_RESPONSE_GRAMMAR] = AddResponseGrammar.getInstance();
        grammars[LdapStatesEnum.COMPARE_RESPONSE_GRAMMAR] = CompareResponseGrammar.getInstance();
        grammars[LdapStatesEnum.DEL_RESPONSE_GRAMMAR] = DelResponseGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_RESPONSE_GRAMMAR] = ModifyResponseGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_DN_RESPONSE_GRAMMAR] = ModifyDNResponseGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_RESULT_DONE_GRAMMAR] = SearchResultDoneGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_REQUEST_GRAMMAR] = SearchRequestGrammar.getInstance();
        grammars[LdapStatesEnum.FILTER_GRAMMAR] = FilterGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_RESULT_ENTRY_GRAMMAR] = SearchResultEntryGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_REQUEST_GRAMMAR] = ModifyRequestGrammar.getInstance();
        grammars[LdapStatesEnum.SEARCH_RESULT_REFERENCE_GRAMMAR] = SearchResultReferenceGrammar.getInstance();
        grammars[LdapStatesEnum.ADD_REQUEST_GRAMMAR] = AddRequestGrammar.getInstance();
        grammars[LdapStatesEnum.MODIFY_DN_REQUEST_GRAMMAR] = ModifyDNRequestGrammar.getInstance();
        grammars[LdapStatesEnum.DEL_REQUEST_GRAMMAR] = DelRequestGrammar.getInstance();
        grammars[LdapStatesEnum.COMPARE_REQUEST_GRAMMAR] = CompareRequestGrammar.getInstance();
        grammars[LdapStatesEnum.EXTENDED_REQUEST_GRAMMAR] = ExtendedRequestGrammar.getInstance();
        grammars[LdapStatesEnum.EXTENDED_RESPONSE_GRAMMAR] = ExtendedResponseGrammar.getInstance();
        grammars[LdapStatesEnum.SUBSTRING_FILTER_GRAMMAR] = SubstringFilterGrammar.getInstance();
        grammars[LdapStatesEnum.MATCHING_RULE_ASSERTION_GRAMMAR] = MatchingRuleAssertionGrammar.getInstance();

        grammarStack[currentGrammar] = grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR];

        states = LdapStatesEnum.getInstance();

        this.binaries = binaries;
    }

    //~ Methods ------------------------------------------------------------------------------------
    /**
     * @return Returns the ldapMessage.
     */
    public LdapMessage getLdapMessage()
    {

        return ldapMessage;
{'fraction_non_alphanumeric': 0.12406737943235135, 'fraction_numerical': 0.003076686408737789, 'mean_word_length': 3.757409440175631, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3959879', 'n_tokens_mistral': 4056, 'n_tokens_neox': 3953, 'n_words': 638}