Class: DatatypeMapping
- Includes:
- Singleton
- Defined in:
- lib/ontomde-uml2/UMLdatatypeMapping.rb,
lib/ontomde-uml2/kb/datatypeMapping.rb
Direct Known Subclasses
DatatypeMappingBLOB, DatatypeMappingBoolean, DatatypeMappingCalendar, DatatypeMappingFile, DatatypeMappingGenericClass, DatatypeMappingGenericEnum, DatatypeMappingText, DatatypeMappingTimeStamp
Constant Summary collapse
- @@types =
Array.new
Instance Attribute Summary collapse
-
#maxStringLength ⇒ Object
max length of this element represented as a string.
Instance Method Summary collapse
-
#appliesTo?(datatype) ⇒ Boolean
returns true if this templates applies to datatype.
-
#getHelp ⇒ Object
return a help message on this datatype mapping definition.
- #getMapping(datatype) ⇒ Object
- #getMappings ⇒ Object
- #getValidationRegexp ⇒ Object
-
#initialize ⇒ DatatypeMapping
constructor
A new instance of DatatypeMapping.
- #prot_getProtegeType ⇒ Object
Constructor Details
#initialize ⇒ DatatypeMapping
Returns a new instance of DatatypeMapping.
40 41 42 43 44 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 40 def initialize return if self.class==DatatypeMapping @@types << self #log.debug { %{registered(##{@@types.size}): #{self.class}} } end |
Instance Attribute Details
#maxStringLength ⇒ Object
max length of this element represented as a string
111 112 113 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 111 def maxStringLength @maxStringLength end |
Instance Method Details
#appliesTo?(datatype) ⇒ Boolean
returns true if this templates applies to datatype
46 47 48 49 50 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 46 def appliesTo?(datatype) # inheriting class should redefine this method log.error %{appliesTo? not implemented for #{self.class}} return false end |
#getHelp ⇒ Object
return a help message on this datatype mapping definition.
121 122 123 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 121 def getHelp return "No help available for datatype mapping #{self.class}" end |
#getMapping(datatype) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 51 def getMapping(datatype) @@types.each {|t| next unless t.appliesTo?(datatype) return t } if !datatype.context[:silentlyForceUnknownDatatypeToString,false] msg= " \nERROR: OntoMDE generator encountered in your UML model\nERROR: an unknown datatype named \"\#{datatype}\".\nHELP: \nHELP: OntoMDE should be provided a datatype mapping \nHELP: definition in order to map your custom datatype\nHELP: to target code (java conversion, jsp code,\nHELP: ..., validation code, ...)\nHELP: This mapping definition should be placed in a\nHELP: file that is loaded by your ontomde generation script.\nHELP: (ontomde-java script uses --load option \nHELP: to load configuration files)\nHELP: \nHELP: Sample1: \nHELP: restriction of DatatypeMappingText for string mapping \nHELP: a particular regexp:\nHELP: addDataTypeMapping(\"\#{datatype}\",\nHELP: DatatypeMappingText, \nHELP: /[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]/ )\nHELP: \nHELP: Sample2:\nHELP: restriction of DatatypeMappingText for string mapping a particular regexp.\nHELP: addDataTypeMapping(\"\#{datatype}\",\nHELP: DatatypeMappingText, \nHELP: /[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]/ ) {\nHELP: # a datatype mapping definition is a set \nHELP: # of method called by generator.\nHELP: # Any method may be redefined :\nHELP: def java_getType\nHELP: return \"java.lang.String\"\nHELP: end\nHELP: #def getFormCopyTo(field) \nHELP: # (...)\nHELP: #end\nHELP: #def getFormInitFrom(field)\nHELP: # (...)\nHELP: #end\nHELP: }\nHELP: \nHELP: Available datatypes mapping in current running instance are:\n\#{@@types.collect {|t| \"HELP: \"+\"\#{t.class} : \#{t.getHelp} \\n\"}}.\n\n\nEnd of help on adding custom datatype mapping definition.\n" log.error msg unless log_already_displayed?(msg) end return DatatypeMappingText.instance #return DatatypeMappingerror.instance end |
#getMappings ⇒ Object
36 37 38 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 36 def getMappings return @@types end |
#getValidationRegexp ⇒ Object
115 116 117 118 |
# File 'lib/ontomde-uml2/UMLdatatypeMapping.rb', line 115 def getValidationRegexp #log.error %{getValidationRegexp not implemented for #{self.class}} return nil #%{/* TODO: implement ruby getValidationRegexp for #{self.class}*/} end |
#prot_getProtegeType ⇒ Object
2 3 4 |
# File 'lib/ontomde-uml2/kb/datatypeMapping.rb', line 2 def prot_getProtegeType return nil # no protege mapping defined end |