Example #1
0
  /**
   * We will initialize file contents with a sample text.
   *
   * @throws SAXException
   */
  @Override
  protected InputStream openContentStream(String containerName, String fileName) {
    String name = containerName;
    int lastSlash = name.lastIndexOf('/');
    if (lastSlash >= 0) name = name.substring(lastSlash + 1);

    CSpecBuilder builder = new CSpecBuilder();
    builder.setName(name);
    builder.setComponentTypeID(INIT_COMPONENT_TYPE);
    builder.setVersion(Version.parseVersion(INIT_VERSION_STRING));

    CSpec cspec = new CSpec(builder);

    AccessibleByteArrayOutputStream bld = new AccessibleByteArrayOutputStream();
    try {
      Utils.serialize(cspec, bld);
    } catch (SAXException e) {
      throw new RuntimeException(
          Messages.cannot_create_a_new_buckminster_component_specification_file, e);
    }

    return bld.getInputStream();
  }