1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

[180562] [api] Classes should not implement interfaces just to bring constants into namespace. Do not implement ITarConstants.

This commit is contained in:
Kushal Munir 2007-04-03 08:35:08 +00:00
parent 57d908cf59
commit 8ec970dced
3 changed files with 37 additions and 37 deletions

View file

@ -24,7 +24,7 @@ import java.io.OutputStream;
/**
* This class represents a tar file entry.
*/
public class TarEntry implements ITarConstants, Cloneable {
public class TarEntry implements Cloneable {
// NOTE: Read the GNU tar specification to understand what each of the fields mean.
// http://www.gnu.org/software/tar/manual/html_mono/tar.html#SEC118
@ -39,22 +39,22 @@ public class TarEntry implements ITarConstants, Cloneable {
// on different machines, but not between locales.
// block header fields
public byte[] name = new byte[NAME_LENGTH];
public byte[] mode = new byte[MODE_LENGTH];
public byte[] uid = new byte[UID_LENGTH];
public byte[] gid = new byte[GID_LENGTH];
public byte[] size = new byte[SIZE_LENGTH];
public byte[] mtime = new byte[MTIME_LENGTH];
public byte[] chksum = new byte[CHKSUM_LENGTH];
public byte[] name = new byte[ITarConstants.NAME_LENGTH];
public byte[] mode = new byte[ITarConstants.MODE_LENGTH];
public byte[] uid = new byte[ITarConstants.UID_LENGTH];
public byte[] gid = new byte[ITarConstants.GID_LENGTH];
public byte[] size = new byte[ITarConstants.SIZE_LENGTH];
public byte[] mtime = new byte[ITarConstants.MTIME_LENGTH];
public byte[] chksum = new byte[ITarConstants.CHKSUM_LENGTH];
public byte typeflag;
public byte[] linkname = new byte[LINKNAME_LENGTH];
public byte[] magic = new byte[MAGIC_LENGTH];
public byte[] version = new byte[VERSION_LENGTH];
public byte[] uname = new byte[UNAME_LENGTH];
public byte[] gname = new byte[GNAME_LENGTH];
public byte[] devmajor = new byte[DEVMAJOR_LENGTH];
public byte[] devminor = new byte[DEVMINOR_LENGTH];
public byte[] prefix = new byte[PREFIX_LENGTH];
public byte[] linkname = new byte[ITarConstants.LINKNAME_LENGTH];
public byte[] magic = new byte[ITarConstants.MAGIC_LENGTH];
public byte[] version = new byte[ITarConstants.VERSION_LENGTH];
public byte[] uname = new byte[ITarConstants.UNAME_LENGTH];
public byte[] gname = new byte[ITarConstants.GNAME_LENGTH];
public byte[] devmajor = new byte[ITarConstants.DEVMAJOR_LENGTH];
public byte[] devminor = new byte[ITarConstants.DEVMINOR_LENGTH];
public byte[] prefix = new byte[ITarConstants.PREFIX_LENGTH];
/**
* Creates a new tar entry with the specified name. Use the setter methods to
@ -78,7 +78,7 @@ public class TarEntry implements ITarConstants, Cloneable {
TarEntry(byte[] blockData) throws IOException {
checkNull(blockData);
if (blockData.length != BLOCK_SIZE) {
if (blockData.length != ITarConstants.BLOCK_SIZE) {
throw new IllegalArgumentException();
}
@ -141,7 +141,7 @@ public class TarEntry implements ITarConstants, Cloneable {
public void setName(String fileName) {
checkNull(fileName);
int length = NAME_LENGTH - fileName.length();
int length = ITarConstants.NAME_LENGTH - fileName.length();
// append null characters to the name
for (int i = 0; i < length; i++) {
@ -223,7 +223,7 @@ public class TarEntry implements ITarConstants, Cloneable {
// get the length of the string
int length = sizeString.length();
int diff = SIZE_LENGTH - length - 1;
int diff = ITarConstants.SIZE_LENGTH - length - 1;
// prepend the string with 0s
for (int i = 0; i < diff; i++) {
@ -256,7 +256,7 @@ public class TarEntry implements ITarConstants, Cloneable {
// get the length of the string
int length = mtimeString.length();
int diff = MTIME_LENGTH - length - 1;
int diff = ITarConstants.MTIME_LENGTH - length - 1;
// prepend the string with 0s
for (int i = 0; i < diff; i++) {
@ -326,7 +326,7 @@ public class TarEntry implements ITarConstants, Cloneable {
public void setUserName(String userName) {
checkNull(userName);
int length = UNAME_LENGTH - userName.length();
int length = ITarConstants.UNAME_LENGTH - userName.length();
// append null characters to the user name
for (int i = 0; i < length; i++) {
@ -394,7 +394,7 @@ public class TarEntry implements ITarConstants, Cloneable {
/**
* Write the fields to the given output stream.
* @param out the output stream to write to.
* @param outStream the output stream to write to.
*/
public void writeFields(OutputStream outStream) throws IOException {
outStream.write(name);
@ -508,7 +508,7 @@ public class TarEntry implements ITarConstants, Cloneable {
// get the length of the string
int length = sumString.length();
int diff = CHKSUM_LENGTH - length - 2;
int diff = ITarConstants.CHKSUM_LENGTH - length - 2;
// prepend the string with 0s
for (int i = 0; i < diff; i++) {

View file

@ -27,7 +27,7 @@ import java.util.Vector;
/**
* This class is used to read entries from a tar file.
*/
public class TarFile implements ITarConstants {
public class TarFile {
private File file;
private Vector blockHeaders;
@ -170,8 +170,8 @@ public class TarFile implements ITarConstants {
// add header only if the size is valid
blockHeaders.add(header);
int numFileBlocks = (int)(fileSize / BLOCK_SIZE);
numFileBlocks += (fileSize % BLOCK_SIZE) > 0 ? 1 : 0;
int numFileBlocks = (int)(fileSize / ITarConstants.BLOCK_SIZE);
numFileBlocks += (fileSize % ITarConstants.BLOCK_SIZE) > 0 ? 1 : 0;
// if the file is a symbolic link, number of blocks will be 0
if (header.getTypeFlag() == ITarConstants.TF_SYMLINK) {
@ -179,7 +179,7 @@ public class TarFile implements ITarConstants {
}
// skip the blocks that contain file content
stream.skip(numFileBlocks * BLOCK_SIZE);
stream.skip(numFileBlocks * ITarConstants.BLOCK_SIZE);
}
// now read the next block
@ -206,12 +206,12 @@ public class TarFile implements ITarConstants {
* @throws IOException if an I/O error occurs.
*/
private byte[] readBlock(InputStream stream) throws IOException {
byte[] blockData = new byte[BLOCK_SIZE];
byte[] blockData = new byte[ITarConstants.BLOCK_SIZE];
// read a block of data
int byteRead = 0;
for (int i = 0; i < BLOCK_SIZE; i++) {
for (int i = 0; i < ITarConstants.BLOCK_SIZE; i++) {
byteRead = stream.read();
if (byteRead != -1) {
@ -330,8 +330,8 @@ public class TarFile implements ITarConstants {
if (!header.getName().equals(entry.getName())) {
// determine how many blocks make up the contents of the file
int numFileBlocks = (int)(fileSize / BLOCK_SIZE);
numFileBlocks += (fileSize % BLOCK_SIZE) > 0 ? 1 : 0;
int numFileBlocks = (int)(fileSize / ITarConstants.BLOCK_SIZE);
numFileBlocks += (fileSize % ITarConstants.BLOCK_SIZE) > 0 ? 1 : 0;
// if the file is a symbolic link, number of blocks will be 0
if (header.getTypeFlag() == ITarConstants.TF_SYMLINK) {
@ -339,7 +339,7 @@ public class TarFile implements ITarConstants {
}
// skip the blocks that contain file content
stream.skip(numFileBlocks * BLOCK_SIZE);
stream.skip(numFileBlocks * ITarConstants.BLOCK_SIZE);
}
// the header name matches the entry name, so return the input stream with
// the data for that entry

View file

@ -23,7 +23,7 @@ import java.io.OutputStream;
* This class implements an output stream filter for writing files in the
* tar file format.
*/
public class TarOutputStream extends OutputStream implements ITarConstants {
public class TarOutputStream extends OutputStream {
private OutputStream out;
private boolean isClosed;
@ -49,7 +49,7 @@ public class TarOutputStream extends OutputStream implements ITarConstants {
// before closing though, write out a block of empty data
if (!isClosed) {
byte[] dummy = new byte[BLOCK_SIZE];
byte[] dummy = new byte[ITarConstants.BLOCK_SIZE];
out.write(dummy);
out.close();
@ -94,7 +94,7 @@ public class TarOutputStream extends OutputStream implements ITarConstants {
entry.writeFields(out);
// get the part of a block we need to fill
int diff = BLOCK_SIZE - HEADER_LENGTH;
int diff = ITarConstants.BLOCK_SIZE - ITarConstants.HEADER_LENGTH;
// fill the block if we have used a part of it
if (diff != 0) {
@ -116,11 +116,11 @@ public class TarOutputStream extends OutputStream implements ITarConstants {
public void closeEntry() throws IOException {
// get the part of a block
int temp = (int)(dataCount % BLOCK_SIZE);
int temp = (int)(dataCount % ITarConstants.BLOCK_SIZE);
// fill the rest of the block with dummy data if we have filled part of a block
if (temp != 0) {
int diff = BLOCK_SIZE - temp;
int diff = ITarConstants.BLOCK_SIZE - temp;
byte[] dummy = new byte[diff];
out.write(dummy);
}