All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.ocl.expressions.operations.TupleLiteralPartOperations Maven / Gradle / Ivy

/**
 * 
 * 
 * Copyright (c) 2008 IBM Corporation, Zeligsoft Inc., and others.
 * 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:
 *   IBM - Initial API and implementation
 *   Zeligsoft - Bug 207365
 * 
 * 
 *
 * $Id: TupleLiteralPartOperations.java,v 1.4 2009/06/25 19:23:52 ewillink Exp $
 */
package org.eclipse.ocl.expressions.operations;

import java.util.Map;

import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;

import org.eclipse.ocl.Environment;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.expressions.TupleLiteralExp;
import org.eclipse.ocl.expressions.TupleLiteralPart;

import org.eclipse.ocl.expressions.util.ExpressionsValidator;
import org.eclipse.ocl.utilities.Visitor;
import org.eclipse.ocl.internal.l10n.OCLMessages;
import org.eclipse.ocl.util.OCLUtil;
import org.eclipse.ocl.util.TypeUtil;

/**
 * 
 * A static utility class that provides operations related to 'Tuple Literal Part' model objects.
 * 
 *
 * 

* The following operations are supported: *

    *
  • {@link org.eclipse.ocl.utilities.TypedElement#getName() Get Name}
  • *
  • {@link org.eclipse.ocl.utilities.TypedElement#getType() Get Type}
  • *
  • {@link org.eclipse.ocl.utilities.TypedElement#setName(java.lang.String) Set Name}
  • *
  • {@link org.eclipse.ocl.utilities.TypedElement#setType(java.lang.Object) Set Type}
  • *
  • {@link org.eclipse.ocl.utilities.Visitable#accept(org.eclipse.ocl.utilities.Visitor) Accept}
  • *
  • {@link org.eclipse.ocl.expressions.TupleLiteralPart#checkValueType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) Check Value Type}
  • *
*

* * @generated */ public class TupleLiteralPartOperations { /** * * * @generated */ protected TupleLiteralPartOperations() { super(); } /** * * @since 1.3 * * @generated NOT */ public static String getName(TupleLiteralPart tupleLiteralPart) { throw new UnsupportedOperationException(); } /** * * @since 1.3 * * @generated NOT */ public static C getType(TupleLiteralPart tupleLiteralPart) { throw new UnsupportedOperationException(); } /** * * @since 1.3 * * @generated NOT */ public static void setName(TupleLiteralPart tupleLiteralPart, String name) { throw new UnsupportedOperationException(); } /** * * @since 1.3 * * @generated NOT */ public static void setType(TupleLiteralPart tupleLiteralPart, C type) { throw new UnsupportedOperationException(); } /** * * @since 1.3 * * @generated NOT */ public static > T accept( TupleLiteralPart tupleLiteralPart, U v) { throw new UnsupportedOperationException(); } /** * * * * attribute.type = value.type * @param tupleLiteralPart The receiving 'Tuple Literal Part' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * * @generated NOT */ public static boolean checkValueType( TupleLiteralPart tupleLiteralPart, DiagnosticChain diagnostics, Map context) { boolean result = true; String message = null; Environment env = OCLUtil .getValidationEnvironment(tupleLiteralPart, context); if (env != null) { P attribute = tupleLiteralPart.getAttribute(); OCLExpression value = tupleLiteralPart.getValue(); C type = (value == null) ? null : value.getType(); if ((attribute != null) && (type != null)) { C attrType = env.getUMLReflection().getOCLType(attribute); if (attrType != null) { if (!TypeUtil.exactTypeMatch(env, attrType, type)) { result = false; String tupleLiteral = null; if (tupleLiteralPart.eContainer() instanceof TupleLiteralExp) { tupleLiteral = tupleLiteralPart.eContainer() .toString(); } message = OCLMessages.bind( OCLMessages.TuplePartType_ERROR_, tupleLiteralPart .getName(), tupleLiteral); } } } } if (!result) { if (diagnostics != null) { diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, ExpressionsValidator.DIAGNOSTIC_SOURCE, ExpressionsValidator.TUPLE_LITERAL_PART__VALUE_TYPE, message, new Object[]{tupleLiteralPart})); } } return result; } } // TupleLiteralPartOperations




© 2015 - 2024 Weber Informatics LLC | Privacy Policy