Exemple #1
0
  /**
   * Compile outputs.
   *
   * @param outputResources the output resources
   * @param outputNodeMap the output node map
   * @return the hash map
   */
  public HashMap<Node, Object> compileOutputs(
      HashMap<String, ConfigurationResource> outputResources, HashMap<String, Node> outputNodeMap) {
    HashMap<Node, Object> outputs = new HashMap<Node, Object>();
    System.out.println(outputResources.size() + " output objects.");
    for (String nodeName : outputResources.keySet()) {
      Node node = outputNodeMap.get(nodeName);
      ConfigurationResource resource = outputResources.get(nodeName);
      String resourceString = resource.getValue();

      if (resource.getRefType() == ConfigurationResource.RefTypes.INLINE_REF) {
        outputs.put(node, resourceString);
      } else if (resource.getRefType() == ConfigurationResource.RefTypes.URI_REF) {
        outputs.put(node, resourceString);
      } else if (resource.getRefType() == ConfigurationResource.RefTypes.FILE_REF) {
        //                String outputString = new String(resource.getBundleFile().getBytes());
        //                System.out.println("BundleFile at node : " + node + " contains : " +
        // outputString);
        //                outputs.put(node, outputString);
        String tempBundleLocation = resource.getBundleFile().getSystemPath();
        System.out.println(
            "BundleFile at node : " + node + " temp location : " + tempBundleLocation);
        String outputString = BundleUtils.readFile(tempBundleLocation);
        outputs.put(node, outputString);
      }

      System.out.println(
          "Node "
              + node.getAbsoluteNodeIndex()
              + " named : "
              + nodeName
              + " outputs : "
              + outputs.get(node));
    }
    return outputs;
  }
Exemple #2
0
  /**
   * Write configuration resource to file.
   *
   * @param configurationResource the configuration resource
   * @param file the file
   * @param outputLocation the output location
   * @return the file
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public static File writeConfigurationResourceToFile(
      ConfigurationResource configurationResource, File file, File outputLocation)
      throws IOException {
    String longName = configurationResource.getBundleFile().getFilename();
    if (file == null) {
      file = new File(outputLocation, longName.substring(longName.lastIndexOf("/") + 1));
    }
    System.out.println("   >> Made : " + file.getAbsolutePath());

    return DataUtils.extractToFile(configurationResource, file);
  }