Many ‘GetAttribute’-classes are present in the package named ‘nl.wietmazairac.bimql.get.attribute’. To all write them manually would have been a cumbersome task and therefore it was decided to apply the concept of metaprogramming. While metaprogramming, the programmer does not write the final code itself, instead he writes the code that generates that final code for him. This concept may be applied when the final code is very long and when that code contains a lot of repetitive elements, like in our case.
The class that generates the ‘GetAttribute’-classes is called ‘CreateGetAttributeMainSubObjectWrap.java’ and is located in the package named ‘nl.wietmazairac.bimql’. This class first loops through all the classes located in the package named ‘org.bimserver.models.ifc2x3.impl’. If the name of a class starts with “Ifc” and ends with “Impl”, a second loop is initiated. This second loop checks whether the class found in the first loop has any methods that start with “get”. The methods the second loop goes through are part of the BimServer.org functionality. A method that starts with “get” is, in this particular case, a method that retrieves the value of an attribute. Now the classes of interest and the relevant methods are known, the ‘java.io.Printwriter’-class can be used to generate the ‘GetAttribute’- classes.