Package org.eclipse.emf.ecore

Examples of org.eclipse.emf.ecore.EEnumLiteral


   * @generated
   */
  public static Object performCast(Object value, EDataType targetType) {
    if (targetType instanceof EEnum) {
      if (value instanceof EEnumLiteral) {
        EEnumLiteral literal = (EEnumLiteral) value;
        return (literal.getInstance() != null) ? literal.getInstance()
            : literal;
      }
    }
    if (false == value instanceof Number || targetType == null
        || targetType.getInstanceClass() == null) {
View Full Code Here


              Messages.AbstractParser_UnexpectedValueType,
              iClass.getName()));
        }
      } else if (type instanceof EEnum) {
        if (value instanceof String) {
          EEnumLiteral literal = ((EEnum) type)
              .getEEnumLiteralByLiteral((String) value);
          if (literal == null) {
            value = new InvalidValue(NLS.bind(
                Messages.AbstractParser_UnknownLiteral, value));
          } else {
            value = literal.getInstance();
          }
        } else {
          value = new InvalidValue(NLS.bind(
              Messages.AbstractParser_UnexpectedValueType,
              String.class.getName()));
View Full Code Here

              Messages.AbstractParser_UnexpectedValueType,
              iClass.getName()));
        }
      } else if (type instanceof EEnum) {
        if (value instanceof String) {
          EEnumLiteral literal = ((EEnum) type)
              .getEEnumLiteralByLiteral((String) value);
          if (literal == null) {
            value = new InvalidValue(NLS.bind(
                Messages.AbstractParser_UnknownLiteral, value));
          } else {
            value = literal.getInstance();
          }
        } else {
          value = new InvalidValue(NLS.bind(
              Messages.AbstractParser_UnexpectedValueType,
              String.class.getName()));
View Full Code Here

    // if aType is a "subtype" of uima.cas.String, create an EEnum for it
    if (CAS.TYPE_NAME_STRING.equals(aType.getSupertypeName())) {
      eclassifier = EcoreFactory.eINSTANCE.createEEnum();
      AllowedValue[] vals = aType.getAllowedValues();
      for (int i = 0; i < vals.length; i++) {
        EEnumLiteral literal = EcoreFactory.eINSTANCE.createEEnumLiteral();
        literal.setValue(i);
        literal.setName(vals[i].getString());
        if (vals[i].getDescription() != null && vals[i].getDescription().length() > 0) {
          EAnnotation eannot = EcoreFactory.eINSTANCE.createEAnnotation();
          eannot.setSource("http://uima.apache.org");
          eannot.getDetails().put("description", vals[i].getDescription());
          literal.getEAnnotations().add(eannot);
        }
        ((EEnum) eclassifier).getELiterals().add(literal);
      }
    } else {
      // create EClass
View Full Code Here

    }
    // set allowed values
    EList literals = aEEnum.getELiterals();
    AllowedValue[] vals = new AllowedValue[literals.size()];
    for (int i = 0; i < literals.size(); i++) {
      EEnumLiteral literal = (EEnumLiteral) literals.get(i);
      vals[i] = uimaFactory.createAllowedValue();
      vals[i].setString(literal.getName());
      EAnnotation literalAnnot = literal.getEAnnotation("http://uima.apache.org");
      if (literalAnnot != null) {
        vals[i].setDescription((String) literalAnnot.getDetails().get("description"));
      }
    }
    type.setAllowedValues(vals);
View Full Code Here

                  es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.diagram.part.Messages.AbstractParser_UnexpectedValueType,
                  iClass.getName()));
        }
      } else if (type instanceof EEnum) {
        if (value instanceof String) {
          EEnumLiteral literal = ((EEnum) type)
              .getEEnumLiteralByLiteral((String) value);
          if (literal == null) {
            value = new InvalidValue(
                NLS.bind(
                    es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.diagram.part.Messages.AbstractParser_UnknownLiteral,
                    value));
          } else {
            value = literal.getInstance();
          }
        } else {
          value = new InvalidValue(
              NLS.bind(
                  es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.diagram.part.Messages.AbstractParser_UnexpectedValueType,
View Full Code Here

                  es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.diagram.part.Messages.AbstractParser_UnexpectedValueType,
                  iClass.getName()));
        }
      } else if (type instanceof EEnum) {
        if (value instanceof String) {
          EEnumLiteral literal = ((EEnum) type)
              .getEEnumLiteralByLiteral((String) value);
          if (literal == null) {
            value = new InvalidValue(
                NLS.bind(
                    es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.diagram.part.Messages.AbstractParser_UnknownLiteral,
                    value));
          } else {
            value = literal.getInstance();
          }
        } else {
          value = new InvalidValue(
              NLS.bind(
                  es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.diagram.part.Messages.AbstractParser_UnexpectedValueType,
View Full Code Here

              Messages.AbstractParser_UnexpectedValueType, iClass
                  .getName()));
        }
      } else if (type instanceof EEnum) {
        if (value instanceof String) {
          EEnumLiteral literal = ((EEnum) type)
              .getEEnumLiteralByLiteral((String) value);
          if (literal == null) {
            value = new InvalidValue(NLS.bind(
                Messages.AbstractParser_UnknownLiteral, value));
          } else {
            value = literal.getInstance();
          }
        } else {
          value = new InvalidValue(NLS.bind(
              Messages.AbstractParser_UnexpectedValueType,
              String.class.getName()));
View Full Code Here

   * @generated
   */
  public static Object performCast(Object value, EDataType targetType) {
    if (targetType instanceof EEnum) {
      if (value instanceof EEnumLiteral) {
        EEnumLiteral literal = (EEnumLiteral) value;
        return (literal.getInstance() != null) ? literal.getInstance()
            : literal;
      }
    }
    if (false == value instanceof Number || targetType == null
        || targetType.getInstanceClass() == null) {
View Full Code Here

    }
    // set allowed values
    EList literals = aEEnum.getELiterals();
    AllowedValue[] vals = new AllowedValue[literals.size()];
    for (int i = 0; i < literals.size(); i++) {
      EEnumLiteral literal = (EEnumLiteral) literals.get(i);
      vals[i] = uimaFactory.createAllowedValue();
      vals[i].setString(literal.getName());
      EAnnotation literalAnnot = literal.getEAnnotation("http://uima.apache.org");
      if (literalAnnot != null) {
        vals[i].setDescription((String) literalAnnot.getDetails().get("description"));
      }
    }
    type.setAllowedValues(vals);
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.EEnumLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.