コード例 #1
0
ファイル: FileWriter.java プロジェクト: isuruw/wso2-axis2
  /**
   * Finds the file name extension.
   *
   * @param language
   * @return Returns the file extension.
   */
  protected String getFileExtensionForLanguage(String language) {
    Map languageSpecificPropertyMap =
        (Map) ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
    Iterator keys = languageSpecificPropertyMap.keySet().iterator();
    String key;
    String extension = null;
    while (keys.hasNext()) {
      // check for template entries
      key = keys.next().toString();
      if (key.endsWith(EXTENSION_SUFFIX)) {
        extension = languageSpecificPropertyMap.get(key).toString();
        // add a . to the front
        extension = "." + extension;
      }
    }

    return extension;
  }
コード例 #2
0
ファイル: FileWriter.java プロジェクト: isuruw/wso2-axis2
  /** Loads the template. */
  public void loadTemplate() throws CodeGenerationException {
    // the default behavior for the class writers is to use the property map from the languge
    // specific types
    // The properties are arranged in the following order
    // <lang-name>.* .template=<write-class>,<template-name>

    // first get the language specific property map
    Class clazz = this.getClass();
    Map languageSpecificPropertyMap =
        (Map) ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
    if (languageSpecificPropertyMap == null) {
      throw new CodeGenerationException(
          CodegenMessages.getMessage("writer.noLangPropertiesExtension"));
    }

    String templateName = findTemplate(languageSpecificPropertyMap);
    if (templateName != null) {
      this.xsltStream = clazz.getResourceAsStream(templateName);
    } else {
      throw new CodeGenerationException(CodegenMessages.getMessage("writer.templateMissing"));
    }
  }