KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > util > ZipItem


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * ZipItem.java
26  *
27  * Created on February 2, 2002, 12:53 PM
28  *
29  * @author bnevins
30  * @version $Revision: 1.3 $
31  * <BR> <I>$Source: /cvs/glassfish/admin/backup/src/java/com/sun/enterprise/config/backup/util/ZipItem.java,v $
32  *
33  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
34  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
35  * All rights reserved.
36  *
37  * This software is the confidential and proprietary information
38  * of iPlanet/Sun Microsystems, Inc. ("Confidential Information").
39  * You shall not disclose such Confidential Information and shall
40  * use it only in accordance with the terms of the license
41  * agreement you entered into with iPlanet/Sun Microsystems.
42  *
43  */

44
45 package com.sun.enterprise.config.backup.util;
46
47 import java.io.File JavaDoc;
48
49 /**
50  * This class encapsulates the two pieces of information required to make a
51  * ZipEntry -- the "real" path, and the path you want to appear in the zip file
52  */

53 public class ZipItem
54 {
55     /**
56      * Construct a ZipItem
57      *
58      * @param file The actual file
59      * @param name The zip entry name - i.e. the relative path in the zip file
60      * @throws ZipFileException
61      */

62     public ZipItem(File JavaDoc file, String JavaDoc name) throws ZipFileException
63     {
64         //if(!file.exists())
65
// throw new ZipFileException("File doesn't exist: " + file);
66
if(name == null || name.length() <= 0)
67             throw new ZipFileException("null or empty name for ZipItem");
68         
69         this.file = file;
70         this.name = name;
71     }
72
73     /**
74      * Returns a String represenation of the real filename and the zip entry
75      * name.
76      *
77      * @return String with the path and the zip entry name
78      */

79     public String JavaDoc toString()
80     {
81         return "File: " + file.getPath() + ", name: " + name;
82     }
83
84     /**
85      * Returns the zip entry name
86      *
87      * @return the zip entry name
88      */

89     public String JavaDoc getName()
90     {
91         return this.name;
92     }
93
94     /**
95      * Returns the actual file
96      *
97      * @return the actual file
98      */

99     public File JavaDoc getFile()
100     {
101         return this.file;
102     }
103     
104     ///////////////////////////////////////////////////////////////////////////
105

106     File JavaDoc file;
107     String JavaDoc name;
108 }
109
Popular Tags