Module: Muml_Enumeration

Defined in:
lib/ontomde-java/java/xsd.rb,
lib/ontomde-java/flex/main.rb,
lib/ontomde-java/java/java.rb,
lib/ontomde-java/vmware/vso.rb,
lib/ontomde-java/struts/jsp_edit.rb

Overview

end

Instance Method Summary collapse

Instance Method Details

#as_writeClassBodyObject

write enum body (list of litterals) using as_writeClassComment, as_writeClassModifiers, as_writeMetaClassName.

Example:

  • { red,blue,green }



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/ontomde-java/flex/main.rb', line 270

def as_writeClassBody
	as_writeClassComment
	as_writeAnnotation
	as_writeClassModifiers
	as_writeMetaClassName
	write("\n{\n")
	uml_ownedLiteral.each {|c|
		write(%{public static var #{c}:#{as_Name} = new EtatDossier("#{c}");\n})
	}
	write <<END

public function #{as_Name}(str:String){
  name=str;
}

public static function getValues():ArrayCollection{
  var values:ArrayCollection = new ArrayCollection();
END
uml_ownedLiteral.each {|c|
write("   values.addItem(#{c});\n");
}
write <<END
  return values;
}

public function toString(){
  return name;
  }
END

	#as_writeDeclarationSpecificOnBegin
	as_writeAttributes
	write("\n\n")
	#as_writeConstructors
	write("\n\n")
	as_writeOperations
	#as_writeDeclarationSpecificOnEnd



	write("\n}");
end

#java_ownedLiteralObject

returns literals in a controlled ordered



499
500
501
# File 'lib/ontomde-java/java/java.rb', line 499

def java_ownedLiteral
 return  uml_ownedLiteral.sort { |a,b| a.java_Name.to_s <=> b.java_Name.to_s }
end

#java_writeClassBodyObject

write enum body (list of litterals) using java_writeClassComment, java_writeClassModifiers, java_writeMetaClassName.

Example:

  • { red,blue,green }



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/ontomde-java/java/java.rb', line 507

def java_writeClassBody
  java_writeClassComment
  java_writeJavadoc
  java_writeAnnotation
  java_writeMdatkAnno(['imports','javadoc','annotations','custom_code']) if context[:hasGlobalReverse]
  java_writeClassModifiers
  java_writeMetaClassName
  java_writeImplements
  write(" {\n")
  sep=""
 java_ownedLiteral.each { |c|
    write(sep);
    c.java_write
    sep=",\n"
  }
  
  if uml_ownedLiteral.empty?
    label="null_literal"
    write("/* TODO: #{label} literal  added by generator to work around a bug in hibernate which crash when an enum has no literal.*/\n#{label}\n")
  end
  
  write(";\n") # literal/code separator

  #java_writeDeclarationSpecificOnBegin
  java_writeAttributes
  write("\n\n")
  #java_writeConstructors
  write("\n\n")
  java_writeOperations
  java_writeCustomCode
  #java_writeDeclarationSpecificOnEnd



  write("\n}");
end

#java_writeImplementsObject

write java implements declaration clause if needed.

Example:

  • implements interface1, interface2



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/ontomde-java/java/java.rb', line 548

def java_writeImplements
  imp=Set.new
  uml_implementation.each { |g|
    next if (g.umlx_hasStereotype?("private") )
    imp.add(g.uml_supplier_one.java_qualifiedName)
  }
  java_implements.each { |g|
    imp.add(g)
  }

  sep="\nimplements "
  imp.sort{ |a,b| a <=> b}.each { |g|
    write(sep)
    write(g)
    sep=","
  }
end

#java_writeMetaClassNameObject

writes java5 enum keyword and enum class name

Example:

  • enum Colors



494
495
496
# File 'lib/ontomde-java/java/java.rb', line 494

def java_writeMetaClassName
  write("enum #{java_Name}")
end

#struts_edit_writeField(field, owner) ⇒ Object



493
494
495
496
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 493

def struts_edit_writeField(field,owner)
  tpl=DatatypeMapping.instance.getMapping(self)
  write tpl.getJSP(self,field,owner)
end

#vso_writeEnumerationMapping(tab) ⇒ Object



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/ontomde-java/vmware/vso.rb', line 310

def vso_writeEnumerationMapping(tab)
	tab2=tab.tab
	tab3=tab2.tab
	encloseWrite(
		%{#{tab}<enumeration type="#{self.java_qualifiedName}">\n},
		%{#{tab}</enumeration>\n}) {
		
		vso_writeJavadoc(tab2)
		#write(%#{tab2}<url></url>\n})	
		encloseWrite(%{#{tab2}<entries>\n},%{#{tab2}</entries>\n}) {
			i=0
			java_ownedLiteral.each {|e|
				i=i+1
				write(%{#{tab3}<entry id="#{i}" name="#{e.java_Name}"/>\n})
				#TODO: comment ?
			}
		}
	}
end

#xsd_writeImplementsObject

write java implements declaration clause if needed.

Example:

  • implements interface1, interface2



626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/ontomde-java/java/xsd.rb', line 626

def xsd_writeImplements
  imp=Set.new
  uml_implementation.each { |g|
    imp.add(g.uml_supplier_one.xsd_qualifiedName)
  }
  xsd_implements.each { |g|
    imp.add(g)
  }

  sep="\n<!-- implements "
  e=""
  imp.sort{ |a,b| a <=> b}.each { |g|
    write(sep)
    write(g)
    sep=","
    e=" -->"
  }
  write(e)
end

#xsd_writeMetaClassName(&block) ⇒ Object

writes java5 enum keyword and enum class name

Example:

  • enum Colors



588
589
590
591
592
# File 'lib/ontomde-java/java/xsd.rb', line 588

def xsd_writeMetaClassName(&block)
  write(%{    <xsd:simpleType name="#{xsd_qualifiedName}" >\n})
  yield
  write(%{    </xsd:simpleType>\n})
end

#xsd_writeTypeObject

write enum body (list of litterals) using xsd_writeClassComment, xsd_writeClassModifiers, xsd_writeMetaClassName.

Example:

  • { red,blue,green }



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/ontomde-java/java/xsd.rb', line 598

def xsd_writeType
  xsd_writeMetaClassName {
    xsd_writeExtends {
      xsd_writeClassComment
      #xsd_writeJavadoc
      #xsd_writeAnnotation
      xsd_writeClassModifiers
    
      write(%{     <xsd:restriction base="xsd:string">\n})
      uml_ownedLiteral.each {|c|
        write(%{       <xsd:enumeration value="#{c.xsd_Name}"/>\n})
      }
      write(%{     </xsd:restriction>\n})
  
      #xsd_writeDeclarationSpecificOnBegin
      #skip: xsd_writeAttributes
      #xsd_writeConstructors
      #xsd_writeOperations
      xsd_writeCustomCode
      #xsd_writeDeclarationSpecificOnEnd
    }
  }
end