/**
   * Retrieve the value of an option.
   *
   * @param id a string uniquely identifying the option
   * @return its value or null, if not found
   */
  public String getOption(String id) {

    assert (id != null);
    assert (fStorage != null);

    for (ICStorageElement child : fStorage.getChildrenByName("option")) {

      if (child.hasAttribute("id") && id.equals(child.getAttribute("id"))) {
        return child.getAttribute("value");
      }
    }

    return null;
  }
  /**
   * Retrieve a map with all properties.
   *
   * @return a map of strings.
   */
  public Map<String, String> getOptions() {

    assert (fStorage != null);

    Map<String, String> map = new HashMap<String, String>();

    for (ICStorageElement child : fStorage.getChildrenByName("option")) {

      if (child.hasAttribute("id")) {
        map.put(child.getAttribute("id"), child.getAttribute("value"));
      }
    }

    return map;
  }
  /**
   * Store the value of an option.
   *
   * @param id a string uniquely identifying the option
   * @param value a string to be assigned as option value; if null, the empty string is assigned
   */
  public void setOption(String id, String value) {

    assert (id != null);
    assert (fStorage != null);

    ICStorageElement option = null;
    for (ICStorageElement child : fStorage.getChildrenByName("option")) {

      if (id.equals(child.getAttribute("id"))) {
        if (option == null) {
          // Remember first occurrence
          option = child;
        } else {
          // remove possible duplicates
          fStorage.removeChild(child);
        }
      }
    }

    if (option == null) {
      option = fStorage.createChild("option");
      option.setAttribute("id", id);
    }
    if (value == null) {
      value = "";
    } else {
      value = value.trim();
    }
    option.setAttribute("value", value);
  }
示例#4
0
  private Map<String, Map<String, String>> decodeProjectContentTypeMappings(
      ICStorageElement rootElement) {
    Map<String, Map<String, String>> decodedMappings = new TreeMap<String, Map<String, String>>();
    ICStorageElement[] mappingElements = rootElement.getChildrenByName(CONTENT_TYPE_MAPPING);
    for (int j = 0; j < mappingElements.length; j++) {
      ICStorageElement mapping = mappingElements[j];
      String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION);

      Map<String, String> contentTypeMappings = decodedMappings.get(configuration);
      if (contentTypeMappings == null) {
        contentTypeMappings = new TreeMap<String, String>();
        decodedMappings.put(configuration, contentTypeMappings);
      }
      String contentType = mapping.getAttribute(ATTRIBUTE_CONTENT_TYPE);
      String language = mapping.getAttribute(ATTRIBUTE_LANGUAGE);
      contentTypeMappings.put(contentType, language);
    }
    return decodedMappings;
  }
示例#5
0
  private Map<String, Map<String, String>> decodeFileMappings(ICStorageElement rootElement)
      throws CoreException {
    Map<String, Map<String, String>> decodedMappings = new TreeMap<String, Map<String, String>>();
    ICStorageElement[] mappingElements = rootElement.getChildrenByName(FILE_MAPPING);
    for (int j = 0; j < mappingElements.length; j++) {
      ICStorageElement mapping = mappingElements[j];
      String path = mapping.getAttribute(ATTRIBUTE_PATH);

      Map<String, String> configurationMappings = decodedMappings.get(path);
      if (configurationMappings == null) {
        configurationMappings = new TreeMap<String, String>();
        decodedMappings.put(path, configurationMappings);
      }
      String configuration = mapping.getAttribute(ATTRIBUTE_CONFIGURATION);
      String language = mapping.getAttribute(ATTRIBUTE_LANGUAGE);
      configurationMappings.put(configuration, language);
    }
    return decodedMappings;
  }
  public Map<String, String[]> getMemoryMap() {

    Map<String, String[]> map = new TreeMap<String, String[]>();

    for (ICStorageElement child : fStorage.getChildrenByName("memory")) {

      String section = child.getAttribute("section");
      String arr[] =
          new String[] {
            section,
            child.getAttribute("start"),
            child.getAttribute("size"),
            child.getAttribute("startup")
          };
      map.put(section, arr);
    }

    return map;
  }
示例#7
0
  /* (non-Javadoc)
   * Initialize the resource configuration information from the XML element
   * specified in the argument
   *
   * @param element An XML element containing the resource configuration information
   */
  protected void loadFromProject(ICStorageElement element) {
    // toolsToInvoke
    if (element.getAttribute(IResourceConfiguration.TOOLS_TO_INVOKE) != null) {
      toolsToInvoke =
          SafeStringInterner.safeIntern(
              element.getAttribute(IResourceConfiguration.TOOLS_TO_INVOKE));
    }

    // rcbsApplicability
    if (element.getAttribute(IResourceConfiguration.RCBS_APPLICABILITY) != null) {
      String rcbsApplicabilityStr = element.getAttribute(IResourceConfiguration.RCBS_APPLICABILITY);
      if (rcbsApplicabilityStr == null || rcbsApplicabilityStr.equals(DISABLE_RCBS_TOOL)) {
        rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);
      } else if (rcbsApplicabilityStr.equals(APPLY_RCBS_TOOL_BEFORE)) {
        rcbsApplicability = new Integer(KIND_APPLY_RCBS_TOOL_BEFORE);
      } else if (rcbsApplicabilityStr.equals(APPLY_RCBS_TOOL_AFTER)) {
        rcbsApplicability = new Integer(KIND_APPLY_RCBS_TOOL_AFTER);
      } else if (rcbsApplicabilityStr.equals(APPLY_RCBS_TOOL_AS_OVERRIDE)) {
        rcbsApplicability = new Integer(KIND_APPLY_RCBS_TOOL_AS_OVERRIDE);
      }
    }
  }
  /**
   * Store the description of a memory section.
   *
   * @param section a string with the section name, using the CMSIS convention (like IRAM1, IROM1)
   * @param start a string with the hex value of the start address
   * @param size a string with the hex value of the size, in bytes
   * @param startup a string with 1 if the section will be used for startup (to host the vectors
   *     table)
   */
  public void setMemory(String section, String start, String size, String startup) {

    ICStorageElement memory = null;
    for (ICStorageElement child : fStorage.getChildrenByName("memory")) {

      if (section.equals(child.getAttribute("section"))) {
        if (memory == null) {
          // Remember first occurrence
          memory = child;
        } else {
          // remove possible duplicates
          fStorage.removeChild(child);
        }
      }
    }

    if (memory == null) {
      memory = fStorage.createChild("memory");
      memory.setAttribute("section", section);
    }
    memory.setAttribute("start", start);
    memory.setAttribute("size", size);
    memory.setAttribute("startup", startup);
  }