001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.commons.compress.archivers.tar; 020 021import java.util.Objects; 022 023/** 024 * This class represents struct sparse in a Tar archive. 025 * <p> 026 * Whereas, "struct sparse" is: 027 * <pre> 028 * struct sparse { 029 * char offset[12]; // offset 0 030 * char numbytes[12]; // offset 12 031 * }; 032 * </pre> 033 * @since 1.20 034 */ 035public final class TarArchiveStructSparse { 036 private final long offset; 037 private final long numbytes; 038 039 public TarArchiveStructSparse(long offset, long numbytes) { 040 this.offset = offset; 041 this.numbytes = numbytes; 042 } 043 044 @Override 045 public boolean equals(Object o) { 046 if (this == o) { 047 return true; 048 } 049 if (o == null || getClass() != o.getClass()) { 050 return false; 051 } 052 TarArchiveStructSparse that = (TarArchiveStructSparse) o; 053 return offset == that.offset && 054 numbytes == that.numbytes; 055 } 056 057 @Override 058 public int hashCode() { 059 return Objects.hash(offset, numbytes); 060 } 061 062 @Override 063 public String toString() { 064 return "TarArchiveStructSparse{" + 065 "offset=" + offset + 066 ", numbytes=" + numbytes + 067 '}'; 068 } 069 070 public long getOffset() { 071 return offset; 072 } 073 074 public long getNumbytes() { 075 return numbytes; 076 } 077}