Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: cf08edb880058b3d07a5f395d4026e3a9f87e120 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*******************************************************************************
 * Copyright (c) 2001, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.commonarchivecore.internal.strategy;



import org.eclipse.jst.j2ee.commonarchivecore.internal.ReadOnlyDirectory;

public class ReadOnlyDirectoryLoadStrategyImpl extends DirectoryLoadStrategyImpl {
	protected java.io.File subdirectory;

	/**
	 * ReadOnlyDirectoryLoadStrategy constructor comment.
	 */
	public ReadOnlyDirectoryLoadStrategyImpl(String aDirectoryUri) {
		super(aDirectoryUri);
	}

	/**
	 * ReadOnlyDirectoryLoadStrategy constructor comment.
	 */
	public ReadOnlyDirectoryLoadStrategyImpl(String rootDirectoryUri, java.io.File subdir) {
		super(rootDirectoryUri);
		setSubdirectory(subdir);
	}

	/**
	 * addDirectory method comment.
	 */
	protected void addDirectory(java.io.File aFile, java.util.List aList) {
		ReadOnlyDirectory dir = getArchiveFactory().createReadOnlyDirectory();
		dir.setLastModified(aFile.lastModified());
		dir.setURI(getURIFrom(aFile));
		dir.setLoadingContainer(getContainer());
		dir.setLoadStrategy(new ReadOnlyDirectoryLoadStrategyImpl(getDirectoryUri(), aFile));
		aList.add(dir);

	}

	public boolean contains(java.lang.String uri) {
		return super.contains(uri) && (getSubdirectory() == null || subdirectoryContains(uri));
	}

	/**
	 * @see com.ibm.etools.archive.LoadStrategy
	 */
	public java.lang.String getAbsolutePath() throws java.io.FileNotFoundException {
		java.io.File subdir = getSubdirectory();
		if (subdir == null) {
			return super.getAbsolutePath();
		}
		return subdir.getAbsolutePath();
	}

	/**
	 * getDirectoryForList method comment.
	 */
	protected java.io.File getDirectoryForList() {
		if (getSubdirectory() != null)
			return getSubdirectory();
		return new java.io.File(getDirectoryUri());
	}

	/**
	 * Insert the method's description here. Creation date: (01/08/01 1:10:47 PM)
	 * 
	 * @return java.io.File
	 */
	protected java.io.File getSubdirectory() {
		return subdirectory;
	}

	/**
	 * Always return false, because we want to treat the entries in a file system directory as basic
	 * files
	 */
	protected boolean isArchive(String uri) {
		return false;
	}

	/**
	 * Insert the method's description here. Creation date: (01/08/01 1:10:47 PM)
	 * 
	 * @param newSubdirectory
	 *            java.io.File
	 */
	protected void setSubdirectory(java.io.File newSubdirectory) {
		subdirectory = newSubdirectory;
	}

	protected boolean subdirectoryContains(String uri) {
		if (getSubdirectory() == null)
			return false;
		java.io.File aFile = new java.io.File(getFileNameFrom(uri)).getParentFile();
		boolean contains = false;
		while (aFile != null && !contains) {
			if (getSubdirectory().equals(aFile)) {
				contains = true;
			} else {
				aFile = aFile.getParentFile();
			}
		}
		return contains;
	}
}

Back to the top