<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.objects;

import java.util.Arrays;
import java.util.LinkedList;

import org.getcomposer.core.annotation.Name;
import org.getcomposer.core.collection.JsonArray;
import org.getcomposer.core.collection.Psr0;
import org.json.simple.JSONObject;


/**
 * Represents the autoload entity of a composer package.
 * 
 * @see http://getcomposer.org/doc/04-schema.md#autoload
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <gos.si>
 */
public class Autoload extends JsonObject {
	
	private JsonArray classmap = new JsonArray();
	private JsonArray files = new JsonArray();
	
	@Name("psr-0")
	private Psr0 psr0 = new Psr0();
	
	public Autoload() {
		listen();
	}
	
	protected void parse(Object obj) {
		if (obj instanceof JSONObject) {
			JSONObject json = (JSONObject) obj;
			
			parseField(json, "psr-0");
			parseField(json, "classmap");
			parseField(json, "files");
		}
	}
	
	@Override
	public Object prepareJson(LinkedList<String> fields) {
		if (classmap.size() == 0 && files.size() == 0 && psr0.size() == 0) {
			return null;
		}
		String[] order = new String[]{"psr-0", "classmap", "files"};
		fields.addAll(Arrays.asList(order));
		return super.prepareJson(fields);
	}
	
	public String getPsr0Path() {
		if (psr0.size() > 0) {
			return ((Namespace)psr0.iterator().next()).getFirst();
		}
		return null;
	}

	public boolean hasPsr0() {
		return psr0 != null;
	}
	
	public boolean hasClassMap() {
		return classmap != null && classmap.size() > 0;
	}
	
	public boolean hasFiles() {
		return files != null && files.size() > 0;
	}
	
	public Psr0 getPsr0() {
		return psr0;
	}
	
	public JsonArray getClassMap() {
		return classmap;
	}
	
	public JsonArray getFiles() {
		return files;
	}
}<commit_msg>added some getters/setters<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.objects;

import java.util.Arrays;
import java.util.LinkedList;

import org.getcomposer.core.annotation.Name;
import org.getcomposer.core.collection.JsonArray;
import org.getcomposer.core.collection.Psr0;
import org.json.simple.JSONObject;


/**
 * Represents the autoload entity of a composer package.
 * 
 * @see http://getcomposer.org/doc/04-schema.md#autoload
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <gos.si>
 */
public class Autoload extends JsonObject {
	
	private JsonArray classmap = new JsonArray();
	private JsonArray files = new JsonArray();
	
	@Name("psr-0")
	private Psr0 psr0 = new Psr0();
	
	public Autoload() {
		listen();
	}
	
	protected void parse(Object obj) {
		if (obj instanceof JSONObject) {
			JSONObject json = (JSONObject) obj;
			
			parseField(json, "psr-0");
			parseField(json, "classmap");
			parseField(json, "files");
		}
	}
	
	@Override
	public Object prepareJson(LinkedList<String> fields) {
		if (classmap.size() == 0 && files.size() == 0 && psr0.size() == 0) {
			return null;
		}
		String[] order = new String[]{"psr-0", "classmap", "files"};
		fields.addAll(Arrays.asList(order));
		return super.prepareJson(fields);
	}
	
	public String getPsr0Path() {
		if (psr0.size() > 0) {
			return ((Namespace)psr0.iterator().next()).getFirst();
		}
		return null;
	}

	public boolean hasPsr0() {
		return psr0 != null;
	}
	
	public boolean hasClassMap() {
		return classmap != null && classmap.size() > 0;
	}
	
	public boolean hasFiles() {
		return files != null && files.size() > 0;
	}
	
	public Psr0 getPsr0() {
		return psr0;
	}
	
	public JsonArray getClassMap() {
		return classmap;
	}
	
	public JsonArray getFiles() {
		return files;
	}

	public void setPsr0(Psr0 psr0) {
		this.psr0 = psr0;
	}

	public Namespace getNamespace() {
		return (Namespace)psr0.iterator().next();
	}
}
{'fraction_non_alphanumeric': 0.19812554489973844, 'fraction_numerical': 0.015257192676547515, 'mean_word_length': 4.197055492638731, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '933454', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1447, 'n_words': 375}