/// <summary> Merges a Multimap with inherited maps.
        /// Values specified always overrules/replaces the inherited values.
        /// 
        /// </summary>
        /// <returns> a MultiMap with all values from local and extra values
        /// from inherited
        /// </returns>
        public static MultiMap MergeMetaMaps(MultiMap local, MultiMap inherited)
        {
            MultiHashMap result = new MultiHashMap();
            SupportClass.PutAll(result, local);

            if (inherited != null)
            {
                for (IEnumerator iter = new SupportClass.SetSupport(inherited.Keys).GetEnumerator(); iter.MoveNext();)
                {
                    string key = (String) iter.Current;

                    if (!local.ContainsKey(key))
                    {
                        // inheriting a meta attribute only if it is inheritable
                        ArrayList ml = (ArrayList) inherited[key];
                        for (IEnumerator iterator = ml.GetEnumerator(); iterator.MoveNext();)
                        {
                            MetaAttribute element = (MetaAttribute) iterator.Current;
                            if (element.inheritable)
                            {
                                if (result[key] == null)
                                    result[key] = new SupportClass.ListCollectionSupport();

                                ((SupportClass.ListCollectionSupport) result[key]).Add(element);
                            }
                        }
                    }
                }
            }

            return result;
        }
Пример #2
0
        private void DoFields(SupportClass.ListCollectionSupport fieldList, SupportClass.SetSupport imports,
                              IDictionary class2classmap, StringWriter writer)
        {
            for (IEnumerator fields = fieldList.GetEnumerator(); fields.MoveNext();)
            {
                FieldProperty field = (FieldProperty)fields.Current;

                if (field.GeneratedAsProperty)
                {
                    string fieldScope = GetFieldScope(field, "scope-field", "private");
                    writer.WriteLine("    /// <summary>\n    /// Holder for " +
                                     (field.Nullable && !field.Identifier ? "nullable " : string.Empty) +
                                     (field.Identifier ? "identifier" : "persistent") + " field " + field.FieldName +
                                     "\n    /// </summary>");

                    writer.Write("    " + fieldScope + " " + field.FullyQualifiedTypeName + " " + field.fieldcase);

                    if (field.GetMeta("default-value") != null)
                    {
                        writer.Write(" = " + field.GetMetaAsString("default-value"));
                    }
                    writer.WriteLine(';');
                }
                writer.WriteLine();
            }
        }
Пример #3
0
        /// <summary> Merges a Multimap with inherited maps.
        /// Values specified always overrules/replaces the inherited values.
        ///
        /// </summary>
        /// <returns> a MultiMap with all values from local and extra values
        /// from inherited
        /// </returns>
        public static MultiMap MergeMetaMaps(MultiMap local, MultiMap inherited)
        {
            MultiHashMap result = new MultiHashMap();

            SupportClass.PutAll(result, local);

            if (inherited != null)
            {
                for (IEnumerator iter = new SupportClass.SetSupport(inherited.Keys).GetEnumerator(); iter.MoveNext();)
                {
                    string key = (String)iter.Current;

                    if (!local.ContainsKey(key))
                    {
                        // inheriting a meta attribute only if it is inheritable
                        ArrayList ml = (ArrayList)inherited[key];
                        for (IEnumerator iterator = ml.GetEnumerator(); iterator.MoveNext();)
                        {
                            MetaAttribute element = (MetaAttribute)iterator.Current;
                            if (element.inheritable)
                            {
                                if (result[key] == null)
                                {
                                    result[key] = new SupportClass.ListCollectionSupport();
                                }

                                ((SupportClass.ListCollectionSupport)result[key]).Add(element);
                            }
                        }
                    }
                }
            }

            return(result);
        }
Пример #4
0
 public virtual void DoFields(ClassMapping classMapping, IDictionary class2classmap, StringWriter writer)
 {
     // fields
     if (!classMapping.Interface)
     {
         if (classMapping.SuperInterface)
         {
             DoFields(classMapping.AllFields, classMapping.Imports, class2classmap, writer);
         }
     }
     SupportClass.ListCollectionSupport fieldList = classMapping.Fields;
     SupportClass.SetSupport            imports   = classMapping.Imports;
     DoFields(fieldList, imports, class2classmap, writer);
 }
Пример #5
0
        /// <summary> Returns the last part of type if it is in the set of imports.
        /// e.g. java.util.Date would become Date, if imports contains
        /// java.util.Date.
        ///
        /// </summary>
        /// <returns> String
        /// </returns>
        public static string ShortenType(string type, SupportClass.SetSupport imports)
        {
            string result = type;

            if (imports.Contains(type))
            {
                result = type.Substring(type.LastIndexOf(StringHelper.Dot) + 1);
            }
            else if (type.EndsWith("[]"))
            {
                result = ShortenType(type.Substring(0, (type.Length - 2) - (0)), imports) + "[]";
            }
            else if (type.StartsWith("java.lang."))
            {
                result = type.Substring("java.lang.".Length);
            }

            return(result);
        }
Пример #6
0
 protected internal virtual void InitWith(string name, ClassName type, ClassName implementationClassName, bool nullable,
                                          bool id, bool generated, ClassName foreignClass,
                                          SupportClass.SetSupport foreignKeys, MultiMap metaattribs)
 {
     this.fieldName = name.Replace("`", "");
     Type           = type;
     this.nullable  = nullable;
     this.id        = id;
     this.generated = generated;
     this.implementationClassName = implementationClassName;
     this.accessorName            = BeanCapitalize(fieldName);
     this.foreignClass            = foreignClass;
     this.foreignKeys             = foreignKeys;
     MetaAttribs = metaattribs;
     if (fieldName.Substring(0, 1) == fieldName.Substring(0, 1).ToLower())
     {
         log.Warn("Nonstandard naming convention found on " + fieldName);
     }
     IsValueType = CheckValueType(type);
 }
Пример #7
0
 protected internal virtual void InitWith(string name, ClassName type, ClassName implementationClassName, bool nullable,
     bool id, bool generated, ClassName foreignClass,
     SupportClass.SetSupport foreignKeys, MultiMap metaattribs)
 {
     this.fieldName = name;
     Type = type;
     this.nullable = nullable;
     this.id = id;
     this.generated = generated;
     this.implementationClassName = implementationClassName;
     this.accessorName = BeanCapitalize(name);
     this.foreignClass = foreignClass;
     this.foreignKeys = foreignKeys;
     MetaAttribs = metaattribs;
     if (fieldName.Substring(0, 1) == fieldName.Substring(0, 1).ToLower())
         log.Warn("Nonstandard naming convention found on " + fieldName);
 }
Пример #8
0
 public FieldProperty(Element element, MappingElement parent, string name, ClassName type,
                      ClassName implementationClassName, bool nullable, ClassName foreignClass,
                      SupportClass.SetSupport foreignKeys, MultiMap metaattribs) : base(element, parent)
 {
     InitWith(name, type, implementationClassName, nullable, id, false, foreignClass, foreignKeys, metaattribs);
 }