/** * Gets all the ServerConfiguration objects belonging to a WorldServer object. There will be at * least one in every configuration or else a DataFormatException will be thrown. * * @param file The GlobalServerConfigurationFile which represents the interface to the parsed data * between the implementation of the parsers and the implementation of how the parsed * information should be interpreted. * @return The ServerConfiguration objects belonging to a WorldServer configuration. * @throws DataFormatException If the file contains an incorrect format. */ public LinkedList<ServerConfiguration> getWorlds(GlobalServerConfigurationFile file) throws DataFormatException { MappedAttributeList parameters = file.getParameters(); LinkedList<ServerConfiguration> worldList = parameters.get(ServerType.WORLD.toString()); if (worldList.size() < 1) throw new DataFormatException( "No world servers were configured. You need to configure at least one!"); return worldList; }
/** * Gets the root server in the configuration. In the current setup there will only be one root * server possible in any configuration. * * @param file The GlobalServerConfigurationFile which represents the interface to the parsed data * between the implementation of the parsers and the implementation of how the parsed * information should be interpreted. * @return The ServerConfiguration belonging to a RootServer configuration. * @throws DataFormatException If the file contains an incorrect format. */ public ServerConfiguration getRoot(GlobalServerConfigurationFile file) throws DataFormatException { MappedAttributeList parameters = file.getParameters(); LinkedList<ServerConfiguration> rootList = parameters.get(ServerType.ROOT.toString()); if (rootList.size() > 1 || rootList.isEmpty()) throw new DataFormatException( "Error in root server configuration format. Either too many (more than 1) or" + " none were configured!"); ServerConfiguration configuration = rootList.getFirst(); if (configuration != null) return configuration; else throw new DataFormatException( "Error in root server configuration format. Root server object is NULL."); }