Package java.util.zip

Examples of java.util.zip.ZipFile$Window


        @Override
        public void run() {
          try {
            final X11 x11 = X11.INSTANCE;
            final Display display = x11.XOpenDisplay(null);
            Window window = new Window(nativeHandle);
            x11.XSelectInput(display, window,
                new NativeLong(X11.ExposureMask |
                    X11.VisibilityChangeMask |
                    X11.StructureNotifyMask |
                    X11.FocusChangeMask |
View Full Code Here


        screenVisual = new HashMap<Integer,Visual>();
 
  defaultDepth = display.default_depth;

        atomsWmSelection = new Atom[display.screens.length];
        Window wmSelectionWin = new Window(rootWin, 0,0, 1, 1, 0, new Window.Attributes());

  for (int i = 0; i< display.screens.length; i++) {
      Screen screen = display.screens[i];
      gnu.x11.Enum scrdepths = screen.depths();
      while (scrdepths.more()) {
          Depth depth = (Depth) scrdepths.next();
          screenDepth.put(depth.depth(), depth);
   
    gnu.x11.Enum enm = depth.visuals();       
    while (enm.more()) {
        Visual visual = (Visual) enm.next();             
        screenVisual.put(visual.id(), visual);
    }
      }

      // AWT in Java6u1 requires that the WM acquire these selections.
      // Note: even though the WM conventions recommend that CurrentTime
      // not be used we can use it here because the LG WM is the only one
      // acquiring these selections.

      atomsWmSelection[i] = (Atom)Atom.intern(display, "WM_S" + i);
      wmSelectionWin.set_selection_owner(atomsWmSelection[i], Display.CURRENT_TIME);
      display.check_error();
  }

  atomWmState = (Atom)Atom.intern(display, "WM_STATE");
  atomWmChangeState = (Atom)Atom.intern(display, "WM_CHANGE_STATE");
  atomWmProtocols = (Atom)Atom.intern(display, "WM_PROTOCOLS");
  atomWmDeleteWindow = (Atom)Atom.intern(display, "WM_DELETE_WINDOW");
  atomWmTakeFocus = (Atom)Atom.intern(display, "WM_TAKE_FOCUS");
  atomWmColormapWindows=(Atom)Atom.intern(display,"WM_COLORMAP_WINDOWS");
  atomWmTransientFor = (Atom)Atom.intern(display, "WM_TRANSIENT_FOR");
  atomCompoundText = (Atom)Atom.intern(display, "COMPOUND_TEXT");
  atomServerShutdown = (Atom)Atom.intern(display, "SERVER_SHUTDOWN");

  try {
            selectInput(rootWin);
  } catch (Error err) {
      if (err.code == Error.BAD_ACCESS && err.bad == rootWin.id) {
                logger.severe("Failed to access root window. Another WM is running?");
    throw new RuntimeException ("Failed to access root window\n"
        + "Another WM is running?"); // FIXME
      } else {
    throw err;
      }
  }
       
        // Remote Windows: Automatically composite redirect all root top-level windows
  compositeTopLevelWindows();

  // Init WmNET support for screen 0
  // TODO: multiscreen
  Window[] rootWins = new Window[1];
  Window[] checkWins = new Window[1];
  rootWins[0] = rootWin;
        checkWins[0] = new Window(rootWin, 0,0, 1, 1, 0, new Window.Attributes());
  X11WindowManagerHints.initWmNETSupport(display, rootWins, checkWins);

  // prepare for the event dispatch thread
  Thread eventThread = new Thread( this, "X11WindowManager" );
  // eventThread.setPriority(Thread.NORM_PRIORITY + 2); // FIXME
View Full Code Here

   *            The root directory to extract to.
   * @throws IOException
   */
  static void extract(final File sourceZipFile, File unzipDestinationDirectory) throws IOException {
    // Open Zip file for reading
    ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);

    // Create an enumeration of the entries in the zip file
    Enumeration zipFileEntries = zipFile.entries();

    // Process each entry
    while (zipFileEntries.hasMoreElements()) {
      // grab a zip file entry
      ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();

      String currentEntry = entry.getName();

      File destFile = new File(unzipDestinationDirectory, currentEntry);

      // grab file's parent directory structure
      File destinationParent = destFile.getParentFile();

      // create the parent directory structure if needed
      destinationParent.mkdirs();

      // extract file if not a directory
      if (!entry.isDirectory()) {
        ObjectConverterUtil.write(zipFile.getInputStream(entry),
            destFile);
      }
    }
    zipFile.close();
  }
View Full Code Here

        log.info("retrieve " + f);
       
        // create document and read it from file
        doc = new HttpDoc();
        doc.setURL(url);
        ZipFile zf = new ZipFile(f);
       
        // read headers
        readHeadersFromZipFile(doc, zf);
       
        // read links
        readLinksFromZipFile(doc, zf);
       
        doc.setCached(true);
       
        // read content
        String md5 = doc.getContentMD5();
        File contentFile = contentFile(md5, ".zip");
        if (contentFile.exists()) {
          ZipFile contentZip = new ZipFile(contentFile);
          readContentFromZipFile(doc, contentZip);
          contentZip.close();
        } else {
          doc.setContent(new byte[0]);
        }
        zf.close();
      }
View Full Code Here

     * responsability to call close() in it when it is no longer needed.
     * @return a ZipFile for reading
     * @throws IOException
     */
    protected ZipFile getZipFile() throws IOException {
        return new ZipFile(file);
    }
View Full Code Here

    public synchronized void update() {
        if (file.lastModified() != lastModified ||
                repositories == null ||
                resources == null) {
            lastModified = file.lastModified();
            ZipFile zipfile = null;

            try {
                zipfile = getZipFile();
                Enumeration en = zipfile.entries();
                HashMap newRepositories = new HashMap();
                HashMap newResources = new HashMap();

                while (en.hasMoreElements()) {
                    ZipEntry entry = (ZipEntry) en.nextElement();
                    String eName = entry.getName();

                    if (!eName.regionMatches(0, entryPath, 0, entryPath.length())) {
                        // names don't match - not a child of ours
                        continue;
                    }
                    String[] entrypath = StringUtils.split(eName, "/");
                    if (depth > 0 && !shortName.equals(entrypath[depth-1])) {
                        // catch case where our name is Foo and other's is FooBar
                        continue;
                    }

                    // create new repositories and resources for all entries with a
                    // path depth of this.depth + 1
                    if (entrypath.length == depth + 1 && !entry.isDirectory()) {
                        // create a new child resource
                        ZipResource resource = new ZipResource(entry.getName(), this);
                        newResources.put(resource.getShortName(), resource);
                    } else if (entrypath.length > depth) {
                        // create a new child repository
                        if (!newRepositories.containsKey(entrypath[depth])) {
                            ZipEntry child = composeChildEntry(entrypath[depth]);
                            ZipRepository rep = new ZipRepository(file, this, child);
                            newRepositories.put(entrypath[depth], rep);
                        }
                    }
                }

                repositories = (Repository[]) newRepositories.values()
                        .toArray(new Repository[newRepositories.size()]);
                resources = newResources;

            } catch (Exception ex) {
                ex.printStackTrace();
                repositories = emptyRepositories;
                if (resources == null) {
                    resources = new HashMap();
                } else {
                    resources.clear();
                }

            } finally {
                try {
                    // unlocks the zip file in the underlying filesystem
                    zipfile.close();
                } catch (Exception ex) {}
            }
        }
    }
View Full Code Here

    public long getChecksum() {
        return file.lastModified();
    }

    public boolean exists() {
        ZipFile zipfile = null;
        try {
            /* a ZipFile needs to be created to see if the zip file actually
             exists; this is not cached to provide blocking the zip file in
             the underlying filesystem */
            zipfile = getZipFile();
            return true;
        } catch (IOException ex) {
            return false;
        }
        finally {
            try {
                // unlocks the zip file in the underlying filesystem
                zipfile.close();
            } catch (Exception ex) {
                return false;
            }
        }
    }
View Full Code Here

    public long lastModified() {
        return repository.lastModified();
    }

    public InputStream getInputStream() throws IOException {
        ZipFile zipfile = null;
        try {
            zipfile = repository.getZipFile();
            ZipEntry entry = zipfile.getEntry(entryName);
            if (entry == null) {
                throw new IOException("Zip resource " + this + " does not exist");
            }
            int size = (int) entry.getSize();
            byte[] buf = new byte[size];
            InputStream in = zipfile.getInputStream(entry);
            int read = 0;
            while (read < size) {
                int r = in.read(buf, read, size-read);
                if (r == -1)
                    break;
                read += r;
            }
            in.close();
            return new ByteArrayInputStream(buf);
        } finally {
            zipfile.close();
        }
    }
View Full Code Here

            zipfile.close();
        }
    }

    public boolean exists() {
        ZipFile zipfile = null;
        try {
            zipfile = repository.getZipFile();
            return (zipfile.getEntry(entryName) != null);
        } catch (Exception ex) {
            return false;
        } finally {
            try {
                zipfile.close();
            } catch (Exception ex) {}
        }
    }
View Full Code Here

            } catch (Exception ex) {}
        }
    }

    public String getContent(String encoding) throws IOException {
        ZipFile zipfile = null;
        try {
            zipfile = repository.getZipFile();
            ZipEntry entry = zipfile.getEntry(entryName);
            if (entry == null) {
                throw new IOException("Zip resource " + this + " does not exist");
            }
            InputStream in = zipfile.getInputStream(entry);
            int size = (int) entry.getSize();
            byte[] buf = new byte[size];
            int read = 0;
            while (read < size) {
                int r = in.read(buf, read, size-read);
                if (r == -1)
                    break;
                read += r;
            }
            in.close();
            return encoding == null ?
                    new String(buf) :
                    new String(buf, encoding);
        } finally {
            if (zipfile != null) {
                zipfile.close();
            }
        }
    }
View Full Code Here

TOP

Related Classes of java.util.zip.ZipFile$Window

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.