<commit_before>/*
 * Copyright (C) <NAME> 2010-2012 All rights reserved.
 */
// AUTO_GENERATED:START
package net.dependableos.dcase.diagram.parsers;

import java.util.Arrays;


import net.dependableos.dcase.diagram.part.DcaseDiagramEditorPlugin;
import net.dependableos.dcase.diagram.part.Messages;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.osgi.util.NLS;

/**
 * @generated
 */
public abstract class AbstractParser implements IParser {

    /**
     * @generated
     */
    protected final EAttribute[] features;

    /**
     * @generated
     */
    protected final EAttribute[] editableFeatures;

    /**
     * @generated
     */
    private String viewPattern;

    /**
     * @generated
     */
    private String editorPattern;

    /**
     * @generated
     */
    private String editPattern;

    /**
     * @generated
     */
    public AbstractParser(EAttribute[] features) {
        if (features == null || Arrays.asList(features).contains(null)) {
            throw new IllegalArgumentException();
        }
        this.editableFeatures = this.features = features;
    }

    /**
     * @generated
     */
    public AbstractParser(EAttribute[] features, EAttribute[] editableFeatures) {
        if (features == null || Arrays.asList(features).contains(null)) {
            throw new IllegalArgumentException();
        }
        this.features = features;
        if (editableFeatures == null
                || Arrays.asList(editableFeatures).contains(null)) {
            throw new IllegalArgumentException();
        }
        this.editableFeatures = editableFeatures;
    }

    /**
     * @generated
     */
    public String getViewPattern() {
        return viewPattern;
    }

    /**
     * @generated
     */
    public void setViewPattern(String viewPattern) {
        this.viewPattern = viewPattern;
    }

    /**
     * @generated
     */
    public String getEditorPattern() {
        return editorPattern;
    }

    /**
     * @generated
     */
    public void setEditorPattern(String editorPattern) {
        this.editorPattern = editorPattern;
    }

    /**
     * @generated
     */
    public String getEditPattern() {
        return editPattern;
    }

    /**
     * @generated
     */
    public void setEditPattern(String editPattern) {
        this.editPattern = editPattern;
    }

    /**
     * @generated
     */
    public boolean isAffectingEvent(Object event, int flags) {
        if (event instanceof Notification) {
            return isAffectingFeature(((Notification) event).getFeature());
        }
        return false;
    }

    /**
     * @generated
     */
    protected boolean isAffectingFeature(Object feature) {
        for (int i = 0; i < features.length; i++) {
            if (features[i] == feature) {
                return true;
            }
        }
        return false;
    }

    /**
     * @generated
     */
    public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
        return null;
    }

    /**
     * @generated
     */
    protected Object[] getValues(EObject element) {
        Object[] values = new Object[features.length];
        for (int i = 0; i < features.length; i++) {
            values[i] = getValue(element, features[i]);
        }
        return values;
    }

    /**
     * @generated
     */
    protected Object[] getEditableValues(EObject element) {
        Object[] values = new Object[editableFeatures.length];
        for (int i = 0; i < editableFeatures.length; i++) {
            values[i] = getValue(element, editableFeatures[i]);
        }
        return values;
    }

    /**
     * @generated
     */
    protected Object getValue(EObject element, EAttribute feature) {
        Object value = element.eGet(feature);
        Class iClass = feature.getEAttributeType().getInstanceClass();
        if (String.class.equals(iClass)) {
            if (value == null) {
                value = ""; //$NON-NLS-1$
            }
        }
        return value;
    }

    /**
     * @generated
     */
    protected ICommand getParseCommand(IAdaptable adapter, Object[] values,
            int flags) {
        if (values == null
                || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
            return UnexecutableCommand.INSTANCE;
        }
        EObject element = (EObject) adapter.getAdapter(EObject.class);
        TransactionalEditingDomain editingDomain = TransactionUtil
                .getEditingDomain(element);
        if (editingDomain == null) {
            return UnexecutableCommand.INSTANCE;
        }
        CompositeTransactionalCommand command = new CompositeTransactionalCommand(
                editingDomain, "Set Values"); //$NON-NLS-1$
        for (int i = 0; i < values.length; i++) {<commit_msg>catch exceptions when creating the module<commit_after>/*
 * Copyright (C) <NAME> 2010-2012 All rights reserved.
 */
// AUTO_GENERATED:START
package net.dependableos.dcase.diagram.parsers;

import java.util.Arrays;


import net.dependableos.dcase.diagram.part.DcaseDiagramEditorPlugin;
import net.dependableos.dcase.diagram.part.Messages;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.osgi.util.NLS;

/**
 * @generated
 */
public abstract class AbstractParser implements IParser {

    /**
     * @generated
     */
    protected final EAttribute[] features;

    /**
     * @generated
     */
    protected final EAttribute[] editableFeatures;

    /**
     * @generated
     */
    private String viewPattern;

    /**
     * @generated
     */
    private String editorPattern;

    /**
     * @generated
     */
    private String editPattern;

    /**
     * @generated
     */
    public AbstractParser(EAttribute[] features) {
        if (features == null || Arrays.asList(features).contains(null)) {
            throw new IllegalArgumentException();
        }
        this.editableFeatures = this.features = features;
    }

    /**
     * @generated
     */
    public AbstractParser(EAttribute[] features, EAttribute[] editableFeatures) {
        if (features == null || Arrays.asList(features).contains(null)) {
            throw new IllegalArgumentException();
        }
        this.features = features;
        if (editableFeatures == null
                || Arrays.asList(editableFeatures).contains(null)) {
            throw new IllegalArgumentException();
        }
        this.editableFeatures = editableFeatures;
    }

    /**
     * @generated
     */
    public String getViewPattern() {
        return viewPattern;
    }

    /**
     * @generated
     */
    public void setViewPattern(String viewPattern) {
        this.viewPattern = viewPattern;
    }

    /**
     * @generated
     */
    public String getEditorPattern() {
        return editorPattern;
    }

    /**
     * @generated
     */
    public void setEditorPattern(String editorPattern) {
        this.editorPattern = editorPattern;
    }

    /**
     * @generated
     */
    public String getEditPattern() {
        return editPattern;
    }

    /**
     * @generated
     */
    public void setEditPattern(String editPattern) {
        this.editPattern = editPattern;
    }

    /**
     * @generated
     */
    public boolean isAffectingEvent(Object event, int flags) {
        if (event instanceof Notification) {
            return isAffectingFeature(((Notification) event).getFeature());
        }
        return false;
    }

    /**
     * @generated
     */
    protected boolean isAffectingFeature(Object feature) {
        for (int i = 0; i < features.length; i++) {
            if (features[i] == feature) {
                return true;
            }
        }
        return false;
    }

    /**
     * @generated
     */
    public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
        return null;
    }

    /**
     * @generated
     */
    protected Object[] getValues(EObject element) {
        Object[] values = new Object[features.length];
        for (int i = 0; i < features.length; i++) {
            values[i] = getValue(element, features[i]);
        }
        return values;
    }

    /**
     * @generated
     */
    protected Object[] getEditableValues(EObject element) {
        Object[] values = new Object[editableFeatures.length];
        for (int i = 0; i < editableFeatures.length; i++) {
            values[i] = getValue(element, editableFeatures[i]);
        }
        return values;
    }

    /**
     * @generated
     */
    protected Object getValue(EObject element, EAttribute feature) {
    	Object value = null;
    	try {
    		value = element.eGet(feature);
    	} catch (NullPointerException e) {
    		// for systemDesc_4031Parser
        }
        Class iClass = feature.getEAttributeType().getInstanceClass();
        if (String.class.equals(iClass)) {
            if (value == null) {
                value = ""; //$NON-NLS-1$
            }
        }
        return value;
    }

    /**
     * @generated
     */
    protected ICommand getParseCommand(IAdaptable adapter, Object[] values,
            int flags) {
        if (values == null
                || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
            return UnexecutableCommand.INSTANCE;
        }
        EObject element = (EObject) adapter.getAdapter(EObject.class);
        TransactionalEditingDomain editingDomain = TransactionUtil
                .getEditingDomain(element);
        if (editingDomain == null) {
            return UnexecutableCommand.INSTANCE;
        }
        CompositeTransactionalCommand command = new CompositeTransactionalCommand(
                editingDomain, "Set Values"); //$NON-NLS-1$
        for (int i = 0; i < values.length; i++) {
{'fraction_non_alphanumeric': 0.11372251705837756, 'fraction_numerical': 0.002695644848791172, 'mean_word_length': 2.385229540918164, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4503866', 'n_tokens_mistral': 3407, 'n_tokens_neox': 3334, 'n_words': 639}