Package civquest.io

Examples of civquest.io.ConfigurationException


  public String getHeightVegSectionName(Field.Height height, String vegetation)
    throws ConfigurationException {

    if (!(vegetationDefinitions.containsKey(vegetation))) {
      throw new ConfigurationException("No vegetation with name " + vegetation
                       + " defined!");
    }
   
    return height.name().toLowerCase() + SEPARATOR + vegetation;
  }
View Full Code Here


    String[] parts = name.split(SEPARATOR);

    if (parts.length < 2) {
      String msg = "When parsing height-vegetation-section-name: "
        + "Must contain a " + SEPARATOR;
      throw new ConfigurationException(msg);
    }
   
    if (!(vegetationDefinitions.containsKey(parts[parts.length - 1]))) {
      String msg = "When parsing height-vegetation-section-name: "
        + parts[parts.length - 1] + " is not a vegetation!";
      throw new ConfigurationException(msg);
    }

    String tmpString = "";
    for (int n = 0; n < parts.length - 1; n++) {
      tmpString += parts[n];
    }

    String heightString = tmpString.toUpperCase();
    Field.Height height;
    try {
      height = Enum.valueOf(Field.Height.class, heightString);
    } catch (IllegalArgumentException e) {
      String msg = "When parsing height-vegetation-section-name: "
        + tmpString + " is no valid height string!";
      throw new ConfigurationException(msg);
    }
  }
View Full Code Here

  private void checkVegetationName(String name)
    throws ConfigurationException {
   
    if (name.contains(SEPARATOR)) {
      throw new ConfigurationException("Vegetation name may not contain this substring: "
                       + SEPARATOR);
    }
  }
View Full Code Here

      String resourceName = field.getName();
      String amountString = field.getStringValue();
      PhysicalAmount amount = getAmount(amountString);
     
      if (!(mapConfig.resourceExists(resourceName))) {
        throw new ConfigurationException(resourceName + " is not a valid "
                         + "resource name!");
      } else {
        ResourceDefinition resourceDef = mapConfig.getResourceDefinition(resourceName);
        PhysicalAmount.PhysicalUnit standardUnit = resourceDef.getStandardUnit();
       
        if ((!amount.getUnit().canTransform(standardUnit))) {
          String msg = "Can't transform unit " + amount.getUnit() +
            " into standard unit for resource " + resourceName +
            ", which is " + standardUnit;
          throw new ConfigurationException(msg);
        } else {
          resourceSet.addToThis(resourceName, amount);
        }
      }
    }
View Full Code Here

TOP

Related Classes of civquest.io.ConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.