Package com.torrent4j.model.metadata

Source Code of com.torrent4j.model.metadata.MetadataFile

package com.torrent4j.model.metadata;

import java.io.IOException;

import com.torrent4j.util.bencoding.BList;
import com.torrent4j.util.bencoding.BMap;

public class MetadataFile {
  private String fileName;
  private long length;
  private String hash;

  public MetadataFile(BMap file) throws IOException {
    if (file.get("path") != null) {
      final BList path = file.getList("path");
      final StringBuilder builder = new StringBuilder();
      for (final Object pathPart : path) {
        builder.append(new String((byte[]) pathPart)).append("/");
      }
      this.fileName = builder.substring(0, builder.length() - 1);
    } else {
      this.fileName = file.getString("name");
    }
    this.length = file.getLong("length");
    this.hash = file.getString("md5sum");
  }

  public String getFileName() {
    return fileName;
  }

  public void setFileName(String fileName) {
    this.fileName = fileName;
  }

  public long getLength() {
    return length;
  }

  public void setLength(long length) {
    this.length = length;
  }

  public String getHash() {
    return hash;
  }

  public void setHash(String hash) {
    this.hash = hash;
  }
}
TOP

Related Classes of com.torrent4j.model.metadata.MetadataFile

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.