Package org.dmd.dmc.util

Examples of org.dmd.dmc.util.DmcUncheckedObject


    out.write("\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderTypes.size(); i++){
      DmcUncheckedObject td = typeDefs.get(origOrderTypes.get(i));
      String internallyGenerated = td.getSV("internallyGenerated");
      if (internallyGenerated != null)
//      if (origOrderTypes.get(i).endsWith("REF"))
        continue;
      out.write("    public static TypeDefinition      _" + origOrderTypes.get(i) + ";\n");
    }
View Full Code Here


    out.write("\n");
    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
    out.write("    private void initClasses() throws DmcValueException {\n\n");
   
    for(String cn : origOrderClasses){
      DmcUncheckedObject classDef = classDefs.get(cn);
      String name = classDef.getSV("name");
      String dmoName = "_" + name + "OBJ";
     
      out.write("        ClassDefinitionDMO " + dmoName + " = new ClassDefinitionDMO();\n");
      out.write("        _" + name + " = new ClassDefinition(" + dmoName + ",MetaDMSAG.__" + name + ");\n");
      dumpAttrValues("        ", dmoName, classDef, out);
View Full Code Here

      return;
   
    while(names.hasNext()){
      String         an       = names.next();
      String        anCapped  = GenUtility.capTheName(an);
      DmcUncheckedObject  attrDef   = attributeDefs.get(an);
      String        valueType  = attrDef.getSV("valueType");
      boolean        sv      = true;
     
      if ( (valueType != null) && (valueType.equals("MULTI")) )
        sv = false;
     
View Full Code Here

        String isNameType = typedef.getSV("isNameType");
        String isFilterType = typedef.getSV("isFilterType");

        if (isNameType != null) {
          String nameAttributeDef = typedef.getSV("nameAttributeDef");
          DmcUncheckedObject attrDef = attributeDefs
              .get(nameAttributeDef);
          nameAttrID = attrDef.getSV("dmdID");
        }

        if (isFilterType != null) {
          String filterAttributeDef = typedef
              .getSV("filterAttributeDef");
          DmcUncheckedObject attrDef = attributeDefs
              .get(filterAttributeDef);
          nameAttrID = attrDef.getSV("dmdID");
        }
        // dmotypedir basePackage baseTypeImport typeName dmcTypeImport
        // nameAttrImport nameAttr nameAttrID generic isRef isNameType
        // isFilterType fileHeader progress
        GenUtility.dumpSVType(typedir, "org.dmd.dms",
View Full Code Here

      String designatedFilterAttribute = obj
          .getSV("designatedFilterAttribute");
      if (designatedNameAttribute != null) {
        String type = obj.getSV("type");

        DmcUncheckedObject typeDef = typeDefs.get(type);

        typeDef.addValue("nameAttributeDef", name);

        // DebugInfo.debug("\n" + typeDef.toOIF(15));
      }
      if (designatedFilterAttribute != null) {
        String type = obj.getSV("type");

        DmcUncheckedObject typeDef = typeDefs.get(type);

        typeDef.addValue("filterAttributeDef", name);

        // DebugInfo.debug("\n" + typeDef.toOIF(15));
      }
    } else if (objClass.equals("ClassDefinition")) {
      classDefs.put(name, obj);
View Full Code Here

  void createClassDefForRuleDef(DmcUncheckedObject uco)
      throws ResultException {
    ArrayList<String> objClasses = new ArrayList<String>();
    objClasses.add("ClassDefinition");
    DmcUncheckedObject classDef = new DmcUncheckedObject(objClasses, 0);

    String name = GenUtility.capTheName(uco.getSV("name"));
    String isExtensible = uco.getSV("isExtensible");
    String ctype = "STRUCTURAL";

    if (isExtensible != null) {
      ctype = "EXTENSIBLE";
    }

    classDef.addValue("name", name + "Data");
    classDef.addValue("classType", ctype);
    classDef.addValue("derivedFrom", "RuleData");
    classDef.addValue("dmdID", uco.getSV("dmdID"));
    classDef.addValue("dmoImport", "org.dmd.dms.generated.dmo." + name
        + "DataDMO");
    classDef.addValue("javaClass", "org.dmd.dms.generated.dmo." + name
        + "DataDMO");
    classDef.addValue("internallyGenerated", "true");
    classDef.addValue("ruleDefinition", name);
    classDef.addValue("must", "ruleTitle");
    classDef.addValue("may", "description");

    NamedStringArray must = uco.get("must");
    if (must != null) {
      for (String attr : must) {
        classDef.addValue("must", attr);
      }
    }

    NamedStringArray may = uco.get("may");
    if (may != null) {
      for (String attr : may) {
        classDef.addValue("may", attr);
      }
    }

    classDefs.put(name + "Data", classDef);
    origOrderClasses.add(name + "Data");
View Full Code Here

  }

  void createInternalTypesForComplexTypes() throws ResultException {
    Iterator<DmcUncheckedObject> ite = complexTypeDefs.values().iterator();
    while (ite.hasNext()) {
      DmcUncheckedObject complexTypeDef = ite.next();
      String cn = complexTypeDef.getSV("name");
      String tn = cn;

      ArrayList<String> objClasses = new ArrayList<String>();
      objClasses.add("TypeDefinition");
      DmcUncheckedObject typeDef = new DmcUncheckedObject(objClasses, 0);
      typeDef.addValue("name", cn);
      typeDef.addValue("typeClassName",
          "org.dmd.dms.generated.types.DmcType" + cn);
      typeDef.addValue("primitiveType", "org.dmd.dms.generated.types."
          + cn);
      typeDef.addValue("internallyGenerated", "true");
      typeDef.addValue("description",
          "This is an internally generated type to represent complex type "
              + cn + ".");

      typeDefs.put(tn, typeDef);
      origOrderTypes.add(tn);
View Full Code Here

   * TypeDefinitions for each ClassDefinition.
   */
  void createInternalReferenceTypes() throws ResultException {
    Iterator<DmcUncheckedObject> it = classDefs.values().iterator();
    while (it.hasNext()) {
      DmcUncheckedObject classDef = it.next();

      String cn = classDef.getSV("name");
      String isNamedBy = classDef.getSV("isNamedBy");
      String tn = null;
      DmcUncheckedObject typeDef = null;

      if (isNamedBy == null) {

      } else {
        tn = cn + "REF";
        ArrayList<String> objClasses = new ArrayList<String>();
        objClasses.add("TypeDefinition");
        typeDef = new DmcUncheckedObject(objClasses, 0);
        typeDef.addValue("name", cn + "REF");
        typeDef.addValue("typeClassName",
            "org.dmd.dms.generated.types.DmcType" + cn + "REF");
        typeDef.addValue("wrapperClassName",
            classDef.getSV("javaClass"));
        typeDef.addValue("internallyGenerated", "true");
        typeDef.addValue("isRefType", "true");
        typeDef.addValue("description",
            "This is an internally generated type to allow references to "
                + cn + " objects.");
        typeDef.addValue("originalClass", cn);

        typeDefs.put(tn, typeDef);
        origOrderTypes.add(tn);
      }
    }

    Iterator<DmcUncheckedObject> ite = enumDefs.values().iterator();
    while (ite.hasNext()) {
      DmcUncheckedObject enumDef = ite.next();
      String cn = enumDef.getSV("name");
      String tn = cn + "REF";

      ArrayList<String> objClasses = new ArrayList<String>();
      objClasses.add("TypeDefinition");
      DmcUncheckedObject typeDef = new DmcUncheckedObject(objClasses, 0);
      typeDef.addValue("name", cn + "REF");
      typeDef.addValue("enumName", cn);
      typeDef.addValue("typeClassName",
          "org.dmd.dms.generated.types.DmcType" + cn);
      typeDef.addValue("primitiveType", "org.dmd.dms.generated.enums."
          + cn);
      typeDef.addValue("internallyGenerated", "true");
      // Need to know if it's an enum type so that we can set values
      // properly later
      typeDef.addValue("isEnumType", "true");
      typeDef.addValue("description",
          "This is an internally generated type to allow references to "
              + cn + " objects.");

      typeDefs.put(tn, typeDef);
      origOrderTypes.add(tn);
View Full Code Here

        } else
          predefname = predefname.replace("REF", "");
        // predefname = origOrderTypes.get(i) + "REF";
      }

      DmcUncheckedObject typeObj = typeDefs.get(defn);
      String typeClassName = typeObj.getSV("typeClassName");
      String wrapperClassName = typeObj.getSV("wrapperClassName");
      out.write("            _" + pf.sprintf(defn));
      if (wrapperClassName == null)
        out.write("= new TypeDefinition(\"" + predefname + "\", "
            + typeClassName + ".class);\n");
      else
        out.write("= new TypeDefinition(\"" + predefname + "\", "
            + typeClassName + ".class, " + wrapperClassName
            + ".class);\n");
    }
    out.write("\n");

    out.write("            // Create the attribute definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderAttrs.size(); i++) {
      String attrName = origOrderAttrs.get(i);
      String mediatorName = null;

      DmcUncheckedObject attrDef = attributeDefs.get(attrName);
      String typeName = attrDef.getSV("type");
      DmcUncheckedObject typeDef = typeDefs.get(typeName);

      // If we couldn't find the type by its name, it's because its a
      // reference
      // to a class or enum, and the actual TypeDefinition name will be
      // _<ClassName>Reference
View Full Code Here

  private void setAttributeValues(BufferedWriter out,
      TreeMap<String, DmcUncheckedObject> objects, PrintfFormat pf)
      throws IOException, ResultException {
    String attrName = null;
    String objName = null;
    DmcUncheckedObject attrDef = null;
    String typeName = null;
    DmcUncheckedObject typeDef = null;
    boolean multiValued = false;
    boolean isReference = false;
    boolean isEnumType = false;

    Iterator<DmcUncheckedObject> it = objects.values().iterator();
    while (it.hasNext()) {
      DmcUncheckedObject obj = it.next();
      objName = obj.getSV("name");

      // // trickiness here to handle the fact that the actual rule
      // definition object
      // // has to be called RuleDEF since Rule is the name of the class
      // definition that
      // // is created to represent the Rule instance.
      // if (obj.getConstructionClass().equals("RuleDefinition")){
      // objName = objName + "DEF";
      // }

      Iterator<String> attributeNames = obj.getAttributeNames();
      while (attributeNames.hasNext()) {
        NamedStringArray attr = obj.get(attributeNames.next());
        attrName = attr.getName();
        if (attrName == null) {
          DebugInfo.debug("Attr name null");
          continue;
        }
        attrDef = attributeDefs.get(attrName);
        multiValued = false;
        isReference = false;
        isEnumType = false;

        if (attrDef == null) {
          ResultException ex = new ResultException();
          ex.addError("Unknown attribute: " + attrName);
          ex.result.lastResult().fileName("metaSchema.dms");
          ex.result.lastResult().lineNumber(obj.lineNumber);
          throw (ex);
        }

        // MULTIVALUED 1
        if (attrDef.getSV("valueType") != null)
          multiValued = true;

        typeName = attrDef.getSV("type");
        typeDef = typeDefs.get(typeName);

        if (typeDef == null) {
          // If this is null, we need to look for an internally
          // generated Reference type
          typeDef = typeDefs.get(typeName + "REF");
          isReference = true;

          if (typeDef.getSV("isEnumType") != null)
            isEnumType = true;
        }

        StringBuffer attrNameCapped = new StringBuffer();
        attrNameCapped.append(attrName);
        attrNameCapped.setCharAt(0,
            Character.toUpperCase(attrNameCapped.charAt(0)));

        if (attrName.equals("type")) {
          // The type attribute has to be handled slightly differently
          // than most attributes
          // to adjust for the fact that we create those internal
          // Reference types to handle
          // references to definitions.
          isReference = false;
          isEnumType = false;
          typeName = obj.getSV("type");
          typeDef = typeDefs.get(typeName);

          if (typeDef == null) {
            // If this is null, we need to look for an internally
            // generated Reference type
            typeDef = typeDefs.get(typeName + "REF");
            isReference = true;

            if (typeDef.getSV("isEnumType") != null)
              isEnumType = true;
          }

          out.write("            _" + pf.sprintf(objName));

          out.write(".setType(");

          if (isReference) {
            out.write("_" + obj.getSV(attrName) + "REF);\n");
          } else {
            out.write("_" + obj.getSV(attrName) + ");\n");
          }
        } else {
          if (multiValued) {

            for (String attrVal : attr) {
              out.write("            _" + pf.sprintf(objName));
              out.write(".add" + attrNameCapped + "(");

              if (isReference) {
                if (isEnumType)
                  out.write(typeName + "." + attrVal + ");\n");
                else
                  out.write("_" + attrVal + ");\n");
              } else {
                out.write("\"" + attrVal + "\");\n");
              }
            }
          } else {
            out.write("            _" + pf.sprintf(objName));
            out.write(".set" + attrNameCapped + "(");

            if (isReference) {
              if (isEnumType)
                out.write(typeName + "." + obj.getSV(attrName)
                    + ");\n");
              else
                out.write("_" + obj.getSV(attrName) + ");\n");
            } else {
              String value = obj.getSV(attrName);

              if (attrName.equals("name")) {
                String val = obj.getSV(attrName);
                if (val.endsWith("EnumREF")) {
                  // DebugInfo.debug("Enum name: " + val);
                  value = val.replaceFirst("REF", "");
                  // DebugInfo.debug("value = " + value);
                }
View Full Code Here

TOP

Related Classes of org.dmd.dmc.util.DmcUncheckedObject

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.