001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.vfs;
031:
032: import com.caucho.loader.EnvironmentLocal;
033: import com.caucho.make.CachedDependency;
034: import com.caucho.util.Alarm;
035: import com.caucho.util.CacheListener;
036: import com.caucho.util.Log;
037: import com.caucho.util.LruCache;
038: import com.caucho.util.L10N;
039:
040: import java.io.FileNotFoundException;
041: import java.io.IOException;
042: import java.io.InputStream;
043: import java.lang.ref.SoftReference;
044: import java.security.cert.Certificate;
045: import java.util.ArrayList;
046: import java.util.Enumeration;
047: import java.util.Iterator;
048: import java.util.jar.JarEntry;
049: import java.util.jar.JarFile;
050: import java.util.jar.Manifest;
051: import java.util.logging.Level;
052: import java.util.logging.Logger;
053: import java.util.zip.ZipEntry;
054: import java.util.zip.ZipFile;
055: import java.util.zip.ZipInputStream;
056:
057: /**
058: * Entry for a Jar.
059: */
060: public class JarNode {
061: private static final Logger log = Logger.getLogger(JarNode.class
062: .getName());
063: private static final L10N L = new L10N(JarNode.class);
064:
065: private final String _name;
066: private final String _segment;
067:
068: private long _size;
069: private long _time;
070:
071: private boolean _isDirectory;
072: private boolean _exists;
073:
074: private ArrayList<JarNode> _children;
075:
076: JarNode(String name, String segment) {
077: _name = name;
078: _segment = segment;
079: _size = 0;
080: _time = Alarm.getCurrentTime();
081: _isDirectory = true;
082: }
083:
084: void fill(ZipEntry entry) {
085: _size = entry.getSize();
086: _time = entry.getTime();
087: _isDirectory = entry.isDirectory();
088: _exists = true;
089: }
090:
091: public String getName() {
092: return _name;
093: }
094:
095: public String getSegment() {
096: return _segment;
097: }
098:
099: public boolean isDirectory() {
100: return _isDirectory;
101: }
102:
103: public boolean exists() {
104: return _exists;
105: }
106:
107: public long getSize() {
108: return _size;
109: }
110:
111: public long getTime() {
112: return _time;
113: }
114:
115: public void addChild(JarNode child) {
116: if (_children == null)
117: _children = new ArrayList<JarNode>();
118:
119: _children.add(child);
120: }
121:
122: public ArrayList<JarNode> getChildren() {
123: return _children;
124: }
125: }
|