Package org.jmule.core.edonkey.packet.tag

Examples of org.jmule.core.edonkey.packet.tag.Tag


      //Load Tags
      this.tagList = new TagList();
     
      for(int i = 0 ; i < tagCount; i++) {
       
        Tag tag = TagScanner.scanTag(fileChannel);
        if (tag != null)
          tagList.addTag(tag);
        else {
          System.out.println("Null tag!");
          throw new PartMetException("Corrupted tag list in file : " + file.getName() );
        }
      }   
      gapList = new GapList();
      byte tag_id = E2DKConstants.GAP_OFFSET;
      Tag start_tag, end_tag;
      while (true) {
        start_tag = tagList.getTag(new byte[]{FT_GAPSTART[0],tag_id});
        if (start_tag == null) break;
        end_tag = tagList.getTag(new byte[]{FT_GAPEND[0],tag_id});
        if (end_tag == null)
          throw new PartMetException("Can't find end of gap in file partial file ");
        tagList.removeTag(start_tag.getTagName());
        tagList.removeTag(end_tag.getTagName());
        try {
          long begin = Convert.intToLong((Integer)start_tag.getValue());
          long end = Convert.intToLong((Integer)end_tag.getValue());
          gapList.addGap(begin,end );
        } catch (Throwable e) {
          throw new PartMetException("Failed to extract gap positions form file : " + file.getName());
        }
View Full Code Here


      byte metaTagEnd[] = FT_GAPEND.clone();
      JMIterable<Gap> gap_list = gapList.getGaps();
      for(Gap gap : gap_list){
               
        metaTagBegin[1] = counter;
        Tag tagBegin = new IntTag(metaTagBegin,Convert.longToInt(gap.getStart()));
               
        metaTagEnd[1]=counter;
        Tag tagEnd = new IntTag(metaTagEnd,Convert.longToInt(gap.getEnd()));

       
        data = Misc.getByteBuffer(tagBegin.getSize()+tagEnd.getSize());
        data.put(tagBegin.getAsByteBuffer());
        data.put(tagEnd.getAsByteBuffer());
       
        data.position(0);
        fileChannel.write(data);
       
        counter++;
View Full Code Here

    return tmpFileName;
  }
 
  public void setTempFileName(String tempFileName) {
    this.tagList.removeTag(FT_TEMPFILE);
    Tag tag = new StringTag(FT_TEMPFILE, tempFileName);
    tagList.addTag(tag);
  }
View Full Code Here

    return realFileName;
  }
 
  public void setRealFileName(String realFileName) {
    this.tagList.removeTag(FT_FILENAME);
    Tag tag = new StringTag(FT_FILENAME, realFileName);
    tagList.addTag(tag);
  }
View Full Code Here

    return fileSize;
  }
 
  public void setFileSize(long fileSize){
    this.tagList.removeTag(FT_FILESIZE);
    Tag tag = new IntTag(FT_FILESIZE, Convert.longToInt(fileSize));
    this.tagList.addTag(tag);
  }
View Full Code Here

       
        int tagCount = data.getInt(0);
               
        //Load tags....
        for(int j = 0; j<tagCount; j++) {
          Tag tag = TagScanner.scanTag(fileChannel);
          if (tag != null)
            tagList.addTag(tag);
        }
       
        ip_list.add(remonteAddress);
View Full Code Here

  }
 
  private void init() {
    String fileName = this.getSharingName();
    if (fileName==null) fileName = file.getName();
    Tag tag = new StringTag(FT_FILENAME, fileName);
    tagList.addTag(tag);

    tag = new IntTag(FT_FILESIZE, Convert.longToInt(file.length()));
    tagList.addTag(tag);
  }
View Full Code Here

    return result;
  }
 
  public static Map<PeerFeatures, Integer> scanTagListPeerFeatures(TagList tagList) {
    Map<PeerFeatures,Integer> result = new Hashtable<PeerFeatures,Integer>();
    Tag tag;
   
    tag = tagList.getTag(ET_COMPRESSION);
    if (tag != null)
      result.put(DataCompressionVer, (Integer)tag.getValue());
   
    tag = tagList.getTag(ET_UDPVER);
    if (tag != null)
      result.put(UDPVer, (Integer)tag.getValue());
   
    tag = tagList.getTag(ET_SOURCEEXCHANGE);
    if (tag != null)
      result.put(SourceExchange1Ver, (Integer)tag.getValue());
   
    tag = tagList.getTag(ET_COMMENTS);
    if (tag != null)
      result.put(AcceptCommentVer, (Integer)tag.getValue());
   
    tag = tagList.getTag(ET_EXTENDEDREQUEST);
    if (tag != null)
      result.put(ExtendedRequestsVer, (Integer)tag.getValue());
   
    tag = tagList.getTag(ET_FEATURES);
    if (tag != null)
      result.put(SupportPreview, (Integer)tag.getValue());
   
    return result;
  }
View Full Code Here

TOP

Related Classes of org.jmule.core.edonkey.packet.tag.Tag

Copyright © 2018 www.massapicom. 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.