KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > JarEntryDirectory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import java.io.ByteArrayInputStream JavaDoc;
14 import java.io.InputStream JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.jdt.core.IJarEntryResource;
18
19 public class JarEntryDirectory extends JarEntryResource {
20     private IJarEntryResource[] children;
21     
22     public JarEntryDirectory(String JavaDoc simpleName) {
23         super(simpleName);
24     }
25     
26     public JarEntryResource clone(Object JavaDoc newParent) {
27         JarEntryDirectory dir = new JarEntryDirectory(this.simpleName);
28         dir.setParent(newParent);
29         int length = this.children.length;
30         if (length > 0) {
31             IJarEntryResource[] newChildren = new IJarEntryResource[length];
32             for (int i = 0; i < length; i++) {
33                 JarEntryResource child = (JarEntryResource) this.children[i];
34                 newChildren[i] = child.clone(dir);
35             }
36             dir.setChildren(newChildren);
37         }
38         return dir;
39     }
40     
41     public IJarEntryResource[] getChildren() {
42         return this.children;
43     }
44
45     public InputStream JavaDoc getContents() throws CoreException {
46         return new ByteArrayInputStream JavaDoc(new byte[0]);
47     }
48
49     public boolean isFile() {
50         return false;
51     }
52
53     public void setChildren(IJarEntryResource[] children) {
54         this.children = children;
55     }
56
57     public String JavaDoc toString() {
58         return "JarEntryDirectory["+getEntryName()+"]"; //$NON-NLS-1$ //$NON-NLS-2$
59
}
60 }
61
Popular Tags