replaced StringBuffer with StringBuilder in tar lib

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6213 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 49bbb9bd45
commit aee35bff6f

@ -20,6 +20,10 @@
* This package is based on the work done by Timothy Gerard Endres * This package is based on the work done by Timothy Gerard Endres
* (time@ice.com) to whom the Ant project is very grateful for his great code. * (time@ice.com) to whom the Ant project is very grateful for his great code.
*/ */
/*
* Modifications (Michael Christen)
* - replaced StringBuffer with StringBuilder
*/
package org.apache.tools.tar; package org.apache.tools.tar;
@ -78,7 +82,7 @@ import java.util.Locale;
public class TarEntry implements TarConstants { public class TarEntry implements TarConstants {
/** The entry's name. */ /** The entry's name. */
private StringBuffer name; private StringBuilder name;
/** The entry's permission mode. */ /** The entry's permission mode. */
private int mode; private int mode;
@ -99,16 +103,16 @@ public class TarEntry implements TarConstants {
private byte linkFlag; private byte linkFlag;
/** The entry's link name. */ /** The entry's link name. */
private StringBuffer linkName; private StringBuilder linkName;
/** The entry's magic tag. */ /** The entry's magic tag. */
private StringBuffer magic; private StringBuilder magic;
/** The entry's user name. */ /** The entry's user name. */
private StringBuffer userName; private StringBuilder userName;
/** The entry's group name. */ /** The entry's group name. */
private StringBuffer groupName; private StringBuilder groupName;
/** The entry's major device number. */ /** The entry's major device number. */
private int devMajor; private int devMajor;
@ -135,9 +139,9 @@ public class TarEntry implements TarConstants {
* Construct an empty entry and prepares the header values. * Construct an empty entry and prepares the header values.
*/ */
private TarEntry () { private TarEntry () {
this.magic = new StringBuffer(TMAGIC); this.magic = new StringBuilder(TMAGIC);
this.name = new StringBuffer(); this.name = new StringBuilder();
this.linkName = new StringBuffer(); this.linkName = new StringBuilder();
String user = System.getProperty("user.name", ""); String user = System.getProperty("user.name", "");
@ -147,8 +151,8 @@ public class TarEntry implements TarConstants {
this.userId = 0; this.userId = 0;
this.groupId = 0; this.groupId = 0;
this.userName = new StringBuffer(user); this.userName = new StringBuilder(user);
this.groupName = new StringBuffer(""); this.groupName = new StringBuilder("");
this.file = null; this.file = null;
} }
@ -165,16 +169,16 @@ public class TarEntry implements TarConstants {
this.devMajor = 0; this.devMajor = 0;
this.devMinor = 0; this.devMinor = 0;
this.name = new StringBuffer(name); this.name = new StringBuilder(name);
this.mode = isDir ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE; this.mode = isDir ? DEFAULT_DIR_MODE : DEFAULT_FILE_MODE;
this.linkFlag = isDir ? LF_DIR : LF_NORMAL; this.linkFlag = isDir ? LF_DIR : LF_NORMAL;
this.userId = 0; this.userId = 0;
this.groupId = 0; this.groupId = 0;
this.size = 0; this.size = 0;
this.modTime = (new Date()).getTime() / MILLIS_PER_SECOND; this.modTime = (new Date()).getTime() / MILLIS_PER_SECOND;
this.linkName = new StringBuffer(""); this.linkName = new StringBuilder("");
this.userName = new StringBuffer(""); this.userName = new StringBuilder("");
this.groupName = new StringBuffer(""); this.groupName = new StringBuilder("");
this.devMajor = 0; this.devMajor = 0;
this.devMinor = 0; this.devMinor = 0;
@ -238,8 +242,8 @@ public class TarEntry implements TarConstants {
fileName = fileName.substring(1); fileName = fileName.substring(1);
} }
this.linkName = new StringBuffer(""); this.linkName = new StringBuilder("");
this.name = new StringBuffer(fileName); this.name = new StringBuilder(fileName);
if (file.isDirectory()) { if (file.isDirectory()) {
this.mode = DEFAULT_DIR_MODE; this.mode = DEFAULT_DIR_MODE;
@ -331,7 +335,7 @@ public class TarEntry implements TarConstants {
* @param name This entry's new name. * @param name This entry's new name.
*/ */
public void setName(String name) { public void setName(String name) {
this.name = new StringBuffer(name); this.name = new StringBuilder(name);
} }
/** /**
@ -403,7 +407,7 @@ public class TarEntry implements TarConstants {
* @param userName This entry's new user name. * @param userName This entry's new user name.
*/ */
public void setUserName(String userName) { public void setUserName(String userName) {
this.userName = new StringBuffer(userName); this.userName = new StringBuilder(userName);
} }
/** /**
@ -421,7 +425,7 @@ public class TarEntry implements TarConstants {
* @param groupName This entry's new group name. * @param groupName This entry's new group name.
*/ */
public void setGroupName(String groupName) { public void setGroupName(String groupName) {
this.groupName = new StringBuffer(groupName); this.groupName = new StringBuilder(groupName);
} }
/** /**

@ -20,6 +20,10 @@
* This package is based on the work done by Timothy Gerard Endres * This package is based on the work done by Timothy Gerard Endres
* (time@ice.com) to whom the Ant project is very grateful for his great code. * (time@ice.com) to whom the Ant project is very grateful for his great code.
*/ */
/*
* Modifications (Michael Christen)
* - replaced StringBuffer with StringBuilder
*/
package org.apache.tools.tar; package org.apache.tools.tar;
@ -258,7 +262,7 @@ public class TarInputStream extends FilterInputStream {
if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) { if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) {
// read in the name // read in the name
StringBuffer longName = new StringBuffer(); StringBuilder longName = new StringBuilder();
byte[] buf = new byte[SMALL_BUFFER_SIZE]; byte[] buf = new byte[SMALL_BUFFER_SIZE];
int length = 0; int length = 0;
while ((length = read(buf)) >= 0) { while ((length = read(buf)) >= 0) {

@ -20,6 +20,10 @@
* This package is based on the work done by Timothy Gerard Endres * This package is based on the work done by Timothy Gerard Endres
* (time@ice.com) to whom the Ant project is very grateful for his great code. * (time@ice.com) to whom the Ant project is very grateful for his great code.
*/ */
/*
* Modifications (Michael Christen)
* - replaced StringBuffer with StringBuilder
*/
package org.apache.tools.tar; package org.apache.tools.tar;
@ -78,8 +82,8 @@ public class TarUtils {
* @param length The number of header bytes to parse. * @param length The number of header bytes to parse.
* @return The header's entry name. * @return The header's entry name.
*/ */
public static StringBuffer parseName(byte[] header, int offset, int length) { public static StringBuilder parseName(byte[] header, int offset, int length) {
StringBuffer result = new StringBuffer(length); StringBuilder result = new StringBuilder(length);
int end = offset + length; int end = offset + length;
for (int i = offset; i < end; ++i) { for (int i = offset; i < end; ++i) {
@ -102,7 +106,7 @@ public class TarUtils {
* @param length The number of header bytes to parse. * @param length The number of header bytes to parse.
* @return The number of bytes in a header's entry name. * @return The number of bytes in a header's entry name.
*/ */
public static int getNameBytes(StringBuffer name, byte[] buf, int offset, int length) { public static int getNameBytes(StringBuilder name, byte[] buf, int offset, int length) {
int i; int i;
for (i = 0; i < length && i < name.length(); ++i) { for (i = 0; i < length && i < name.length(); ++i) {

Loading…
Cancel
Save