<commit_before>/*
 * $URL$
 * $Revision$
 * $Author$
 *
 * Copyright (C) 2007-2008 <NAME>
 */


package net.fortytwo.ripple;

import java.util.Properties;
import java.io.File;

//import net.fortytwo.ripple.rdf.RdfUtils;
/*import net.fortytwo.ripple.model.enums.ExpressionOrder;
import net.fortytwo.ripple.model.enums.EvaluationStyle;
import net.fortytwo.ripple.model.enums.EvaluationOrder;*/

//import org.openrdf.rio.RDFFormat;

public class RippleProperties
{
	private Properties props;
	
	public RippleProperties( final Properties props )
	{
		this.props = props;
	}
	
	public String getString( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
		return value;
	}

    public String getString( final String name, final String defaultValue ) throws RippleException
	{
		String value = getProperty( name, false );
        
        return ( null == value )
                ? defaultValue
                : value;
	}

    public boolean getBoolean( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
		
		return value.equals( "true" );
	}
	
	public int getInt( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
	
		try
		{
			return ( new Integer( value ) ).intValue();
		}
		
		catch ( java.lang.NumberFormatException e )
		{
			throw new RippleException( e );
		}
	}
	
	public long getLong( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
		
		try
		{
			return ( new Long( value ) ).longValue();
		}
		
		catch ( java.lang.NumberFormatException e )
		{
			throw new RippleException( e );
		}
	}

    public File getFile( final String name ) throws RippleException
    {
        String value = getProperty( name, true );
        
        return new File( value );
    }

    public File getFile( final String name, final File defaultValue ) throws RippleException
    {
        String value = getProperty( name, false );

        return ( null == value )
                ? defaultValue
                : new File( value );
    }

    private String getProperty( final String name, final boolean required ) throws RippleException
	{
		String s = props.getProperty( name );
		
		if ( null == s && required )
		{
			throw new RippleException( "no value for property: " + name );
		}
		
		return s;
	}
}<commit_msg>RippleProperties now inherits java.util.Properties and has type-specific set methods.<commit_after>/*
 * $URL$
 * $Revision$
 * $Author$
 *
 * Copyright (C) 2007-2008 <NAME>
 */


package net.fortytwo.ripple;

import java.util.Properties;
import java.util.Date;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

public class RippleProperties extends Properties
{
    public RippleProperties( final Properties defaults )
    {
        super( defaults );
    }

    public RippleProperties()
    {
        super();
    }
    
    public String getString( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
		return value;
	}

    public String getString( final String name, final String defaultValue ) throws RippleException
	{
		String value = getProperty( name, false );
        
        return ( null == value )
                ? defaultValue
                : value;
	}

    public boolean getBoolean( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
		
		return value.equals( "true" );
	}

    public void setBoolean( final String name, final boolean value ) throws RippleException
    {
        setProperty( name, "" + value );
    }

    public double getDouble( final String name ) throws RippleException
	{
		String value = getProperty( name, true );

		try
		{
			return ( new Double( value ) ).doubleValue();
		}

		catch ( java.lang.NumberFormatException e )
		{
			throw new RippleException( e );
		}
	}

    public void setDouble( final String name, final double value ) throws RippleException
    {
        setProperty( name, "" + value );
    }

    public float getFloat( final String name ) throws RippleException
	{
		String value = getProperty( name, true );

		try
		{
			return ( new Float( value ) ).floatValue();
		}

		catch ( java.lang.NumberFormatException e )
		{
			throw new RippleException( e );
		}
	}

    public void setFloat( final String name, final float value ) throws RippleException
    {
        setProperty( name, "" + value );
    }

    public int getInt( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
	
		try
		{
			return ( new Integer( value ) ).intValue();
		}
		
		catch ( java.lang.NumberFormatException e )
		{
			throw new RippleException( e );
		}
	}

    public void setInt( final String name, final int value ) throws RippleException
    {
        setProperty( name, "" + value );
    }

    public long getLong( final String name ) throws RippleException
	{
		String value = getProperty( name, true );
		
		try
		{
			return ( new Long( value ) ).longValue();
		}
		
		catch ( java.lang.NumberFormatException e )
		{
			throw new RippleException( e );
		}
	}

    public void setLong( final String name, final long value ) throws RippleException
    {
        setProperty( name, "" + value );
    }

    public URI getURI( final String name ) throws RippleException
    {
        String value = getProperty( name, true );

        try
        {
            return new URI( value );
        }

        catch ( URISyntaxException e )
        {
            throw new RippleException( e );
        }
    }

    public void setURI( final String name, final URI value ) throws RippleException
    {
        setProperty( name, "" + value );
    }

    public File getFile( final String name ) throws RippleException
    {
        String value = getProperty( name, true );
        
        return new File( value );
    }

    public void setFile( final String name, final File value ) throws RippleException
    {
        setProperty( name, "" + value.getAbsolutePath() );
    }

    public File getFile( final String name, final File defaultValue ) throws RippleException
    {
        String value = getProperty( name, false );

        return ( null == value )
                ? defaultValue
                : new File( value );
    }

    public Date getDate( final String name ) throws RippleException
    {
        long millis = getLong( name );
        return new Date( millis );
    }

    public void setDate( final String name, final Date value ) throws RippleException
    {
        setProperty( name, "" + value.getTime() );
    }

    private String getProperty( final String name, final boolean required ) throws RippleException
	{
		String s = getProperty( name );
		
		if ( null == s && required )
		{
			throw new RippleException( "no value for property: " + name );
		}
		
		return s;
	}
}
{'fraction_non_alphanumeric': 0.09258720930232558, 'fraction_numerical': 0.002325581395348837, 'mean_word_length': 2.5143003064351377, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6272625', 'n_tokens_mistral': 2179, 'n_tokens_neox': 1930, 'n_words': 631}