Package org.dmd.dmc.types

Examples of org.dmd.dmc.types.IntegerVar


    /**
     * String based constructor.
     */
    public GPBField(String initialInput) throws DmcValueException {
        IntegerVar seppos = new IntegerVar(-1);
        String input = initialInput.trim();
        input = input.replaceAll("(\\s)+", " ");
        fieldType = DmcTypeGPBFieldTypeEnumSTATIC.instance.typeCheck(getNextField(input,seppos,"fieldType",false));
        attribute = DmcTypeAttributeDefinitionREFSTATIC.instance.typeCheck(getNextField(input,seppos,"attribute",false));
        fieldTag = DmcTypeIntegerSTATIC.instance.typeCheck(getNextField(input,seppos,"fieldTag",true));
View Full Code Here


    /**
     * String based constructor.
     */
    public Field(String initialInput) throws DmcValueException {
        IntegerVar seppos = new IntegerVar(-1);
        String input = initialInput.trim();
        input = input.replaceAll("(\\s)+", " ");
        type = DmcTypeTypeDefinitionREFSTATIC.instance.typeCheck(getNextField(input,seppos,"type",false));
        name = DmcTypeStringSTATIC.instance.typeCheck(getNextField(input,seppos,"name",false));
        description = DmcTypeStringSTATIC.instance.typeCheck(getNextField(input,seppos,"description",true));
View Full Code Here

    /**
     * String based constructor.
     * Generated from: org.dmd.dms.util.ComplexTypeFormatter.dumpComplexType(ComplexTypeFormatter.java:175)
     */
    public MenuElementTypeAndComment(String initialInput) throws DmcValueException {
        IntegerVar seppos = new IntegerVar(-1);
        String input = initialInput.trim();
        type = DmcTypeStringSTATIC.instance.typeCheck(getNextField(input,seppos,"type",false));
        comment = DmcTypeStringSTATIC.instance.typeCheck(getNextField(input,seppos,"comment",true));
    }
View Full Code Here

   * @param cd        The class definition of the object.
   * @param allAttr   An array that will be populated with all attribute definitions of the class.
   * @param sb        The buffer where the import statements are accumulated.
   */
  public void getAttributesAndImports(ClassDefinition cd, ArrayList<AttributeDefinition> allAttr, StringBuffer sb){
    IntegerVar    longestImport  = new IntegerVar();
    TreeMap<StringName,TypeDefinition>  types = new TreeMap<StringName,TypeDefinition>();
    TreeMap<StringName,TypeDefinition>  iterables = new TreeMap<StringName,TypeDefinition>();
    TreeSet<String>            genericImports  = new TreeSet<String>();
    TreeMap<String,TypeAndAttr>      typeAndAttr   = new TreeMap<String,TypeAndAttr>();
    boolean                needDmwOmni    = false;
   
    // Key: type name
    // Value: comment
    TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();

    anyAttributes = false;
   
    if (cd.getDMWPackage() != null){
      cd.adjustJavaClass();
    }

    Iterator<AttributeDefinition> may = cd.getMay();
    if (may != null){
      while(may.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
       
        anyAttributes = true;
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
         
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
         
          break;
        }
       
        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        allAttr.add(ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
        anyAttributes = true;
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        }

        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");

        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
       
    addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
   
    if ( (cd.getClassType() != ClassTypeEnum.ABSTRACT) && (cd.getClassType() != ClassTypeEnum.AUXILIARY)){
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.types.DmcTypeModifierMV", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.MetaDMSAG", "Required for MODREC constructor");
    }
   
   
    if (cd.getUseWrapperType() == WrapperTypeEnum.EXTENDED){
        addImport(uniqueImports, longestImport, cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes)
      addImport(uniqueImports, longestImport, "org.dmd.dmc.*", "If any attributes");
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

    for(TypeAndAttr ta : typeAndAttr.values()){
      TypeDefinition td = ta.td;
     
      if (td.getIsRefType()){
        // We have to make some adjustments to handle the fact that we
        // may not be generating this code in the same location as the DMOs
        td.adjustJavaClass();
       
        addImport(uniqueImports, longestImport, td.getAuxHolderImport(), "Is reference type aux");
       
        // If this is multi-valued, we don't need the REF because we're returning the Iterable
        if (ta.valueType == ValueTypeEnum.SINGLE){
          if (td.getOriginalClass().getIsNamedBy() == null)
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
          else
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
        }
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          addImport(uniqueImports, longestImport, ta.getImport(), "Reference in an auxiliary class");
        }
       
        if (td.getOriginalClass().getIsNamedBy() != null)
          addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs");
       
      }
      else if (td.getPrimitiveType() != null){
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type");
      }
      else if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        addImport(uniqueImports, longestImport, ta.getImport(), "Type in an auxiliary class");
      }
     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
      if (td.getKeyImport() != null)
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
     
      if (ta.valueType != ValueTypeEnum.SINGLE)
        addImport(uniqueImports, longestImport, "java.util.Iterator", "To support getMVCopy()");
       
      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        addImport(uniqueImports, longestImport, "java.util.ArrayList", "To support getMVCopy()");
        break;
      case HASHMAPPED:
        addImport(uniqueImports, longestImport, "java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        addImport(uniqueImports, longestImport, "java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        addImport(uniqueImports, longestImport, "java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        addImport(uniqueImports, longestImport, "java.util.TreeSet", "To support getMVCopy()");
        break;
      }
       
    }
   
    Iterator<TypeDefinition> t  = iterables.values().iterator();
    while(t.hasNext()){
      TypeDefinition td = t.next();
     
      addImport(uniqueImports, longestImport, td.getDmwIteratorImport(), "For multi-valued " + td.getName().getNameString());
     
      if (td.getPrimitiveType() != null)
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "For multi-valued contains" + td.getName().getNameString());
     
    }
   
    if (cd.getClassType() == ClassTypeEnum.ABSTRACT){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Abstract class");
    }

    if (cd.getDerivedFrom() == null){
      if (cd.getIsNamedBy() == null){
        addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwWrapper", "Unnamed object wrapper");
      }
      else{
        if (cd.getIsNamedBy().getType().getIsHierarchicName()){
          addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwHierarchicObjectWrapper", "Hierarchic object wrapper");
        }
        else{
          addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwNamedObjectWrapper", "Named object wrapper");
        }
      }
    }
    else{
      cd.getDerivedFrom().adjustJavaClass();
      addImport(uniqueImports, longestImport, cd.getDerivedFrom().getJavaClass(), "Derived class");
    }
     
    if ((cd.getClassType() != ClassTypeEnum.AUXILIARY) && (cd.getClassType() != ClassTypeEnum.ABSTRACT)){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Class not auxiliary or abstract");
    }
   
    sb.append(formatImports(uniqueImports, longestImport.intValue()));
  }
View Full Code Here

        switch(optionType){
            case FLAG:
                // Error
            break;
            case INTEGER:
                IntegerVar i = (IntegerVar) option;
                i.set(str);
            break;
            case STRING:
                StringBuffer s = (StringBuffer) option;
                if (s.length() != 0)
                    s.delete(0,s.length());
View Full Code Here

   * @param cd        The class definition of the object.
   * @param allAttr   An array that will be populated with all attribute definitions of the class.
   * @param sb        The buffer where the import statements are accumulated.
   */
  public void getAttributesAndImports(ClassDefinition cd, ArrayList<AttributeDefinition> allAttr, StringBuffer sb){
    IntegerVar    longestImport  = new IntegerVar();
    TreeMap<StringName,TypeDefinition>  types = new TreeMap<StringName,TypeDefinition>();
    TreeMap<StringName,TypeDefinition>  iterables = new TreeMap<StringName,TypeDefinition>();
    TreeSet<String>            genericImports  = new TreeSet<String>();
    TreeMap<String,TypeAndAttr>      typeAndAttr   = new TreeMap<String,TypeAndAttr>();
    boolean                needDmwOmni    = false;
   
    // Key: type name
    // Value: comment
    TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();

    anyAttributes = false;
   
    cd.adjustJavaClass(genContext,genSuffix);

    Iterator<AttributeDefinition> may = cd.getMay();
    if (may != null){
      while(may.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
       
        anyAttributes = true;
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
         
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
         
          break;
        }
       
        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (ad.getValueType() != ValueTypeEnum.SINGLE){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }

        allAttr.add(ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
        anyAttributes = true;
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        }

        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (ad.getValueType() != ValueTypeEnum.SINGLE){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }
       
        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
     
    if (useWrappedObjectRefs)
      addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
   
    if ( (cd.getClassType() != ClassTypeEnum.ABSTRACT) && (cd.getClassType() != ClassTypeEnum.AUXILIARY)){
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.types.DmcTypeModifierMV", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.MetaDMSAG", "Required for MODREC constructor");
    }
   
    if (cd.getDmwWrapperType(genContext) == WrapperTypeEnum.EXTENDED){
      addImport(uniqueImports, longestImport, cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes)
      addImport(uniqueImports, longestImport, "org.dmd.dmc.*", "If any attributes");
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

    for(TypeAndAttr ta : typeAndAttr.values()){
      TypeDefinition td = ta.td;
     
      if (td.getIsRefType()){
        if (useWrappedObjectRefs){
          // We have to make some adjustments to handle the fact that we
          // may not be generating this code in the same location as the DMOs
          td.adjustJavaClass();
         
          addImport(uniqueImports, longestImport, td.getAuxHolderImport(), "Is reference type aux");
         
          // If this is multi-valued, we don't need the REF because we're returning the Iterable
          if (ta.valueType == ValueTypeEnum.SINGLE){
            if (td.getOriginalClass().getIsNamedBy() == null)
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
            else
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
          }
         
          if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
            addImport(uniqueImports, longestImport, ta.getImport(), "Reference in an auxiliary class");
          }
         
          if (td.getOriginalClass().getIsNamedBy() != null){
            if ( (ta.valueType == ValueTypeEnum.TREEMAPPED) || (ta.valueType == ValueTypeEnum.HASHMAPPED) || (ta.indexed))
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs");
          }
        }
        else{
          // If this is multi-valued, we don't need the REF because we're returning the Iterable
          if (ta.valueType == ValueTypeEnum.SINGLE){
            if (td.getOriginalClass().getIsNamedBy() == null)
              addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
            else{
              if (!td.getIsExtendedRefType())
                addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
            }
          }
         
//          if (td.getOriginalClass().getIsNamedBy() != null)
            addImport(uniqueImports, longestImport, td.getPrimitiveType(), "DMO reference");         

          if (td.getHelperClassName() != null){
            addImport(uniqueImports, longestImport, td.getHelperClassName(), "Helper class");
          }
        }
      }
      else if (td.getPrimitiveType() != null){
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type");
      }
      else if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        addImport(uniqueImports, longestImport, ta.getImport(), "Type in an auxiliary class");
      }
     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
      if (td.getKeyImport() != null)
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
     
      if (ta.valueType != ValueTypeEnum.SINGLE)
        addImport(uniqueImports, longestImport, "java.util.Iterator", "To support getMVCopy()");

      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        addImport(uniqueImports, longestImport, "java.util.ArrayList", "To support getMVCopy()");
        break;
      case HASHMAPPED:
        if (useWrappedObjectRefs)
          addImport(uniqueImports, longestImport, "java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        if (useWrappedObjectRefs)
          addImport(uniqueImports, longestImport, "java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        addImport(uniqueImports, longestImport, "java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        addImport(uniqueImports, longestImport, "java.util.TreeSet", "To support getMVCopy()");
        break;
      }
       
    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition> t  = iterables.values().iterator();
      while(t.hasNext()){
        TypeDefinition td = t.next();
       
        addImport(uniqueImports, longestImport, td.getDmwIteratorImport(), "For multi-valued " + td.getName().getNameString());
       
        if (td.getPrimitiveType() != null)
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "For multi-valued contains" + td.getName().getNameString());
       
      }
    }
   
    if (cd.getClassType() == ClassTypeEnum.ABSTRACT){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Abstract class");
    }

    if (cd.getDerivedFrom() == null){
      if (cd.getIsNamedBy() == null){
        addImport(uniqueImports, longestImport, baseWrapperImport, "Unnamed object wrapper");
      }
      else{
        if (cd.getIsNamedBy().getType().getIsHierarchicName()){
          addImport(uniqueImports, longestImport, hierarchicWrapperImport, "Hierarchic object wrapper");
        }
        else{
          addImport(uniqueImports, longestImport, namedWrapperImport, "Named object wrapper");
        }
      }
    }
    else{
      cd.getDerivedFrom().adjustJavaClass(genContext,genSuffix);
      addImport(uniqueImports, longestImport, cd.getDerivedFrom().getJavaClass(), "Derived class");
    }
     
    if ((cd.getClassType() != ClassTypeEnum.AUXILIARY) && (cd.getClassType() != ClassTypeEnum.ABSTRACT)){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Class not auxiliary or abstract");
    }
   
    sb.append(formatImports(uniqueImports, longestImport.intValue()));
  }
View Full Code Here

   * @param in
   * @param objects
   * @throws ResultException
   */
  DmcUncheckedObject parseObject(String in) throws ResultException {
    IntegerVar    index       = new IntegerVar(0);
    boolean     wantStartCurly   = true;
    boolean     wantEndCurly     = false;
    String       input       = in.trim();
    DmcUncheckedObject  basic       = new DmcUncheckedObject();
   
    // Reset the result set
    rsG.reset();
   
    for(; index.intValue()<input.length(); index.set(index.intValue()+1)){
     
      if (wantStartCurly){
        if (input.charAt(index.intValue()) == '{'){
          wantStartCurly = false;
          index.set(index.intValue()+1);
          parseObject(input, index, basic);
          wantEndCurly = true;
        }
        else{
          // ERROR Expecting {
          ResultException ex = new ResultException();
          ex.addError("Expecting opening bracket for object.");
          throw(ex);
        }
      }
      else if (wantEndCurly){
        eatWhiteSpace(input, index, "end bracket for object");
       
        if (input.charAt(index.intValue()) == '}'){
          // This should be the last character, if not, we have extraneous stuff - and, because
          // we trimmed the string at the beginning of the process, we know that there's not
          // just whitespace there.
          if ( (input.length()-1) != index.intValue()){
            // ERROR extraneous stuff
            ResultException ex = new ResultException();
            ex.addError("Extraneous characters after object.");
            throw(ex);
          }
View Full Code Here

   * @param cd        The class definition of the object.
   * @param allAttr   An array that will be populated with all attribute definitions of the class.
   * @param sb        The buffer where the import statements are accumulated.
   */
  public void getAttributesAndImports(ClassDefinition cd, ArrayList<AttributeDefinition> allAttr, StringBuffer sb){
    IntegerVar    longestImport  = new IntegerVar();
    TreeMap<StringName,TypeDefinition>  types = new TreeMap<StringName,TypeDefinition>();
    TreeMap<StringName,TypeDefinition>  iterables = new TreeMap<StringName,TypeDefinition>();
    TreeSet<String>            genericImports  = new TreeSet<String>();
    TreeMap<String,TypeAndAttr>      typeAndAttr   = new TreeMap<String,TypeAndAttr>();
    boolean                needDmwOmni    = false;
   
    // Key: type name
    // Value: comment
    TreeMap<String,String>  uniqueImports = new TreeMap<String, String>();

    anyAttributes = false;
   
    cd.adjustJavaClass(genContext,genSuffix);

    Iterator<AttributeDefinition> may = cd.getMay();
    if (may != null){
      while(may.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
       
        anyAttributes = true;
        AttributeDefinition ad = may.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
         
          if (ad.getType().getIsRefType())
            anyMVRefs = true;
         
          iterables.put(td.getName(),td);
         
          break;
        }
       
        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (ad.getValueType() != ValueTypeEnum.SINGLE){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }

        allAttr.add(ad);
      }
    }
   
    Iterator<AttributeDefinition> must = cd.getMust();
    if (must != null){
      while(must.hasNext()){
        // NOTE: COMPLICATED! We always add the type of the attribute to our global types
        // map EXCEPT IF the type is a non-referential, MULTI/SET attribute. Gaa!
        //
        // This is because WE DON'T want the primitive type any more, just the TYPEIterableDMW.
        // If the value is a single valued type, we'll want the primitive type.
       
        boolean shouldAddType = true;
        anyAttributes = true;
        AttributeDefinition ad = must.next();
        TypeDefinition td = ad.getType();
       
        if (ad.getGenericArgs() != null){
          if (ad.getGenericArgs().equals("<DmcObjectName>"))
            needDmwOmni = true;
        }
       
        switch(ad.getValueType()){
        case SINGLE:
          anySVAttributes =  true;
          break;
        case HASHMAPPED:
        case TREEMAPPED:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        case MULTI:
        case HASHSET:
        case TREESET:
          anyMVAttributes = true;
          if (ad.getType().getIsRefType())
            anyMVRefs = true;

          iterables.put(td.getName(),td);
          break;
        }

        if (shouldAddType){
          types.put(td.getName(), td);
          TypeAndAttr ta = new TypeAndAttr(td,ad.getValueType(),ad.getIndexSize());
          typeAndAttr.put(ta.name, ta);
        }
       
        appendAttributeInfo(attributeInfo, ad.getName().getNameString(), ad.getDmdID(), ad.getType().getName().getNameString(), ad.getValueType(), ad.getDataType());

        if (ad.getGenericArgsImport() != null)
          genericImports.add(ad.getGenericArgsImport());

        if (ad.getValueType() != ValueTypeEnum.SINGLE){
          addImport(uniqueImports, longestImport, ad.getDefinedIn().getDMSASGImport(), "Attribute from " + ad.getDefinedIn().getName() + " schema");
        }
       
        allAttr.add(ad);
      }
    }
   
    if (cd.getIsNamedBy() != null){
      AttributeDefinition isNamedBy = cd.getIsNamedBy();
      String nameAttributeType = isNamedBy.getType().getPrimitiveType();
     
      addImport(uniqueImports, longestImport, nameAttributeType, "Is named by");
    }
       
//    addImport(uniqueImports, longestImport, "org.dmd.dms.*", "Always 2");
   
    if ( (cd.getClassType() != ClassTypeEnum.ABSTRACT) && (cd.getClassType() != ClassTypeEnum.AUXILIARY)){
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.types.DmcTypeModifierMV", "Required for MODREC constructor");
      addImport(uniqueImports, longestImport, "org.dmd.dms.generated.dmo.MetaDMSAG", "Required for MODREC constructor");
    }
   
    if (cd.getDmwWrapperType(genContext) == WrapperTypeEnum.EXTENDED){
      addImport(uniqueImports, longestImport, cd.getDmeImport(), "Required for getModificationRecorder()");
    }
     
    if (needDmwOmni)
      addImport(uniqueImports, longestImport, "org.dmd.dmw.DmwOmni", "Have DmcObjectName attributes");
   
    if (anyAttributes)
      addImport(uniqueImports, longestImport, "org.dmd.dmc.*", "If any attributes");
   
    for(String s: genericImports){
      addImport(uniqueImports, longestImport, s, "Generic args import");
    }

    for(TypeAndAttr ta : typeAndAttr.values()){
      TypeDefinition td = ta.td;
     
      if (td.getIsRefType()){
        // We have to make some adjustments to handle the fact that we
        // may not be generating this code in the same location as the DMOs
        td.adjustJavaClass();
       
        addImport(uniqueImports, longestImport, td.getAuxHolderImport(), "Is reference type aux");
       
        // If this is multi-valued, we don't need the REF because we're returning the Iterable
        if (ta.valueType == ValueTypeEnum.SINGLE){
          if (td.getOriginalClass().getIsNamedBy() == null)
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmoImport(), "Reference to unnamed object");
          else
            addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "Is reference type REF");
        }
       
        if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
          addImport(uniqueImports, longestImport, ta.getImport(), "Reference in an auxiliary class");
        }
       
        if (td.getOriginalClass().getIsNamedBy() != null)
          addImport(uniqueImports, longestImport, td.getOriginalClass().getDmtREFImport(), "To support getMVCopy() for REFs");
       
      }
      else if (td.getPrimitiveType() != null){
        addImport(uniqueImports, longestImport, td.getPrimitiveType(), "Primitive type");
      }
      else if (cd.getClassType() == ClassTypeEnum.AUXILIARY){
        addImport(uniqueImports, longestImport, ta.getImport(), "Type in an auxiliary class");
      }
     
      if (td.getAltType() != null){
        if (td.getAltTypeImport() != null)
          addImport(uniqueImports, longestImport, td.getAltTypeImport(), "Alternative type for " + td.getName() + " values");
      }
     
      if (td.getKeyImport() != null)
        addImport(uniqueImports, longestImport, td.getKeyImport(), "Key class");
     
      if (ta.valueType != ValueTypeEnum.SINGLE)
        addImport(uniqueImports, longestImport, "java.util.Iterator", "To support getMVCopy()");

      switch(ta.valueType){
      case SINGLE:
        break;
      case MULTI:
        addImport(uniqueImports, longestImport, "java.util.ArrayList", "To support getMVCopy()");
        break;
      case HASHMAPPED:
        addImport(uniqueImports, longestImport, "java.util.HashMap", "To support getMVCopy()");
        break;
      case TREEMAPPED:
        addImport(uniqueImports, longestImport, "java.util.TreeMap", "To support getMVCopy()");
        break;
      case HASHSET:
        addImport(uniqueImports, longestImport, "java.util.HashSet", "To support getMVCopy()");
        break;
      case TREESET:
        addImport(uniqueImports, longestImport, "java.util.TreeSet", "To support getMVCopy()");
        break;
      }
       
    }
   
    if (useWrappedObjectRefs){
      Iterator<TypeDefinition> t  = iterables.values().iterator();
      while(t.hasNext()){
        TypeDefinition td = t.next();
       
        addImport(uniqueImports, longestImport, td.getDmwIteratorImport(), "For multi-valued " + td.getName().getNameString());
       
        if (td.getPrimitiveType() != null)
          addImport(uniqueImports, longestImport, td.getPrimitiveType(), "For multi-valued contains" + td.getName().getNameString());
       
      }
    }
   
    if (cd.getClassType() == ClassTypeEnum.ABSTRACT){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Abstract class");
    }

    if (cd.getDerivedFrom() == null){
      if (cd.getIsNamedBy() == null){
        addImport(uniqueImports, longestImport, baseWrapperImport, "Unnamed object wrapper");
      }
      else{
        if (cd.getIsNamedBy().getType().getIsHierarchicName()){
          addImport(uniqueImports, longestImport, hierarchicWrapperImport, "Hierarchic object wrapper");
        }
        else{
          addImport(uniqueImports, longestImport, namedWrapperImport, "Named object wrapper");
        }
      }
    }
    else{
      cd.getDerivedFrom().adjustJavaClass(genContext,genSuffix);
      addImport(uniqueImports, longestImport, cd.getDerivedFrom().getJavaClass(), "Derived class");
    }
     
    if ((cd.getClassType() != ClassTypeEnum.AUXILIARY) && (cd.getClassType() != ClassTypeEnum.ABSTRACT)){
      addImport(uniqueImports, longestImport, cd.getDmoImport(), "Class not auxiliary or abstract");
    }
   
    sb.append(formatImports(uniqueImports, longestImport.intValue()));
  }
View Full Code Here

    /**
     * String based constructor.
     * Generated from: org.dmd.dms.util.ComplexTypeFormatter.dumpComplexType(ComplexTypeFormatter.java:175)
     */
    public EventSpec(String initialInput) throws DmcValueException {
        IntegerVar seppos = new IntegerVar(-1);
        String input = initialInput.trim();
        input = input.replaceAll("(\\s)+", " ");
        varName = DmcTypeStringSTATIC.instance.typeCheck(getNextField(input,seppos,"varName",false));
        cardinality = DmcTypeSelectionTypeEnumSTATIC.instance.typeCheck(getNextField(input,seppos,"cardinality",false));
        scope = DmcTypeEventScopeEnumSTATIC.instance.typeCheck(getNextField(input,seppos,"scope",true));
View Full Code Here

    /**
     * String based constructor.
     * Generated from: org.dmd.dms.util.ComplexTypeFormatter.dumpComplexType(ComplexTypeFormatter.java:175)
     */
    public DisplayDataSpec(String initialInput) throws DmcValueException {
        IntegerVar seppos = new IntegerVar(-1);
        String input = initialInput.trim();
        input = input.replaceAll("(\\s)+", " ");
        dataClass = DmcTypeClassDefinitionREFSTATIC.instance.typeCheck(getNextField(input,seppos,"dataClass",false));
        cardinality = DmcTypeSelectionTypeEnumSTATIC.instance.typeCheck(getNextField(input,seppos,"cardinality",false));
        varName = DmcTypeStringSTATIC.instance.typeCheck(getNextField(input,seppos,"varName",true));
View Full Code Here

TOP

Related Classes of org.dmd.dmc.types.IntegerVar

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.