/// <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; }
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(); } }
/// <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); }
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); }
/// <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); }
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); }
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); }
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); }