KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > archive > JarEntry


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.archive;
8
9 import org.ejtools.archive.io.Reader;
10 import org.ejtools.archive.io.Writer;
11
12 /**
13  * Implementation for a Jar based entry.
14  *
15  * @author Laurent Etiemble
16  * @version $Revision: 1.2 $
17  */

18 public class JarEntry implements Entry
19 {
20    /** The binary content */
21    private byte[] content;
22    /** The absolute URI */
23    private String JavaDoc uri = "";
24
25
26    /**
27     * Constructor for the JarEntry object
28     *
29     * @param uri The URI of the entry
30     */

31    public JarEntry(String JavaDoc uri)
32    {
33       this.uri = uri;
34    }
35
36
37    /**
38     * Visitor Pattern method to accept a Writer visitor
39     *
40     * @param visitor The writer visitor
41     */

42    public void accept(Writer visitor)
43    {
44       visitor.visit(this);
45    }
46
47
48    /**
49     * Visitor Pattern method to accept a Reader visitor
50     *
51     * @param visitor The reader visitor
52     */

53    public void accept(Reader visitor)
54    {
55       visitor.visit(this);
56    }
57
58
59    /**
60     * Adds this entry to an archive
61     *
62     * @param archive The archive to be added to
63     */

64    public void addTo(Archive archive)
65    {
66       archive.addEntry(this);
67    }
68
69
70    /**
71     * Returns the content of this entry
72     *
73     * @return The content
74     */

75    public byte[] getContent()
76    {
77       return this.content;
78    }
79
80
81    /**
82     * Return the absolute URI of this entry
83     *
84     * @return The URI
85     */

86    public String JavaDoc getURI()
87    {
88       return this.uri;
89    }
90
91
92    /**
93     * Always returns false as it is not an archive
94     *
95     * @return Always false
96     */

97    public boolean isArchive()
98    {
99       return false;
100    }
101
102
103    /**
104     * Sets the content of this entry
105     *
106     * @param content The new content
107     */

108    public void setContent(byte[] content)
109    {
110       this.content = content;
111    }
112
113
114    /**
115     * Sets the URI of this entry
116     *
117     * @param uri The new URI
118     */

119    public void setURI(String JavaDoc uri)
120    {
121       this.uri = uri;
122    }
123 }
124
Popular Tags