<commit_before>/*
 * Copyright 2014 Nastel Technologies, Inc.
 *
 * 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 com.nastel.jkool.tnt4j.dump;

import java.util.Map;

import com.nastel.jkool.tnt4j.config.Configurable;
import com.nastel.jkool.tnt4j.config.ConfigurationException;
import com.nastel.jkool.tnt4j.core.UsecTimestamp;



/**
 * <p>
 * This class implements a default dump destination factory based on file based dump destination
 * backed by <code>FileDumpSink</code> implementation. By default dump destinations are 
 * name using this convention: <code>DEFAULT_DUMP_FOLDER + Utils.VM_NAME + ".dump"</code>.
 * Default dump directory location can be specified using <code>DumpLocation</code> configuration
 * attribute or java property <code>tnt4j.dump.folder=./</code>.
 * </p>
 * 
 * 
 * @version $Revision: 1 $
 * 
 * @see FileDumpSink
 */
public class DefaultDumpSinkFactory implements DumpSinkFactory, Configurable {
	public static final String DEFAULT_DUMP_FOLDER = System.getProperty("tnt4j.dump.folder", "./");

	protected Map<String, Object> config = null;
	private boolean append = true;
	private String dumpLocation = DEFAULT_DUMP_FOLDER + UsecTimestamp.getTimeStamp("yyyy-MM-dd") + ".dump";
	
	/**
	 * Obtain default dump location URL.
	 *
	 * @return default dump location URL.
	 */
	public  String getDefaultLocation() {
		return dumpLocation;
	}
	
	@Override
    public DumpSink getInstance() {
	    return new FileDumpSink(dumpLocation, append);
    }<commit_msg>Optimize dump sink factory initialization<commit_after>/*
 * Copyright 2014 Nastel Technologies, Inc.
 *
 * 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 com.nastel.jkool.tnt4j.dump;

import java.io.File;
import java.util.Map;

import com.nastel.jkool.tnt4j.config.Configurable;
import com.nastel.jkool.tnt4j.config.ConfigurationException;
import com.nastel.jkool.tnt4j.core.UsecTimestamp;
import com.nastel.jkool.tnt4j.utils.Utils;



/**
 * <p>
 * This class implements a default dump destination factory based on file based dump destination
 * backed by <code>FileDumpSink</code> implementation. By default dump destinations are 
 * name using this convention: <code>DEFAULT_DUMP_FOLDER + Utils.VM_NAME + ".dump"</code>.
 * Default dump directory location can be specified using <code>DumpLocation</code> configuration
 * attribute or java property <code>tnt4j.dump.folder=./</code>.
 * </p>
 * 
 * 
 * @version $Revision: 1 $
 * 
 * @see FileDumpSink
 */
public class DefaultDumpSinkFactory implements DumpSinkFactory, Configurable {
	public static final String DEFAULT_DUMP_FOLDER = System.getProperty("tnt4j.dump.folder", "." + File.separator);

	protected Map<String, Object> config = null;
	private boolean append = true;
	private String dumpLocation;
	
	
	/**
	 * Create a default dump sink factory with default dump
	 * location.
	 */
	public DefaultDumpSinkFactory() {
		dumpLocation = DEFAULT_DUMP_FOLDER;
		if (!dumpLocation.endsWith(File.separator)) {
			dumpLocation += File.separator;
		}
		dumpLocation += Utils.getVMName() + ".dump";
	}
	
	/**
	 * Obtain default dump location URL.
	 *
	 * @return default dump location URL.
	 */
	public  String getDefaultLocation() {
		return dumpLocation;
	}
	
	@Override
    public DumpSink getInstance() {
	    return new FileDumpSink(dumpLocation, append);
    }
{'fraction_non_alphanumeric': 0.0980211688909342, 'fraction_numerical': 0.007132995858260469, 'mean_word_length': 4.156583629893238, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '4821587', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1258, 'n_words': 419}