1
/*******************************************************************************
2
* Copyright (c) 2007 Intel Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Intel Corporation - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.core.settings.model;
13
import java.util.Arrays;
15
import org.eclipse.core.resources.IFolder;
16
import org.eclipse.core.runtime.IPath;
18
public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICExclusionPatternPathEntry {
19
private IPath[] exclusionPatterns;
20
private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
21
char[][]fullCharExclusionPatterns = UNINIT_PATTERNS;
24
ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int flags) {
26
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
29
ACExclusionFilterEntry(IFolder rc, IPath exclusionPatterns[], int flags) {
31
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
34
ACExclusionFilterEntry(String value, IPath exclusionPatterns[], int flags) {
36
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0];
40
protected final boolean isFile() {
45
* Returns the exclusion patterns
48
public IPath[] getExclusionPatterns() {
49
return exclusionPatterns.length != 0 ? (IPath[])exclusionPatterns.clone() : exclusionPatterns;
53
* Returns a char based representation of the exclusions patterns full path.
55
public char[][] fullExclusionPatternChars() {
56
if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) {
57
int length = this.exclusionPatterns.length;
58
this.fullCharExclusionPatterns = new char[length][];
59
IPath path = getFullPath();
62
IPath prefixPath = path.removeTrailingSeparator();
63
for (int i = 0; i < length; i++) {
64
this.fullCharExclusionPatterns[i] =
65
prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray();
68
return this.fullCharExclusionPatterns;
72
public boolean equals(Object other) {
73
if(!super.equals(other))
76
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)other;
77
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
81
public int hashCode() {
82
return super.hashCode() + exclusionPatterns.hashCode();
86
public boolean equalsByContents(ICSettingEntry entry) {
87
if(!super.equalsByContents(entry))
90
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry;
91
return Arrays.equals(exclusionPatterns, otherEntry.exclusionPatterns);
95
protected String contentsToString() {
96
String result = super.contentsToString();
97
if(exclusionPatterns.length != 0){
98
StringBuffer buf = new StringBuffer();
100
buf.append(" ; exclude: "); //$NON-NLS-1$
101
for(int i = 0; i < exclusionPatterns.length; i++){
103
buf.append(", "); //$NON-NLS-1$
104
buf.append(exclusionPatterns[i].toString());
106
result = buf.toString();