コード例 #1
0
 private boolean loadContext(String zipPostfix, String entryName) {
   try {
     JBZipFile archive = getTasksArchive(zipPostfix);
     JBZipEntry entry = archive.getEntry(entryName.startsWith("/") ? entryName : "/" + entryName);
     if (entry != null) {
       byte[] bytes = entry.getData();
       Document document = JDOMUtil.loadDocument(new String(bytes));
       Element rootElement = document.getRootElement();
       loadContext(rootElement);
       archive.close();
       return true;
     }
   } catch (Exception e) {
     LOG.error(e);
   }
   return false;
 }
コード例 #2
0
 private void saveContext(
     @Nullable String entryName, String zipPostfix, @Nullable String comment) {
   try {
     JBZipFile archive = getTasksArchive(zipPostfix);
     if (entryName == null) {
       int i = archive.getEntries().size();
       do {
         entryName = "context" + i++;
       } while (archive.getEntry("/" + entryName) != null);
     }
     JBZipEntry entry = archive.getOrCreateEntry("/" + entryName);
     if (comment != null) {
       entry.setComment(comment);
     }
     Element element = new Element("context");
     saveContext(element);
     String s = new XMLOutputter().outputString(element);
     entry.setData(s.getBytes());
     archive.close();
   } catch (IOException e) {
     LOG.error(e);
   }
 }
コード例 #3
0
 public int compare(JBZipEntry o1, JBZipEntry o2) {
   return (int) (o2.getTime() - o1.getTime());
 }