List of usage examples for org.eclipse.jgit.internal.storage.pack PackExt getExtension
public String getExtension()
From source file:com.benhumphreys.jgitcassandra.store.DescMapper.java
License:Apache License
/** * Extracts a file size map from the pack description. * * @param desc/*from w w w .j a v a 2s . c om*/ * @return a map mapping extension strings to file sizes */ public static Map<String, Long> getFileSizeMap(DfsPackDescription desc) { Map<String, Long> sizeMap = new HashMap<String, Long>(); for (PackExt ext : PackExt.values()) { long sz = desc.getFileSize(ext); if (sz > 0) { sizeMap.put(ext.getExtension(), sz); } } return sizeMap; }
From source file:com.benhumphreys.jgitcassandra.store.DescMapper.java
License:Apache License
/** * The PackExt class defines a number of static instances *//* w ww . jav a 2 s . co m*/ private static PackExt lookupExt(String extStr) { for (PackExt ext : PackExt.values()) { if (ext.getExtension().equals(extStr)) { return ext; } } // If we get here, the extension does not exist so create it. It gets // added to the list of known extensions in PackExt, so next time the // lookup will be successful return PackExt.newPackExt(extStr); }
From source file:org.chodavarapu.jgitaws.repositories.PackDescriptionRepository.java
License:Eclipse Distribution License
private static DfsPackDescription fromJson(String json, DfsPackDescription desc) { JSONObject object = new JSONObject(json); desc.setPackSource(object.optEnum(DfsObjDatabase.PackSource.class, "source")) .setLastModified(object.optLong("modified")).setObjectCount(object.optLong("objects")) .setDeltaCount(object.optLong("deltas")).setIndexVersion(object.optInt("ixVersion")) .clearPackStats();/*from w w w . j a v a 2 s . c o m*/ for (PackExt ext : PackExt.values()) { if (object.has(ext.getExtension() + "Size")) { desc.addFileExt(ext); desc.setFileSize(ext, object.getLong(ext.getExtension() + "Size")); } } return desc; }
From source file:org.chodavarapu.jgitaws.repositories.PackDescriptionRepository.java
License:Eclipse Distribution License
private static String toJson(DfsPackDescription desc) { JSONObject json = new JSONObject().put("modified", desc.getLastModified()) .put("objects", desc.getObjectCount()).put("deltas", desc.getDeltaCount()) .put("ixVersion", desc.getIndexVersion()); for (PackExt ext : PackExt.values()) { if (desc.hasFileExt(ext)) { json.put(ext.getExtension() + "Size", desc.getFileSize(ext)); }//from w w w . ja va 2 s .c o m } if (desc.getPackSource() != null) { json.put("source", desc.getPackSource().name()); } return json.toString(); }