コード例 #1
0
  public void parse() {
    String bundlePath = null;
    if (bundle.getBundleFile() != null)
      bundlePath = FilenameNormalization.normalize(bundle.getBundleFile().getAbsolutePath());

    try {
      while (reader.hasNext()) {
        final int next = reader.next();
        if (next != XMLStreamConstants.START_ELEMENT) continue;

        final String tagName = reader.getName().getLocalPart();
        if (tagName.equals(TAG_LIBRARY)) {
          if (reader.isStartElement()) {
            library = new BundleLibrary(reader.getAttributeValue(null, "name"));
            bundle.addLibrary(library);
          } else if (reader.isEndElement()) {

            library = null;
          }
        } else if (library != null) {
          final String containerType = tagName;
          final String categoryType = reader.getAttributeValue(null, "type");
          BundleContainer container =
              (BundleContainer) library.getContainer(IBundleContainer.Type.toType(containerType));

          if (container == null) {
            container =
                (BundleContainer) library.addContainer(IBundleContainer.Type.toType(containerType));
          }

          IBundleCategory category =
              container.addCategory(IBundleCategory.Type.toType(categoryType));

          category.addFile(bundlePath, reader.getAttributeValue(null, "path"));
        } else if (tagName.equals("versions")) {
          version = (BundleVersion) bundle.getVersion();
        } else if (tagName.equals("bundle")) {
          version.setBundleVersion(reader.getAttributeValue(null, "version"));
        } else if (tagName.equals("randori")) {
          version.setRandoriVersion(reader.getAttributeValue(null, "version"));
          version.setRandoriBuild(reader.getAttributeValue(null, "build"));
          version.setRandoriMinSupportedVersion(
              reader.getAttributeValue(null, "minimumSupportedVersion"));
        } else if (tagName.equals("compiler")) {
          version.setCompilerName(reader.getAttributeValue(null, "name"));
          version.setCompilerVersion(reader.getAttributeValue(null, "version"));
        } else if (tagName.equals("version")) {

        }
      }
    } catch (XMLStreamException e) {
      File bundleFile = bundle.getBundleFile();
      final String file =
          (bundleFile != null) ? FilenameNormalization.normalize(bundleFile.getAbsolutePath()) : "";
      bundle.addProblem(
          new FileInLibraryIOProblem(BundleReader.MANIFEST_XML, file, e.getLocalizedMessage()));
    }
  }