obsolete code removed
[fedora-idea.git] / java / compiler / impl / src / com / intellij / compiler / impl / packagingCompiler / FileCopyInstructionImpl.java
blob4596c36c4cda9eff0cf331fa21b23cf4aef84531
1 /*
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.compiler.impl.packagingCompiler;
18 import com.intellij.openapi.compiler.CompilerBundle;
19 import com.intellij.openapi.compiler.make.BuildInstructionVisitor;
20 import com.intellij.openapi.compiler.make.FileCopyInstruction;
21 import com.intellij.openapi.compiler.make.PackagingFileFilter;
22 import com.intellij.openapi.module.Module;
23 import com.intellij.openapi.module.ModuleUtil;
24 import org.jetbrains.annotations.Nullable;
26 import java.io.File;
27 import java.util.List;
29 public class FileCopyInstructionImpl extends BuildInstructionBase implements FileCopyInstruction {
30 private File myFile;
31 private boolean myIsDirectory;
32 // for a directory keep the subset of changed files that need to be copied
33 private List<FileCopyInstructionImpl> myChangedSet;
34 private @Nullable final PackagingFileFilter myFileFilter;
36 protected FileCopyInstructionImpl(File source,
37 boolean isDirectory,
38 Module module,
39 String outputRelativePath) {
40 this(source, isDirectory, module, outputRelativePath, null);
43 public FileCopyInstructionImpl(File source,
44 boolean isDirectory,
45 Module module,
46 String outputRelativePath,
47 @Nullable final PackagingFileFilter fileFilter) {
48 super(outputRelativePath, module);
49 myFileFilter = fileFilter;
50 setFile(source, isDirectory);
53 @Nullable
54 public PackagingFileFilter getFileFilter() {
55 return myFileFilter;
58 public boolean accept(BuildInstructionVisitor visitor) throws Exception {
59 return visitor.visitFileCopyInstruction(this);
62 public String toString() {
63 if (myChangedSet == null) {
64 if (getModule() != null) {
65 return CompilerBundle.message("file.copy.instruction.file.from.module.to.file.message.text", getFile(),
66 ModuleUtil.getModuleNameInReadAction(getModule()), getOutputRelativePath());
67 } else {
68 return CompilerBundle.message("file.copy.instruction.file.to.file.message.text", getFile(), getOutputRelativePath());
71 else {
72 StringBuilder builder = new StringBuilder(CompilerBundle.message("file.copy.instruction.message.text", myFile));
73 for (FileCopyInstruction fileCopyInstruction : myChangedSet) {
74 builder.append(fileCopyInstruction).append(", ");
76 return builder.toString();
80 public boolean equals(Object o) {
81 if (this == o) return true;
82 if (!(o instanceof FileCopyInstruction)) return false;
84 final FileCopyInstruction item = (FileCopyInstruction) o;
86 if (getFile() != null ? !getFile().equals(item.getFile()) : item.getFile() != null) return false;
88 if (getOutputRelativePath() != null) {
89 if (!getOutputRelativePath().equals( item.getOutputRelativePath() )) return false;
90 } else if ( item.getOutputRelativePath() != null ) {
91 return false;
94 return true;
97 public int hashCode() {
98 return (getFile() != null ? getFile().hashCode() : 0) +
99 (getOutputRelativePath() != null ? getOutputRelativePath().hashCode():0);
102 public File getFile() {
103 return myFile;
106 public boolean isDirectory() {
107 return myIsDirectory;
110 private void setFile(File file, boolean isDirectory) {
111 myFile = file;
112 myIsDirectory = isDirectory;