Esempio n. 1
0
  /**
   * Lists all the alias names of this keystore.
   *
   * @return enumeration of the alias names
   */
  public Enumeration<String> engineAliases() {
    final Iterator<Map.Entry<String, KeyStore>> iterator = keystores.entrySet().iterator();

    return new Enumeration<String>() {
      private int index = 0;
      private Map.Entry<String, KeyStore> keystoresEntry = null;
      private String prefix = null;
      private Enumeration<String> aliases = null;

      public boolean hasMoreElements() {
        try {
          if (aliases == null) {
            if (iterator.hasNext()) {
              keystoresEntry = iterator.next();
              prefix = keystoresEntry.getKey() + entryNameSeparator;
              aliases = keystoresEntry.getValue().aliases();
            } else {
              return false;
            }
          }
          if (aliases.hasMoreElements()) {
            return true;
          } else {
            if (iterator.hasNext()) {
              keystoresEntry = iterator.next();
              prefix = keystoresEntry.getKey() + entryNameSeparator;
              aliases = keystoresEntry.getValue().aliases();
            } else {
              return false;
            }
          }
        } catch (KeyStoreException e) {
          return false;
        }

        return aliases.hasMoreElements();
      }

      public String nextElement() {
        if (hasMoreElements()) {
          return prefix + aliases.nextElement();
        }
        throw new NoSuchElementException();
      }
    };
  }
Esempio n. 2
0
 private void writeGenerators(RIFFWriter writer, Map<Integer, Short> generators)
     throws IOException {
   Short keyrange = (Short) generators.get(SF2Region.GENERATOR_KEYRANGE);
   Short velrange = (Short) generators.get(SF2Region.GENERATOR_VELRANGE);
   if (keyrange != null) {
     writer.writeUnsignedShort(SF2Region.GENERATOR_KEYRANGE);
     writer.writeShort(keyrange);
   }
   if (velrange != null) {
     writer.writeUnsignedShort(SF2Region.GENERATOR_VELRANGE);
     writer.writeShort(velrange);
   }
   for (Map.Entry<Integer, Short> generator : generators.entrySet()) {
     if (generator.getKey() == SF2Region.GENERATOR_KEYRANGE) continue;
     if (generator.getKey() == SF2Region.GENERATOR_VELRANGE) continue;
     writer.writeUnsignedShort(generator.getKey());
     writer.writeShort(generator.getValue());
   }
 }