Package org.dmd.dms.types

Examples of org.dmd.dms.types.EnumValue


      System.out.println("Couldn't get enumValues from:\n" + enumObj);
      return;
    }

    for (String enumValName : al) {
      EnumValue ev = new EnumValue(enumValName);

      if (byId.get(ev.getId()) != null) {
        ResultException ex = new ResultException();
        ex.addError("Duplicate enum id: " + ev.getId());
        ex.result.lastResult().lineNumber(enumObj.lineNumber);
        throw (ex);
      }
      byId.put(ev.getId(), ev);

      if (byName.get(ev.getName()) != null) {
        ResultException ex = new ResultException();
        ex.addError("Duplicate enum name: " + ev.getName());
        ex.result.lastResult().lineNumber(enumObj.lineNumber);
        throw (ex);
      }
      byName.put(ev.getName(), ev);
    }

    // DebugInfo.debug("Generating: " + od + File.separator + cn + ".java");

    // enumClassDef = new BufferedWriter(new FileWriter(od + File.separator
    // + cn + ".java"));
    enumClassDef = FileUpdateManager.instance().getWriter(od, cn + ".java");

    enumClassDef.write(LGPL.toString());
    enumClassDef.write("package " + cp + ".generated.enums;\n\n");

    enumClassDef.write("import java.util.*;\n\n");

    enumClassDef.write("/**\n * The " + cn + " enumeration.\n");
    enumClassDef
        .write(" * This code was auto-generated by the createmeta utility and shouldn't be alterred\n");
    enumClassDef.write(" * manually.\n");
    enumClassDef.write(" * Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    enumClassDef.write(" */\n");
    enumClassDef.write("public enum " + cn + "\n{\n");

    Iterator<EnumValue> enumit = byId.values().iterator();
    while (enumit.hasNext()) {
      EnumValue ev = enumit.next();

      enumClassDef.write("    /**\n");
      this.dumpCodeComment(ev.getDescription(), enumClassDef, "     * ");
      enumClassDef.write("     */\n");

      enumClassDef.write("    " + ev.getName() + "(" + ev.getId() + ")");
      if (enumit.hasNext())
        enumClassDef.write(",\n\n");
      else
        enumClassDef.write(";\n\n");
    }
View Full Code Here


    }
   
    @Override
    // org.dmd.dms.util.GenUtility.dumpSVType(GenUtility.java:2010)
    public EnumValue set(Object v) throws DmcValueException {
        EnumValue rc = typeCheck(v);
        // We only return a value if the value actually changed. This supports
        // the applyModifier() mechanism on DmcObject where we only return true
        // if something changed as a result of the modifier
        if (value == null)
            value = rc;
View Full Code Here

            errors.result.lastResult().lineNumber(mapping.getLineNumber());
          }
          else{
            mapping.setEnumDef(ed);
         
            EnumValue ev = ed.getEnumValue(mapping.getUnsetValue());
            if (ev == null){
              if (errors == null)
                errors = new ResultException();
             
              errors.addError(mapping.getUnsetValue() + " is not a valid member of enum: " + ed.getName());
View Full Code Here

   
    @Override
    // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2659)
    public EnumValue add(Object v) throws DmcValueException {
        synchronized(this){
            EnumValue rc = typeCheck(v);
            if (value == null)
                initValue();
       
            // If false is returned, we didn't modify the set, so return null
            if (!value.add(rc))
View Full Code Here

   
    @Override
    // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2676)
    public EnumValue del(Object v){
        synchronized(this){
            EnumValue rc = null;
            if (value == null)
                return(rc);
           
            try {
                rc = typeCheck(v);
View Full Code Here

        synchronized(this){
            if (value == null)
                return(false);
           
            try {
                EnumValue val = typeCheck(v);
                return(value.contains(val));
            } catch (DmcValueException e) {
                return(false);
            }
        }
View Full Code Here

  protected EnumDefinition(String mn) throws DmcValueException {
    super(mn);
  }
 
  public EnumValue getEnumValue(String valueName){
    EnumValue rc = null;
   
    Iterator<EnumValue> values = getEnumValue();
    while(values.hasNext()){
      EnumValue value = values.next();
      if (value.getName().equals(valueName)){
        rc = value;
        break;
      }
    }
    return(rc);
View Full Code Here

        out.write(" */\n");
        out.write("public enum " + cn + " implements DmcEnumIF\n{\n");

        Iterator<EnumValue> enumit = ed.getEnumValue();
        while(enumit.hasNext()){
          EnumValue ev = enumit.next();
         
//            out.write("    /**\n");
//            CodeFormatter.dumpCodeComment(ev.getDescription(),out,"     * ");
//            out.write("     */\n");
           
            out.write("    " + ev.getName() + "(" + ev.getId() + ",\"" + ev.getDescription() + "\")");
            if (enumit.hasNext())
              out.write(",\n\n");
            else
              out.write(";\n\n");
        }
View Full Code Here

    enumName(out, ed);
    description(out, ed);
    Iterator<EnumValue>  evi = ed.getEnumValue();
    while(evi.hasNext()){
      EnumValue ev = evi.next();
      enumValue(out, ev);
    }
  }
View Full Code Here

   
    @Override
    // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2363)
    public EnumValue add(Object v) throws DmcValueException {
        synchronized(this){
            EnumValue rc = typeCheck(v);
            if (value == null)
                value = new ArrayList<EnumValue>();
            value.add(rc);
            return(rc);
        }
View Full Code Here

TOP

Related Classes of org.dmd.dms.types.EnumValue

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.