1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.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 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 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. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.build.builders; 18 19 import com.android.annotations.NonNull; 20 21 import org.apache.tools.ant.types.selectors.SelectorUtils; 22 import org.eclipse.core.runtime.IPath; 23 24 /** 25 * Collection of file path or path patterns to be checked for changes. 26 * 27 * All paths should be relative to the project they belong to. 28 * Patterns can use Ant-type glob patterns. 29 * 30 * This is an immutable class that does not store any info beyond the list of paths. This is to 31 * be used in conjunction with {@link PatternBasedDeltaVisitor}. 32 */ 33 class ChangedFileSet { 34 35 private final String mLogName; 36 37 private final String[] mInputs; 38 private String mOutput; 39 ChangedFileSet(String logName, String... inputs)40 ChangedFileSet(String logName, String... inputs) { 41 mLogName = logName; 42 mInputs = inputs; 43 } 44 setOutput(@onNull String output)45 public void setOutput(@NonNull String output) { 46 mOutput = output; 47 } 48 isInput(@onNull String path, @NonNull IPath iPath)49 public boolean isInput(@NonNull String path, @NonNull IPath iPath) { 50 for (String i : mInputs) { 51 if (SelectorUtils.matchPath(i, path)) { 52 return true; 53 } 54 } 55 56 return false; 57 } 58 isOutput(@onNull String path, @NonNull IPath iPath)59 public boolean isOutput(@NonNull String path, @NonNull IPath iPath) { 60 if (mOutput != null) { 61 return SelectorUtils.matchPath(mOutput, path); 62 } 63 64 return false; 65 } 66 getLogName()67 public String getLogName() { 68 return mLogName; 69 } 70 } 71