[Ejtools-cvs] libraries/common/src/main/org/ejtools/archive Archive.java,NONE,1.1 Entry.java,NONE,1.
Brought to you by:
letiemble
|
From: <let...@us...> - 2003-09-15 23:14:34
|
Update of /cvsroot/ejtools/libraries/common/src/main/org/ejtools/archive In directory sc8-pr-cvs1:/tmp/cvs-serv359/libraries/common/src/main/org/ejtools/archive Added Files: Archive.java Entry.java JarArchive.java JarEntry.java Log Message: Add support for Archive manipulation : reading, writing, modification and iteration. The collection of classes will be the base of the Deployment Browser --- NEW FILE: Archive.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package org.ejtools.archive; import java.util.Enumeration; import java.util.Iterator; /** * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public interface Archive extends Entry { /** * Gets the parent attribute of the Archive object * * @return The parent value */ public Archive getParent(); /** * Gets the nested attribute of the Archive object * * @return The nested value */ public boolean isNested(); /** * Gets the entries attribute of the Archive object * * @return The entries value */ public Enumeration getEntries(); /** * Description of the Method * * @return Description of the Return Value */ public Iterator iterator(); /** * Adds a feature to the Entry attribute of the Archive object * * @param entry The feature to be added to the Entry attribute */ public void addEntry(Entry entry); /** * Description of the Method * * @param uri Description of the Parameter */ public void removeEntry(String uri); /** * Description of the Method * * @param entry Description of the Parameter */ public void removeEntry(Entry entry); /** * Gets the entry attribute of the Archive object * * @param uri Description of the Parameter * @return The entry value */ public Entry getEntry(String uri); /** * Gets the manifest attribute of the Archive object * * @return The manifest value */ public Entry getManifest(); } --- NEW FILE: Entry.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package org.ejtools.archive; import org.ejtools.archive.io.Reader; import org.ejtools.archive.io.Writer; /** * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public interface Entry { /** * Description of the Method * * @param visitor Description of the Parameter */ public void accept(Reader visitor); /** * Description of the Method * * @param visitor Description of the Parameter */ public void accept(Writer visitor); /** * Adds a feature to the To attribute of the Entry object * * @param archive The feature to be added to the To attribute */ public void addTo(Archive archive); /** * Gets the archive attribute of the ArchiveEntry object * * @return The archive value */ public boolean isArchive(); /** * Gets the uRI attribute of the ArchiveEntry object * * @return The uRI value */ public String getURI(); /** * Sets the uRI attribute of the Entry object * * @param uri The new uRI value */ public void setURI(String uri); /** * Sets the content attribute of the ArchiveEntry object * * @param content The new content value */ public void setContent(byte[] content); /** * Gets the content attribute of the ArchiveEntry object * * @return The content value */ public byte[] getContent(); } --- NEW FILE: JarArchive.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package org.ejtools.archive; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.ejtools.archive.io.Reader; import org.ejtools.archive.io.Writer; /** * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public class JarArchive extends JarEntry implements Archive { /** Description of the Field */ private Map entries = new HashMap(); /** Description of the Field */ private Archive parent = null; /** *Constructor for the JarArchive object * * @param uri Description of the Parameter */ public JarArchive(String uri) { super(uri); } /** * Description of the Method * * @param visitor Description of the Parameter */ public void accept(Reader visitor) { visitor.visit(this); } /** * Description of the Method * * @param visitor Description of the Parameter */ public void accept(Writer visitor) { visitor.visit(this); } /** * Adds a feature to the Entry attribute of the JarArchive object * * @param entry The feature to be added to the Entry attribute */ public void addEntry(Entry entry) { this.entries.put(entry.getURI(), entry); } /** * Adds a feature to the To attribute of the JarArchive object * * @param archive The feature to be added to the To attribute */ public void addTo(Archive archive) { this.parent = archive; archive.addEntry(this); } /** * Gets the entries attribute of the JarArchive object * * @return The entries value */ public Enumeration getEntries() { return Collections.enumeration(entries.values()); } /** * Gets the entry attribute of the JarArchive object * * @param uri Description of the Parameter * @return The entry value */ public Entry getEntry(String uri) { return (Entry) this.entries.get(uri); } /** * Gets the manifest attribute of the JarArchive object * * @return The manifest value */ public Entry getManifest() { return (Entry) this.entries.get("META-INF/MANIFEST.MF"); } /** * Gets the parent attribute of the JarArchive object * * @return The parent value */ public Archive getParent() { return this.parent; } /** * Gets the archive attribute of the JarArchiveEntry object * * @return The archive value * @see test.archive.ArchiveEntry#isArchive() */ public boolean isArchive() { return true; } /** * Gets the nested attribute of the JarArchive object * * @return The nested value */ public boolean isNested() { return (this.parent != null); } /** * Description of the Method * * @return Description of the Return Value */ public Iterator iterator() { return this.entries.values().iterator(); } /** * Description of the Method * * @param uri Description of the Parameter */ public void removeEntry(String uri) { this.entries.remove(uri); } /** * Description of the Method * * @param entry Description of the Parameter */ public void removeEntry(Entry entry) { this.removeEntry(entry.getURI()); } } --- NEW FILE: JarEntry.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package org.ejtools.archive; import org.ejtools.archive.io.Reader; import org.ejtools.archive.io.Writer; /** * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public class JarEntry implements Entry { /** Description of the Field */ private byte[] content; /** Description of the Field */ private String uri = ""; /** *Constructor for the JarEntry object * * @param uri Description of the Parameter */ public JarEntry(String uri) { this.uri = uri; } /** * Description of the Method * * @param visitor Description of the Parameter */ public void accept(Writer visitor) { visitor.visit(this); } /** * Description of the Method * * @param visitor Description of the Parameter */ public void accept(Reader visitor) { visitor.visit(this); } /** * Adds a feature to the To attribute of the JarArchiveEntry object * * @param archive The feature to be added to the To attribute */ public void addTo(Archive archive) { archive.addEntry(this); } /** * Gets the content attribute of the JarArchiveEntry object * * @return The content value */ public byte[] getContent() { return this.content; } /** * Gets the uRI attribute of the JarArchiveEntry object * * @return The uRI value * @see test.archive.ArchiveEntry#getURI() */ public String getURI() { return this.uri; } /** * Gets the archive attribute of the JarArchiveEntry object * * @return The archive value * @see test.archive.ArchiveEntry#isArchive() */ public boolean isArchive() { return false; } /** * Sets the content attribute of the JarArchiveEntry object * * @param content The new content value */ public void setContent(byte[] content) { this.content = content; } /** * Sets the uRI attribute of the JarEntry object * * @param uri The new uRI value */ public void setURI(String uri) { this.uri = uri; } } |