|
|
@@ -13,66 +13,26 @@ package org.eclipse.jgit.internal.storage.pack; |
|
|
|
/** |
|
|
|
* A pack file extension. |
|
|
|
*/ |
|
|
|
public class PackExt { |
|
|
|
private static volatile PackExt[] VALUES = new PackExt[] {}; |
|
|
|
|
|
|
|
public enum PackExt { |
|
|
|
/** A pack file extension. */ |
|
|
|
public static final PackExt PACK = newPackExt("pack"); //$NON-NLS-1$ |
|
|
|
PACK("pack"), //$NON-NLS-1$ |
|
|
|
|
|
|
|
/** A pack index file extension. */ |
|
|
|
public static final PackExt INDEX = newPackExt("idx"); //$NON-NLS-1$ |
|
|
|
INDEX("idx"), //$NON-NLS-1$ |
|
|
|
|
|
|
|
/** A keep pack file extension. */ |
|
|
|
public static final PackExt KEEP = newPackExt("keep"); //$NON-NLS-1$ |
|
|
|
KEEP("keep"), //$NON-NLS-1$ |
|
|
|
|
|
|
|
/** A pack bitmap index file extension. */ |
|
|
|
public static final PackExt BITMAP_INDEX = newPackExt("bitmap"); //$NON-NLS-1$ |
|
|
|
BITMAP_INDEX("bitmap"), //$NON-NLS-1$ |
|
|
|
|
|
|
|
/** A reftable file. */ |
|
|
|
public static final PackExt REFTABLE = newPackExt("ref"); //$NON-NLS-1$ |
|
|
|
|
|
|
|
/** |
|
|
|
* Get all of the PackExt values. |
|
|
|
* |
|
|
|
* @return all of the PackExt values. |
|
|
|
*/ |
|
|
|
public static PackExt[] values() { |
|
|
|
return VALUES; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Returns a PackExt for the file extension and registers it in the values |
|
|
|
* array. |
|
|
|
* |
|
|
|
* @param ext |
|
|
|
* the file extension. |
|
|
|
* @return the PackExt for the ext |
|
|
|
*/ |
|
|
|
public static synchronized PackExt newPackExt(String ext) { |
|
|
|
PackExt[] dst = new PackExt[VALUES.length + 1]; |
|
|
|
for (int i = 0; i < VALUES.length; i++) { |
|
|
|
PackExt packExt = VALUES[i]; |
|
|
|
if (packExt.getExtension().equals(ext)) |
|
|
|
return packExt; |
|
|
|
dst[i] = packExt; |
|
|
|
} |
|
|
|
if (VALUES.length >= 32) |
|
|
|
throw new IllegalStateException( |
|
|
|
"maximum number of pack extensions exceeded"); //$NON-NLS-1$ |
|
|
|
|
|
|
|
PackExt value = new PackExt(ext, VALUES.length); |
|
|
|
dst[VALUES.length] = value; |
|
|
|
VALUES = dst; |
|
|
|
return value; |
|
|
|
} |
|
|
|
REFTABLE("ref"); //$NON-NLS-1$ |
|
|
|
|
|
|
|
private final String ext; |
|
|
|
|
|
|
|
private final int pos; |
|
|
|
|
|
|
|
private PackExt(String ext, int pos) { |
|
|
|
private PackExt(String ext) { |
|
|
|
this.ext = ext; |
|
|
|
this.pos = pos; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -85,12 +45,12 @@ public class PackExt { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the position of the extension in the values array. |
|
|
|
* Get the position of the extension in the enum declaration. |
|
|
|
* |
|
|
|
* @return the position of the extension in the values array. |
|
|
|
* @return the position of the extension in the enum declaration. |
|
|
|
*/ |
|
|
|
public int getPosition() { |
|
|
|
return pos; |
|
|
|
return ordinal(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |