<commit_before>/*******************************************************************************
 * Copyright (c) 2012 The PDT Extension Group (https://github.com/pdt-eg)
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.getcomposer.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Represents a composer package. The source can either be a composer.json file
 * or a json response from packagist.org.
 * 
 * See fromJson / fromPackagist for details.
 * 
 * @author <NAME> <<EMAIL>>
 * 
 */
public class PHPPackage extends ObservableModel implements PackageInterface {

	public String name;
	public String type;
	public String description;
	public String homepage;
	public String url;
	public String fullPath;
	public String minimumStability = ComposerConstants.STABILITIES[0];
	public Map<String, String> require;
	public Map<String, String> requireDev;
	public Autoload autoload;
	public String targetDir;
	public String version;
	public String versionNormalized;
	public Support support;
	public License license;
	public String[] keywords;
	public Map<String, PHPPackage> versions;
	public ArrayList<Author> authors;

	public PHPPackage() {
		authors = new ArrayList<Author>();
		require = new HashMap<String, String>();
		requireDev = new HashMap<String, String>();
		versions = new HashMap<String, PHPPackage>();
	}
	
	public String toString() {
		return name;
	}

	/**
	 * Deserializes a package from a composer.json file
	 * 
	 * @param input
	 * @return {@link PHPPackage} the deserialized package
	 * @throws FileNotFoundException
	 */
	public static PHPPackage fromJson(File input) throws FileNotFoundException {
		Gson gson = getBuilder();
		InputStream stream = new FileInputStream(input);
		InputStreamReader reader = new InputStreamReader(stream);
		PHPPackage phpPackage = gson.fromJson(reader, PHPPackage.class);
		// gson.fromJson returns null if file is empty, make a blank package
		if (phpPackage == null) {
			phpPackage = new PHPPackage();
		}<commit_msg>Create empty support for new package<commit_after>/*******************************************************************************
 * Copyright (c) 2012 The PDT Extension Group (https://github.com/pdt-eg)
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.getcomposer.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * Represents a composer package. The source can either be a composer.json file
 * or a json response from packagist.org.
 * 
 * See fromJson / fromPackagist for details.
 * 
 * @author <NAME> <<EMAIL>>
 * 
 */
public class PHPPackage extends ObservableModel implements PackageInterface {

	public String name;
	public String type;
	public String description;
	public String homepage;
	public String url;
	public String fullPath;
	public String minimumStability = ComposerConstants.STABILITIES[0];
	public Map<String, String> require;
	public Map<String, String> requireDev;
	public Autoload autoload;
	public String targetDir;
	public String version;
	public String versionNormalized;
	public Support support;
	public License license;
	public String[] keywords;
	public Map<String, PHPPackage> versions;
	public ArrayList<Author> authors;

	public PHPPackage() {
		authors = new ArrayList<Author>();
		require = new HashMap<String, String>();
		requireDev = new HashMap<String, String>();
		versions = new HashMap<String, PHPPackage>();
		support = new Support();
	}
	
	public String toString() {
		return name;
	}

	/**
	 * Deserializes a package from a composer.json file
	 * 
	 * @param input
	 * @return {@link PHPPackage} the deserialized package
	 * @throws FileNotFoundException
	 */
	public static PHPPackage fromJson(File input) throws FileNotFoundException {
		Gson gson = getBuilder();
		InputStream stream = new FileInputStream(input);
		InputStreamReader reader = new InputStreamReader(stream);
		PHPPackage phpPackage = gson.fromJson(reader, PHPPackage.class);
		// gson.fromJson returns null if file is empty, make a blank package
		if (phpPackage == null) {
			phpPackage = new PHPPackage();
		}
{'fraction_non_alphanumeric': 0.14729887291099883, 'fraction_numerical': 0.003497862417411582, 'mean_word_length': 4.998834498834499, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '2007344', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1365, 'n_words': 472}