<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.xerces.xni.parser;

import java.util.Hashtable;

import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLString;

/**
 * A convenience implementation of the assertions interface. All compliant assertions
 * processors (using a specific XPath 2.0 engine), should extend this class.
 * 
 * @version $Id$
 * @author: <NAME>, IBM
 */
public class XMLAssertAdapter implements XMLAssertHandler {
    
    // this hashtable contains any implementation specific
    // attributes/properties
    private Hashtable attributes = null;

    public void startElement(QName element, XMLAttributes attributes,
                                              Object assertObject) {
        // TODO Auto-generated method stub

    }
    
    public void endElement(QName element, Augmentations augs) throws Exception {
        // TODO Auto-generated method stub

    }
    
    public void characters(XMLString text) {
        // TODO Auto-generated method stub

    }
    
    /**
     * Allows the user to set specific attributes on the underlying 
     * implementation.
     * @param name    name of attribute
     * @param value   null means to remove attribute
     */
    public void setAttribute(String name, Object value)
                     throws IllegalArgumentException {
        // This handles removal of attributes
        if (value == null) {
          if (attributes != null) {
            attributes.remove(name);
          }
          // Unrecognized attributes do not cause an exception
          return;
        }
        
        // Create Hashtable if none existed before
        if (attributes == null) {
            attributes = new Hashtable();
        }
        
        attributes.put(name, value);
    }
    
    
    /**
     * Allows the user to retrieve specific attributes on the underlying 
     * implementation.
     */
    public Object getAttribute(String name) throws IllegalArgumentException {
        // See if it's in the attributes Hashtable
        if (attributes != null) {
            Object val = attributes.get(name);
            if (val != null) {
              return val;
            }
            else {
              throw new IllegalArgumentException("the attribute "+name+" is not set. can't find it's value");
            }
        }
        
        // unreach
        return null;
    }

}<commit_msg>improvements as per comments from <NAME><commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.xerces.xni.parser;

import java.util.Hashtable;

import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLString;

/**
 * A convenience implementation of the assertions interface. All compliant assertions
 * processors (using a specific XPath 2.0 engine), should extend this class.
 * 
 * @version $Id$
 * @author: <NAME>, IBM
 */
public class XMLAssertAdapter implements XMLAssertHandler {
    
    // this hashtable contains any implementation specific
    // properties
    private Hashtable properties = null;

    public void startElement(QName element, XMLAttributes attributes,
                                            Augmentations augs) {
        // TODO Auto-generated method stub

    }
    
    public void endElement(QName element, Augmentations augs) throws Exception {
        // TODO Auto-generated method stub

    }
    
    public void characters(XMLString text) {
        // TODO Auto-generated method stub

    }
    
    /**
     * Allows the user to set specific properties on the underlying 
     * implementation.
     * @param name    name of property
     * @param value   null means to remove property
     */
    public void setProperty(String name, Object value)
                     throws IllegalArgumentException {
        // this handles removal of properties
        if (value == null) {
          if (properties != null) {
             properties.remove(name);
          }
          // Unrecognized properties do not cause an exception
          return;
        }
        
        // create Hashtable if none existed before
        if (properties == null) {
            properties = new Hashtable();
        }
        
        properties.put(name, value);
    }
    
    
    /**
     * Allows the user to retrieve specific properties on the underlying 
     * implementation.
     */
    public Object getProperty(String name) throws IllegalArgumentException {
        // See if it's in the properties Hashtable
        if (properties != null) {
            Object val = properties.get(name);
            if (val != null) {
              return val;
            }
            else {
              throw new IllegalArgumentException("the property "+name+" is not set. can't find it's value");
            }
        }
        
        // unreach
        return null;
    }

}
{'fraction_non_alphanumeric': 0.07287387798569907, 'fraction_numerical': 0.0018256503879507074, 'mean_word_length': 2.2544554455445542, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5624840', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1572, 'n_words': 635}