2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.cvsSupport2
.cvsoperations
.cvsContent
;
18 import com
.intellij
.util
.containers
.HashSet
;
20 import java
.util
.ArrayList
;
21 import java
.util
.Collection
;
22 import java
.util
.Collections
;
23 import java
.util
.Comparator
;
25 public class DirectoryContent
{
26 private final Collection
<String
> mySubDirectories
= new HashSet
<String
>();
27 private final Collection
<String
> myFiles
= new HashSet
<String
>();
28 private final Collection
<String
> myModules
= new HashSet
<String
>();
30 public void addSubDirectory(String subDirectoryName
){
31 mySubDirectories
.add(subDirectoryName
);
34 public void addFile(String fileName
){
35 myFiles
.add(fileName
);
38 public void addModule(String moduleName
){
39 myModules
.add(moduleName
);
42 public Collection
<String
> getSubDirectories() {
43 return convertToSortedCollection(mySubDirectories
);
46 public Collection
<String
> getFiles() {
47 return convertToSortedCollection(myFiles
);
50 public Collection
<String
> getSubModules() {
51 return convertToSortedCollection(myModules
);
54 private static Collection
<String
> convertToSortedCollection(Collection
<String
> collection
) {
55 ArrayList
<String
> result
= new ArrayList
<String
>(collection
);
56 Collections
.sort(result
, new Comparator
<String
>() {
57 public int compare(String o
, String o1
) {
58 return o
.compareToIgnoreCase(o1
);
64 public void copyDataFrom(DirectoryContent directoryContent
) {
65 mySubDirectories
.addAll(directoryContent
.getSubDirectories());
66 myFiles
.addAll(directoryContent
.getFiles());
67 myModules
.addAll(directoryContent
.getSubModules());