Examples of AsciiBytes


Examples of org.springframework.boot.loader.util.AsciiBytes

    JarFile jarFile = this.jarFile.getNestedJarFile(data);
    return new JarFileArchive(jarFile);
  }

  private Archive getUnpackedNestedArchive(JarEntryData data) throws IOException {
    AsciiBytes hash = data.getComment().substring(UNPACK_MARKER.length());
    String name = data.getName().toString();
    if (name.lastIndexOf("/") != -1) {
      name = name.substring(name.lastIndexOf("/") + 1);
    }
    File file = new File(getTempUnpackFolder(), hash.toString() + "-" + name);
    if (!file.exists() || file.length() != data.getSize()) {
      unpack(data, file);
    }
    return new JarFileArchive(file, file.toURI().toURL());
  }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

  private void buildEntries(File file, boolean recursive) {
    if (!file.equals(this.root)) {
      String name = file.toURI().getPath()
          .substring(this.root.toURI().getPath().length());
      FileEntry entry = new FileEntry(new AsciiBytes(name), file);
      this.entries.put(entry.getName(), entry);
    }
    if (file.isDirectory()) {
      File[] files = file.listFiles();
      if (files == null) {
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

  @Override
  public Archive getFilteredArchive(EntryRenameFilter filter) throws IOException {
    Map<AsciiBytes, Entry> filteredEntries = new LinkedHashMap<AsciiBytes, Archive.Entry>();
    for (Map.Entry<AsciiBytes, Entry> entry : this.entries.entrySet()) {
      AsciiBytes filteredName = filter.apply(entry.getKey(), entry.getValue());
      if (filteredName != null) {
        filteredEntries.put(filteredName, new FileEntry(filteredName,
            ((FileEntry) entry.getValue()).getFile()));
      }
    }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

    @Override
    protected URLConnection openConnection(URL url) throws IOException {
      String name = url.getPath().substring(
          ExplodedArchive.this.root.toURI().getPath().length());
      if (ExplodedArchive.this.entries.containsKey(new AsciiBytes(name))) {
        return new URL(url.toString()).openConnection();
      }
      return new FileNotFoundURLConnection(url, name);
    }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

    this.source = source;
    this.header = header;
    long nameLength = Bytes.littleEndianValue(header, 28, 2);
    long extraLength = Bytes.littleEndianValue(header, 30, 2);
    long commentLength = Bytes.littleEndianValue(header, 32, 2);
    this.name = new AsciiBytes(Bytes.get(inputStream, nameLength));
    this.extra = Bytes.get(inputStream, extraLength);
    this.comment = new AsciiBytes(Bytes.get(inputStream, commentLength));
    this.localHeaderOffset = Bytes.littleEndianValue(header, 42, 4);
  }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

    }

    private AsciiBytes decode(String source) {
      int length = (source == null ? 0 : source.length());
      if ((length == 0) || (source.indexOf('%') < 0)) {
        return new AsciiBytes(source);
      }
      ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
      for (int i = 0; i < length; i++) {
        int ch = source.charAt(i);
        if (ch == '%') {
          if ((i + 2) >= length) {
            throw new IllegalArgumentException("Invalid encoded sequence \""
                + source.substring(i) + "\"");
          }
          ch = decodeEscapeSequence(source, i);
          i += 2;
        }
        bos.write(ch);
      }
      // AsciiBytes is what is used to store the JarEntries so make it symmetric
      return new AsciiBytes(bos.toByteArray());
    }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

  @Rule
  public ExpectedException thrown = ExpectedException.none();

  @Test
  public void createFromBytes() throws Exception {
    AsciiBytes bytes = new AsciiBytes(new byte[] { 65, 66 });
    assertThat(bytes.toString(), equalTo("AB"));
  }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

    assertThat(bytes.toString(), equalTo("AB"));
  }

  @Test
  public void createFromBytesWithOffset() throws Exception {
    AsciiBytes bytes = new AsciiBytes(new byte[] { 65, 66, 67, 68 }, 1, 2);
    assertThat(bytes.toString(), equalTo("BC"));
  }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

    assertThat(bytes.toString(), equalTo("BC"));
  }

  @Test
  public void createFromString() throws Exception {
    AsciiBytes bytes = new AsciiBytes("AB");
    assertThat(bytes.toString(), equalTo("AB"));
  }
View Full Code Here

Examples of org.springframework.boot.loader.util.AsciiBytes

    assertThat(bytes.toString(), equalTo("AB"));
  }

  @Test
  public void length() throws Exception {
    AsciiBytes b1 = new AsciiBytes(new byte[] { 65, 66 });
    AsciiBytes b2 = new AsciiBytes(new byte[] { 65, 66, 67, 68 }, 1, 2);
    assertThat(b1.length(), equalTo(2));
    assertThat(b2.length(), equalTo(2));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.