001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.dependency;
034:
035: import java.util.*;
036:
037: public class AndCompositeSelectionCriteria extends
038: CompositeSelectionCriteria {
039: public AndCompositeSelectionCriteria(
040: Collection<? extends SelectionCriteria> subcriteria) {
041: super (subcriteria);
042: }
043:
044: public boolean isMatchingPackages() {
045: boolean result = true;
046:
047: Iterator<? extends SelectionCriteria> i = getSubcriteria()
048: .iterator();
049: while (result && i.hasNext()) {
050: result = i.next().isMatchingPackages();
051: }
052:
053: return result;
054: }
055:
056: public boolean isMatchingClasses() {
057: boolean result = true;
058:
059: Iterator<? extends SelectionCriteria> i = getSubcriteria()
060: .iterator();
061: while (result && i.hasNext()) {
062: result = i.next().isMatchingClasses();
063: }
064:
065: return result;
066: }
067:
068: public boolean isMatchingFeatures() {
069: boolean result = true;
070:
071: Iterator<? extends SelectionCriteria> i = getSubcriteria()
072: .iterator();
073: while (result && i.hasNext()) {
074: result = i.next().isMatchingFeatures();
075: }
076:
077: return result;
078: }
079:
080: public boolean matches(PackageNode node) {
081: boolean result = true;
082:
083: Iterator<? extends SelectionCriteria> i = getSubcriteria()
084: .iterator();
085: while (result && i.hasNext()) {
086: result = i.next().matches(node);
087: }
088:
089: return result;
090: }
091:
092: public boolean matches(ClassNode node) {
093: boolean result = true;
094:
095: Iterator<? extends SelectionCriteria> i = getSubcriteria()
096: .iterator();
097: while (result && i.hasNext()) {
098: result = i.next().matches(node);
099: }
100:
101: return result;
102: }
103:
104: public boolean matches(FeatureNode node) {
105: boolean result = true;
106:
107: Iterator<? extends SelectionCriteria> i = getSubcriteria()
108: .iterator();
109: while (result && i.hasNext()) {
110: result = i.next().matches(node);
111: }
112:
113: return result;
114: }
115:
116: public boolean matchesPackageName(String name) {
117: boolean result = true;
118:
119: Iterator<? extends SelectionCriteria> i = getSubcriteria()
120: .iterator();
121: while (result && i.hasNext()) {
122: result = i.next().matchesPackageName(name);
123: }
124:
125: return result;
126: }
127:
128: public boolean matchesClassName(String name) {
129: boolean result = true;
130:
131: Iterator<? extends SelectionCriteria> i = getSubcriteria()
132: .iterator();
133: while (result && i.hasNext()) {
134: result = i.next().matchesClassName(name);
135: }
136:
137: return result;
138: }
139:
140: public boolean matchesFeatureName(String name) {
141: boolean result = true;
142:
143: Iterator<? extends SelectionCriteria> i = getSubcriteria()
144: .iterator();
145: while (result && i.hasNext()) {
146: result = i.next().matchesFeatureName(name);
147: }
148:
149: return result;
150: }
151: }
|