Ejemplo n.º 1
0
 public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() {
   if (bufferPools == null) {
     bufferPools = new ArrayList<>(2);
     bufferPools.add(
         createBufferPoolMXBean(
             j86.sun.misc.SharedSecrets.getJavaNioAccess().getDirectBufferPool()));
     bufferPools.add(createBufferPoolMXBean(j86.sun.nio.ch.FileChannelImpl.getMappedBufferPool()));
   }
   return bufferPools;
 }
Ejemplo n.º 2
0
 /** TypeArguments: "<" TypeArgument+ ">" */
 private TypeArgument[] parseTypeArguments() {
   List<TypeArgument> tas = new ArrayList<>(3);
   assert (current() == '<');
   if (current() != '<') {
     throw error("expected '<'");
   }
   advance();
   tas.add(parseTypeArgument());
   while (current() != '>') {
     // (matches(current(),  '+', '-', 'L', '[', 'T', '*')) {
     tas.add(parseTypeArgument());
   }
   advance();
   return tas.toArray(new TypeArgument[tas.size()]);
 }
Ejemplo n.º 3
0
 /** SuperclassSignature: ClassTypeSignature */
 private ClassTypeSignature[] parseSuperInterfaces() {
   List<ClassTypeSignature> cts = new ArrayList<>(5);
   while (current() == 'L') {
     cts.add(parseClassTypeSignature());
   }
   return cts.toArray(new ClassTypeSignature[cts.size()]);
 }
Ejemplo n.º 4
0
 /** FormalTypeParameters: "<" FormalTypeParameter+ ">" */
 private FormalTypeParameter[] parseFormalTypeParameters() {
   List<FormalTypeParameter> ftps = new ArrayList<>(3);
   assert (current() == '<'); // should not have been called at all
   if (current() != '<') {
     throw error("expected '<'");
   }
   advance();
   ftps.add(parseFormalTypeParameter());
   while (current() != '>') {
     int startingPosition = index;
     ftps.add(parseFormalTypeParameter());
     progress(startingPosition);
   }
   advance();
   return ftps.toArray(new FormalTypeParameter[ftps.size()]);
 }
Ejemplo n.º 5
0
 // ThrowSignature*
 private FieldTypeSignature[] parseZeroOrMoreThrowsSignatures() {
   List<FieldTypeSignature> ets = new ArrayList<>(3);
   while (current() == '^') {
     ets.add(parseThrowsSignature());
   }
   return ets.toArray(new FieldTypeSignature[ets.size()]);
 }
Ejemplo n.º 6
0
  public List<ReferenceType> visibleClasses() {
    List<ReferenceType> classes = null;
    try {
      Cache local = (Cache) getCache();

      if (local != null) {
        classes = local.visibleClasses;
      }
      if (classes == null) {
        JDWP.ClassLoaderReference.VisibleClasses.ClassInfo[] jdwpClasses =
            JDWP.ClassLoaderReference.VisibleClasses.process(vm, this).classes;
        classes = new ArrayList<ReferenceType>(jdwpClasses.length);
        for (int i = 0; i < jdwpClasses.length; ++i) {
          classes.add(vm.referenceType(jdwpClasses[i].typeID, jdwpClasses[i].refTypeTag));
        }
        classes = Collections.unmodifiableList(classes);
        if (local != null) {
          local.visibleClasses = classes;
          if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) {
            vm.printTrace(
                description()
                    + " temporarily caching visible classes (count = "
                    + classes.size()
                    + ")");
          }
        }
      }
    } catch (JDWPException exc) {
      throw exc.toJDIException();
    }
    return classes;
  }
Ejemplo n.º 7
0
 @Override
 public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
   AnnotationNode an = new AnnotationNode(desc);
   if (visible) {
     if (visibleAnnotations == null) {
       visibleAnnotations = new ArrayList<AnnotationNode>(1);
     }
     visibleAnnotations.add(an);
   } else {
     if (invisibleAnnotations == null) {
       invisibleAnnotations = new ArrayList<AnnotationNode>(1);
     }
     invisibleAnnotations.add(an);
   }
   return an;
 }
Ejemplo n.º 8
0
 @Override
 public void visitAttribute(final Attribute attr) {
   if (attrs == null) {
     attrs = new ArrayList<Attribute>(1);
   }
   attrs.add(attr);
 }
Ejemplo n.º 9
0
 // TypeSignature*
 private TypeSignature[] parseZeroOrMoreTypeSignatures() {
   List<TypeSignature> ts = new ArrayList<>();
   boolean stop = false;
   while (!stop) {
     switch (current()) {
       case 'B':
       case 'C':
       case 'D':
       case 'F':
       case 'I':
       case 'J':
       case 'S':
       case 'Z':
       case 'L':
       case 'T':
       case '[':
         {
           ts.add(parseTypeSignature());
           break;
         }
       default:
         stop = true;
     }
   }
   return ts.toArray(new TypeSignature[ts.size()]);
 }
Ejemplo n.º 10
0
 /**
  * Process Win32-style command files for the specified command line arguments and return the
  * resulting arguments. A command file argument is of the form '@file' where 'file' is the name of
  * the file whose contents are to be parsed for additional arguments. The contents of the command
  * file are parsed using StreamTokenizer and the original '@file' argument replaced with the
  * resulting tokens. Recursive command files are not supported. The '@' character itself can be
  * quoted with the sequence '@@'.
  */
 public static String[] parse(String[] args) throws IOException {
   List<String> newArgs = new ArrayList<>(args.length);
   for (int i = 0; i < args.length; i++) {
     String arg = args[i];
     if (arg.length() > 1 && arg.charAt(0) == '@') {
       arg = arg.substring(1);
       if (arg.charAt(0) == '@') {
         newArgs.add(arg);
       } else {
         loadCmdFile(arg, newArgs);
       }
     } else {
       newArgs.add(arg);
     }
   }
   return newArgs.toArray(new String[newArgs.size()]);
 }
Ejemplo n.º 11
0
 public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
   MemoryPoolMXBean[] pools = MemoryImpl.getMemoryPools();
   List<MemoryPoolMXBean> list = new ArrayList<>(pools.length);
   for (MemoryPoolMXBean p : pools) {
     list.add(p);
   }
   return list;
 }
Ejemplo n.º 12
0
 @Override
 public AnnotationVisitor visitTypeAnnotation(
     int typeRef, TypePath typePath, String desc, boolean visible) {
   TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
   if (visible) {
     if (visibleTypeAnnotations == null) {
       visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
     }
     visibleTypeAnnotations.add(an);
   } else {
     if (invisibleTypeAnnotations == null) {
       invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
     }
     invisibleTypeAnnotations.add(an);
   }
   return an;
 }
Ejemplo n.º 13
0
 public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
   MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers();
   List<MemoryManagerMXBean> result = new ArrayList<>(mgrs.length);
   for (MemoryManagerMXBean m : mgrs) {
     result.add(m);
   }
   return result;
 }
Ejemplo n.º 14
0
 /**
  * Method addX509Data
  *
  * @param x509data
  */
 public void add(X509Data x509data) {
   if (x509Datas == null) {
     x509Datas = new ArrayList<X509Data>();
   }
   x509Datas.add(x509data);
   this.constructionElement.appendChild(x509data.getElement());
   XMLUtils.addReturnToElement(this.constructionElement);
 }
Ejemplo n.º 15
0
 /**
  * Method addEncryptedKey
  *
  * @param encryptedKey
  * @throws XMLEncryptionException
  */
 public void add(EncryptedKey encryptedKey) throws XMLEncryptionException {
   if (encryptedKeys == null) {
     encryptedKeys = new ArrayList<EncryptedKey>();
   }
   encryptedKeys.add(encryptedKey);
   XMLCipher cipher = XMLCipher.getInstance();
   this.constructionElement.appendChild(cipher.martial(encryptedKey));
 }
Ejemplo n.º 16
0
 public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
   MemoryManagerMXBean[] mgrs = MemoryImpl.getMemoryManagers();
   List<GarbageCollectorMXBean> result = new ArrayList<>(mgrs.length);
   for (MemoryManagerMXBean m : mgrs) {
     if (GarbageCollectorMXBean.class.isInstance(m)) {
       result.add(GarbageCollectorMXBean.class.cast(m));
     }
   }
   return result;
 }
Ejemplo n.º 17
0
  /**
   * ClassBound: ":" FieldTypeSignature_opt
   *
   * <p>InterfaceBound: ":" FieldTypeSignature
   */
  private FieldTypeSignature[] parseBounds() {
    List<FieldTypeSignature> fts = new ArrayList<>(3);

    if (current() == ':') {
      advance();
      switch (current()) {
        case ':': // empty class bound
          break;

        default: // parse class bound
          fts.add(parseFieldTypeSignature());
      }

      // zero or more interface bounds
      while (current() == ':') {
        advance();
        fts.add(parseFieldTypeSignature());
      }
    } else error("Bound expected");

    return fts.toArray(new FieldTypeSignature[fts.size()]);
  }
Ejemplo n.º 18
0
  /**
   * Returns all listeners in the map.
   *
   * @return an array of all listeners
   */
  public final synchronized L[] getListeners() {
    if (this.map == null) {
      return newArray(0);
    }
    List<L> list = new ArrayList<>();

    L[] listeners = this.map.get(null);
    if (listeners != null) {
      for (L listener : listeners) {
        list.add(listener);
      }
    }
    for (Entry<String, L[]> entry : this.map.entrySet()) {
      String name = entry.getKey();
      if (name != null) {
        for (L listener : entry.getValue()) {
          list.add(newProxy(name, listener));
        }
      }
    }
    return list.toArray(newArray(list.size()));
  }
Ejemplo n.º 19
0
 private static void loadCmdFile(String name, List<String> args) throws IOException {
   Reader r = new BufferedReader(new FileReader(name));
   StreamTokenizer st = new StreamTokenizer(r);
   st.resetSyntax();
   st.wordChars(' ', 255);
   st.whitespaceChars(0, ' ');
   st.commentChar('#');
   st.quoteChar('"');
   st.quoteChar('\'');
   while (st.nextToken() != StreamTokenizer.TT_EOF) {
     args.add(st.sval);
   }
   r.close();
 }
Ejemplo n.º 20
0
  /**
   * ClassTypeSignature: "L" PackageSpecifier_opt SimpleClassTypeSignature ClassTypeSignatureSuffix*
   * ";"
   */
  private ClassTypeSignature parseClassTypeSignature() {
    assert (current() == 'L');
    if (current() != 'L') {
      throw error("expected a class type");
    }
    advance();
    List<SimpleClassTypeSignature> scts = new ArrayList<>(5);
    scts.add(parsePackageNameAndSimpleClassTypeSignature());

    parseClassTypeSignatureSuffix(scts);
    if (current() != ';') throw error("expected ';' got '" + current() + "'");

    advance();
    return ClassTypeSignature.make(scts);
  }
Ejemplo n.º 21
0
 public void addResource(SoundbankResource resource) {
   if (resource instanceof SF2Instrument) instruments.add((SF2Instrument) resource);
   if (resource instanceof SF2Layer) layers.add((SF2Layer) resource);
   if (resource instanceof SF2Sample) samples.add((SF2Sample) resource);
 }
Ejemplo n.º 22
0
 public void addInstrument(SF2Instrument resource) {
   instruments.add(resource);
 }
Ejemplo n.º 23
0
 static {
   List<StorageResolver> list = new ArrayList<StorageResolver>(1);
   list.add(null);
   nullList = j86.java.util.Collections.unmodifiableList(list);
 }
Ejemplo n.º 24
0
  private static List<String> splitStringAtNonEnclosedWhiteSpace(String value)
      throws IllegalArgumentException {
    List<String> al = new ArrayList<String>();
    char[] arr;
    int startPosition = 0;
    int endPosition = 0;
    final char SPACE = ' ';
    final char DOUBLEQ = '"';
    final char SINGLEQ = '\'';

    /*
     * An "open" or "active" enclosing state is where
     * the first valid start quote qualifier is found,
     * and there is a search in progress for the
     * relevant end matching quote
     *
     * enclosingTargetChar set to SPACE
     * is used to signal a non open enclosing state
     */
    char enclosingTargetChar = SPACE;

    if (value == null) {
      throw new IllegalArgumentException(MessageOutput.format("value string is null"));
    }

    // split parameter string into individual chars
    arr = value.toCharArray();

    for (int i = 0; i < arr.length; i++) {
      switch (arr[i]) {
        case SPACE:
          {
            // do nothing for spaces
            // unless last in array
            if (isLastChar(arr, i)) {
              endPosition = i;
              // break for substring creation
              break;
            }
            continue;
          }
        case DOUBLEQ:
        case SINGLEQ:
          {
            if (enclosingTargetChar == arr[i]) {
              // potential match to close open enclosing
              if (isNextCharWhitespace(arr, i)) {
                // if peek next is whitespace
                // then enclosing is a valid substring
                endPosition = i;
                // reset enclosing target char
                enclosingTargetChar = SPACE;
                // break for substring creation
                break;
              }
            }
            if (enclosingTargetChar == SPACE) {
              // no open enclosing state
              // handle as normal char
              if (isPreviousCharWhitespace(arr, i)) {
                startPosition = i;
                // peek forward for end candidates
                if (value.indexOf(arr[i], i + 1) >= 0) {
                  // set open enclosing state by
                  // setting up the target char
                  enclosingTargetChar = arr[i];
                } else {
                  // no more target chars left to match
                  // end enclosing, handle as normal char
                  if (isNextCharWhitespace(arr, i)) {
                    endPosition = i;
                    // break for substring creation
                    break;
                  }
                }
              }
            }
            continue;
          }
        default:
          {
            // normal non-space, non-" and non-' chars
            if (enclosingTargetChar == SPACE) {
              // no open enclosing state
              if (isPreviousCharWhitespace(arr, i)) {
                // start of space delim substring
                startPosition = i;
              }
              if (isNextCharWhitespace(arr, i)) {
                // end of space delim substring
                endPosition = i;
                // break for substring creation
                break;
              }
            }
            continue;
          }
      }

      // break's end up here
      if (startPosition > endPosition) {
        throw new IllegalArgumentException(MessageOutput.format("Illegal option values"));
      }

      // extract substring and add to List<String>
      al.add(value.substring(startPosition, ++endPosition));

      // set new start position
      i = startPosition = endPosition;
    } // for loop

    return al;
  }
Ejemplo n.º 25
0
  private void readPdtaChunk(RIFFReader riff) throws IOException {

    List<SF2Instrument> presets = new ArrayList<SF2Instrument>();
    List<Integer> presets_bagNdx = new ArrayList<Integer>();
    List<SF2InstrumentRegion> presets_splits_gen = new ArrayList<SF2InstrumentRegion>();
    List<SF2InstrumentRegion> presets_splits_mod = new ArrayList<SF2InstrumentRegion>();

    List<SF2Layer> instruments = new ArrayList<SF2Layer>();
    List<Integer> instruments_bagNdx = new ArrayList<Integer>();
    List<SF2LayerRegion> instruments_splits_gen = new ArrayList<SF2LayerRegion>();
    List<SF2LayerRegion> instruments_splits_mod = new ArrayList<SF2LayerRegion>();

    while (riff.hasNextChunk()) {
      RIFFReader chunk = riff.nextChunk();
      String format = chunk.getFormat();
      if (format.equals("phdr")) {
        // Preset Header / Instrument
        if (chunk.available() % 38 != 0) throw new RIFFInvalidDataException();
        int count = chunk.available() / 38;
        for (int i = 0; i < count; i++) {
          SF2Instrument preset = new SF2Instrument(this);
          preset.name = chunk.readString(20);
          preset.preset = chunk.readUnsignedShort();
          preset.bank = chunk.readUnsignedShort();
          presets_bagNdx.add(chunk.readUnsignedShort());
          preset.library = chunk.readUnsignedInt();
          preset.genre = chunk.readUnsignedInt();
          preset.morphology = chunk.readUnsignedInt();
          presets.add(preset);
          if (i != count - 1) this.instruments.add(preset);
        }
      } else if (format.equals("pbag")) {
        // Preset Zones / Instruments splits
        if (chunk.available() % 4 != 0) throw new RIFFInvalidDataException();
        int count = chunk.available() / 4;

        // Skip first record
        {
          int gencount = chunk.readUnsignedShort();
          int modcount = chunk.readUnsignedShort();
          while (presets_splits_gen.size() < gencount) presets_splits_gen.add(null);
          while (presets_splits_mod.size() < modcount) presets_splits_mod.add(null);
          count--;
        }

        int offset = presets_bagNdx.get(0);
        // Offset should be 0 (but just case)
        for (int i = 0; i < offset; i++) {
          if (count == 0) throw new RIFFInvalidDataException();
          int gencount = chunk.readUnsignedShort();
          int modcount = chunk.readUnsignedShort();
          while (presets_splits_gen.size() < gencount) presets_splits_gen.add(null);
          while (presets_splits_mod.size() < modcount) presets_splits_mod.add(null);
          count--;
        }

        for (int i = 0; i < presets_bagNdx.size() - 1; i++) {
          int zone_count = presets_bagNdx.get(i + 1) - presets_bagNdx.get(i);
          SF2Instrument preset = presets.get(i);
          for (int ii = 0; ii < zone_count; ii++) {
            if (count == 0) throw new RIFFInvalidDataException();
            int gencount = chunk.readUnsignedShort();
            int modcount = chunk.readUnsignedShort();
            SF2InstrumentRegion split = new SF2InstrumentRegion();
            preset.regions.add(split);
            while (presets_splits_gen.size() < gencount) presets_splits_gen.add(split);
            while (presets_splits_mod.size() < modcount) presets_splits_mod.add(split);
            count--;
          }
        }
      } else if (format.equals("pmod")) {
        // Preset Modulators / Split Modulators
        for (int i = 0; i < presets_splits_mod.size(); i++) {
          SF2Modulator modulator = new SF2Modulator();
          modulator.sourceOperator = chunk.readUnsignedShort();
          modulator.destinationOperator = chunk.readUnsignedShort();
          modulator.amount = chunk.readShort();
          modulator.amountSourceOperator = chunk.readUnsignedShort();
          modulator.transportOperator = chunk.readUnsignedShort();
          SF2InstrumentRegion split = presets_splits_mod.get(i);
          if (split != null) split.modulators.add(modulator);
        }
      } else if (format.equals("pgen")) {
        // Preset Generators / Split Generators
        for (int i = 0; i < presets_splits_gen.size(); i++) {
          int operator = chunk.readUnsignedShort();
          short amount = chunk.readShort();
          SF2InstrumentRegion split = presets_splits_gen.get(i);
          if (split != null) split.generators.put(operator, amount);
        }
      } else if (format.equals("inst")) {
        // Instrument Header / Layers
        if (chunk.available() % 22 != 0) throw new RIFFInvalidDataException();
        int count = chunk.available() / 22;
        for (int i = 0; i < count; i++) {
          SF2Layer layer = new SF2Layer(this);
          layer.name = chunk.readString(20);
          instruments_bagNdx.add(chunk.readUnsignedShort());
          instruments.add(layer);
          if (i != count - 1) this.layers.add(layer);
        }
      } else if (format.equals("ibag")) {
        // Instrument Zones / Layer splits
        if (chunk.available() % 4 != 0) throw new RIFFInvalidDataException();
        int count = chunk.available() / 4;

        // Skip first record
        {
          int gencount = chunk.readUnsignedShort();
          int modcount = chunk.readUnsignedShort();
          while (instruments_splits_gen.size() < gencount) instruments_splits_gen.add(null);
          while (instruments_splits_mod.size() < modcount) instruments_splits_mod.add(null);
          count--;
        }

        int offset = instruments_bagNdx.get(0);
        // Offset should be 0 (but just case)
        for (int i = 0; i < offset; i++) {
          if (count == 0) throw new RIFFInvalidDataException();
          int gencount = chunk.readUnsignedShort();
          int modcount = chunk.readUnsignedShort();
          while (instruments_splits_gen.size() < gencount) instruments_splits_gen.add(null);
          while (instruments_splits_mod.size() < modcount) instruments_splits_mod.add(null);
          count--;
        }

        for (int i = 0; i < instruments_bagNdx.size() - 1; i++) {
          int zone_count = instruments_bagNdx.get(i + 1) - instruments_bagNdx.get(i);
          SF2Layer layer = layers.get(i);
          for (int ii = 0; ii < zone_count; ii++) {
            if (count == 0) throw new RIFFInvalidDataException();
            int gencount = chunk.readUnsignedShort();
            int modcount = chunk.readUnsignedShort();
            SF2LayerRegion split = new SF2LayerRegion();
            layer.regions.add(split);
            while (instruments_splits_gen.size() < gencount) instruments_splits_gen.add(split);
            while (instruments_splits_mod.size() < modcount) instruments_splits_mod.add(split);
            count--;
          }
        }

      } else if (format.equals("imod")) {
        // Instrument Modulators / Split Modulators
        for (int i = 0; i < instruments_splits_mod.size(); i++) {
          SF2Modulator modulator = new SF2Modulator();
          modulator.sourceOperator = chunk.readUnsignedShort();
          modulator.destinationOperator = chunk.readUnsignedShort();
          modulator.amount = chunk.readShort();
          modulator.amountSourceOperator = chunk.readUnsignedShort();
          modulator.transportOperator = chunk.readUnsignedShort();
          SF2LayerRegion split = instruments_splits_gen.get(i);
          if (split != null) split.modulators.add(modulator);
        }
      } else if (format.equals("igen")) {
        // Instrument Generators / Split Generators
        for (int i = 0; i < instruments_splits_gen.size(); i++) {
          int operator = chunk.readUnsignedShort();
          short amount = chunk.readShort();
          SF2LayerRegion split = instruments_splits_gen.get(i);
          if (split != null) split.generators.put(operator, amount);
        }
      } else if (format.equals("shdr")) {
        // Sample Headers
        if (chunk.available() % 46 != 0) throw new RIFFInvalidDataException();
        int count = chunk.available() / 46;
        for (int i = 0; i < count; i++) {
          SF2Sample sample = new SF2Sample(this);
          sample.name = chunk.readString(20);
          long start = chunk.readUnsignedInt();
          long end = chunk.readUnsignedInt();
          sample.data = sampleData.subbuffer(start * 2, end * 2, true);
          if (sampleData24 != null) sample.data24 = sampleData24.subbuffer(start, end, true);
          /*
          sample.data = new ModelByteBuffer(sampleData, (int)(start*2),
                  (int)((end - start)*2));
          if (sampleData24 != null)
              sample.data24 = new ModelByteBuffer(sampleData24,
                      (int)start, (int)(end - start));
           */
          sample.startLoop = chunk.readUnsignedInt() - start;
          sample.endLoop = chunk.readUnsignedInt() - start;
          if (sample.startLoop < 0) sample.startLoop = -1;
          if (sample.endLoop < 0) sample.endLoop = -1;
          sample.sampleRate = chunk.readUnsignedInt();
          sample.originalPitch = chunk.readUnsignedByte();
          sample.pitchCorrection = chunk.readByte();
          sample.sampleLink = chunk.readUnsignedShort();
          sample.sampleType = chunk.readUnsignedShort();
          if (i != count - 1) this.samples.add(sample);
        }
      }
    }

    Iterator<SF2Layer> liter = this.layers.iterator();
    while (liter.hasNext()) {
      SF2Layer layer = liter.next();
      Iterator<SF2LayerRegion> siter = layer.regions.iterator();
      SF2Region globalsplit = null;
      while (siter.hasNext()) {
        SF2LayerRegion split = siter.next();
        if (split.generators.get(SF2LayerRegion.GENERATOR_SAMPLEID) != null) {
          int sampleid = split.generators.get(SF2LayerRegion.GENERATOR_SAMPLEID);
          split.generators.remove(SF2LayerRegion.GENERATOR_SAMPLEID);
          split.sample = samples.get(sampleid);
        } else {
          globalsplit = split;
        }
      }
      if (globalsplit != null) {
        layer.getRegions().remove(globalsplit);
        SF2GlobalRegion gsplit = new SF2GlobalRegion();
        gsplit.generators = globalsplit.generators;
        gsplit.modulators = globalsplit.modulators;
        layer.setGlobalZone(gsplit);
      }
    }

    Iterator<SF2Instrument> iiter = this.instruments.iterator();
    while (iiter.hasNext()) {
      SF2Instrument instrument = iiter.next();
      Iterator<SF2InstrumentRegion> siter = instrument.regions.iterator();
      SF2Region globalsplit = null;
      while (siter.hasNext()) {
        SF2InstrumentRegion split = siter.next();
        if (split.generators.get(SF2LayerRegion.GENERATOR_INSTRUMENT) != null) {
          int instrumentid = split.generators.get(SF2InstrumentRegion.GENERATOR_INSTRUMENT);
          split.generators.remove(SF2LayerRegion.GENERATOR_INSTRUMENT);
          split.layer = layers.get(instrumentid);
        } else {
          globalsplit = split;
        }
      }

      if (globalsplit != null) {
        instrument.getRegions().remove(globalsplit);
        SF2GlobalRegion gsplit = new SF2GlobalRegion();
        gsplit.generators = globalsplit.generators;
        gsplit.modulators = globalsplit.modulators;
        instrument.setGlobalZone(gsplit);
      }
    }
  }
Ejemplo n.º 26
0
  /*
   * Parse a keystore domain configuration file and associated collection
   * of keystore passwords to create a collection of KeyStore.Builder.
   */
  private List<KeyStoreBuilderComponents> getBuilders(
      URI configuration, Map<String, KeyStore.ProtectionParameter> passwords) throws IOException {

    PolicyParser parser = new PolicyParser(true); // expand properties
    Collection<PolicyParser.DomainEntry> domains = null;
    List<KeyStoreBuilderComponents> builders = new ArrayList<>();
    String uriDomain = configuration.getFragment();

    try (InputStreamReader configurationReader =
        new InputStreamReader(PolicyUtil.getInputStream(configuration.toURL()), "UTF-8")) {
      parser.read(configurationReader);
      domains = parser.getDomainEntries();

    } catch (MalformedURLException mue) {
      throw new IOException(mue);

    } catch (PolicyParser.ParsingException pe) {
      throw new IOException(pe);
    }

    for (PolicyParser.DomainEntry domain : domains) {
      Map<String, String> domainProperties = domain.getProperties();

      if (uriDomain != null && (!uriDomain.equalsIgnoreCase(domain.getName()))) {
        continue; // skip this domain
      }

      if (domainProperties.containsKey(ENTRY_NAME_SEPARATOR)) {
        this.entryNameSeparator = domainProperties.get(ENTRY_NAME_SEPARATOR);
        // escape any regex meta characters
        char ch = 0;
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < this.entryNameSeparator.length(); i++) {
          ch = this.entryNameSeparator.charAt(i);
          if (REGEX_META.indexOf(ch) != -1) {
            s.append('\\');
          }
          s.append(ch);
        }
        this.entryNameSeparatorRegEx = s.toString();
      }

      Collection<PolicyParser.KeyStoreEntry> keystores = domain.getEntries();
      for (PolicyParser.KeyStoreEntry keystore : keystores) {
        String keystoreName = keystore.getName();
        Map<String, String> properties = new HashMap<>(domainProperties);
        properties.putAll(keystore.getProperties());

        String keystoreType = DEFAULT_KEYSTORE_TYPE;
        if (properties.containsKey(KEYSTORE_TYPE)) {
          keystoreType = properties.get(KEYSTORE_TYPE);
        }

        Provider keystoreProvider = null;
        if (properties.containsKey(KEYSTORE_PROVIDER_NAME)) {
          String keystoreProviderName = properties.get(KEYSTORE_PROVIDER_NAME);
          keystoreProvider = Security.getProvider(keystoreProviderName);
          if (keystoreProvider == null) {
            throw new IOException("Error locating JCE provider: " + keystoreProviderName);
          }
        }

        File keystoreFile = null;
        if (properties.containsKey(KEYSTORE_URI)) {
          String uri = properties.get(KEYSTORE_URI);

          try {
            if (uri.startsWith("file://")) {
              keystoreFile = new File(new URI(uri));
            } else {
              keystoreFile = new File(uri);
            }

          } catch (URISyntaxException | IllegalArgumentException e) {
            throw new IOException(
                "Error processing keystore property: " + "keystoreURI=\"" + uri + "\"", e);
          }
        }

        KeyStore.ProtectionParameter keystoreProtection = null;
        if (passwords.containsKey(keystoreName)) {
          keystoreProtection = passwords.get(keystoreName);

        } else if (properties.containsKey(KEYSTORE_PASSWORD_ENV)) {
          String env = properties.get(KEYSTORE_PASSWORD_ENV);
          String pwd = System.getenv(env);
          if (pwd != null) {
            keystoreProtection = new KeyStore.PasswordProtection(pwd.toCharArray());
          } else {
            throw new IOException(
                "Error processing keystore property: " + "keystorePasswordEnv=\"" + env + "\"");
          }
        } else {
          keystoreProtection = new KeyStore.PasswordProtection(null);
        }

        builders.add(
            new KeyStoreBuilderComponents(
                keystoreName, keystoreType, keystoreProvider, keystoreFile, keystoreProtection));
      }
      break; // skip other domains
    }
    if (builders.isEmpty()) {
      throw new IOException("Error locating domain configuration data " + "for: " + configuration);
    }

    return builders;
  }
Ejemplo n.º 27
0
 /** ClassTypeSignatureSuffix: "." SimpleClassTypeSignature */
 private void parseClassTypeSignatureSuffix(List<SimpleClassTypeSignature> scts) {
   while (current() == '.') {
     advance();
     scts.add(parseSimpleClassTypeSignature(true));
   }
 }