diff options
Diffstat (limited to 'org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java')
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java index 311dba478..3a7689df2 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/DirectorySourceContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 2013 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 @@ -13,6 +13,7 @@ package org.eclipse.debug.core.sourcelookup.containers; import java.io.File; import java.util.ArrayList; import java.util.List; + import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.debug.core.DebugPlugin; @@ -24,14 +25,14 @@ import org.eclipse.debug.core.sourcelookup.ISourceContainerType; * from <code>findSourceElements(...)</code> are instances * of <code>LocalFileStorage</code>. * <p> - * Clients may instantiate this class. + * Clients may instantiate this class. * </p> * @since 3.0 * @noextend This class is not intended to be subclassed by clients. */ public class DirectorySourceContainer extends CompositeSourceContainer { - + // root directory private File fDirectory; // whether to search sub-folders @@ -41,11 +42,11 @@ public class DirectorySourceContainer extends CompositeSourceContainer { * (value <code>org.eclipse.debug.core.containerType.directory</code>). */ public static final String TYPE_ID = DebugPlugin.getUniqueIdentifier() + ".containerType.directory"; //$NON-NLS-1$ - + /** * Constructs an external folder container for the * directory identified by the given path. - * + * * @param dirPath path to a directory in the local file system * @param subfolders whether folders within the root directory * should be searched for source elements @@ -53,11 +54,11 @@ public class DirectorySourceContainer extends CompositeSourceContainer { public DirectorySourceContainer(IPath dirPath, boolean subfolders) { this(dirPath.toFile(), subfolders); } - + /** * Constructs an external folder container for the * directory identified by the given file. - * + * * @param dir a directory in the local file system * @param subfolders whether folders within the root directory * should be searched for source elements @@ -65,29 +66,31 @@ public class DirectorySourceContainer extends CompositeSourceContainer { public DirectorySourceContainer(File dir, boolean subfolders) { fDirectory = dir; fSubfolders = subfolders; - } - + } + /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName() */ + @Override public String getName() { return fDirectory.getName(); - } - + } + /** * Returns the root directory in the local file system associated * with this source container. - * + * * @return the root directory in the local file system associated * with this source container */ public File getDirectory() { return fDirectory; } - + /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType() */ + @Override public ISourceContainerType getType() { return getSourceContainerType(TYPE_ID); } @@ -95,15 +98,16 @@ public class DirectorySourceContainer extends CompositeSourceContainer { /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String) */ + @Override public Object[] findSourceElements(String name) throws CoreException { - ArrayList sources = new ArrayList(); + ArrayList<Object> sources = new ArrayList<Object>(); File directory = getDirectory(); File file = new File(directory, name); if (file.exists() && file.isFile()) { sources.add(new LocalFileStorage(file)); } - - //check sub-folders + + //check sub-folders if ((isFindDuplicates() && fSubfolders) || (sources.isEmpty() && fSubfolders)) { ISourceContainer[] containers = getSourceContainers(); for (int i=0; i < containers.length; i++) { @@ -112,23 +116,26 @@ public class DirectorySourceContainer extends CompositeSourceContainer { continue; } if (isFindDuplicates()) { - for(int j=0; j < objects.length; j++) + for(int j=0; j < objects.length; j++) { sources.add(objects[j]); + } } else { sources.add(objects[0]); break; } } - } - - if(sources.isEmpty()) + } + + if(sources.isEmpty()) { return EMPTY; + } return sources.toArray(); } /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#isComposite() */ + @Override public boolean isComposite() { return fSubfolders; } @@ -136,6 +143,7 @@ public class DirectorySourceContainer extends CompositeSourceContainer { /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object obj) { if (obj instanceof DirectorySourceContainer) { DirectorySourceContainer container = (DirectorySourceContainer) obj; @@ -146,18 +154,20 @@ public class DirectorySourceContainer extends CompositeSourceContainer { /* (non-Javadoc) * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return getDirectory().hashCode(); } - + /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers() */ + @Override protected ISourceContainer[] createSourceContainers() throws CoreException { if (isComposite()) { String[] files = fDirectory.list(); if (files != null) { - List dirs = new ArrayList(); + List<ISourceContainer> dirs = new ArrayList<ISourceContainer>(); for (int i = 0; i < files.length; i++) { String name = files[i]; File file = new File(getDirectory(), name); @@ -165,11 +175,11 @@ public class DirectorySourceContainer extends CompositeSourceContainer { dirs.add(new DirectorySourceContainer(file, true)); } } - ISourceContainer[] containers = (ISourceContainer[]) dirs.toArray(new ISourceContainer[dirs.size()]); + ISourceContainer[] containers = dirs.toArray(new ISourceContainer[dirs.size()]); for (int i = 0; i < containers.length; i++) { ISourceContainer container = containers[i]; container.init(getDirector()); - } + } return containers; } } |