<commit_before>/**
 * Copyright (c) 2017 Inria
 *  
 * 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
 * 
 * Contributors:
 * - <NAME> <<EMAIL>>
 */
package org.eclipse.cmf.occi.core.util;

import java.io.PrintStream;

import org.eclipse.cmf.occi.core.Action;
import org.eclipse.cmf.occi.core.Attribute;
import org.eclipse.cmf.occi.core.AttributeState;
import org.eclipse.cmf.occi.core.Configuration;
import org.eclipse.cmf.occi.core.DataType;
import org.eclipse.cmf.occi.core.Entity;
import org.eclipse.cmf.occi.core.Extension;
import org.eclipse.cmf.occi.core.Kind;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.Mixin;
import org.eclipse.cmf.occi.core.Resource;
import org.eclipse.emf.ecore.EClassifier;


/**
 * This class provides utility methods for printing OCCI extensions and configurations.
 *
 * @author <NAME> - Inria
 */
public class OcciPrinter
{
	/**
	 * Print a given OCCI extension.
	 * @param ps the print stream where to print the given OCCI extension.
	 * @param extension the given OCCI extension.
	 */
	public static void print(PrintStream ps, Extension extension)
	{
		ps.println("Extension");
		ps.println("  - name: " + extension.getName());
		ps.println("  - scheme: " + extension.getScheme());
		ps.println("  - import extensions:");
		for(Extension importExtension : extension.getImport()) {
			ps.println("        * Extension " + importExtension.getScheme() + importExtension.getName());
		}
		ps.println("  - kinds:");
		for(Kind kind : extension.getKinds()) {
			ps.println("    * Kind");
			ps.println("      - term: " + kind.getTerm());
			ps.println("      - scheme: " + kind.getScheme());
			ps.println("      - title: " + kind.getTitle());
			Kind parent = kind.getParent();
			if(parent != null) {
				ps.println("      - parent: " + parent.getScheme() + parent.getTerm());					
			} else {
				ps.println("      - no parent");
			}
			ps.println("      - attributes:");
			for(Attribute attribute : kind.getAttributes()) {
				ps.println("        * Attribute");
				ps.println("          - name: " + attribute.getName());
				ps.println("          - description: " + attribute.getDescription());
				ps.println("          - mutable: " + attribute.isMutable());
				ps.println("          - required: " + attribute.isRequired());
				ps.println("          - type: " + attribute.getType().getName());
				ps.println("          - default: " + attribute.getDefault());
			}
			ps.println("      - actions:");
			for(Action action : kind.getActions()) {
				ps.println("        * Action");
				ps.println("          - term: " + action.getTerm());
				ps.println("          - scheme: " + action.getScheme());
				ps.println("          - title: " + action.getTitle());
			}
			ps.println("      - entities:");
			for(Entity entity : kind.getEntities()) {
				ps.println("        * Entity id " + entity.getId());
			}
		}
		ps.println("  - mixins:");
		for(Mixin mixin : extension.getMixins()) {
			ps.println("    * Mixin");
			ps.println("      - term: " + mixin.getTerm());
			ps.println("      - scheme: " + mixin.getScheme());
			ps.println("      - title: " + mixin.getTitle());
			ps.println("      - depends:");
			for(Mixin depend : mixin.getDepends()) {
				ps.println("        * Mixin " + depend.getScheme() + depend.getTerm());
			}
			ps.println("      - applies:");
			for(Kind apply : mixin.getApplies()) {
				ps.println("        * Kind " + apply.getScheme() + apply.getTerm());
			}				
			ps.println("      - attributes:");
			for(Attribute attribute : mixin.getAttributes()) {
				ps.println("        * Attribute");
				ps.println("          - name: " + attribute.getName());
				ps.println("          - description: " + attribute.getDescription());
				ps.println("          - mutable: " + attribute.isMutable());
				ps.println("          - required: " + attribute.isRequired());
				ps.println("          - type: " + attribute.getType().getName());
				ps.println("          - default: " + attribute.getDefault());
			}
			ps.println("      - actions:");
			for(Action action : mixin.getActions()) {
				ps.println("        * Action");
				ps.println("          - term: " + action.getTerm());
				ps.println("          - scheme: " + action.getScheme());
				ps.println("          - title: " + action.getTitle());
			}
			ps.println("      - entities:");
			for(Entity entity : mixin.getEntities()) {
				ps.println("        * Entity id " + entity.getId());
			}
		}
		ps.println("  - types:");
		for(DataType type : extension.getTypes()) {
			ps.println("    * EDataType " + type.getName());
		}
	}

	/**
	 * Print a given OCCI configuration.
	 * @param ps the print stream where to print the given OCCI configuration.
	 * @param configuration the given OCCI configuration.
	 */
	public static void print(PrintStream ps, Configuration configuration)
	{
		ps.println("Configuration");
		ps.println("  - used extensions:");
		for(Extension extension : configuration.getUse()) {
			ps.println("    * Extension " + extension.getScheme() + extension.getName());
		}
		ps.println("  - resources:");
		for(Resource resource : configuration.getResources()) {
			ps.println("    * Resource id " + resource.getId());
			Kind resourceKind = resource.getKind();
			ps.println("      - Kind " + resourceKind.getScheme() + resourceKind.getTerm());
			ps.println("      - mixins:");<commit_msg>Update file header.<commit_after>/**
 * Copyright (c) 2015-17 Inria
 *  
 * 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
 * 
 * Contributors:
 * - <NAME> <<EMAIL>>
 * - <NAME> <<EMAIL>>
 */
package org.eclipse.cmf.occi.core.util;

import java.io.PrintStream;

import org.eclipse.cmf.occi.core.Action;
import org.eclipse.cmf.occi.core.Attribute;
import org.eclipse.cmf.occi.core.AttributeState;
import org.eclipse.cmf.occi.core.Configuration;
import org.eclipse.cmf.occi.core.DataType;
import org.eclipse.cmf.occi.core.Entity;
import org.eclipse.cmf.occi.core.Extension;
import org.eclipse.cmf.occi.core.Kind;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.Mixin;
import org.eclipse.cmf.occi.core.Resource;

/**
 * This class provides utility methods for printing OCCI extensions and configurations.
 *
 * @author <NAME> - Inria
 */
public class OcciPrinter
{
	/**
	 * Print a given OCCI extension.
	 * @param ps the print stream where to print the given OCCI extension.
	 * @param extension the given OCCI extension.
	 */
	public static void print(PrintStream ps, Extension extension)
	{
		ps.println("Extension");
		ps.println("  - name: " + extension.getName());
		ps.println("  - scheme: " + extension.getScheme());
		ps.println("  - import extensions:");
		for(Extension importExtension : extension.getImport()) {
			ps.println("        * Extension " + importExtension.getScheme() + importExtension.getName());
		}
		ps.println("  - kinds:");
		for(Kind kind : extension.getKinds()) {
			ps.println("    * Kind");
			ps.println("      - term: " + kind.getTerm());
			ps.println("      - scheme: " + kind.getScheme());
			ps.println("      - title: " + kind.getTitle());
			Kind parent = kind.getParent();
			if(parent != null) {
				ps.println("      - parent: " + parent.getScheme() + parent.getTerm());					
			} else {
				ps.println("      - no parent");
			}
			ps.println("      - attributes:");
			for(Attribute attribute : kind.getAttributes()) {
				ps.println("        * Attribute");
				ps.println("          - name: " + attribute.getName());
				ps.println("          - description: " + attribute.getDescription());
				ps.println("          - mutable: " + attribute.isMutable());
				ps.println("          - required: " + attribute.isRequired());
				ps.println("          - type: " + attribute.getType().getName());
				ps.println("          - default: " + attribute.getDefault());
			}
			ps.println("      - actions:");
			for(Action action : kind.getActions()) {
				ps.println("        * Action");
				ps.println("          - term: " + action.getTerm());
				ps.println("          - scheme: " + action.getScheme());
				ps.println("          - title: " + action.getTitle());
			}
			ps.println("      - entities:");
			for(Entity entity : kind.getEntities()) {
				ps.println("        * Entity id " + entity.getId());
			}
		}
		ps.println("  - mixins:");
		for(Mixin mixin : extension.getMixins()) {
			ps.println("    * Mixin");
			ps.println("      - term: " + mixin.getTerm());
			ps.println("      - scheme: " + mixin.getScheme());
			ps.println("      - title: " + mixin.getTitle());
			ps.println("      - depends:");
			for(Mixin depend : mixin.getDepends()) {
				ps.println("        * Mixin " + depend.getScheme() + depend.getTerm());
			}
			ps.println("      - applies:");
			for(Kind apply : mixin.getApplies()) {
				ps.println("        * Kind " + apply.getScheme() + apply.getTerm());
			}				
			ps.println("      - attributes:");
			for(Attribute attribute : mixin.getAttributes()) {
				ps.println("        * Attribute");
				ps.println("          - name: " + attribute.getName());
				ps.println("          - description: " + attribute.getDescription());
				ps.println("          - mutable: " + attribute.isMutable());
				ps.println("          - required: " + attribute.isRequired());
				ps.println("          - type: " + attribute.getType().getName());
				ps.println("          - default: " + attribute.getDefault());
			}
			ps.println("      - actions:");
			for(Action action : mixin.getActions()) {
				ps.println("        * Action");
				ps.println("          - term: " + action.getTerm());
				ps.println("          - scheme: " + action.getScheme());
				ps.println("          - title: " + action.getTitle());
			}
			ps.println("      - entities:");
			for(Entity entity : mixin.getEntities()) {
				ps.println("        * Entity id " + entity.getId());
			}
		}
		ps.println("  - types:");
		for(DataType type : extension.getTypes()) {
			ps.println("    * DataType " + type.getName());
		}
	}

	/**
	 * Print a given OCCI configuration.
	 * @param ps the print stream where to print the given OCCI configuration.
	 * @param configuration the given OCCI configuration.
	 */
	public static void print(PrintStream ps, Configuration configuration)
	{
		ps.println("Configuration");
		ps.println("  - used extensions:");
		for(Extension extension : configuration.getUse()) {
			ps.println("    * Extension " + extension.getScheme() + extension.getName());
		}
		ps.println("  - resources:");
		for(Resource resource : configuration.getResources()) {
			ps.println("    * Resource id " + resource.getId());
			Kind resourceKind = resource.getKind();
			ps.println("      - Kind " + resourceKind.getScheme() + resourceKind.getTerm());
			ps.println("      - mixins:");
{'fraction_non_alphanumeric': 0.16836504644242042, 'fraction_numerical': 0.0016232302281540265, 'mean_word_length': 2.6770557029177717, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '6747737', 'n_tokens_mistral': 3763, 'n_tokens_neox': 3349, 'n_words': 721}