Ignore:
Timestamp:
09/20/12 09:40:26 (12 years ago)
Author:
sherbold
Message:
  • code documentation and clean-up
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/guimodel/GUIElementFactory.java

    r784 r831  
     1 
    12package de.ugoe.cs.quest.eventcore.guimodel; 
    23 
     
    1415 
    1516/** 
    16  * TODO comment 
     17 * <p> 
     18 * Creates {@link IGUIElement}s from a given specification. Implemented as singleton. 
     19 * </p> 
    1720 *  
    18  * @version $Revision: $ $Date: 13.05.2012$ 
    19  * @author 2012, last modified by $Author: patrick$ 
     21 * @version 1.0 
     22 * @author Patrick Harms 
    2023 */ 
    2124public class GUIElementFactory implements IGUIElementFactory { 
    22      
    23     /** */ 
     25 
     26    /** 
     27     * <p> 
     28     * Instance of the class (singleton) 
     29     * </p> 
     30     */ 
    2431    private static GUIElementFactory instance = new GUIElementFactory(); 
    2532 
    2633    /** 
    27      * TODO: comment 
     34     * <p> 
     35     * Constructor. Creates a new GUIElementFactory. Private to preserve singleton property. 
     36     * </p> 
     37     */ 
     38    private GUIElementFactory() {} 
     39 
     40    /** 
     41     * <p> 
     42     * Returns the instance of this class. 
     43     * </p> 
    2844     *  
    29      */ 
    30     private GUIElementFactory() { 
    31     } 
    32  
    33     /** 
    34      * TODO: comment 
    35      *  
    36      * @return 
     45     * @return the instance 
    3746     */ 
    3847    public static synchronized GUIElementFactory getInstance() { 
     
    4049    } 
    4150 
     51    /** 
     52     * <p> 
     53     * A property mapping that defines to which Java class is created given the type of the GUI 
     54     * element found in the specification. 
     55     * </p> 
     56     */ 
     57    private Properties mappingsFromConfiguration; 
     58 
    4259     
    43     /** */ 
    44     private Properties mappingsFromConfiguration; 
    45  
    46     /** 
    47      * TODO: comment 
     60    /* 
     61     * (non-Javadoc) 
    4862     *  
    49      * @param object1 
    50      * @param object2 
    51      * @return 
    52      */ 
    53     protected boolean equals(Object object1, Object object2) { 
    54         if (object1 == object2) { 
    55             return true; 
    56         } 
    57         else if (object1 != null) { 
    58             return object1.equals(object2); 
    59         } 
    60         else { 
    61             // object 1 is null but object 2 not --> return false 
    62             return false; 
    63         } 
    64     } 
    65  
    66     /** 
    67      * TODO: comment 
    68      *  
    69      * @param parameterTypes 
    70      * @param parameters 
    71      * @return 
    72      * @throws GUIModelConfigurationException 
     63     * @see 
     64     * de.ugoe.cs.quest.eventcore.guimodel.IGUIElementFactory#instantiateGUIElement(de.ugoe.cs.quest 
     65     * .eventcore.guimodel.IGUIElementSpec, de.ugoe.cs.quest.eventcore.guimodel.IGUIElement) 
    7366     */ 
    7467    @Override 
     
    8679                if (!IGUIElement.class.isAssignableFrom(clazz)) { 
    8780                    Console.traceln(Level.WARNING, "configured GUI element representing class " + 
    88                                     className + " is no valid GUIElement derivate."); 
     81                        className + " is no valid GUIElement derivate."); 
    8982 
    9083                    return null; 
     
    9386                Constructor<?> constructor = null; 
    9487                Class<?> parentClass = (parent == null) ? null : parent.getClass(); 
    95                  
     88 
    9689                // search for a constructor, that perfectly matches the types 
    9790                for (Constructor<?> candidate : clazz.getConstructors()) { 
    98                     if ((parentClass != null) && 
    99                         (candidate.getParameterTypes().length == 2) && 
     91                    if ((parentClass != null) && (candidate.getParameterTypes().length == 2) && 
    10092                        (candidate.getParameterTypes()[0].equals(specification.getClass())) && 
    10193                        (candidate.getParameterTypes()[1].equals(parentClass))) 
     
    113105                    } 
    114106                } 
    115                  
     107 
    116108                if (constructor == null) { 
    117109                    // search for an assignable constructor 
     
    125117                        } 
    126118                    } 
    127                      
     119 
    128120                } 
    129121                 
     
    205197 
    206198    /** 
    207      * TODO: comment 
     199     * <p> 
     200     * Loads the mappings for GUI elements. All files that start with &quot;guimapping&quot;, end 
     201     * with &quot;.txt&quot;, and are located in the folter &quot;data/guimappings&quot; (relative 
     202     * to the working directory) are loaded. 
     203     * </p> 
    208204     *  
    209      * @return 
     205     * @return loaded GUI mappings 
    210206     */ 
    211207    private synchronized Properties getMappingsFromConfiguration() 
     
    217213        else { 
    218214            mappingsFromConfiguration = new Properties(); 
    219              
     215 
    220216            File mappingsFolder = new File("data/guimappings"); 
    221217            File[] children = mappingsFolder.listFiles(); 
    222              
     218 
    223219            if (children != null) { 
    224220                for (File mappingsFile : children) { 
     
    233229                        } 
    234230                        catch (FileNotFoundException e) { 
    235                             throw new GUIModelConfigurationException 
    236                                 ("could not read mapping configuration file " + mappingsFile, e); 
     231                            throw new GUIModelConfigurationException( 
     232                                                                     "could not read mapping configuration file " + 
     233                                                                         mappingsFile, e); 
    237234                        } 
    238235                        catch (IOException e) { 
    239                             throw new GUIModelConfigurationException 
    240                                 ("could not read mapping configuration file " + mappingsFile, e); 
     236                            throw new GUIModelConfigurationException( 
     237                                                                     "could not read mapping configuration file " + 
     238                                                                         mappingsFile, e); 
    241239                        } 
    242240                        finally { 
     
    254252            } 
    255253            else { 
    256                 throw new GUIModelConfigurationException 
    257                     ("no GUI mappings file provided in folder " + mappingsFolder); 
     254                throw new GUIModelConfigurationException( 
     255                                                         "no GUI mappings file provided in folder " + 
     256                                                             mappingsFolder); 
    258257            } 
    259258 
Note: See TracChangeset for help on using the changeset viewer.