<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 wicket.util.license;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.net.URI;
import java.net.URL;

import wicket.util.string.Strings;

import junit.framework.Assert;


abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler
{
	protected static final String LINE_ENDING = System.getProperty("line.separator");
	private String licenseHeader;
	private String[] ignoreFiles;

	/**
	 * Construct.
	 * 
	 * @param ignoreFiles
	 */
	public AbstractLicenseHeaderHandler(String[] ignoreFiles)
	{
		this.ignoreFiles = ignoreFiles;
	}

	public String[] getIgnoreFiles()
	{
		return ignoreFiles;
	}

	public boolean addLicenseHeader(File file)
	{
		System.out.println("Not supported yet.");
		return false;
	}

	public String getLicenseType(File file)
	{
		return null;
	}

	protected abstract String getLicenseHeaderFilename();

	protected String getLicenseHeader()
	{
		if (Strings.isEmpty(licenseHeader))
		{
			try
			{
				URL url = ApacheLicenseHeaderTestCase.class.getResource(getLicenseHeaderFilename());
				licenseHeader = new wicket.util.file.File(new URI(url.toString())).readString();
				licenseHeader = licenseHeader.trim();
			}
			catch (Exception e)
			{
				Assert.fail(e.getMessage());

			}
		}

		return licenseHeader;
	}

	protected String extractLicenseHeader(File file, int start, int length)
	{
		String header = "";
		FileReader fileReader = null;

		try
		{<commit_msg>no uri or file directly input stream<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 wicket.util.license;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.LineNumberReader;

import junit.framework.Assert;
import wicket.util.io.Streams;
import wicket.util.string.Strings;


abstract class AbstractLicenseHeaderHandler implements ILicenseHeaderHandler
{
	protected static final String LINE_ENDING = System.getProperty("line.separator");
	private String licenseHeader;
	private String[] ignoreFiles;

	/**
	 * Construct.
	 * 
	 * @param ignoreFiles
	 */
	public AbstractLicenseHeaderHandler(String[] ignoreFiles)
	{
		this.ignoreFiles = ignoreFiles;
	}

	public String[] getIgnoreFiles()
	{
		return ignoreFiles;
	}

	public boolean addLicenseHeader(File file)
	{
		System.out.println("Not supported yet.");
		return false;
	}

	public String getLicenseType(File file)
	{
		return null;
	}

	protected abstract String getLicenseHeaderFilename();

	protected String getLicenseHeader()
	{
		if (Strings.isEmpty(licenseHeader))
		{
			try
			{
				InputStream in = ApacheLicenseHeaderTestCase.class.getResourceAsStream(getLicenseHeaderFilename());
				try
				{
					licenseHeader = Streams.readString(in);
				}
				finally
				{
					in.close();
				}
				licenseHeader = licenseHeader.trim();
			}
			catch (Exception e)
			{
				Assert.fail(e.getMessage());

			}
		}

		return licenseHeader;
	}

	protected String extractLicenseHeader(File file, int start, int length)
	{
		String header = "";
		FileReader fileReader = null;

		try
		{
{'fraction_non_alphanumeric': 0.08594583066751972, 'fraction_numerical': 0.0017061207080400938, 'mean_word_length': 4.05933117583603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6348336', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1265, 'n_words': 437}