Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 206812
Collapse All | Expand All

(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:39:25 EST 2006
1
#Sun Oct 21 00:00:43 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/emf/query/tests/EObjectStructuralFeatureValueConditionTest.java (-5 / +6 lines)
Lines 25-30 Link Here
25
import junit.framework.TestSuite;
25
import junit.framework.TestSuite;
26
import junit.textui.TestRunner;
26
import junit.textui.TestRunner;
27
27
28
import org.eclipse.emf.ecore.EObject;
28
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
29
import org.eclipse.emf.examples.extlibrary.EXTLibraryFactory;
29
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
30
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
30
import org.eclipse.emf.examples.extlibrary.Library;
31
import org.eclipse.emf.examples.extlibrary.Library;
Lines 60-66 Link Here
60
    }
61
    }
61
62
62
    public void test_searchForNullValue_184011() {
63
    public void test_searchForNullValue_184011() {
63
        Collection objects = new java.util.HashSet();
64
        Collection<EObject> objects = new java.util.HashSet<EObject>();
64
65
65
        Library a = EXTLibraryFactory.eINSTANCE.createLibrary();
66
        Library a = EXTLibraryFactory.eINSTANCE.createLibrary();
66
        objects.add(a);
67
        objects.add(a);
Lines 80-86 Link Here
80
            EXTLibraryPackage.Literals.LIBRARY__NAME,
81
            EXTLibraryPackage.Literals.LIBRARY__NAME,
81
            ObjectInstanceCondition.IS_NULL);
82
            ObjectInstanceCondition.IS_NULL);
82
83
83
        Collection results = query(objects, cond);
84
        Collection<EObject> results = query(objects, cond);
84
        assertEquals(Collections.singleton(b), results);
85
        assertEquals(Collections.singleton(b), results);
85
86
86
        cond = new EObjectReferenceValueCondition(
87
        cond = new EObjectReferenceValueCondition(
Lines 95-102 Link Here
95
    // Framework methods
96
    // Framework methods
96
    //
97
    //
97
98
98
    Collection query(Collection source, EObjectCondition cond) {
99
    Collection<EObject> query(Collection<? extends EObject> source,
99
        return new SELECT(new FROM(source), new WHERE(cond)).execute()
100
    		EObjectCondition cond) {
100
            .getEObjects();
101
        return new SELECT(new FROM(source), new WHERE(cond)).execute();
101
    }
102
    }
102
}
103
}
(-)src/org/eclipse/emf/query/tests/AllTests.java (-1 / +1 lines)
Lines 30-35 Link Here
30
 * @author Yasser Lulu
30
 * @author Yasser Lulu
31
 * 
31
 * 
32
 */
32
 */
33
@SuppressWarnings("deprecation")
33
public class AllTests extends TestCase implements IPlatformRunnable {
34
public class AllTests extends TestCase implements IPlatformRunnable {
34
35
35
    public static void main(String[] args) {
36
    public static void main(String[] args) {
Lines 52-56 Link Here
52
        TestRunner.run(suite());
53
        TestRunner.run(suite());
53
		return Arrays.asList(new String[] { "Please see raw test suite output for details." }); //$NON-NLS-1$
54
		return Arrays.asList(new String[] { "Please see raw test suite output for details." }); //$NON-NLS-1$
54
    }
55
    }
55
56
}
56
}
(-)src/org/eclipse/emf/query/tests/EMFQueryTest.java (-12 / +21 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 47-53 Link Here
47
import org.eclipse.emf.query.conditions.ObjectInstanceCondition;
47
import org.eclipse.emf.query.conditions.ObjectInstanceCondition;
48
import org.eclipse.emf.query.conditions.booleans.BooleanCondition;
48
import org.eclipse.emf.query.conditions.booleans.BooleanCondition;
49
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
49
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
50
import org.eclipse.emf.query.conditions.eobjects.EObjectSource;
51
import org.eclipse.emf.query.conditions.eobjects.EObjectTypeRelationCondition;
50
import org.eclipse.emf.query.conditions.eobjects.EObjectTypeRelationCondition;
52
import org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectAttributeValueCondition;
51
import org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectAttributeValueCondition;
53
import org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectReferenceValueCondition;
52
import org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectReferenceValueCondition;
Lines 74-80 Link Here
74
		return new TestSuite(EMFQueryTest.class);
73
		return new TestSuite(EMFQueryTest.class);
75
	}
74
	}
76
75
77
	private Collection modelElements;
76
	private Collection<EObject> modelElements;
78
77
79
	private Library library;
78
	private Library library;
80
79
Lines 106-115 Link Here
106
	/**
105
	/**
107
	 * @see junit.framework.TestCase#setUp()
106
	 * @see junit.framework.TestCase#setUp()
108
	 */
107
	 */
108
	@Override
109
	protected void setUp() throws Exception {
109
	protected void setUp() throws Exception {
110
		super.setUp();
110
		super.setUp();
111
		
111
		
112
		modelElements = new ArrayList();
112
		modelElements = new ArrayList<EObject>();
113
		modelElements.add(getLibrary());
113
		modelElements.add(getLibrary());
114
114
115
		book_EClass = EXTLibraryPackage.Literals.BOOK;
115
		book_EClass = EXTLibraryPackage.Literals.BOOK;
Lines 121-126 Link Here
121
	/**
121
	/**
122
	 * @see junit.framework.TestCase#tearDown()
122
	 * @see junit.framework.TestCase#tearDown()
123
	 */
123
	 */
124
	@Override
124
	protected void tearDown() throws Exception {
125
	protected void tearDown() throws Exception {
125
		resource = null;
126
		resource = null;
126
		super.tearDown();
127
		super.tearDown();
Lines 129-140 Link Here
129
	private void logicalOperatorsTesting() {
130
	private void logicalOperatorsTesting() {
130
		Condition FALSE = new BooleanCondition(false) {
131
		Condition FALSE = new BooleanCondition(false) {
131
132
133
			@Override
132
			public boolean isSatisfied(Object object) {
134
			public boolean isSatisfied(Object object) {
133
				return false;
135
				return false;
134
			}
136
			}
135
		};
137
		};
136
		Condition TRUE = new BooleanCondition(true) {
138
		Condition TRUE = new BooleanCondition(true) {
137
139
140
			@Override
138
			public boolean isSatisfied(Object object) {
141
			public boolean isSatisfied(Object object) {
139
				return true;
142
				return true;
140
			}
143
			}
Lines 189-203 Link Here
189
	public void test_QueryStatementExceptionHandling() {
192
	public void test_QueryStatementExceptionHandling() {
190
		final RuntimeException exception = new RuntimeException();
193
		final RuntimeException exception = new RuntimeException();
191
		
194
		
192
		QueryStatement statement = new QueryStatement(false, new NullProgressMonitor()) {
195
		QueryStatement statement = new QueryStatement(false,
196
				new NullProgressMonitor()) {
197
			@Override
193
			public boolean canBeResumed() {
198
			public boolean canBeResumed() {
194
				return false;
199
				return false;
195
			}
200
			}
196
201
202
			@Override
197
			protected void doExecute() {
203
			protected void doExecute() {
198
				throw exception;
204
				throw exception;
199
			}
205
			}
200
206
207
			@Override
201
			protected void doResume() {
208
			protected void doResume() {
202
				doExecute();
209
				doExecute();
203
			}
210
			}
Lines 226-232 Link Here
226
		EAttribute categoryAttribute = EXTLibraryPackage.eINSTANCE.getBook_Category();
233
		EAttribute categoryAttribute = EXTLibraryPackage.eINSTANCE.getBook_Category();
227
		
234
		
228
		SELECT s = new SELECT(
235
		SELECT s = new SELECT(
229
				new FROM(new EObjectSource(b)),
236
				new FROM(b),
230
				new WHERE(new EObjectAttributeValueCondition(categoryAttribute,
237
				new WHERE(new EObjectAttributeValueCondition(categoryAttribute,
231
							new ObjectInstanceCondition(categoryAttribute.getDefaultValue()),
238
							new ObjectInstanceCondition(categoryAttribute.getDefaultValue()),
232
							EStructuralFeatureValueGetter.getInstance())));
239
							EStructuralFeatureValueGetter.getInstance())));
Lines 276-287 Link Here
276
283
277
				private boolean shouldPrune;
284
				private boolean shouldPrune;
278
285
286
				@Override
279
				public boolean shouldPrune(EObject object) {
287
				public boolean shouldPrune(EObject object) {
280
					return shouldPrune;
288
					return shouldPrune;
281
				}
289
				}
282
290
291
				@Override
283
				public boolean isSatisfied(EObject element) {
292
				public boolean isSatisfied(EObject element) {
284
					if (element.eClass() == book_EClass) {
293
					if (element instanceof Book) {
285
						if (((Book) element).getTitle().equals(title)) {
294
						if (((Book) element).getTitle().equals(title)) {
286
							shouldPrune = true;
295
							shouldPrune = true;
287
							return true;
296
							return true;
Lines 290-298 Link Here
290
					return false;
299
					return false;
291
				}
300
				}
292
			}));
301
			}));
293
		Collection resultSet = statement.execute();
302
		Collection<EObject> resultSet = statement.execute();
294
		instance_Book1 = (Book) ((resultSet.isEmpty()) ? null
303
		instance_Book1 = ((resultSet.isEmpty()) ? null
295
			: (EObject) resultSet.toArray()[0]);
304
			: resultSet.toArray(new Book[resultSet.size()])[0]);
296
		return instance_Book1;
305
		return instance_Book1;
297
	}
306
	}
298
307
Lines 300-306 Link Here
300
		if (resource == null) {
309
		if (resource == null) {
301
			resource = new ResourceImpl(URI.createURI("foo:///foo.xml")); //$NON-NLS-1$
310
			resource = new ResourceImpl(URI.createURI("foo:///foo.xml")); //$NON-NLS-1$
302
			
311
			
303
			List contents = resource.getContents();
312
			List<EObject> contents = resource.getContents();
304
			
313
			
305
			Library l = EXTLibraryFactory.eINSTANCE.createLibrary();
314
			Library l = EXTLibraryFactory.eINSTANCE.createLibrary();
306
			l.setName("New Library"); //$NON-NLS-1$
315
			l.setName("New Library"); //$NON-NLS-1$
Lines 336-342 Link Here
336
		return library;
345
		return library;
337
	}
346
	}
338
347
339
	private Collection getQueryObjects() {
348
	private Collection<EObject> getQueryObjects() {
340
		return modelElements;
349
		return modelElements;
341
	}
350
	}
342
}
351
}
(-)META-INF/MANIFEST.MF (-5 / +5 lines)
Lines 2-14 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.query.tests
4
Bundle-SymbolicName: org.eclipse.emf.query.tests
5
Bundle-Version: 1.1.0.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Vendor: %Plugin.providerName
6
Bundle-Vendor: %Plugin.providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Export-Package: org.eclipse.emf.query.tests
8
Export-Package: org.eclipse.emf.query.tests
9
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
9
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
10
 org.junit;bundle-version="[3.8.1,4.0.0)",
10
 org.junit;bundle-version="[3.8.1,4.0.0)",
11
 org.eclipse.emf.ecore;bundle-version="[2.2.0,3.0.0)",
11
 org.eclipse.emf.ecore;bundle-version="[2.3.0,3.0.0)",
12
 org.eclipse.emf.query;bundle-version="1.0.0",
12
 org.eclipse.emf.query;bundle-version="1.2.0",
13
 org.eclipse.emf.examples.library;bundle-version="[2.2.0,3.0.0)"
13
 org.eclipse.emf.examples.library;bundle-version="[2.3.0,3.0.0)"
14
Bundle-RequiredExecutionEnvironment: J2SE-1.4
14
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.query.examples;singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.query.examples;singleton:=true
5
Bundle-Version: 1.1.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Vendor: %Plugin.providerName
6
Bundle-Vendor: %Plugin.providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Eclipse-LazyStart: true
8
Eclipse-LazyStart: true
Lines 13-16 Link Here
13
Bundle-Activator: org.eclipse.emf.query.examples.internal.QueryExamplesPlugin
13
Bundle-Activator: org.eclipse.emf.query.examples.internal.QueryExamplesPlugin
14
Export-Package: org.eclipse.emf.query.examples.internal;x-internal:=true,
14
Export-Package: org.eclipse.emf.query.examples.internal;x-internal:=true,
15
 org.eclipse.emf.query.examples.internal.wizard;x-internal:=true
15
 org.eclipse.emf.query.examples.internal.wizard;x-internal:=true
16
Bundle-RequiredExecutionEnvironment: J2SE-1.4
16
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:36:42 EST 2006
1
#Sun Oct 21 00:31:23 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/query/examples/internal/wizard/AbstractExampleWizard.java (-9 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 24-35 Link Here
24
import java.lang.reflect.InvocationTargetException;
24
import java.lang.reflect.InvocationTargetException;
25
import java.net.URL;
25
import java.net.URL;
26
import java.util.Collection;
26
import java.util.Collection;
27
import java.util.Iterator;
28
import java.util.zip.ZipEntry;
27
import java.util.zip.ZipEntry;
29
import java.util.zip.ZipInputStream;
28
import java.util.zip.ZipInputStream;
30
29
31
import org.eclipse.core.resources.IFile;
32
import org.eclipse.core.resources.IProject;
30
import org.eclipse.core.resources.IProject;
31
import org.eclipse.core.resources.IResource;
33
import org.eclipse.core.resources.ResourcesPlugin;
32
import org.eclipse.core.resources.ResourcesPlugin;
34
import org.eclipse.core.runtime.CoreException;
33
import org.eclipse.core.runtime.CoreException;
35
import org.eclipse.core.runtime.FileLocator;
34
import org.eclipse.core.runtime.FileLocator;
Lines 114-121 Link Here
114
		}
113
		}
115
	}
114
	}
116
115
116
	@Override
117
	public boolean performFinish() {
117
	public boolean performFinish() {
118
		final Collection projectDescriptors = getProjectDescriptors();
118
		final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();
119
		
119
		
120
		try {
120
		try {
121
			getContainer().run(true, false, new IRunnableWithProgress() {
121
			getContainer().run(true, false, new IRunnableWithProgress() {
Lines 123-135 Link Here
123
					throws InvocationTargetException, InterruptedException {
123
					throws InvocationTargetException, InterruptedException {
124
					
124
					
125
					WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
125
					WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
126
						@Override
126
						protected void execute(IProgressMonitor m)
127
						protected void execute(IProgressMonitor m)
127
						
128
						
128
							throws CoreException, InvocationTargetException, InterruptedException {
129
							throws CoreException, InvocationTargetException, InterruptedException {
129
							m.beginTask("Unzipping Projects", projectDescriptors.size());
130
							m.beginTask("Unzipping Projects", projectDescriptors.size()); //$NON-NLS-1$
130
							
131
							
131
							for (Iterator i = projectDescriptors.iterator(); i.hasNext();) {
132
							for (ProjectDescriptor desc : projectDescriptors) {
132
								unzipProject((ProjectDescriptor)i.next(), m);
133
								unzipProject(desc, m);
133
								m.worked(1);
134
								m.worked(1);
134
							}
135
							}
135
						}
136
						}
Lines 157-163 Link Here
157
	 * @return The collection of project descriptors that should be
158
	 * @return The collection of project descriptors that should be
158
	 *  unzipped into the workspace.
159
	 *  unzipped into the workspace.
159
	 */
160
	 */
160
	protected abstract Collection getProjectDescriptors();
161
	protected abstract Collection<ProjectDescriptor> getProjectDescriptors();
161
	
162
	
162
	private void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
163
	private void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
163
		String bundleName = descriptor.getBundleName();
164
		String bundleName = descriptor.getBundleName();
Lines 247-253 Link Here
247
			}
248
			}
248
			
249
			
249
			project.open(monitor);
250
			project.open(monitor);
250
			project.refreshLocal(IFile.DEPTH_INFINITE, monitor);
251
			project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
251
			
252
			
252
			// Close and re-open the project to force eclipse to re-evaluate
253
			// Close and re-open the project to force eclipse to re-evaluate
253
			//  any natures that this project has.
254
			//  any natures that this project has.
(-)src/org/eclipse/emf/query/examples/internal/wizard/StatementsExampleWizard.java (-3 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-39 Link Here
30
public class StatementsExampleWizard
30
public class StatementsExampleWizard
31
	extends AbstractExampleWizard {
31
	extends AbstractExampleWizard {
32
	
32
	
33
	protected Collection getProjectDescriptors() {
33
	@Override
34
	protected Collection<ProjectDescriptor> getProjectDescriptors() {
34
		// We need the statements example to be unzipped along with the
35
		// We need the statements example to be unzipped along with the
35
		// EMF library example model, edit and editor examples
36
		// EMF library example model, edit and editor examples
36
		List projects = new ArrayList(4);
37
		List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(4);
37
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
40
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Lines 42-47 Link Here
42
		return projects;
43
		return projects;
43
	}
44
	}
44
	
45
	
46
	@Override
45
	protected void log(Exception e) {
47
	protected void log(Exception e) {
46
		if (e instanceof CoreException) {
48
		if (e instanceof CoreException) {
47
			QueryExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
49
			QueryExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
(-)src/org/eclipse/emf/query/examples/internal/wizard/OCLExampleWizard.java (-3 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-39 Link Here
30
public class OCLExampleWizard
30
public class OCLExampleWizard
31
	extends AbstractExampleWizard {
31
	extends AbstractExampleWizard {
32
	
32
	
33
	protected Collection getProjectDescriptors() {
33
	@Override
34
	protected Collection<ProjectDescriptor> getProjectDescriptors() {
34
		// We need the OCL example to be unzipped along with the
35
		// We need the OCL example to be unzipped along with the
35
		// EMF library example model, edit and editor examples
36
		// EMF library example model, edit and editor examples
36
		List projects = new ArrayList(4);
37
		List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(4);
37
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
40
		projects.add(new ProjectDescriptor("org.eclipse.emf.query.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Lines 42-47 Link Here
42
		return projects;
43
		return projects;
43
	}
44
	}
44
45
46
	@Override
45
	protected void log(Exception e) {
47
	protected void log(Exception e) {
46
		if (e instanceof CoreException) {
48
		if (e instanceof CoreException) {
47
			QueryExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
49
			QueryExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 2-10 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.query.doc;singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.query.doc;singleton:=true
5
Bundle-Version: 1.1.0.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Vendor: %Provider.name
6
Bundle-Vendor: %Provider.name
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.help;bundle-version="[3.2.0,4.0.0)"
8
Require-Bundle: org.eclipse.help;bundle-version="[3.2.0,4.0.0)"
9
Eclipse-LazyStart: true
9
Eclipse-LazyStart: true
10
Bundle-RequiredExecutionEnvironment: J2SE-1.4
10
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)feature.xml (-3 / +3 lines)
Lines 2-8 Link Here
2
<feature
2
<feature
3
      id="org.eclipse.emf.query"
3
      id="org.eclipse.emf.query"
4
      label="%featureName"
4
      label="%featureName"
5
      version="1.1.0.qualifier"
5
      version="1.2.0.qualifier"
6
      provider-name="%providerName"
6
      provider-name="%providerName"
7
      image="modeling32.png">
7
      image="modeling32.png">
8
8
Lines 11-17 Link Here
11
   </description>
11
   </description>
12
12
13
   <copyright url="http://www.eclipse.org/legal/epl-v10.html">
13
   <copyright url="http://www.eclipse.org/legal/epl-v10.html">
14
      Copyright (c) 2005, 2006 IBM Corporation and others.
14
      Copyright (c) 2005, 2007 IBM Corporation and others.
15
All rights reserved.   This program and the accompanying materials
15
All rights reserved.   This program and the accompanying materials
16
are made available under the terms of the Eclipse Public License v1.0
16
are made available under the terms of the Eclipse Public License v1.0
17
which accompanies this distribution, and is available at
17
which accompanies this distribution, and is available at
Lines 29-35 Link Here
29
29
30
   <requires>
30
   <requires>
31
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
31
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
32
      <import plugin="org.eclipse.emf.ecore" version="2.2.0" match="compatible"/>
32
      <import plugin="org.eclipse.emf.ecore" version="2.3.0" match="compatible"/>
33
      <import plugin="com.ibm.icu" version="3.4.3" match="compatible"/>
33
      <import plugin="com.ibm.icu" version="3.4.3" match="compatible"/>
34
   </requires>
34
   </requires>
35
35
(-)feature.xml (-5 / +6 lines)
Lines 18-24 Link Here
18
<feature
18
<feature
19
      id="org.eclipse.emf.query.tests"
19
      id="org.eclipse.emf.query.tests"
20
      label="%featureName"
20
      label="%featureName"
21
      version="1.1.0.qualifier"
21
      version="1.2.0.qualifier"
22
      provider-name="%providerName"
22
      provider-name="%providerName"
23
      image="modeling32.png">
23
      image="modeling32.png">
24
24
Lines 46-55 Link Here
46
   <requires>
46
   <requires>
47
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
47
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
48
      <import plugin="org.junit" version="3.8.1" match="compatible"/>
48
      <import plugin="org.junit" version="3.8.1" match="compatible"/>
49
      <import plugin="org.eclipse.emf.ecore" version="2.2.0" match="compatible"/>
49
      <import plugin="org.eclipse.emf.ecore" version="2.3.0" match="compatible"/>
50
      <import plugin="org.eclipse.emf.query" version="1.0.0" match="greaterOrEqual"/>
50
      <import plugin="org.eclipse.emf.query" version="1.2.0" match="greaterOrEqual"/>
51
      <import plugin="org.eclipse.emf.examples.library" version="2.2.0" match="compatible"/>
51
      <import plugin="org.eclipse.emf.examples.library" version="2.3.0" match="compatible"/>
52
      <import plugin="org.eclipse.emf.query.ocl" version="1.0.0" match="greaterOrEqual"/>
52
      <import plugin="org.eclipse.emf.query.ocl" version="1.1.0" match="greaterOrEqual"/>
53
      <import plugin="org.eclipse.ocl.ecore" version="1.1.0" match="compatible"/>
53
   </requires>
54
   </requires>
54
55
55
   <plugin
56
   <plugin
(-)src/org/eclipse/emf/query/conditions/strings/SubStringValue.java (-7 / +42 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
17
18
package org.eclipse.emf.query.conditions.strings;
18
package org.eclipse.emf.query.conditions.strings;
19
19
20
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
20
import com.ibm.icu.text.Collator;
22
import com.ibm.icu.text.Collator;
21
import com.ibm.icu.text.RuleBasedCollator;
23
import com.ibm.icu.text.RuleBasedCollator;
22
import com.ibm.icu.text.SearchIterator;
24
import com.ibm.icu.text.SearchIterator;
Lines 59-68 Link Here
59
	 * It defaults to being case-sensitive.
61
	 * It defaults to being case-sensitive.
60
	 *    
62
	 *    
61
	 * @param subString The initialization <code>String<code> to see if it is a sub-string of those being evaluated
63
	 * @param subString The initialization <code>String<code> to see if it is a sub-string of those being evaluated
62
	 * @param adpater The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
64
	 * @param adapter The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
63
	 */
65
	 */
64
	public SubStringValue(String subString, StringAdapter adpater) {
66
	public SubStringValue(String subString, StringAdapter adapter) {
65
		this(subString, true, adpater);
67
		this(subString, true, adapter);
68
	}
69
70
	/**
71
	 * A constructor that takes an initialization <code>String<code> to 
72
	 * see if it is a sub-string of those being evaluated and a <code>StringAdapter</code> for  
73
	 * adapting the evaluated object to string before checking them.	 
74
	 * It defaults to being case-sensitive.
75
	 *    
76
	 * @param subString The initialization <code>String<code> to see if it is a sub-string of those being evaluated
77
	 * @param adapter a generic string adapter to use to get a <code>String<code> out of evaluated Objects
78
	 * 
79
	 * @since 1.2
80
	 */
81
	public SubStringValue(String subString, IDataTypeAdapter<String> adapter) {
82
		this(subString, true, adapter);
66
	}
83
	}
67
84
68
	/**
85
	/**
Lines 87-97 Link Here
87
	 *    
104
	 *    
88
	 * @param subString The initialization <code>String<code> to see if it is a sub-string of those being evaluated
105
	 * @param subString The initialization <code>String<code> to see if it is a sub-string of those being evaluated
89
	 * @param caseSensitive A boolean value specifying whether to use case in matching strings
106
	 * @param caseSensitive A boolean value specifying whether to use case in matching strings
90
	 * @param adpater The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
107
	 * @param adapter The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
108
	 */
109
	public SubStringValue(String subString, boolean caseSensitive,
110
		StringAdapter adapter) {
111
		super(subString, caseSensitive, adapter);
112
	}
113
114
	/**
115
	 * A constructor that takes an initialization <code>String<code> to 
116
	 * see if it is a sub-string of those being evaluated, a boolean  
117
	 * flag indicating whether the matching should be case-sensitive or not and
118
	 * and a <code>StringAdapter</code> for adapting the evaluated object to string before checking them.
119
	 *    
120
	 * @param subString The initialization <code>String<code> to see if it is a sub-string of those being evaluated
121
	 * @param caseSensitive A boolean value specifying whether to use case in matching strings
122
	 * @param adapter a generic string adapter to use to get a <code>String<code> out of evaluated Objects
123
	 * 
124
	 * @since 1.2
91
	 */
125
	 */
92
	public SubStringValue(String subString, boolean caseSensitive,
126
	public SubStringValue(String subString, boolean caseSensitive,
93
		StringAdapter adpater) {
127
		IDataTypeAdapter<String> adapter) {
94
		super(subString, caseSensitive, adpater);
128
		super(subString, caseSensitive, adapter);
95
	}
129
	}
96
130
97
	/**
131
	/**
Lines 101-106 Link Here
101
	 * 
135
	 * 
102
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
136
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
103
	 */
137
	 */
138
	@Override
104
	public boolean isSatisfied(String str) {
139
	public boolean isSatisfied(String str) {
105
		StringSearch search = new StringSearch(getString(), str);
140
		StringSearch search = new StringSearch(getString(), str);
106
		
141
		
(-)src/org/eclipse/emf/query/conditions/strings/StringAdapter.java (-2 / +14 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
17
18
package org.eclipse.emf.query.conditions.strings;
18
package org.eclipse.emf.query.conditions.strings;
19
19
20
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
20
/**
22
/**
21
 * An Adapter class to be used to extract from -adapt- the argument object to
23
 * An Adapter class to be used to extract from -adapt- the argument object to
22
 * some
24
 * some
Lines 26-32 Link Here
26
 *  
28
 *  
27
 * @see StringCondition
29
 * @see StringCondition
28
 */
30
 */
29
public abstract class StringAdapter {
31
public abstract class StringAdapter implements IDataTypeAdapter<String> {
30
32
31
	/**
33
	/**
32
	 * The simplest <code>StringAdapter</code> implementation that represents
34
	 * The simplest <code>StringAdapter</code> implementation that represents
Lines 35-43 Link Here
35
	 */
37
	 */
36
	public static final StringAdapter DEFAULT = new StringAdapter() {
38
	public static final StringAdapter DEFAULT = new StringAdapter() {
37
39
40
		@Override
38
		public String getString(Object object) {
41
		public String getString(Object object) {
39
			return (String) object;
42
			return (String) object;
40
		}
43
		}
44
		
45
		@Override
46
		public String adapt(Object value) {
47
			return (String) value;
48
		}
41
	};
49
	};
42
50
43
	/**
51
	/**
Lines 47-51 Link Here
47
	 * @return String the <code>String<code> object representation of the argument object
55
	 * @return String the <code>String<code> object representation of the argument object
48
	 */
56
	 */
49
	public abstract String getString(Object object);
57
	public abstract String getString(Object object);
58
	
59
	public String adapt(Object value) {
60
		return getString(value);
61
	}
50
62
51
}
63
}
(-)src/org/eclipse/emf/query/conditions/strings/StringCondition.java (-7 / +23 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-23 Link Here
17
17
18
package org.eclipse.emf.query.conditions.strings;
18
package org.eclipse.emf.query.conditions.strings;
19
19
20
import org.eclipse.emf.query.conditions.Condition;
20
import org.eclipse.emf.query.conditions.DataTypeCondition;
21
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
22
22
/**
23
/**
23
 * An abstract <code>Condition</code> object that tests for
24
 * An abstract <code>Condition</code> object that tests for
Lines 26-34 Link Here
26
 *
27
 *
27
 */
28
 */
28
public abstract class StringCondition
29
public abstract class StringCondition
29
	extends Condition {
30
	extends DataTypeCondition<String> {
30
31
	private StringAdapter adapter;
32
31
33
	/**
32
	/**
34
	 * Constructs this <code>StringCondition</code> with a
33
	 * Constructs this <code>StringCondition</code> with a
Lines 39-45 Link Here
39
	 * of the argument object when evaluating it.
38
	 * of the argument object when evaluating it.
40
	 */
39
	 */
41
	protected StringCondition(StringAdapter adapter) {
40
	protected StringCondition(StringAdapter adapter) {
42
		this.adapter = adapter;
41
		this(null, adapter);
42
	}
43
44
	/**
45
	 * Constructs this <code>StringCondition</code> with a
46
	 * <code>StringAdapter</code> adapter to adapt argument objects to
47
	 * <code>String<code> objects in order to do the evaluation, and a string
48
	 * to test inputs against.
49
	 *  
50
	 * @param value the value against which to test inputs
51
	 * @param adapter a generic string adapter to use to extract a <code>String<code> representation
52
	 * of the argument object when evaluating it.
53
	 * 
54
	 * @since 1.2
55
	 */
56
	protected StringCondition(String value, IDataTypeAdapter<String> adapter) {
57
		super(value, adapter);
43
	}
58
	}
44
59
45
	/*
60
	/*
Lines 47-54 Link Here
47
	 * 
62
	 * 
48
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
63
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
49
	 */
64
	 */
65
	@Override
50
	public boolean isSatisfied(Object object) {
66
	public boolean isSatisfied(Object object) {
51
		return isSatisfied(adapter.getString(object));
67
		return isSatisfied(adapter.adapt(object));
52
	}
68
	}
53
69
54
	/**
70
	/**
(-)src/org/eclipse/emf/query/conditions/strings/StringLength.java (-7 / +43 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
17
18
package org.eclipse.emf.query.conditions.strings;
18
package org.eclipse.emf.query.conditions.strings;
19
19
20
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
20
/**
22
/**
21
 * A Condition object that tests for
23
 * A Condition object that tests for
22
 * <code>String<code> length values. The arguments being evaluated
24
 * <code>String<code> length values. The arguments being evaluated
Lines 53-62 Link Here
53
	 * for adapting the evaluated object to string before getting their length.
55
	 * for adapting the evaluated object to string before getting their length.
54
	 * 
56
	 * 
55
	 * @param length The int value that the evaluated string length must match
57
	 * @param length The int value that the evaluated string length must match
56
	 * @param adpater The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
58
	 * @param adapter The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
59
	 */
60
	public StringLength(int length, StringAdapter adapter) {
61
		this(length, length, adapter);
62
	}
63
64
	/**
65
	 * A constructor that takes one int argument to test strings' length against
66
	 * and a <code>StringAdapter</code>. It evaluates to <code>true</code>
67
	 * when the evaluated <code>String<code> length equals the length 
68
	 * initialization argument. It uses the argument <code>StringAdapter</code> 
69
	 * for adapting the evaluated object to string before getting their length.
70
	 * 
71
	 * @param length The int value that the evaluated string length must match
72
	 * @param adapter a generic string adapter to use to get a <code>String<code> out of evaluated Objects
73
	 * 
74
	 * @since 1.2
57
	 */
75
	 */
58
	public StringLength(int length, StringAdapter adpater) {
76
	public StringLength(int length, IDataTypeAdapter<String> adapter) {
59
		this(length, length, adpater);
77
		this(length, length, adapter);
60
	}
78
	}
61
79
62
	/**
80
	/**
Lines 83-92 Link Here
83
	 * 
101
	 * 
84
	 * @param lowerBound the int value representing the lower-bound in range testing
102
	 * @param lowerBound the int value representing the lower-bound in range testing
85
	 * @param upperBound the int value representing the upper-bound in range testing
103
	 * @param upperBound the int value representing the upper-bound in range testing
86
	 * @param adpater The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
104
	 * @param adapter The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
105
	 */
106
	public StringLength(int lowerBound, int upperBound, StringAdapter adapter) {
107
		super(adapter);
108
		this.lowerBound = lowerBound;
109
		this.upperBound = upperBound;
110
	}
111
112
	/**
113
	 * A constructor that takes two int arguments representing a range to test
114
	 * strings' length against. It evaluates to <code>true</code> when the
115
	 * evaluated <code>String<code> length is equal to any 
116
	 * these two int values passed or fall in between. It uses the argument <code>StringAdapter</code> 
117
	 * for adapting the evaluated object to string before getting their length.
118
	 * 
119
	 * @param lowerBound the int value representing the lower-bound in range testing
120
	 * @param upperBound the int value representing the upper-bound in range testing
121
	 * @param adapter a generic string adapter to use to get a <code>String<code> out of evaluated Objects
87
	 */
122
	 */
88
	public StringLength(int lowerBound, int upperBound, StringAdapter adpater) {
123
	public StringLength(int lowerBound, int upperBound, IDataTypeAdapter<String> adapter) {
89
		super(adpater);
124
		super(null, adapter);
90
		this.lowerBound = lowerBound;
125
		this.lowerBound = lowerBound;
91
		this.upperBound = upperBound;
126
		this.upperBound = upperBound;
92
	}
127
	}
Lines 96-101 Link Here
96
	 * 
131
	 * 
97
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
132
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
98
	 */
133
	 */
134
	@Override
99
	public boolean isSatisfied(String str) {
135
	public boolean isSatisfied(String str) {
100
		return ((str.length() >= lowerBound) && (str.length() <= upperBound));
136
		return ((str.length() >= lowerBound) && (str.length() <= upperBound));
101
	}
137
	}
(-)src/org/eclipse/emf/query/conditions/strings/StringValue.java (-8 / +27 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
17
18
package org.eclipse.emf.query.conditions.strings;
18
package org.eclipse.emf.query.conditions.strings;
19
19
20
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
20
import com.ibm.icu.text.Normalizer;
22
import com.ibm.icu.text.Normalizer;
21
23
22
/**
24
/**
Lines 29-36 Link Here
29
public class StringValue
31
public class StringValue
30
	extends StringCondition {
32
	extends StringCondition {
31
33
32
	private String string;
33
34
	private boolean caseSensitive;
34
	private boolean caseSensitive;
35
35
36
	/**
36
	/**
Lines 67-78 Link Here
67
	 *    
67
	 *    
68
	 * @param string the initialization <code>String<code> to use for equality testing
68
	 * @param string the initialization <code>String<code> to use for equality testing
69
	 * @param caseSensitive a boolean value specifying whether to use case in matching strings
69
	 * @param caseSensitive a boolean value specifying whether to use case in matching strings
70
	 * @param adpater The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
70
	 * @param adapter The <code>StringAdapter</code> to use to get a <code>String<code> out of evaluated Objects
71
	 */
72
	public StringValue(String string, boolean caseSensitive,
73
		StringAdapter adapter) {
74
		super(string, adapter);
75
		this.caseSensitive = caseSensitive;
76
	}
77
78
	/**
79
	 * A simple constructor that takes an initialization
80
	 * <code>String<code> to match against,
81
	 * a <code>StringAdapter</code> for adapting the evaluated object to string before matching 
82
	 * them and a boolean flag indicating whether the pattern matching 
83
	 * should be case-sensitive or not.	 
84
	 *    
85
	 * @param string the initialization <code>String<code> to use for equality testing
86
	 * @param caseSensitive a boolean value specifying whether to use case in matching strings
87
	 * @param adapter a generic string adapter to use to get a <code>String<code> out of evaluated Objects
88
	 * 
89
	 * @since 1.2
71
	 */
90
	 */
72
	public StringValue(String string, boolean caseSensitive,
91
	public StringValue(String string, boolean caseSensitive,
73
		StringAdapter adpater) {
92
		IDataTypeAdapter<String> adapter) {
74
		super(adpater);
93
		super(string, adapter);
75
		this.string = string;
76
		this.caseSensitive = caseSensitive;
94
		this.caseSensitive = caseSensitive;
77
	}
95
	}
78
96
Lines 81-86 Link Here
81
	 * <code>String<code>. 
99
	 * <code>String<code>. 
82
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
100
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
83
	 */
101
	 */
102
	@Override
84
	public boolean isSatisfied(String str) {
103
	public boolean isSatisfied(String str) {
85
		return Normalizer.compare(
104
		return Normalizer.compare(
86
				getString(), str,
105
				getString(), str,
Lines 106-112 Link Here
106
	 * @return The initialization <code>String<code> that this <code>StringValue</code> condition uses for testing
125
	 * @return The initialization <code>String<code> that this <code>StringValue</code> condition uses for testing
107
	 */
126
	 */
108
	protected final String getString() {
127
	protected final String getString() {
109
		return string;
128
		return value;
110
	}
129
	}
111
130
112
}
131
}
(-)src/org/eclipse/emf/query/conditions/strings/StringRegularExpressionValue.java (-7 / +56 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 19-24 Link Here
19
19
20
import java.util.regex.Pattern;
20
import java.util.regex.Pattern;
21
21
22
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
23
22
/**
24
/**
23
 * A <code>StringValue</code> condition subclass that tests for
25
 * A <code>StringValue</code> condition subclass that tests for
24
 * <code>String<code> using regular expression. 
26
 * <code>String<code> using regular expression. 
Lines 56-67 Link Here
56
	 *            The regular expression pattern to use for matching strings
58
	 *            The regular expression pattern to use for matching strings
57
	 *            when evaluating this <code>StringRegularExpressionValue</code>
59
	 *            when evaluating this <code>StringRegularExpressionValue</code>
58
	 *            condition.
60
	 *            condition.
59
	 * @param adpater
61
	 * @param adapter
60
	 *            The <code>StringAdapter</code> to use to get a
62
	 *            The <code>StringAdapter</code> to use to get a
61
	 *            <code>String<code> out of evaluated Objects
63
	 *            <code>String<code> out of evaluated Objects
62
	 */
64
	 */
63
	public StringRegularExpressionValue(String patternStr, StringAdapter adpater) {
65
	public StringRegularExpressionValue(String patternStr, StringAdapter adapter) {
64
		this(patternStr, true, adpater);
66
		this(patternStr, true, adapter);
67
	}
68
69
	/**
70
	 * A constructor that takes the regular expression to use for matching, and
71
	 * a <code>StringAdapter</code> for adapting the evaluated object to
72
	 * string before matching them. It defaults to being case-sensitive.
73
	 * 
74
	 * @param patternStr
75
	 *            The regular expression pattern to use for matching strings
76
	 *            when evaluating this <code>StringRegularExpressionValue</code>
77
	 *            condition.
78
	 * @param adapter
79
	 *            A generic string adapter to use to get a
80
	 *            <code>String<code> out of evaluated Objects
81
	 *            
82
	 * @since 1.2
83
	 */
84
	public StringRegularExpressionValue(String patternStr, IDataTypeAdapter<String> adapter) {
85
		this(patternStr, true, adapter);
65
	}
86
	}
66
87
67
	/**
88
	/**
Lines 77-89 Link Here
77
	 * @param caseSensitive
98
	 * @param caseSensitive
78
	 *            a boolean value specifying whether to use case in matching
99
	 *            a boolean value specifying whether to use case in matching
79
	 *            strings
100
	 *            strings
80
	 * @param adpater
101
	 * @param adapter
81
	 *            The <code>StringAdapter</code> to use to get a
102
	 *            The <code>StringAdapter</code> to use to get a
82
	 *            <code>String<code> out of evaluated Objects
103
	 *            <code>String<code> out of evaluated Objects
83
	 */
104
	 */
84
	public StringRegularExpressionValue(String patternStr,
105
	public StringRegularExpressionValue(String patternStr,
85
		boolean caseSensitive, StringAdapter adpater) {
106
		boolean caseSensitive, StringAdapter adapter) {
86
		super(patternStr, caseSensitive, adpater);
107
		super(patternStr, caseSensitive, adapter);
108
		pattern = (caseSensitive) ? Pattern.compile(patternStr) : Pattern
109
			.compile(patternStr, Pattern.CASE_INSENSITIVE
110
				| Pattern.UNICODE_CASE);
111
	}
112
113
	/**
114
	 * A constructor that takes the regular expression to use for matching, a
115
	 * <code>StringAdapter</code> for adapting the evaluated object to string
116
	 * before matching them and a boolean flag indicating whether the pattern
117
	 * matching should be case-sensitive or not.
118
	 * 
119
	 * @param patternStr
120
	 *            The regular expression pattern to use for matching strings
121
	 *            when evaluating this <code>StringRegularExpressionValue</code>
122
	 *            condition.
123
	 * @param caseSensitive
124
	 *            a boolean value specifying whether to use case in matching
125
	 *            strings
126
	 * @param adapter
127
	 *            A generic string adapter to use to get a
128
	 *            <code>String<code> out of evaluated Objects
129
	 *            
130
	 * @since 1.2
131
	 */
132
	public StringRegularExpressionValue(String patternStr,
133
		boolean caseSensitive, IDataTypeAdapter<String> adapter) {
134
		super(patternStr, caseSensitive, adapter);
87
		pattern = (caseSensitive) ? Pattern.compile(patternStr) : Pattern
135
		pattern = (caseSensitive) ? Pattern.compile(patternStr) : Pattern
88
			.compile(patternStr, Pattern.CASE_INSENSITIVE
136
			.compile(patternStr, Pattern.CASE_INSENSITIVE
89
				| Pattern.UNICODE_CASE);
137
				| Pattern.UNICODE_CASE);
Lines 95-100 Link Here
95
	 * 
143
	 * 
96
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
144
	 * @see org.eclipse.emf.query.conditions.strings.StringCondition#isSatisfied(java.lang.String)
97
	 */
145
	 */
146
	@Override
98
	public boolean isSatisfied(String str) {
147
	public boolean isSatisfied(String str) {
99
		return getPattern().matcher(str).find();
148
		return getPattern().matcher(str).find();
100
	}
149
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EObjectContainmentFeatureCondition.java (-1 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 65-70 Link Here
65
	 * 
65
	 * 
66
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
66
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
67
	 */
67
	 */
68
	@Override
68
	public boolean isSatisfied(EObject eObject) {
69
	public boolean isSatisfied(EObject eObject) {
69
		return containmentFeature.equals(eObject.eContainingFeature());
70
		return containmentFeature.equals(eObject.eContainingFeature());
70
	}
71
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EObjectStructuralFeatureCondition.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 62-67 Link Here
62
	 * 
62
	 * 
63
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
63
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
64
	 */
64
	 */
65
	@Override
65
	public boolean isSatisfied(EObject eObject) {
66
	public boolean isSatisfied(EObject eObject) {
66
		return getFeatures(eObject.eClass()).contains(feature);
67
		return getFeatures(eObject.eClass()).contains(feature);
67
	}
68
	}
Lines 90-96 Link Here
90
	 *         EClass and are consequently to be used for testing and evaluation
91
	 *         EClass and are consequently to be used for testing and evaluation
91
	 *         of this condition object
92
	 *         of this condition object
92
	 */
93
	 */
93
	protected List getFeatures(EClass eClass) {
94
	protected List<? extends EStructuralFeature> getFeatures(EClass eClass) {
94
		return eClass.getEAllStructuralFeatures();
95
		return eClass.getEAllStructuralFeatures();
95
	}
96
	}
96
97
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EStructuralFeatureValueGetter.java (-8 / +8 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 43-67 Link Here
43
	/**
43
	/**
44
	 * @deprecated Use the singleton provided by {@link #getInstance()}.
44
	 * @deprecated Use the singleton provided by {@link #getInstance()}.
45
	 */
45
	 */
46
	@Deprecated
46
	public EStructuralFeatureValueGetter() {
47
	public EStructuralFeatureValueGetter() {
47
		super();
48
		super();
48
	}
49
	}
49
50
50
	private List getFilteredContents(EObject eObject,
51
	private List<EObject> getFilteredContents(EObject eObject, EObjectCondition filterCondition) {
51
		EObjectCondition filterCondition) {
52
		Iterator<EObject> it = eObject.eContents().iterator();
52
		Iterator it = eObject.eContents().iterator();
53
		if (it.hasNext()) {
53
		if (it.hasNext()) {
54
			EObject eContainedEObject = null;
54
			EObject eContainedEObject = null;
55
			List list = new ArrayList();
55
			List<EObject> list = new ArrayList<EObject>();
56
			do {
56
			do {
57
				eContainedEObject = (EObject) it.next();
57
				eContainedEObject = it.next();
58
				if (filterCondition.isSatisfied(eContainedEObject)) {
58
				if (filterCondition.isSatisfied(eContainedEObject)) {
59
					list.add(eContainedEObject);
59
					list.add(eContainedEObject);
60
				}
60
				}
61
			} while (it.hasNext());
61
			} while (it.hasNext());
62
			return list;
62
			return list;
63
		}
63
		}
64
		return Collections.EMPTY_LIST;
64
		return Collections.emptyList();
65
	}
65
	}
66
66
67
	/*
67
	/*
Lines 70-76 Link Here
70
	 * @see org.eclipse.emf.query.conditions.eobjects.structuralfeatures.IEStructuralFeatureValueGetter#eContents(org.eclipse.emf.ecore.EObject,
70
	 * @see org.eclipse.emf.query.conditions.eobjects.structuralfeatures.IEStructuralFeatureValueGetter#eContents(org.eclipse.emf.ecore.EObject,
71
	 *      org.eclipse.emf.query.conditions.eobjects.EObjectCondition)
71
	 *      org.eclipse.emf.query.conditions.eobjects.EObjectCondition)
72
	 */
72
	 */
73
	public List eContents(EObject eObject, EObjectCondition filterCondition) {
73
	public List<EObject> eContents(EObject eObject, EObjectCondition filterCondition) {
74
		return (filterCondition == null) ? eObject.eContents()
74
		return (filterCondition == null) ? eObject.eContents()
75
			: getFilteredContents(eObject, filterCondition);
75
			: getFilteredContents(eObject, filterCondition);
76
	}
76
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EObjectReferenceValueCondition.java (-3 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 21-27 Link Here
21
21
22
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EReference;
23
import org.eclipse.emf.ecore.EReference;
24
25
import org.eclipse.emf.query.conditions.ConditionPolicy;
24
import org.eclipse.emf.query.conditions.ConditionPolicy;
26
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
25
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
27
import org.eclipse.emf.query.handlers.PruneHandler;
26
import org.eclipse.emf.query.handlers.PruneHandler;
Lines 307-313 Link Here
307
	 * 
306
	 * 
308
	 * @see org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectStructuralFeatureCondition#getFeatures(org.eclipse.emf.ecore.EClass)
307
	 * @see org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectStructuralFeatureCondition#getFeatures(org.eclipse.emf.ecore.EClass)
309
	 */
308
	 */
310
	protected final List getFeatures(EClass eClass) {
309
	@Override
310
	protected final List<EReference> getFeatures(EClass eClass) {
311
		return eClass.getEAllReferences();
311
		return eClass.getEAllReferences();
312
	}
312
	}
313
313
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/IEStructuralFeatureValueGetter.java (-2 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 53-59 Link Here
53
	 * 
53
	 * 
54
	 * @return List The list of children of the argument eObject.
54
	 * @return List The list of children of the argument eObject.
55
	 */
55
	 */
56
	List eContents(EObject eObject, EObjectCondition filterCondition);
56
	List<EObject> eContents(EObject eObject, EObjectCondition filterCondition);
57
57
58
	/**
58
	/**
59
	 * An <code>EStructuralFeature</code>'s value getter.
59
	 * An <code>EStructuralFeature</code>'s value getter.
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EObjectStructuralFeatureValueCondition.java (-5 / +9 lines)
Lines 60-66 Link Here
60
 * <code>EStructuralFeature</code> and the resultant evaluation of this
60
 * <code>EStructuralFeature</code> and the resultant evaluation of this
61
 * condition will be <code>false</code></li>
61
 * condition will be <code>false</code></li>
62
 * 
62
 * 
63
 * <li>If the collection resturned as a value of a multiple-valued
63
 * <li>If the collection returned as a value of a multiple-valued
64
 * <code>EStructuralFeature</code> is empty, then no further evaluation is
64
 * <code>EStructuralFeature</code> is empty, then no further evaluation is
65
 * done on the <code>EStructuralFeature</code> and the resultant evaluation of
65
 * done on the <code>EStructuralFeature</code> and the resultant evaluation of
66
 * this condition will be <code>false</code></li>
66
 * this condition will be <code>false</code></li>
Lines 146-151 Link Here
146
	 * 
146
	 * 
147
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
147
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
148
	 */
148
	 */
149
	@Override
149
	public boolean isSatisfied(EObject eObject) {
150
	public boolean isSatisfied(EObject eObject) {
150
		if (super.isSatisfied(eObject)) {
151
		if (super.isSatisfied(eObject)) {
151
			return featureCondition.isSatisfied(eObject);
152
			return featureCondition.isSatisfied(eObject);
Lines 210-216 Link Here
210
			this.resolve = resolve;
211
			this.resolve = resolve;
211
		}
212
		}
212
213
213
        public boolean isSatisfied(EObject eObject) {
214
        @Override
215
		public boolean isSatisfied(EObject eObject) {
214
            Object featureValue = null;
216
            Object featureValue = null;
215
            if (eObject.eIsSet(feature)) {
217
            if (eObject.eIsSet(feature)) {
216
                featureValue = eStructuralFeatureValueGetter.eGet(eObject,
218
                featureValue = eStructuralFeatureValueGetter.eGet(eObject,
Lines 248-260 Link Here
248
				eStructuralFeatureValueGetter, resolve);
250
				eStructuralFeatureValueGetter, resolve);
249
		}
251
		}
250
252
253
		@Override
251
		public boolean isSatisfied(EObject eObject) {
254
		public boolean isSatisfied(EObject eObject) {
252
			List list = null;
255
			List<?> list = null;
253
			if (eObject.eIsSet(feature)) {
256
			if (eObject.eIsSet(feature)) {
254
				list = (List) eStructuralFeatureValueGetter.eGet(eObject,
257
				list = (List<?>) eStructuralFeatureValueGetter.eGet(eObject,
255
					feature, resolve);
258
					feature, resolve);
256
			} else if (feature.getDefaultValue() != null) {
259
			} else if (feature.getDefaultValue() != null) {
257
				list = (List)feature.getDefaultValue();
260
				list = (List<?>) feature.getDefaultValue();
258
			}
261
			}
259
			
262
			
260
			return (list == null || list.isEmpty()) ? false : policy.isSatisfied(
263
			return (list == null || list.isEmpty()) ? false : policy.isSatisfied(
Lines 282-287 Link Here
282
				policy, feature, eStructuralFeatureValueGetter, resolve);
285
				policy, feature, eStructuralFeatureValueGetter, resolve);
283
		}
286
		}
284
		
287
		
288
		@Override
285
		public boolean isSatisfied(EObject eObject) {
289
		public boolean isSatisfied(EObject eObject) {
286
			if (FeatureMapUtil.isMany(eObject, feature)) {
290
			if (FeatureMapUtil.isMany(eObject, feature)) {
287
				return multipleEvaluator.isSatisfied(eObject);
291
				return multipleEvaluator.isSatisfied(eObject);
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EObjectReferencerCondition.java (-4 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 104-115 Link Here
104
	 * 
104
	 * 
105
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
105
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
106
	 */
106
	 */
107
	@Override
107
	public boolean isSatisfied(EObject eObject) {
108
	public boolean isSatisfied(EObject eObject) {
108
		boolean result = false;
109
		boolean result = false;
109
		EReference eReference = null;
110
		EReference eReference = null;
110
		Iterator it = eObject.eClass().getEAllReferences().iterator();
111
		Iterator<EReference> it = eObject.eClass().getEAllReferences().iterator();
111
		while (it.hasNext() && (result == false)) {
112
		while (it.hasNext() && (result == false)) {
112
			eReference = (EReference) it.next();
113
			eReference = it.next();
113
			
114
			
114
			// We don't consider containment or container EReferences
115
			// We don't consider containment or container EReferences
115
			//  as "referencers." Plus, the EReference must be set
116
			//  as "referencers." Plus, the EReference must be set
Lines 121-127 Link Here
121
					eReference, true);
122
					eReference, true);
122
				
123
				
123
				if (FeatureMapUtil.isMany(eObject, eReference)) {
124
				if (FeatureMapUtil.isMany(eObject, eReference)) {
124
					result = ((Collection) value).contains(referencedEObject);
125
					result = ((Collection<?>) value).contains(referencedEObject);
125
				} else {
126
				} else {
126
					result = referencedEObject.equals(value);
127
					result = referencedEObject.equals(value);
127
				}
128
				}
(-)src/org/eclipse/emf/query/conditions/eobjects/structuralfeatures/EObjectAttributeValueCondition.java (-3 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 21-27 Link Here
21
21
22
import org.eclipse.emf.ecore.EAttribute;
22
import org.eclipse.emf.ecore.EAttribute;
23
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EClass;
24
25
import org.eclipse.emf.query.conditions.Condition;
24
import org.eclipse.emf.query.conditions.Condition;
26
import org.eclipse.emf.query.conditions.ConditionPolicy;
25
import org.eclipse.emf.query.conditions.ConditionPolicy;
27
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
26
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
Lines 271-277 Link Here
271
	 * 
270
	 * 
272
	 * @see org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectStructuralFeatureCondition#getFeatures(org.eclipse.emf.ecore.EClass)
271
	 * @see org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectStructuralFeatureCondition#getFeatures(org.eclipse.emf.ecore.EClass)
273
	 */
272
	 */
274
	protected final List getFeatures(EClass eClass) {
273
	@Override
274
	protected final List<EAttribute> getFeatures(EClass eClass) {
275
		return eClass.getEAllAttributes();
275
		return eClass.getEAllAttributes();
276
	}
276
	}
277
}
277
}
(-)src/org/eclipse/emf/query/conditions/numbers/NumberAdapter.java (-17 / +93 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-44 Link Here
17
17
18
package org.eclipse.emf.query.conditions.numbers;
18
package org.eclipse.emf.query.conditions.numbers;
19
19
20
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
20
/**
22
/**
21
 * An Adapter class to be used to extract from -adapt- the argument object to
23
 * An Adapter class to be used to extract from -adapt- the argument object to
22
 * some numeric value that would later be used in Condition evaluation.
24
 * some numeric value that would later be used in Condition evaluation.
23
 * 
25
 * 
24
 * Clients can subclass it and provide their own implementation
26
 * Clients can subclass it and provide their own implementation.
27
 * <p>
28
 * Since the 1.2 release, this class is no longer abstract and can be used
29
 * as a generic number adapter for all number types.
30
 * </p>
31
 * 
32
 * @param <N> the kind of number to which I adapt input values
25
 * 
33
 * 
26
 * @see NumberCondition
34
 * @see NumberCondition
27
 */
35
 */
28
36
29
public abstract class NumberAdapter {
37
public class NumberAdapter<N extends Number & Comparable<? super N>>
38
	implements IDataTypeAdapter<N> {
30
39
31
	private NumberAdapter() {
40
	/**
32
		//private
41
	 * A default number adapter, that simply assumes that
42
	 * input values are of my number kind and casts them appropriately.
43
	 * Note that the declaration of this default as type Integer actually
44
	 * doesn't matter at all, because the "cast" to (N), in this case (Integer),
45
	 * doesn't actually exist; hence the "unchecked" warning in the default
46
	 * implementation of {@link #adapt(Object)}.
47
	 */
48
	private static final NumberAdapter<?> DEFAULT = new NumberAdapter<Integer>();
49
	
50
	/**
51
	 * Initializes me as a default number adapter, that simply assumes that
52
	 * input values are of my number kind and casts them appropriately.
53
	 * 
54
	 * @since 1.2
55
	 */
56
	public NumberAdapter() {
57
		super();
58
	}
59
	
60
	/**
61
	 * Obtains a default number adapter, that simply assumes that input
62
	 * values are of the required number kind and casts them appropriately.
63
	 * 
64
	 * @since 1.2
65
	 */
66
	@SuppressWarnings("unchecked")
67
	public static <N extends Number & Comparable<? super N>> NumberAdapter<N> getDefault() {
68
		return (NumberAdapter<N>) DEFAULT;
33
	}
69
	}
34
70
35
	/**
71
	/**
36
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
72
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
37
	 * argument object to <code>int</code> values Clients can either use the
73
	 * argument object to <code>int</code> values Clients can either use the
38
	 * default implemantation supplied or have their own.
74
	 * default implementation supplied or have their own.
39
	 */
75
	 */
40
	public static abstract class IntegerAdapter
76
	public static abstract class IntegerAdapter
41
		extends NumberAdapter {
77
		extends NumberAdapter<Integer> {
42
78
43
		/**
79
		/**
44
		 * The simplest <code>IntegerAdapter</code> implementation that
80
		 * The simplest <code>IntegerAdapter</code> implementation that
Lines 47-55 Link Here
47
		 */
83
		 */
48
		public static final IntegerAdapter DEFAULT = new IntegerAdapter() {
84
		public static final IntegerAdapter DEFAULT = new IntegerAdapter() {
49
85
86
			@Override
50
			public int intValue(Object object) {
87
			public int intValue(Object object) {
51
				return ((Integer) object).intValue();
88
				return ((Integer) object).intValue();
52
			}
89
			}
90
			
91
			@Override
92
			public Integer adapt(Object value) {
93
				return (Integer) value;
94
			}
53
		};
95
		};
54
96
55
		/**
97
		/**
Lines 67-76 Link Here
67
	/**
109
	/**
68
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
110
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
69
	 * argument object to <code>double</code> values Clients can either use
111
	 * argument object to <code>double</code> values Clients can either use
70
	 * the default implemantation supplied or have their own.
112
	 * the default implementation supplied or have their own.
71
	 */
113
	 */
72
	public static abstract class DoubleAdapter
114
	public static abstract class DoubleAdapter
73
		extends NumberAdapter {
115
		extends NumberAdapter<Double> {
74
116
75
		/**
117
		/**
76
		 * The simplest <code>DoubleAdapter</code> implementation that
118
		 * The simplest <code>DoubleAdapter</code> implementation that
Lines 79-87 Link Here
79
		 */
121
		 */
80
		public static final DoubleAdapter DEFAULT = new DoubleAdapter() {
122
		public static final DoubleAdapter DEFAULT = new DoubleAdapter() {
81
123
124
			@Override
82
			public double doubleValue(Object object) {
125
			public double doubleValue(Object object) {
83
				return ((Double) object).doubleValue();
126
				return ((Double) object).doubleValue();
84
			}
127
			}
128
			
129
			@Override
130
			public Double adapt(Object value) {
131
				return (Double) value;
132
			}
85
		};
133
		};
86
134
87
		/**
135
		/**
Lines 99-108 Link Here
99
	/**
147
	/**
100
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
148
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
101
	 * argument object to <code>byte</code> values Clients can either use the
149
	 * argument object to <code>byte</code> values Clients can either use the
102
	 * default implemantation supplied or have their own.
150
	 * default implementation supplied or have their own.
103
	 */
151
	 */
104
	public static abstract class ByteAdapter
152
	public static abstract class ByteAdapter
105
		extends NumberAdapter {
153
		extends NumberAdapter<Byte> {
106
154
107
		/**
155
		/**
108
		 * The simplest <code>ByteAdapter</code> implementation that
156
		 * The simplest <code>ByteAdapter</code> implementation that
Lines 111-119 Link Here
111
		 */
159
		 */
112
		public static final ByteAdapter DEFAULT = new ByteAdapter() {
160
		public static final ByteAdapter DEFAULT = new ByteAdapter() {
113
161
162
			@Override
114
			public byte byteValue(Object object) {
163
			public byte byteValue(Object object) {
115
				return ((Byte) object).byteValue();
164
				return ((Byte) object).byteValue();
116
			}
165
			}
166
			
167
			@Override
168
			public Byte adapt(Object value) {
169
				return (Byte) value;
170
			}
117
		};
171
		};
118
172
119
		/**
173
		/**
Lines 131-140 Link Here
131
	/**
185
	/**
132
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
186
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
133
	 * argument object to <code>long</code> values Clients can either use the
187
	 * argument object to <code>long</code> values Clients can either use the
134
	 * default implemantation supplied or have their own.
188
	 * default implementation supplied or have their own.
135
	 */
189
	 */
136
	public static abstract class LongAdapter
190
	public static abstract class LongAdapter
137
		extends NumberAdapter {
191
		extends NumberAdapter<Long> {
138
192
139
		/**
193
		/**
140
		 * The simplest <code>LongAdapter</code> implementation that
194
		 * The simplest <code>LongAdapter</code> implementation that
Lines 143-151 Link Here
143
		 */
197
		 */
144
		public static final LongAdapter DEFAULT = new LongAdapter() {
198
		public static final LongAdapter DEFAULT = new LongAdapter() {
145
199
200
			@Override
146
			public long longValue(Object object) {
201
			public long longValue(Object object) {
147
				return ((Long) object).longValue();
202
				return ((Long) object).longValue();
148
			}
203
			}
204
			
205
			@Override
206
			public Long adapt(Object value) {
207
				return (Long) value;
208
			}
149
		};
209
		};
150
210
151
		/**
211
		/**
Lines 163-172 Link Here
163
	/**
223
	/**
164
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
224
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
165
	 * argument object to <code>float</code> values Clients can either use the
225
	 * argument object to <code>float</code> values Clients can either use the
166
	 * default implemantation supplied or have their own.
226
	 * default implementation supplied or have their own.
167
	 */
227
	 */
168
	public static abstract class FloatAdapter
228
	public static abstract class FloatAdapter
169
		extends NumberAdapter {
229
		extends NumberAdapter<Float> {
170
230
171
		/**
231
		/**
172
		 * The simplest <code>FloatAdapter</code> implementation that
232
		 * The simplest <code>FloatAdapter</code> implementation that
Lines 175-183 Link Here
175
		 */
235
		 */
176
		public static final FloatAdapter DEFAULT = new FloatAdapter() {
236
		public static final FloatAdapter DEFAULT = new FloatAdapter() {
177
237
238
			@Override
178
			public float floatValue(Object object) {
239
			public float floatValue(Object object) {
179
				return ((Float) object).floatValue();
240
				return ((Float) object).floatValue();
180
			}
241
			}
242
			
243
			@Override
244
			public Float adapt(Object value) {
245
				return (Float) value;
246
			}
181
		};
247
		};
182
248
183
		/**
249
		/**
Lines 195-204 Link Here
195
	/**
261
	/**
196
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
262
	 * A subclass of <code>NumberAdapter</code> to be used to adapt an
197
	 * argument object to <code>short</code> values Clients can either use the
263
	 * argument object to <code>short</code> values Clients can either use the
198
	 * default implemantation supplied or have their own.
264
	 * default implementation supplied or have their own.
199
	 */
265
	 */
200
	public static abstract class ShortAdapter
266
	public static abstract class ShortAdapter
201
		extends NumberAdapter {
267
		extends NumberAdapter<Short> {
202
268
203
		/**
269
		/**
204
		 * The simplest <code>ShortAdapter</code> implementation that
270
		 * The simplest <code>ShortAdapter</code> implementation that
Lines 207-215 Link Here
207
		 */
273
		 */
208
		public static final ShortAdapter DEFAULT = new ShortAdapter() {
274
		public static final ShortAdapter DEFAULT = new ShortAdapter() {
209
275
276
			@Override
210
			public short shortValue(Object object) {
277
			public short shortValue(Object object) {
211
				return ((Short) object).shortValue();
278
				return ((Short) object).shortValue();
212
			}
279
			}
280
			
281
			@Override
282
			public Short adapt(Object value) {
283
				return (Short) value;
284
			}
213
		};
285
		};
214
286
215
		/**
287
		/**
Lines 224-227 Link Here
224
		public abstract short shortValue(Object object);
296
		public abstract short shortValue(Object object);
225
	}
297
	}
226
298
299
	@SuppressWarnings("unchecked")
300
	public N adapt(Object value) {
301
		return (N) value;
302
	}
227
}
303
}
(-)src/org/eclipse/emf/query/conditions/numbers/NumberCondition.java (-20 / +120 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-23 Link Here
17
17
18
package org.eclipse.emf.query.conditions.numbers;
18
package org.eclipse.emf.query.conditions.numbers;
19
19
20
import org.eclipse.emf.query.conditions.Condition;
20
import org.eclipse.emf.query.conditions.DataTypeCondition;
21
21
22
/**
22
/**
23
 * A <code>Condition</code> object that tests for numeric arguments. The
23
 * A <code>Condition</code> object that tests for numeric arguments. The
Lines 25-53 Link Here
25
 * a <code>NumberAdapter</code> and then compared to the initialization value
25
 * a <code>NumberAdapter</code> and then compared to the initialization value
26
 * of this <code>NumberCondition</code>. It evaluates to <code>true</code>
26
 * of this <code>NumberCondition</code>. It evaluates to <code>true</code>
27
 * when the values are equal or if the value is within the range of supplied
27
 * when the values are equal or if the value is within the range of supplied
28
 * lower-bound and upper-bound
28
 * lower-bound and upper-bound.
29
 * <p>
30
 * Since the 1.2 release, this class is no longer abstract, serving as a generic
31
 * number condition, applicable to any number type.  Indeed, the nested
32
 * subclasses specific to different precisions are obsolete (though not
33
 * deprecated).
34
 * </p>
35
 * 
36
 * @see 
29
 */
37
 */
30
38
public class NumberCondition<N extends Number & Comparable<? super N>>
31
public abstract class NumberCondition
39
	extends DataTypeCondition<N> {
32
	extends Condition {
33
40
34
	/** The upper bound of a range condition. */
41
	/** The upper bound of a range condition. */
35
	protected Number upperBound;
42
	protected N upperBound;
36
43
37
	/** The lower bound of a range condition. */
44
	/** The lower bound of a range condition. */
38
	protected Number lowerBound;
45
	protected N lowerBound;
39
46
40
	/**
47
	/**
41
	 * Adapts elements to numbers (usually according to some numeric
48
	 * Initializes me with a single number against which to test input
42
	 * {@link org.eclipse.emf.ecore.EAttribute}.
49
	 * values, assuming that they will be numbers of the appropriate kind.
50
	 * 
51
	 * @param number the number to match against input values
52
	 * 
53
	 * @since 1.2
43
	 */
54
	 */
44
	protected NumberAdapter adapter;
55
	public NumberCondition(N number) {
56
		super(number, NumberAdapter.<N>getDefault());
57
		
58
		this.lowerBound = number;
59
		this.upperBound = number;
60
	}
45
61
46
	private NumberCondition(Number lowerBound, Number upperBound,
62
	/**
47
		NumberAdapter adapter) {
63
	 * Initializes me with upper and lower bounds against which to test input
64
	 * values, assuming that they will be numbers of the appropriate kind.
65
	 * 
66
	 * @param lowerBound the lower bound to test
67
	 * @param upperBound the upper bound to test
68
	 * 
69
	 * @since 1.2
70
	 */
71
	public NumberCondition(N lowerBound, N upperBound) {
72
		super(lowerBound, NumberAdapter.<N>getDefault());
73
		
48
		this.lowerBound = lowerBound;
74
		this.lowerBound = lowerBound;
49
		this.upperBound = upperBound;
75
		this.upperBound = upperBound;
50
		this.adapter = adapter;
76
	}
77
78
	/**
79
	 * Initializes me with a single number against which to test input
80
	 * values, and an adapter to convert those inputs to numbers.
81
	 * 
82
	 * @param number the number to match against input values
83
	 * @param adapter to convert input values to the appropriate number kind
84
	 * 
85
	 * @since 1.2
86
	 */
87
	public NumberCondition(N number, NumberAdapter<? extends N> adapter) {
88
		super(number, adapter);
89
		
90
		this.lowerBound = number;
91
		this.upperBound = number;
92
	}
93
94
	/**
95
	 * Initializes me with upper and lower bounds against which to test input
96
	 * values, and an adapter to convert those inputs to numbers.
97
	 * 
98
	 * @param lowerBound the lower bound to test
99
	 * @param upperBound the upper bound to test
100
	 * @param adapter to convert input values to the appropriate number kind
101
	 * 
102
	 * @since 1.2
103
	 */
104
	public NumberCondition(N lowerBound, N upperBound, NumberAdapter<? extends N> adapter) {
105
		super(lowerBound, adapter);
106
		
107
		this.lowerBound = lowerBound;
108
		this.upperBound = upperBound;
109
	}
110
	
111
	/**
112
	 * Obtains a condition checking for values equal to the specified
113
	 * <tt>number</tt>.
114
	 * 
115
	 * @param number a number to check for
116
	 * @return a condition that does the checking
117
	 * 
118
	 * @since 1.2
119
	 */
120
	public static <N extends Number & Comparable<? super N>> NumberCondition<N>
121
	equals(N number) {
122
		return new NumberCondition<N>(number, number);
123
	}
124
	
125
	/**
126
	 * Obtains a condition checking for values in the range to the specified
127
	 * <tt>lowerBound</tt> and <tt>upperBound</tt> (inclusive).
128
	 * 
129
	 * @param lowerBound the lower bound of numbers to check for
130
	 * @param upperBound the upper bound of numbers to check for
131
	 * @return a condition that does the checking
132
	 * 
133
	 * @since 1.2
134
	 */
135
	public static <N extends Number & Comparable<? super N>> NumberCondition<N>
136
	between(N lowerBound, N upperBound) {
137
		return new NumberCondition<N>(lowerBound, upperBound);
51
	}
138
	}
52
139
53
	/**
140
	/**
Lines 56-62 Link Here
56
	 * or have their own.
143
	 * or have their own.
57
	 */
144
	 */
58
	public static class IntegerValue
145
	public static class IntegerValue
59
		extends NumberCondition {
146
		extends NumberCondition<Integer> {
60
147
61
		/**
148
		/**
62
		 * A simple constructor, it takes only one <code>Integer</code>
149
		 * A simple constructor, it takes only one <code>Integer</code>
Lines 135-140 Link Here
135
		 * 
222
		 * 
136
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
223
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
137
		 */
224
		 */
225
		@Override
138
		public boolean isSatisfied(Object object) {
226
		public boolean isSatisfied(Object object) {
139
			return isSatisfied(((NumberAdapter.IntegerAdapter) adapter)
227
			return isSatisfied(((NumberAdapter.IntegerAdapter) adapter)
140
				.intValue(object));
228
				.intValue(object));
Lines 148-154 Link Here
148
	 * their own.
236
	 * their own.
149
	 */
237
	 */
150
	public static class ByteValue
238
	public static class ByteValue
151
		extends NumberCondition {
239
		extends NumberCondition<Byte> {
152
240
153
		/**
241
		/**
154
		 * A simple constructor, it takes only one <code>Byte</code> argument
242
		 * A simple constructor, it takes only one <code>Byte</code> argument
Lines 225-230 Link Here
225
		 * 
313
		 * 
226
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
314
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
227
		 */
315
		 */
316
		@Override
228
		public boolean isSatisfied(Object object) {
317
		public boolean isSatisfied(Object object) {
229
			return isSatisfied(((NumberAdapter.ByteAdapter) adapter)
318
			return isSatisfied(((NumberAdapter.ByteAdapter) adapter)
230
				.byteValue(object));
319
				.byteValue(object));
Lines 237-243 Link Here
237
	 * or have their own.
326
	 * or have their own.
238
	 */
327
	 */
239
	public static class DoubleValue
328
	public static class DoubleValue
240
		extends NumberCondition {
329
		extends NumberCondition<Double> {
241
330
242
		/**
331
		/**
243
		 * A simple constructor, it takes only one <code>Double</code>
332
		 * A simple constructor, it takes only one <code>Double</code>
Lines 316-321 Link Here
316
		 * 
405
		 * 
317
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
406
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
318
		 */
407
		 */
408
		@Override
319
		public boolean isSatisfied(Object object) {
409
		public boolean isSatisfied(Object object) {
320
			return isSatisfied(((NumberAdapter.DoubleAdapter) adapter)
410
			return isSatisfied(((NumberAdapter.DoubleAdapter) adapter)
321
				.doubleValue(object));
411
				.doubleValue(object));
Lines 328-334 Link Here
328
	 * their own.
418
	 * their own.
329
	 */
419
	 */
330
	public static class FloatValue
420
	public static class FloatValue
331
		extends NumberCondition {
421
		extends NumberCondition<Float> {
332
422
333
		/**
423
		/**
334
		 * A simple constructor, it takes only one Float argument which means in
424
		 * A simple constructor, it takes only one Float argument which means in
Lines 407-412 Link Here
407
		 * 
497
		 * 
408
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
498
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
409
		 */
499
		 */
500
		@Override
410
		public boolean isSatisfied(Object object) {
501
		public boolean isSatisfied(Object object) {
411
			return isSatisfied(((NumberAdapter.FloatAdapter) adapter)
502
			return isSatisfied(((NumberAdapter.FloatAdapter) adapter)
412
				.floatValue(object));
503
				.floatValue(object));
Lines 419-425 Link Here
419
	 * their own.
510
	 * their own.
420
	 */
511
	 */
421
	public static class LongValue
512
	public static class LongValue
422
		extends NumberCondition {
513
		extends NumberCondition<Long> {
423
514
424
		/**
515
		/**
425
		 * A simple constructor, it takes only one Long argument which means in
516
		 * A simple constructor, it takes only one Long argument which means in
Lines 496-501 Link Here
496
		 * 
587
		 * 
497
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
588
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
498
		 */
589
		 */
590
		@Override
499
		public boolean isSatisfied(Object object) {
591
		public boolean isSatisfied(Object object) {
500
			return isSatisfied(((NumberAdapter.LongAdapter) adapter)
592
			return isSatisfied(((NumberAdapter.LongAdapter) adapter)
501
				.longValue(object));
593
				.longValue(object));
Lines 508-514 Link Here
508
	 * their own.
600
	 * their own.
509
	 */
601
	 */
510
	public static class ShortValue
602
	public static class ShortValue
511
		extends NumberCondition {
603
		extends NumberCondition<Short> {
512
604
513
		/**
605
		/**
514
		 * A simple constructor, it takes only one Short argument which means in
606
		 * A simple constructor, it takes only one Short argument which means in
Lines 586-591 Link Here
586
		 * 
678
		 * 
587
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
679
		 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
588
		 */
680
		 */
681
		@Override
589
		public boolean isSatisfied(Object object) {
682
		public boolean isSatisfied(Object object) {
590
			return isSatisfied(((NumberAdapter.ShortAdapter) adapter)
683
			return isSatisfied(((NumberAdapter.ShortAdapter) adapter)
591
				.shortValue(object));
684
				.shortValue(object));
Lines 747-750 Link Here
747
		return (shortValue >= lowerBound.shortValue())
840
		return (shortValue >= lowerBound.shortValue())
748
			&& (shortValue <= upperBound.shortValue());
841
			&& (shortValue <= upperBound.shortValue());
749
	}
842
	}
843
	
844
	@Override
845
	public boolean isSatisfied(Object object) {
846
		N number = adapter.adapt(object);
847
		return (lowerBound.compareTo(number) <= 0)
848
			&& (upperBound.compareTo(number) >= 0);
849
	}
750
}
850
}
(-)src/org/eclipse/emf/query/internal/util/TypeRelationChecker.java (-17 / +27 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 31-56 Link Here
31
 */
31
 */
32
public abstract class TypeRelationChecker {	
32
public abstract class TypeRelationChecker {	
33
33
34
	private static final Map typesRelationsMaps = new WeakHashMap();	
34
	private static final Map<EClass, Map<TypeRelation, Map<EClass, Boolean>>>
35
	typesRelationsMaps = new WeakHashMap<EClass, Map<TypeRelation,Map<EClass,Boolean>>>();	
35
36
36
	private static Map getTypeRelationsCacheMap(EClass type,
37
	private static Map<EClass, Boolean> getTypeRelationsCacheMap(EClass type,
37
		TypeRelation relationKind) {
38
		TypeRelation relationKind) {
38
		return getTypeMap(typesRelationsMaps, type, relationKind);
39
		return getTypeMap(typesRelationsMaps, type, relationKind);
39
	}
40
	}
40
41
41
	private static Map getTypeMap(Map typesMaps, EClass type,
42
	private static Map<EClass, Boolean> getTypeMap(
43
		Map<EClass, Map<TypeRelation, Map<EClass, Boolean>>> typesMaps,
44
		EClass type,
42
		TypeRelation relationKind) {
45
		TypeRelation relationKind) {
43
		Map map = null;
46
		
44
		Map maps = (Map) typesMaps.get(type);
47
		Map<EClass, Boolean> map = null;
48
		Map<TypeRelation, Map<EClass, Boolean>> maps = typesMaps.get(type);
45
		if (maps == null) {
49
		if (maps == null) {
46
			maps = new WeakHashMap();
50
			maps = new WeakHashMap<TypeRelation, Map<EClass,Boolean>>();
47
			typesMaps.put(type, maps);
51
			typesMaps.put(type, maps);
48
			map = new WeakHashMap();
52
			map = new WeakHashMap<EClass, Boolean>();
49
			maps.put(relationKind, map);
53
			maps.put(relationKind, map);
50
		} else {
54
		} else {
51
			map = (Map) maps.get(relationKind);
55
			map = maps.get(relationKind);
52
			if (map == null) {
56
			if (map == null) {
53
				map = new WeakHashMap();
57
				map = new WeakHashMap<EClass, Boolean>();
54
				maps.put(relationKind, map);
58
				maps.put(relationKind, map);
55
			}
59
			}
56
		}
60
		}
Lines 61-67 Link Here
61
	private EClass type;
65
	private EClass type;
62
66
63
	private TypeRelation relationKind;
67
	private TypeRelation relationKind;
64
	private Map typeRelationsCache;
68
	private Map<EClass, Boolean> typeRelationsCache;
65
69
66
	private TypeRelationChecker(EClass type, TypeRelation relationKind) {
70
	private TypeRelationChecker(EClass type, TypeRelation relationKind) {
67
		if (type == null || relationKind == null) {
71
		if (type == null || relationKind == null) {
Lines 81-87 Link Here
81
	 * 
85
	 * 
82
	 * @return the cache
86
	 * @return the cache
83
	 */
87
	 */
84
	protected final Map getRelationsCache() {
88
	protected final Map<EClass, Boolean> getRelationsCache() {
85
		return typeRelationsCache;
89
		return typeRelationsCache;
86
	}
90
	}
87
91
Lines 111-121 Link Here
111
	 * @return whether it relates as required to the checker's type
115
	 * @return whether it relates as required to the checker's type
112
	 */
116
	 */
113
	public boolean isTypeRelationOK(EClass eClass) {
117
	public boolean isTypeRelationOK(EClass eClass) {
114
		Boolean checked = (Boolean) getRelationsCache().get(eClass);
118
		Boolean checked = getRelationsCache().get(eClass);
115
		if (checked == null) {
119
		if (checked == null) {
116
			boolean result = checkRelation(eClass);
120
			boolean result = checkRelation(eClass);
117
			getRelationsCache().put(eClass,
121
			getRelationsCache().put(eClass, result);
118
				(result) ? Boolean.TRUE : Boolean.FALSE);
119
			return result;
122
			return result;
120
		}
123
		}
121
		return checked.booleanValue();
124
		return checked.booleanValue();
Lines 182-194 Link Here
182
	private static class BaseTypeRelationChecker
185
	private static class BaseTypeRelationChecker
183
		extends TypeRelationChecker {
186
		extends TypeRelationChecker {
184
187
185
		private List allSuperTypes;
188
		private List<EClass> allSuperTypes;
186
189
187
		BaseTypeRelationChecker(EClass type) {
190
		BaseTypeRelationChecker(EClass type) {
188
			super(type, TypeRelation.BASETYPE_LITERAL);
191
			super(type, TypeRelation.BASETYPE_LITERAL);
189
			allSuperTypes = type.getEAllSuperTypes();
192
			allSuperTypes = type.getEAllSuperTypes();
190
		}
193
		}
191
194
195
		@Override
192
		protected boolean checkRelation(EClass type) {
196
		protected boolean checkRelation(EClass type) {
193
			return allSuperTypes.contains(type);
197
			return allSuperTypes.contains(type);
194
		}
198
		}
Lines 198-210 Link Here
198
	private static class DirectBaseTypeRelationChecker
202
	private static class DirectBaseTypeRelationChecker
199
		extends TypeRelationChecker {
203
		extends TypeRelationChecker {
200
204
201
		private List directSuperTypes;
205
		private List<EClass> directSuperTypes;
202
206
203
		DirectBaseTypeRelationChecker(EClass type) {
207
		DirectBaseTypeRelationChecker(EClass type) {
204
			super(type, TypeRelation.DIRECT_BASETYPE_LITERAL);
208
			super(type, TypeRelation.DIRECT_BASETYPE_LITERAL);
205
			directSuperTypes = type.getESuperTypes();
209
			directSuperTypes = type.getESuperTypes();
206
		}
210
		}
207
211
212
		@Override
208
		protected boolean checkRelation(EClass type) {
213
		protected boolean checkRelation(EClass type) {
209
			return directSuperTypes.contains(type);
214
			return directSuperTypes.contains(type);
210
		}
215
		}
Lines 218-223 Link Here
218
			super(type, TypeRelation.DIRECT_SUBTYPE_LITERAL);
223
			super(type, TypeRelation.DIRECT_SUBTYPE_LITERAL);
219
		}
224
		}
220
225
226
		@Override
221
		protected boolean checkRelation(EClass type) {
227
		protected boolean checkRelation(EClass type) {
222
			return type.getESuperTypes().contains(getType());
228
			return type.getESuperTypes().contains(getType());
223
		}
229
		}
Lines 231-236 Link Here
231
			super(type, TypeRelation.SAMETYPE_LITERAL);
237
			super(type, TypeRelation.SAMETYPE_LITERAL);
232
		}
238
		}
233
239
240
		@Override
234
		protected boolean checkRelation(EClass type) {
241
		protected boolean checkRelation(EClass type) {
235
			return getType().equals(type);
242
			return getType().equals(type);
236
		}
243
		}
Lines 244-249 Link Here
244
			super(type, TypeRelation.SUBTYPE_LITERAL);
251
			super(type, TypeRelation.SUBTYPE_LITERAL);
245
		}
252
		}
246
253
254
		@Override
247
		protected boolean checkRelation(EClass type) {
255
		protected boolean checkRelation(EClass type) {
248
			return type.getEAllSuperTypes().contains(getType());
256
			return type.getEAllSuperTypes().contains(getType());
249
		}
257
		}
Lines 261-266 Link Here
261
			this.typeRelationCheckers = typeRelationCheckers;
269
			this.typeRelationCheckers = typeRelationCheckers;
262
		}
270
		}
263
271
272
		@Override
264
		protected boolean checkRelation(EClass type) {
273
		protected boolean checkRelation(EClass type) {
265
			for (int i = 0; i < typeRelationCheckers.length; ++i) {
274
			for (int i = 0; i < typeRelationCheckers.length; ++i) {
266
				if (typeRelationCheckers[i].isTypeRelationOK(type)) {
275
				if (typeRelationCheckers[i].isTypeRelationOK(type)) {
Lines 294-299 Link Here
294
			checker = new RelatedTypeRelationChecker(type);
303
			checker = new RelatedTypeRelationChecker(type);
295
		}
304
		}
296
305
306
		@Override
297
		protected boolean checkRelation(EClass type) {
307
		protected boolean checkRelation(EClass type) {
298
			return !checker.checkRelation(type);
308
			return !checker.checkRelation(type);
299
		}
309
		}
(-)src/org/eclipse/emf/query/conditions/eobjects/EObjectTypeRelationCondition.java (-4 / +7 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 24-30 Link Here
24
import org.eclipse.emf.query.internal.util.TypeRelationChecker;
24
import org.eclipse.emf.query.internal.util.TypeRelationChecker;
25
25
26
/**
26
/**
27
 * An <code>EObjectCondition</code> specilaization to be used for evaluating
27
 * An <code>EObjectCondition</code> specialization to be used for evaluating
28
 * the inheritance/type relationship of an <code>EObject</code> to another
28
 * the inheritance/type relationship of an <code>EObject</code> to another
29
 * using the EObjects' EClasses. For example it could be used to find if a given
29
 * using the EObjects' EClasses. For example it could be used to find if a given
30
 * <code>EObject</code> is a subtype/supertype of another <code>EObject</code>.
30
 * <code>EObject</code> is a subtype/supertype of another <code>EObject</code>.
Lines 36-46 Link Here
36
36
37
	/**
37
	/**
38
	 * A constant <code>EObjectTypeRelationCondition</code> object used to
38
	 * A constant <code>EObjectTypeRelationCondition</code> object used to
39
	 * indicate that the type relatioship is undefined and hence it is always
39
	 * indicate that the type relationship is undefined and hence it is always
40
	 * satisfied.
40
	 * satisfied.
41
	 */
41
	 */
42
	public static final EObjectTypeRelationCondition UNDEFINED = new EObjectTypeRelationCondition() {
42
	public static final EObjectTypeRelationCondition UNDEFINED =
43
		new EObjectTypeRelationCondition() {
43
44
45
		@Override
44
		public boolean isSatisfied(EObject eObject) {
46
		public boolean isSatisfied(EObject eObject) {
45
			return true;
47
			return true;
46
		}
48
		}
Lines 130-135 Link Here
130
	 * 
132
	 * 
131
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
133
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
132
	 */
134
	 */
135
	@Override
133
	public boolean isSatisfied(EObject eObject) {
136
	public boolean isSatisfied(EObject eObject) {
134
		return typeRelationChecker.isTypeRelationOK(eObject.eClass());
137
		return typeRelationChecker.isTypeRelationOK(eObject.eClass());
135
	}
138
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/EObjectCondition.java (-6 / +21 lines)
Lines 55-60 Link Here
55
	 */
55
	 */
56
	public static final EObjectCondition E_TRUE = new EObjectCondition() {
56
	public static final EObjectCondition E_TRUE = new EObjectCondition() {
57
57
58
		@Override
58
		public boolean isSatisfied(EObject object) {
59
		public boolean isSatisfied(EObject object) {
59
			return true;
60
			return true;
60
		}
61
		}
Lines 67-72 Link Here
67
	public static final EObjectCondition E_FALSE = new EObjectCondition(
68
	public static final EObjectCondition E_FALSE = new EObjectCondition(
68
		PruneHandler.ALWAYS) {
69
		PruneHandler.ALWAYS) {
69
70
71
		@Override
70
		public boolean isSatisfied(EObject object) {
72
		public boolean isSatisfied(EObject object) {
71
			return false;
73
			return false;
72
		}
74
		}
Lines 75-91 Link Here
75
	private PruneHandler pruneHandler;
77
	private PruneHandler pruneHandler;
76
78
77
	/**
79
	/**
78
	 * A simple constructor. It defaults to using the PruneHandler.NEVER
80
	 * A simple constructor. It defaults to using the PruneHandler.NEVER and
81
	 * matches any {@link EObject}.
79
	 * 
82
	 * 
80
	 * @see org.eclipse.emf.query.handlers.PruneHandler
83
	 * @see org.eclipse.emf.query.handlers.PruneHandler
81
	 */
84
	 */
82
	protected EObjectCondition() {
85
	public EObjectCondition() {
83
		this(PruneHandler.NEVER);
86
		this(PruneHandler.NEVER);
84
	}
87
	}
85
88
86
	/**
89
	/**
87
	 * A constructor that takes in a <code>PruneHandler</code> instaince to
90
	 * A constructor that takes in a <code>PruneHandler</code> instance to
88
	 * use for pruning
91
	 * use for pruning.  This constructor will match any kind of {@link EObject},
92
	 * so it is only safe for conditions with <tt>E == EObject</tt>.
89
	 * 
93
	 * 
90
	 * @param pruneHandler
94
	 * @param pruneHandler
91
	 *            The <code>PruneHandler</code> to use for pruning
95
	 *            The <code>PruneHandler</code> to use for pruning
Lines 125-130 Link Here
125
	 * 
129
	 * 
126
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
130
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
127
	 */
131
	 */
132
	@Override
128
	public boolean isSatisfied(Object object) {
133
	public boolean isSatisfied(Object object) {
129
		if (object instanceof EObject) {
134
		if (object instanceof EObject) {
130
			return isSatisfied((EObject) object);
135
			return isSatisfied((EObject) object);
Lines 160-165 Link Here
160
			super(condition);
165
			super(condition);
161
		}
166
		}
162
167
168
		@Override
163
		public boolean isSatisfied(EObject eObject) {
169
		public boolean isSatisfied(EObject eObject) {
164
			return EObjectCondition.this.isSatisfied(eObject)
170
			return EObjectCondition.this.isSatisfied(eObject)
165
				&& condition.isSatisfied(eObject);
171
				&& condition.isSatisfied(eObject);
Lines 169-174 Link Here
169
		 * Prunes if and only if either of the <code>and</code>ed conditions
175
		 * Prunes if and only if either of the <code>and</code>ed conditions
170
		 * would prune.
176
		 * would prune.
171
		 */
177
		 */
178
		@Override
172
		public boolean shouldPrune(EObject eObject) {
179
		public boolean shouldPrune(EObject eObject) {
173
			return EObjectCondition.this.shouldPrune(eObject)
180
			return EObjectCondition.this.shouldPrune(eObject)
174
				|| condition.shouldPrune(eObject);
181
				|| condition.shouldPrune(eObject);
Lines 182-187 Link Here
182
			super(condition);
189
			super(condition);
183
		}
190
		}
184
191
192
		@Override
185
		public boolean isSatisfied(EObject eObject) {
193
		public boolean isSatisfied(EObject eObject) {
186
			return EObjectCondition.this.isSatisfied(eObject)
194
			return EObjectCondition.this.isSatisfied(eObject)
187
				|| condition.isSatisfied(eObject);
195
				|| condition.isSatisfied(eObject);
Lines 191-196 Link Here
191
		 * Prunes if and only if both of the <code>or</code>ed conditions
199
		 * Prunes if and only if both of the <code>or</code>ed conditions
192
		 * would prune.
200
		 * would prune.
193
		 */
201
		 */
202
		@Override
194
		public boolean shouldPrune(EObject eObject) {
203
		public boolean shouldPrune(EObject eObject) {
195
			return EObjectCondition.this.shouldPrune(eObject)
204
			return EObjectCondition.this.shouldPrune(eObject)
196
				&& condition.shouldPrune(eObject);
205
				&& condition.shouldPrune(eObject);
Lines 204-209 Link Here
204
			super(condition);
213
			super(condition);
205
		}
214
		}
206
215
216
		@Override
207
		public boolean isSatisfied(EObject eObject) {
217
		public boolean isSatisfied(EObject eObject) {
208
			return EObjectCondition.this.isSatisfied(eObject)
218
			return EObjectCondition.this.isSatisfied(eObject)
209
				^ condition.isSatisfied(eObject);
219
				^ condition.isSatisfied(eObject);
Lines 214-219 Link Here
214
		 * Prunes if and only if both of the <code>xor</code>ed conditions
224
		 * Prunes if and only if both of the <code>xor</code>ed conditions
215
		 * would prune.
225
		 * would prune.
216
		 */
226
		 */
227
		@Override
217
		public boolean shouldPrune(EObject eObject) {
228
		public boolean shouldPrune(EObject eObject) {
218
			return EObjectCondition.this.shouldPrune(eObject)
229
			return EObjectCondition.this.shouldPrune(eObject)
219
				&& condition.shouldPrune(eObject);
230
				&& condition.shouldPrune(eObject);
Lines 227-232 Link Here
227
			super(condition);
238
			super(condition);
228
		}
239
		}
229
240
241
		@Override
230
		public boolean isSatisfied(EObject eObject) {
242
		public boolean isSatisfied(EObject eObject) {
231
			return (!(EObjectCondition.this.isSatisfied(eObject)))
243
			return (!(EObjectCondition.this.isSatisfied(eObject)))
232
				|| condition.isSatisfied(eObject);
244
				|| condition.isSatisfied(eObject);
Lines 235-240 Link Here
235
		/**
247
		/**
236
		 * Never prunes.
248
		 * Never prunes.
237
		 */
249
		 */
250
		@Override
238
		public boolean shouldPrune(EObject eObject) {
251
		public boolean shouldPrune(EObject eObject) {
239
			return false;
252
			return false;
240
		}
253
		}
Lines 247-252 Link Here
247
			super(condition);
260
			super(condition);
248
		}
261
		}
249
262
263
		@Override
250
		public boolean isSatisfied(EObject eObject) {
264
		public boolean isSatisfied(EObject eObject) {
251
			return EObjectCondition.this.isSatisfied(eObject) == condition
265
			return EObjectCondition.this.isSatisfied(eObject) == condition
252
				.isSatisfied(eObject);
266
				.isSatisfied(eObject);
Lines 255-260 Link Here
255
		/**
269
		/**
256
		 * Never prunes.
270
		 * Never prunes.
257
		 */
271
		 */
272
		@Override
258
		public boolean shouldPrune(EObject eObject) {
273
		public boolean shouldPrune(EObject eObject) {
259
			return false;
274
			return false;
260
		}
275
		}
Lines 290-296 Link Here
290
	 * <code>EObjectCondition</code> and the argument
305
	 * <code>EObjectCondition</code> and the argument
291
	 * <code>EObjectCondition</code>. The returned
306
	 * <code>EObjectCondition</code>. The returned
292
	 * <code>EObjectCondition</code> is a newly created
307
	 * <code>EObjectCondition</code> is a newly created
293
	 * <code>EObjectCondition</code> which is satisified if either of its
308
	 * <code>EObjectCondition</code> which is satisfied if either of its
294
	 * constituent <code>EObjectCondition</code> is. Please note that the
309
	 * constituent <code>EObjectCondition</code> is. Please note that the
295
	 * newly compounded <code>EObjectCondition</code> will evaluate this
310
	 * newly compounded <code>EObjectCondition</code> will evaluate this
296
	 * <code>EObjectCondition</code> first, and if the result is
311
	 * <code>EObjectCondition</code> first, and if the result is
Lines 320-326 Link Here
320
	 * <code>EObjectCondition</code> and the argument
335
	 * <code>EObjectCondition</code> and the argument
321
	 * <code>EObjectCondition</code>. The returned
336
	 * <code>EObjectCondition</code>. The returned
322
	 * <code>EObjectCondition</code> is a newly created
337
	 * <code>EObjectCondition</code> is a newly created
323
	 * <code>EObjectCondition</code> which is satisified if XORing its
338
	 * <code>EObjectCondition</code> which is satisfied if XORing its
324
	 * constituent <code>EObjectCondition</code> is.
339
	 * constituent <code>EObjectCondition</code> is.
325
	 * 
340
	 * 
326
	 * @param condition
341
	 * @param condition
(-)src/org/eclipse/emf/query/conditions/eobjects/IN.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 38-44 Link Here
38
	 *            The set of EObjects to check if they contain amongst them some
38
	 *            The set of EObjects to check if they contain amongst them some
39
	 *            other <code>EObject</code>
39
	 *            other <code>EObject</code>
40
	 */
40
	 */
41
	public IN(Set eObjects) {
41
	public IN(Set<? extends EObject> eObjects) {
42
		this(new EObjectSource(eObjects));
42
		this(new EObjectSource(eObjects));
43
	}
43
	}
44
44
Lines 72-77 Link Here
72
	 * 
72
	 * 
73
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
73
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
74
	 */
74
	 */
75
	@Override
75
	public boolean isSatisfied(EObject eObject) {
76
	public boolean isSatisfied(EObject eObject) {
76
		return eObjectSource.getEObjects().contains(eObject);
77
		return eObjectSource.getEObjects().contains(eObject);
77
	}
78
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/ENot.java (-1 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 43-48 Link Here
43
	/**
43
	/**
44
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(java.lang.Object)
44
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(java.lang.Object)
45
	 */
45
	 */
46
	@Override
46
	public boolean isSatisfied(Object object) {
47
	public boolean isSatisfied(Object object) {
47
		return !(condition.isSatisfied(object));
48
		return !(condition.isSatisfied(object));
48
	}
49
	}
Lines 52-57 Link Here
52
	 * 
53
	 * 
53
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
54
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
54
	 */
55
	 */
56
	@Override
55
	public boolean isSatisfied(EObject eObject) {
57
	public boolean isSatisfied(EObject eObject) {
56
		return !(condition.isSatisfied(eObject));
58
		return !(condition.isSatisfied(eObject));
57
	}
59
	}
Lines 61-66 Link Here
61
	 * 
63
	 * 
62
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#shouldPrune(org.eclipse.emf.ecore.EObject)
64
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#shouldPrune(org.eclipse.emf.ecore.EObject)
63
	 */
65
	 */
66
	@Override
64
	public boolean shouldPrune(EObject eObject) {
67
	public boolean shouldPrune(EObject eObject) {
65
		return false;
68
		return false;
66
	}
69
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/TypeRelation.java (-51 / +45 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-47 Link Here
17
17
18
package org.eclipse.emf.query.conditions.eobjects;
18
package org.eclipse.emf.query.conditions.eobjects;
19
19
20
import java.util.ArrayList;
21
import java.util.Collections;
20
import java.util.Collections;
22
import java.util.List;
21
import java.util.List;
23
22
24
import org.eclipse.emf.common.util.AbstractEnumerator;
23
import org.eclipse.emf.common.util.Enumerator;
25
24
26
/**
25
/**
27
 * An enumerator for the kinds of relatioships between EClasses/types. It is
26
 * An enumerator for the kinds of relationships between EClasses/types. It is
28
 * primarily used by <code>EObjectTypeRelationCondition</code> to check for
27
 * primarily used by <code>EObjectTypeRelationCondition</code> to check for
29
 * relations between EObjects
28
 * relations between EObjects
30
 */
29
 */
31
public final class TypeRelation
30
public enum TypeRelation
32
	extends AbstractEnumerator {
31
	implements Enumerator {
33
34
	private static int valueCounter;
35
36
	private static final List values = new ArrayList();
37
32
38
	/**
33
	/**
39
	 * A <code>TypeRelation</code> enumeration literal used to denote an
34
	 * A <code>TypeRelation</code> enumeration literal used to denote an
40
	 * undefined relationship between two types which means the two types could
35
	 * undefined relationship between two types which means the two types could
41
	 * or could not be related at all.
36
	 * or could not be related at all.
42
	 */
37
	 */
43
	public static final TypeRelation UNDEFINED_LITERAL = new TypeRelation(
38
	UNDEFINED_LITERAL("UNDEFINED"), //$NON-NLS-1$
44
		"UNDEFINED"); //$NON-NLS-1$
45
39
46
	/**
40
	/**
47
	 * A <code>TypeRelation</code> enumeration literal used to denote the
41
	 * A <code>TypeRelation</code> enumeration literal used to denote the
Lines 49-56 Link Here
49
	 * this relationship, in other words, either type could be a parent of
43
	 * this relationship, in other words, either type could be a parent of
50
	 * another, or they could be the same.
44
	 * another, or they could be the same.
51
	 */
45
	 */
52
	public static final TypeRelation RELATED_TYPE_LITERAL = new TypeRelation(
46
	RELATED_TYPE_LITERAL("RELATED_TYPE"), //$NON-NLS-1$
53
		"RELATED_TYPE"); //$NON-NLS-1$
54
47
55
	/**
48
	/**
56
	 * A <code>TypeRelation</code> enumeration literal used to denote the
49
	 * A <code>TypeRelation</code> enumeration literal used to denote the
Lines 58-128 Link Here
58
	 * this relationship, in other words, either type should not be a parent of
51
	 * this relationship, in other words, either type should not be a parent of
59
	 * the other, nor they should be the same.
52
	 * the other, nor they should be the same.
60
	 */
53
	 */
61
	public static final TypeRelation UNRELATED_TYPE_LITERAL = new TypeRelation(
54
	UNRELATED_TYPE_LITERAL("UNRELATED_TYPE"), //$NON-NLS-1$
62
		"UNRELATED_TYPE"); //$NON-NLS-1$
63
55
64
	/**
56
	/**
65
	 * A <code>TypeRelation</code> enumeration literal used to denote that two
57
	 * A <code>TypeRelation</code> enumeration literal used to denote that two
66
	 * types are exactly the same.
58
	 * types are exactly the same.
67
	 */
59
	 */
68
	public static final TypeRelation SAMETYPE_LITERAL = new TypeRelation(
60
	SAMETYPE_LITERAL("SAMETYPE"), //$NON-NLS-1$
69
		"SAMETYPE"); //$NON-NLS-1$
70
61
71
	/**
62
	/**
72
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
63
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
73
	 * type is a base type of another.
64
	 * type is a base type of another.
74
	 */
65
	 */
75
	public static final TypeRelation BASETYPE_LITERAL = new TypeRelation(
66
	BASETYPE_LITERAL("BASETYPE"), //$NON-NLS-1$
76
		"BASETYPE"); //$NON-NLS-1$
77
67
78
	/**
68
	/**
79
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
69
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
80
	 * type is a sub type of another.
70
	 * type is a sub type of another.
81
	 */
71
	 */
82
	public static final TypeRelation SUBTYPE_LITERAL = new TypeRelation(
72
	SUBTYPE_LITERAL("SUBTYPE"), //$NON-NLS-1$
83
		"SUBTYPE"); //$NON-NLS-1$
84
73
85
	/**
74
	/**
86
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
75
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
87
	 * type is a direct super type of another.
76
	 * type is a direct super type of another.
88
	 */
77
	 */
89
	public static final TypeRelation DIRECT_BASETYPE_LITERAL = new TypeRelation(
78
	DIRECT_BASETYPE_LITERAL("DIRECT_BASETYPE"), //$NON-NLS-1$
90
		"DIRECT_BASETYPE"); //$NON-NLS-1$
91
79
92
	/**
80
	/**
93
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
81
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
94
	 * type is a direct sub type of another.
82
	 * type is a direct sub type of another.
95
	 */
83
	 */
96
	public static final TypeRelation DIRECT_SUBTYPE_LITERAL = new TypeRelation(
84
	DIRECT_SUBTYPE_LITERAL("DIRECT_SUBTYPE"), //$NON-NLS-1$
97
		"DIRECT_SUBTYPE"); //$NON-NLS-1$
98
85
99
	/**
86
	/**
100
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
87
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
101
	 * type is either the same or a direct sub type of another.
88
	 * type is either the same or a direct sub type of another.
102
	 */
89
	 */
103
	public static final TypeRelation SAMETYPE_OR_DIRECT_SUBTYPE_LITERAL = new TypeRelation(
90
	SAMETYPE_OR_DIRECT_SUBTYPE_LITERAL("SAMETYPE_OR_DIRECT_SUBTYPE"), //$NON-NLS-1$
104
		"SAMETYPE_OR_DIRECT_SUBTYPE"); //$NON-NLS-1$
105
91
106
	/**
92
	/**
107
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
93
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
108
	 * type is either the same or a direct base type of another.
94
	 * type is either the same or a direct base type of another.
109
	 */
95
	 */
110
	public static final TypeRelation SAMETYPE_OR_DIRECT_BASETYPE_LITERAL = new TypeRelation(
96
	SAMETYPE_OR_DIRECT_BASETYPE_LITERAL("SAMETYPE_OR_DIRECT_BASETYPE"), //$NON-NLS-1$
111
		"SAMETYPE_OR_DIRECT_BASETYPE"); //$NON-NLS-1$
112
97
113
	/**
98
	/**
114
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
99
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
115
	 * type is either the same or a sub type of another.
100
	 * type is either the same or a sub type of another.
116
	 */
101
	 */
117
	public static final TypeRelation SAMETYPE_OR_SUBTYPE_LITERAL = new TypeRelation(
102
	SAMETYPE_OR_SUBTYPE_LITERAL("SAMETYPE_OR_SUBTYPE"), //$NON-NLS-1$
118
		"SAMETYPE_OR_SUBTYPE"); //$NON-NLS-1$
119
103
120
	/**
104
	/**
121
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
105
	 * A <code>TypeRelation</code> enumeration literal used to denote that one
122
	 * type is either the same or a super type of another.
106
	 * type is either the same or a super type of another.
123
	 */
107
	 */
124
	public static final TypeRelation SAMETYPE_OR_BASETYPE_LITERAL = new TypeRelation(
108
	SAMETYPE_OR_BASETYPE_LITERAL("SAMETYPE_OR_BASETYPE"); //$NON-NLS-1$
125
		"SAMETYPE_OR_BASETYPE"); //$NON-NLS-1$
126
109
127
	/**
110
	/**
128
	 * The integer value of the UNDEFINED_LITERAL <code>TypeRelation</code>
111
	 * The integer value of the UNDEFINED_LITERAL <code>TypeRelation</code>
Lines 201-217 Link Here
201
	public static final int SAMETYPE_OR_BASETYPE = SAMETYPE_OR_BASETYPE_LITERAL
184
	public static final int SAMETYPE_OR_BASETYPE = SAMETYPE_OR_BASETYPE_LITERAL
202
		.getValue();
185
		.getValue();
203
186
187
	private static final List<TypeRelation> values = java.util.Arrays.asList(values());
188
204
	/**
189
	/**
205
	 * An immutable list of the enumeration literals declared by this enumerator
190
	 * An immutable list of the enumeration literals declared by this enumerator
206
	 */
191
	 */
207
	public static final List VALUES = Collections.unmodifiableList(values);
192
	public static final List<TypeRelation> VALUES = Collections.unmodifiableList(values);
208
209
	private static final TypeRelation[] VALUES_ARRAY = (TypeRelation[]) VALUES
210
		.toArray(new TypeRelation[VALUES.size()]);
211
193
194
	private final String name;
195
	
212
	private TypeRelation(String name) {
196
	private TypeRelation(String name) {
213
		super(valueCounter++, name);
197
		this.name = name;
214
		values.add(this);
215
	}
198
	}
216
199
217
	/**
200
	/**
Lines 221-234 Link Here
221
	 * @param value
204
	 * @param value
222
	 *            An integer representing the value of a
205
	 *            An integer representing the value of a
223
	 *            <code>TypeRelation</code> enumeration literal
206
	 *            <code>TypeRelation</code> enumeration literal
224
	 * @return TypeRelation the <code>TypeRelation</code> having this name or
207
	 * @return the <code>TypeRelation</code> having this name or
225
	 *         null if the name is not recognised
208
	 *         null if the name is not recognized
226
	 */
209
	 */
227
	public static TypeRelation get(int value) {
210
	public static TypeRelation get(int value) {
228
		if (value >= VALUES_ARRAY.length || value < 0) {
211
		if (value >= VALUES.size() || value < 0) {
229
			return null;
212
			return null;
230
		}
213
		}
231
		return VALUES_ARRAY[value];
214
		return VALUES.get(value);
232
	}
215
	}
233
216
234
	/**
217
	/**
Lines 238-250 Link Here
238
	 * @param name
221
	 * @param name
239
	 *            A string representing the name of a <code>TypeRelation</code>
222
	 *            A string representing the name of a <code>TypeRelation</code>
240
	 *            enumeration literal
223
	 *            enumeration literal
241
	 * @return TypeRelation the <code>TypeRelation</code> having this name or
224
	 * @return the <code>TypeRelation</code> having this name or
242
	 *         <code>null</code> if the name is not recognised
225
	 *         <code>null</code> if the name is not recognized
243
	 */
226
	 */
244
	public static TypeRelation get(String name) {
227
	public static TypeRelation get(String name) {
245
		for (int i = 0; i < VALUES_ARRAY.length; ++i) {
228
		for (TypeRelation next : VALUES) {
246
			if (VALUES_ARRAY[i].getName().equals(name)) {
229
			if (next.getName().equals(name)) {
247
				return VALUES_ARRAY[i];
230
				return next;
248
			}
231
			}
249
		}
232
		}
250
		return null;
233
		return null;
Lines 253-264 Link Here
253
	/**
236
	/**
254
	 * Answers how many enumeration literals declared by this enumerator.
237
	 * Answers how many enumeration literals declared by this enumerator.
255
	 * 
238
	 * 
256
	 * @return int The total count of all enumeration literals declared by this
239
	 * @return The total count of all enumeration literals declared by this
257
	 *         enumerator
240
	 *         enumerator
258
	 */
241
	 */
259
	public static int getTotalCount() {
242
	public static int getTotalCount() {
260
		return VALUES_ARRAY.length;
243
		return VALUES.size();
261
	}
244
	}
262
245
246
	public String getLiteral() {
247
		return getName();
248
	}
249
	
250
	public String getName() {
251
		return name;
252
	}
253
	
254
	public int getValue() {
255
		return ordinal();
256
	}
263
}
257
}
264
258
(-)src/org/eclipse/emf/query/conditions/eobjects/EObjectConditionAdapter.java (-12 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 61-82 Link Here
61
	}
61
	}
62
62
63
	/**
63
	/**
64
	 * Overrides the parent's implementation by simply forwarding the actual
65
	 * evaluation to the adapted <code>Condition</code> regardless whether or
66
	 * not the argument object conforms to <code>EObject</code>.
67
	 * 
68
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
69
	 */
70
	public boolean isSatisfied(Object object) {
71
		return condition.isSatisfied(object);
72
	}
73
74
	/**
75
	 * The implementation of this function simply forwards the actual evaluation
64
	 * The implementation of this function simply forwards the actual evaluation
76
	 * to the adapted <code>Condition</code>.
65
	 * to the adapted <code>Condition</code>.
77
	 * 
66
	 * 
78
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
67
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
79
	 */
68
	 */
69
	@Override
80
	public boolean isSatisfied(EObject eObject) {
70
	public boolean isSatisfied(EObject eObject) {
81
		return condition.isSatisfied(eObject);
71
		return condition.isSatisfied(eObject);
82
	}
72
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/EObjectConditionDelegator.java (-1 / +4 lines)
Lines 48-54 Link Here
48
	private EObjectCondition eObjectCondition;
48
	private EObjectCondition eObjectCondition;
49
49
50
	/**
50
	/**
51
	 * A simple constructor, initlaizes the wrapped
51
	 * A simple constructor, initializes the wrapped
52
	 * <code>EObjectCondition</code> to <code>null</code>. The supplier of
52
	 * <code>EObjectCondition</code> to <code>null</code>. The supplier of
53
	 * this <code>EObjectConditionDelegator</code> must ensure that a valid
53
	 * this <code>EObjectConditionDelegator</code> must ensure that a valid
54
	 * <code>EObjectCondition</code> is passed to this
54
	 * <code>EObjectCondition</code> is passed to this
Lines 78-83 Link Here
78
	 * 
78
	 * 
79
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
79
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
80
	 */
80
	 */
81
	@Override
81
	public boolean isSatisfied(Object object) {
82
	public boolean isSatisfied(Object object) {
82
		return eObjectCondition.isSatisfied(object);
83
		return eObjectCondition.isSatisfied(object);
83
	}
84
	}
Lines 88-93 Link Here
88
	 * 
89
	 * 
89
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
90
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
90
	 */
91
	 */
92
	@Override
91
	public boolean isSatisfied(EObject eObject) {
93
	public boolean isSatisfied(EObject eObject) {
92
		return eObjectCondition.isSatisfied(eObject);
94
		return eObjectCondition.isSatisfied(eObject);
93
	}
95
	}
Lines 98-103 Link Here
98
	 * 
100
	 * 
99
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#shouldPrune(org.eclipse.emf.ecore.EObject)
101
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#shouldPrune(org.eclipse.emf.ecore.EObject)
100
	 */
102
	 */
103
	@Override
101
	public boolean shouldPrune(EObject eObject) {
104
	public boolean shouldPrune(EObject eObject) {
102
		return eObjectCondition.shouldPrune(eObject);
105
		return eObjectCondition.shouldPrune(eObject);
103
	}
106
	}
(-)src/org/eclipse/emf/query/conditions/eobjects/IEObjectSource.java (-2 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 19-24 Link Here
19
19
20
import java.util.Set;
20
import java.util.Set;
21
21
22
import org.eclipse.emf.ecore.EObject;
23
22
/**
24
/**
23
 * An interface the represents an <code>EObject</code> source/supplier. These
25
 * An interface the represents an <code>EObject</code> source/supplier. These
24
 * EObjects are to be used in queries and subjected to evaluation by
26
 * EObjects are to be used in queries and subjected to evaluation by
Lines 33-37 Link Here
33
	 * @return Set The set of EObjects this <code>IEObjectSource</code>
35
	 * @return Set The set of EObjects this <code>IEObjectSource</code>
34
	 *         furnishes
36
	 *         furnishes
35
	 */
37
	 */
36
	Set getEObjects();
38
	Set<? extends EObject> getEObjects();
37
}
39
}
(-)src/org/eclipse/emf/query/conditions/eobjects/EObjectSource.java (-9 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 25-31 Link Here
25
25
26
/**
26
/**
27
 * <p>
27
 * <p>
28
 * This class represnts a simple implementation of {@link org.eclipse.emf.query.conditions.eobjects.IEObjectSource}
28
 * This class represents a simple implementation of {@link org.eclipse.emf.query.conditions.eobjects.IEObjectSource}
29
 *  that is constructed with one EObject or a collection of EObjects.
29
 *  that is constructed with one EObject or a collection of EObjects.
30
 * </p>
30
 * </p>
31
 * <p>
31
 * <p>
Lines 37-43 Link Here
37
 */
37
 */
38
public class EObjectSource implements IEObjectSource {
38
public class EObjectSource implements IEObjectSource {
39
    private EObject eObject;
39
    private EObject eObject;
40
    private Set set;
40
    private Set<EObject> set;
41
41
42
    /**
42
    /**
43
     * Initializes me with a single sub-tree from which to get objects.
43
     * Initializes me with a single sub-tree from which to get objects.
Lines 54-71 Link Here
54
     * 
54
     * 
55
     * @param eObjects the roots (zero or more) of sub-trees to query
55
     * @param eObjects the roots (zero or more) of sub-trees to query
56
     */
56
     */
57
    public EObjectSource(Collection eObjects) {
57
    public EObjectSource(Collection<? extends EObject> eObjects) {
58
        if (eObjects instanceof Set) {
58
        if (eObjects instanceof Set) {
59
            set = (Set) eObjects;
59
        	@SuppressWarnings("unchecked") // nobody should be adding to this set
60
        	Set<EObject> eObjectSet = (Set<EObject>) eObjects;
61
        	set = eObjectSet;
60
        } else {
62
        } else {
61
            set = new HashSet();
63
            set = new HashSet<EObject>(eObjects);
62
            set.addAll(eObjects);
63
        }
64
        }
64
    }
65
    }
65
66
66
    public Set getEObjects() {
67
    public Set<? extends EObject> getEObjects() {
67
        if (set == null) {
68
        if (set == null) {
68
            set = new HashSet();
69
            set = new HashSet<EObject>();
69
            set.add(eObject);
70
            set.add(eObject);
70
        }
71
        }
71
        return set;
72
        return set;
(-)src/org/eclipse/emf/query/conditions/eobjects/EObjectInstanceCondition.java (-3 / +4 lines)
Lines 41-50 Link Here
41
     * 
41
     * 
42
     * @since 1.1
42
     * @since 1.1
43
     */
43
     */
44
    public static final EObjectInstanceCondition IS_NULL =
44
    public static final EObjectInstanceCondition IS_NULL = new EObjectInstanceCondition(null) {
45
        new EObjectInstanceCondition(null) {
46
        
45
        
47
        public boolean isSatisfied(Object object) {
46
        @Override
47
		public boolean isSatisfied(Object object) {
48
            return object == null;
48
            return object == null;
49
        }};
49
        }};
50
50
Lines 85-90 Link Here
85
	 * 
85
	 * 
86
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
86
	 * @see org.eclipse.emf.query.conditions.eobjects.EObjectCondition#isSatisfied(org.eclipse.emf.ecore.EObject)
87
	 */
87
	 */
88
	@Override
88
	public boolean isSatisfied(EObject eObj) {
89
	public boolean isSatisfied(EObject eObj) {
89
		return getEObject().equals(eObj);
90
		return getEObject().equals(eObj);
90
	}
91
	}
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:33:17 EST 2006
1
#Sat Oct 20 22:49:46 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/query/conditions/Not.java (+1 lines)
Lines 42-47 Link Here
42
	 * 
42
	 * 
43
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
43
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
44
	 */
44
	 */
45
	@Override
45
	public boolean isSatisfied(Object object) {
46
	public boolean isSatisfied(Object object) {
46
		return !(condition.isSatisfied(object));
47
		return !(condition.isSatisfied(object));
47
	}
48
	}
(-)src/org/eclipse/emf/query/conditions/ObjectInstanceCondition.java (-1 / +3 lines)
Lines 41-47 Link Here
41
    public static final ObjectInstanceCondition IS_NULL =
41
    public static final ObjectInstanceCondition IS_NULL =
42
        new ObjectInstanceCondition(null) {
42
        new ObjectInstanceCondition(null) {
43
43
44
        public boolean isSatisfied(Object obj) {
44
        @Override
45
		public boolean isSatisfied(Object obj) {
45
            return obj == null;
46
            return obj == null;
46
        }};
47
        }};
47
48
Lines 65-70 Link Here
65
	 * 
66
	 * 
66
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
67
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
67
	 */
68
	 */
69
	@Override
68
	public boolean isSatisfied(Object obj) {
70
	public boolean isSatisfied(Object obj) {
69
		return getObject().equals(obj);
71
		return getObject().equals(obj);
70
	}
72
	}
(-)src/org/eclipse/emf/query/conditions/ConditionPolicy.java (-15 / +16 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-24 Link Here
18
package org.eclipse.emf.query.conditions;
18
package org.eclipse.emf.query.conditions;
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.Iterator;
22
21
23
/**
22
/**
24
 * An abstract base class for <code>ConditionPolicy</code> objects.
23
 * An abstract base class for <code>ConditionPolicy</code> objects.
Lines 53-59 Link Here
53
	 *         objects -in accordance to this <code>ConditionPolicy</code>,
52
	 *         objects -in accordance to this <code>ConditionPolicy</code>,
54
	 *         <code>false</code> otherwise
53
	 *         <code>false</code> otherwise
55
	 */
54
	 */
56
	public abstract boolean isSatisfied(Condition condition, Collection objects);
55
	public abstract boolean isSatisfied(Condition condition, Collection<?> objects);
57
56
58
	/**
57
	/**
59
	 * Answers whether the argument conditions evaluate -collectively- to
58
	 * Answers whether the argument conditions evaluate -collectively- to
Lines 103-121 Link Here
103
	 */
102
	 */
104
	public static final ConditionPolicy ALL = new ConditionPolicy() {
103
	public static final ConditionPolicy ALL = new ConditionPolicy() {
105
104
106
		public boolean isSatisfied(Condition condition, Collection objects) {
105
		@Override
107
			Iterator it = objects.iterator();
106
		public boolean isSatisfied(Condition condition, Collection<?> objects) {
108
			while (it.hasNext()) {
107
			for (Object o : objects) {
109
				if (condition.isSatisfied(it.next()) == false) {
108
				if (condition.isSatisfied(o) == false) {
110
					return false;
109
					return false;
111
				}
110
				}
112
			}
111
			}
113
			return true;
112
			return true;
114
		}
113
		}
115
114
115
		@Override
116
		public boolean isSatisfied(Condition[] conditions, Object object) {
116
		public boolean isSatisfied(Condition[] conditions, Object object) {
117
			for (int i = 0; i < conditions.length; ++i) {
117
			for (Condition c : conditions) {
118
				if (conditions[i].isSatisfied(object) == false) {
118
				if (c.isSatisfied(object) == false) {
119
					return false;
119
					return false;
120
				}
120
				}
121
			}
121
			}
Lines 133-151 Link Here
133
	 */
133
	 */
134
	public static final ConditionPolicy ANY = new ConditionPolicy() {
134
	public static final ConditionPolicy ANY = new ConditionPolicy() {
135
135
136
		public boolean isSatisfied(Condition condition, Collection objects) {
136
		@Override
137
			Iterator it = objects.iterator();
137
		public boolean isSatisfied(Condition condition, Collection<?> objects) {
138
			while (it.hasNext()) {
138
			for (Object o : objects) {
139
				if (condition.isSatisfied(it.next())) {
139
				if (condition.isSatisfied(o)) {
140
					return true;
140
					return true;
141
				}
141
				}
142
			}
142
			}
143
			return false;
143
			return false;
144
		}
144
		}
145
145
146
		@Override
146
		public boolean isSatisfied(Condition[] conditions, Object object) {
147
		public boolean isSatisfied(Condition[] conditions, Object object) {
147
			for (int i = 0; i < conditions.length; ++i) {
148
			for (Condition c : conditions) {
148
				if (conditions[i].isSatisfied(object)) {
149
				if (c.isSatisfied(object)) {
149
					return true;
150
					return true;
150
				}
151
				}
151
			}
152
			}
(-)src/org/eclipse/emf/query/conditions/Condition.java (+7 lines)
Lines 35-40 Link Here
35
	 */
35
	 */
36
	public static final Condition TRUE = new Condition() {
36
	public static final Condition TRUE = new Condition() {
37
37
38
		@Override
38
		public boolean isSatisfied(Object object) {
39
		public boolean isSatisfied(Object object) {
39
			return true;
40
			return true;
40
		}
41
		}
Lines 46-51 Link Here
46
	 */
47
	 */
47
	public static final Condition FALSE = new Condition() {
48
	public static final Condition FALSE = new Condition() {
48
49
50
		@Override
49
		public boolean isSatisfied(Object object) {
51
		public boolean isSatisfied(Object object) {
50
			return false;
52
			return false;
51
		}
53
		}
Lines 75-80 Link Here
75
			super(condition);
77
			super(condition);
76
		}
78
		}
77
79
80
		@Override
78
		public boolean isSatisfied(Object object) {
81
		public boolean isSatisfied(Object object) {
79
			return Condition.this.isSatisfied(object)
82
			return Condition.this.isSatisfied(object)
80
				|| condition.isSatisfied(object);
83
				|| condition.isSatisfied(object);
Lines 88-93 Link Here
88
			super(condition);
91
			super(condition);
89
		}
92
		}
90
93
94
		@Override
91
		public boolean isSatisfied(Object object) {
95
		public boolean isSatisfied(Object object) {
92
			return Condition.this.isSatisfied(object)
96
			return Condition.this.isSatisfied(object)
93
				&& condition.isSatisfied(object);
97
				&& condition.isSatisfied(object);
Lines 101-106 Link Here
101
			super(condition);
105
			super(condition);
102
		}
106
		}
103
107
108
		@Override
104
		public boolean isSatisfied(Object object) {
109
		public boolean isSatisfied(Object object) {
105
			return Condition.this.isSatisfied(object)
110
			return Condition.this.isSatisfied(object)
106
				^ condition.isSatisfied(object);
111
				^ condition.isSatisfied(object);
Lines 114-119 Link Here
114
			super(condition);
119
			super(condition);
115
		}
120
		}
116
121
122
		@Override
117
		public boolean isSatisfied(Object object) {
123
		public boolean isSatisfied(Object object) {
118
			return (!(Condition.this.isSatisfied(object)))
124
			return (!(Condition.this.isSatisfied(object)))
119
				|| condition.isSatisfied(object);
125
				|| condition.isSatisfied(object);
Lines 127-132 Link Here
127
			super(condition);
133
			super(condition);
128
		}
134
		}
129
135
136
		@Override
130
		public boolean isSatisfied(Object object) {
137
		public boolean isSatisfied(Object object) {
131
			return Condition.this.isSatisfied(object) == condition
138
			return Condition.this.isSatisfied(object) == condition
132
				.isSatisfied(object);
139
				.isSatisfied(object);
(-)META-INF/MANIFEST.MF (-3 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.query
4
Bundle-SymbolicName: org.eclipse.emf.query
5
Bundle-Version: 1.1.0.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.query.internal.EMFQueryPlugin$Implementation
6
Bundle-Activator: org.eclipse.emf.query.internal.EMFQueryPlugin$Implementation
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 20-26 Link Here
20
 org.eclipse.emf.query.internal.util;x-friends:="org.eclipse.emf.query.tests",
20
 org.eclipse.emf.query.internal.util;x-friends:="org.eclipse.emf.query.tests",
21
 org.eclipse.emf.query.statements
21
 org.eclipse.emf.query.statements
22
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
22
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
23
 org.eclipse.emf.ecore;bundle-version="[2.2.0,3.0.0)",
23
 org.eclipse.emf.ecore;bundle-version="[2.3.0,3.0.0)",
24
 com.ibm.icu;bundle-version="[3.4.3,4.0.0)"
24
 com.ibm.icu;bundle-version="[3.4.3,4.0.0)"
25
Eclipse-LazyStart: true
25
Eclipse-LazyStart: true
26
Bundle-RequiredExecutionEnvironment: J2SE-1.4
26
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/query/internal/statements/EObjectContentIterator.java (-11 / +13 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 35-50 Link Here
35
 * 
35
 * 
36
 * @author Yasser Lulu 
36
 * @author Yasser Lulu 
37
 */
37
 */
38
public class EObjectContentIterator extends AbstractTreeIterator {
38
public class EObjectContentIterator extends AbstractTreeIterator<EObject> {
39
39
40
	private static final long serialVersionUID = 4310034547053143619L;
40
	private static final long serialVersionUID = 4310034547053143619L;
41
41
42
	private static class EObjectAdapter extends EObjectImpl {
42
	private static class EObjectAdapter extends EObjectImpl {
43
        private EList list;
43
        private EList<EObject> list;
44
        EObjectAdapter(Collection collection) {
44
        EObjectAdapter(Collection<? extends EObject> collection) {
45
            list = new BasicEList(collection);
45
            list = new BasicEList<EObject>(collection);
46
        }
46
        }
47
        public final EList eContents() {
47
        @Override
48
		public final EList<EObject> eContents() {
48
            return list;
49
            return list;
49
        }
50
        }
50
    }
51
    }
Lines 99-105 Link Here
99
     * 
100
     * 
100
     * @param eObjects the collection to iterate
101
     * @param eObjects the collection to iterate
101
     */
102
     */
102
    public EObjectContentIterator(Collection eObjects) {
103
    public EObjectContentIterator(Collection<? extends EObject> eObjects) {
103
        this(eObjects, null);
104
        this(eObjects, null);
104
    }
105
    }
105
106
Lines 112-118 Link Here
112
     *     from the collection from consideration by the query
113
     *     from the collection from consideration by the query
113
     */
114
     */
114
    public EObjectContentIterator(
115
    public EObjectContentIterator(
115
        Collection eObjects,
116
        Collection<? extends EObject> eObjects,
116
        EObjectCondition filterCondition) {
117
        EObjectCondition filterCondition) {
117
        this(eObjects, filterCondition, EStructuralFeatureValueGetter.getInstance());
118
        this(eObjects, filterCondition, EStructuralFeatureValueGetter.getInstance());
118
    }
119
    }
Lines 128-134 Link Here
128
     *     the filter condition
129
     *     the filter condition
129
     */
130
     */
130
    public EObjectContentIterator(
131
    public EObjectContentIterator(
131
        Collection eObjects,
132
        Collection<? extends EObject> eObjects,
132
        EObjectCondition filterCondition,
133
        EObjectCondition filterCondition,
133
        IEStructuralFeatureValueGetter eStructuralFeatureValueGetter) {
134
        IEStructuralFeatureValueGetter eStructuralFeatureValueGetter) {
134
        this(
135
        this(
Lines 142-152 Link Here
142
     * 
143
     * 
143
     * @return the iterator
144
     * @return the iterator
144
     */
145
     */
145
    protected final Iterator getChildren() {
146
    protected final Iterator<? extends EObject> getChildren() {
146
        return getChildren(rootEObject);
147
        return getChildren(rootEObject);
147
    }
148
    }
148
149
149
    protected final Iterator getChildren(Object obj) {
150
    @Override
151
	protected final Iterator<? extends EObject> getChildren(Object obj) {
150
        return (obj == rootEObject)
152
        return (obj == rootEObject)
151
            ? (obj instanceof EObjectAdapter)
153
            ? (obj instanceof EObjectAdapter)
152
            ? ((EObject)obj).eContents().iterator()
154
            ? ((EObject)obj).eContents().iterator()
(-)src/org/eclipse/emf/query/internal/statements/FlatEObjectContentIterator.java (-6 / +12 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 33-39 Link Here
33
	
33
	
34
	private static final long serialVersionUID = 964764750547412881L;
34
	private static final long serialVersionUID = 964764750547412881L;
35
	
35
	
36
	private Iterator it;
36
	private Iterator<? extends EObject> it;
37
37
38
	/**
38
	/**
39
	 * Initializes me with a single <code>eObject</code> to iterate.
39
	 * Initializes me with a single <code>eObject</code> to iterate.
Lines 61-67 Link Here
61
	 * 
61
	 * 
62
	 * @param eObjects the eobjects to iterate
62
	 * @param eObjects the eobjects to iterate
63
	 */
63
	 */
64
	public FlatEObjectContentIterator(Collection eObjects) {
64
	public FlatEObjectContentIterator(Collection<? extends EObject> eObjects) {
65
		this(eObjects, null);
65
		this(eObjects, null);
66
	}
66
	}
67
67
Lines 72-78 Link Here
72
	 * @param eObjectStructuralFeatureValueGetter the value getter to apply
72
	 * @param eObjectStructuralFeatureValueGetter the value getter to apply
73
	 *     to them
73
	 *     to them
74
	 */
74
	 */
75
	public FlatEObjectContentIterator(Collection eObjects,
75
	public FlatEObjectContentIterator(Collection<? extends EObject> eObjects,
76
		IEStructuralFeatureValueGetter eObjectStructuralFeatureValueGetter) {
76
		IEStructuralFeatureValueGetter eObjectStructuralFeatureValueGetter) {
77
		super(eObjects, null, eObjectStructuralFeatureValueGetter);
77
		super(eObjects, null, eObjectStructuralFeatureValueGetter);
78
	}
78
	}
Lines 80-85 Link Here
80
	/**
80
	/**
81
	 * @see org.eclipse.emf.common.util.TreeIterator#prune()
81
	 * @see org.eclipse.emf.common.util.TreeIterator#prune()
82
	 */
82
	 */
83
	@Override
83
	public void prune() {
84
	public void prune() {
84
		//disable parent's
85
		//disable parent's
85
	}
86
	}
Lines 87-92 Link Here
87
	/**
88
	/**
88
	 * @see java.util.Iterator#hasNext()
89
	 * @see java.util.Iterator#hasNext()
89
	 */
90
	 */
91
	@Override
90
	public boolean hasNext() {
92
	public boolean hasNext() {
91
		return getIterator().hasNext();
93
		return getIterator().hasNext();
92
	}
94
	}
Lines 94-117 Link Here
94
	/**
96
	/**
95
	 * @see java.util.Iterator#next()
97
	 * @see java.util.Iterator#next()
96
	 */
98
	 */
97
	public Object next() {
99
	@Override
100
	public EObject next() {
98
		return getIterator().next();
101
		return getIterator().next();
99
	}
102
	}
100
103
101
	/**
104
	/**
102
	 * @see java.util.Iterator#remove()
105
	 * @see java.util.Iterator#remove()
103
	 */
106
	 */
107
	@Override
104
	public void remove() {
108
	public void remove() {
105
		getIterator().remove();
109
		getIterator().remove();
106
	}
110
	}
107
111
108
	private Iterator getIterator() {
112
	private Iterator<? extends EObject> getIterator() {
109
		if (it == null) {
113
		if (it == null) {
110
			it = getChildren();
114
			it = getChildren();
111
		}
115
		}
112
		return it;
116
		return it;
113
	}
117
	}
114
118
119
	@Override
115
	public boolean canPrune() {
120
	public boolean canPrune() {
116
		return false;
121
		return false;
117
	}
122
	}
Lines 121-126 Link Here
121
	 * 
126
	 * 
122
	 * @return my iterator kind ({@link IteratorKind#FLAT_LITERAL})
127
	 * @return my iterator kind ({@link IteratorKind#FLAT_LITERAL})
123
	 */
128
	 */
129
	@Override
124
	public IteratorKind getIteratorKind() {
130
	public IteratorKind getIteratorKind() {
125
		return IteratorKind.FLAT_LITERAL;
131
		return IteratorKind.FLAT_LITERAL;
126
	}
132
	}
(-)src/org/eclipse/emf/query/internal/statements/QueryResultSet.java (-19 / +22 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 27-36 Link Here
27
import org.eclipse.emf.query.statements.IQueryResult;
27
import org.eclipse.emf.query.statements.IQueryResult;
28
28
29
/**
29
/**
30
 * 
31
 * @param <E> the kind of element provided by the result set
32
 * 
30
 * @author Yasser Lulu 
33
 * @author Yasser Lulu 
31
 */
34
 */
32
public class QueryResultSet implements Set, IQueryResult {
35
public class QueryResultSet implements Set<EObject>, IQueryResult {
33
    private Set eObjects;
36
    private Set<EObject> eObjects;
34
    private Exception exception;
37
    private Exception exception;
35
    private boolean cancelled;
38
    private boolean cancelled;
36
39
Lines 38-44 Link Here
38
     * Initializes me.
41
     * Initializes me.
39
     */
42
     */
40
    public QueryResultSet() {
43
    public QueryResultSet() {
41
        this(new HashSet());
44
        this(new HashSet<EObject>());
42
    }
45
    }
43
46
44
    /**
47
    /**
Lines 46-52 Link Here
46
     * 
49
     * 
47
     * @param eObjects my objects
50
     * @param eObjects my objects
48
     */
51
     */
49
    public QueryResultSet(Set eObjects) {
52
    public QueryResultSet(Set<? extends EObject> eObjects) {
50
        this(eObjects, null);
53
        this(eObjects, null);
51
    }
54
    }
52
55
Lines 57-68 Link Here
57
     * @param eObjects my objects
60
     * @param eObjects my objects
58
     * @param exception the exception that was thrown
61
     * @param exception the exception that was thrown
59
     */
62
     */
60
    public QueryResultSet(Set eObjects, Exception exception) {
63
    public QueryResultSet(Set<? extends EObject> eObjects, Exception exception) {
61
        this.eObjects = eObjects;
64
        this.eObjects = new HashSet<EObject>(eObjects);
62
        this.exception = exception;
65
        this.exception = exception;
63
    }
66
    }
64
67
65
    public Set getEObjects() {
68
    public Set<EObject> getEObjects() {
66
        return eObjects;
69
        return eObjects;
67
    }
70
    }
68
71
Lines 75-81 Link Here
75
    }
78
    }
76
79
77
    public void clear() {
80
    public void clear() {
78
        eObjects = new HashSet();
81
        eObjects = new HashSet<EObject>();
79
        exception = null;
82
        exception = null;
80
    }
83
    }
81
84
Lines 93-120 Link Here
93
        return eObjects.size();
96
        return eObjects.size();
94
    }
97
    }
95
98
96
    public Iterator iterator() {
99
    public Iterator<EObject> iterator() {
97
        return eObjects.iterator();
100
        return eObjects.iterator();
98
    }
101
    }
99
102
100
    /**
103
    /**
101
     * @see java.util.Collection#removeAll(java.util.Collection)
104
     * @see java.util.Collection#removeAll(java.util.Collection)
102
     */
105
     */
103
    public boolean removeAll(Collection c) {
106
    public boolean removeAll(Collection<?> c) {
104
        return eObjects.removeAll(c);
107
        return eObjects.removeAll(c);
105
    }
108
    }
106
109
107
    /**
110
    /**
108
     * @see java.util.Collection#add(java.lang.Object)
111
     * @see java.util.Collection#add(java.lang.Object)
109
     */
112
     */
110
    public boolean add(Object o) {
113
    public boolean add(EObject o) {
111
        return eObjects.add(o);
114
        return eObjects.add(o);
112
    }
115
    }
113
116
    
114
    /**
117
    /**
115
     * @see java.util.Collection#addAll(java.util.Collection)
118
     * @see java.util.Collection#addAll(java.util.Collection)
116
     */
119
     */
117
    public boolean addAll(Collection c) {
120
    public boolean addAll(Collection<? extends EObject> c) {
118
        return eObjects.addAll(c);
121
        return eObjects.addAll(c);
119
    }
122
    }
120
123
Lines 128-134 Link Here
128
    /**
131
    /**
129
     * @see java.util.Collection#containsAll(java.util.Collection)
132
     * @see java.util.Collection#containsAll(java.util.Collection)
130
     */
133
     */
131
    public boolean containsAll(Collection c) {
134
    public boolean containsAll(Collection<?> c) {
132
        return eObjects.containsAll(c);
135
        return eObjects.containsAll(c);
133
    }
136
    }
134
137
Lines 149-155 Link Here
149
    /**
152
    /**
150
     * @see java.util.Collection#retainAll(java.util.Collection)
153
     * @see java.util.Collection#retainAll(java.util.Collection)
151
     */
154
     */
152
    public boolean retainAll(Collection c) {
155
    public boolean retainAll(Collection<?> c) {
153
        return eObjects.retainAll(c);
156
        return eObjects.retainAll(c);
154
    }
157
    }
155
158
Lines 163-176 Link Here
163
    /**
166
    /**
164
     * @see java.util.Collection#toArray(java.lang.Object[])
167
     * @see java.util.Collection#toArray(java.lang.Object[])
165
     */
168
     */
166
    public Object[] toArray(Object[] a) {
169
    public <S> S[] toArray(S[] a) {
167
        return eObjects.toArray(a);
170
        return eObjects.toArray(a);
168
    }
171
    }
169
172
170
    /**
173
    /**
171
     * Asks whether the query was cancelled.
174
     * Asks whether the query was canceled.
172
     * 
175
     * 
173
     * @return whether the query was cancelled
176
     * @return whether the query was canceled
174
     */
177
     */
175
    public boolean isCancelled() {
178
    public boolean isCancelled() {
176
        return cancelled;
179
        return cancelled;
(-)src/org/eclipse/emf/query/internal/statements/QueryStatement.java (-3 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 20-25 Link Here
20
import java.util.Set;
20
import java.util.Set;
21
21
22
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.emf.ecore.EObject;
23
import org.eclipse.emf.query.conditions.eobjects.IEObjectSource;
24
import org.eclipse.emf.query.conditions.eobjects.IEObjectSource;
24
import org.eclipse.emf.query.internal.EMFQueryPlugin;
25
import org.eclipse.emf.query.internal.EMFQueryPlugin;
25
import org.eclipse.emf.query.internal.EMFQueryStatusCodes;
26
import org.eclipse.emf.query.internal.EMFQueryStatusCodes;
Lines 40-46 Link Here
40
    /**
41
    /**
41
     * Initializes me.
42
     * Initializes me.
42
     * 
43
     * 
43
     * @param cancellable whether I can be cancelled
44
     * @param cancellable whether I can be canceled
44
     * @param progressMonitor a monitor to track progress
45
     * @param progressMonitor a monitor to track progress
45
     */
46
     */
46
    public QueryStatement(
47
    public QueryStatement(
Lines 130-136 Link Here
130
        return resultSet;
131
        return resultSet;
131
    }
132
    }
132
133
133
    public Set getEObjects() {
134
    public Set<? extends EObject> getEObjects() {
134
        return execute().getEObjects();
135
        return execute().getEObjects();
135
    }
136
    }
136
137
(-)src/org/eclipse/emf/query/handlers/PruneHandler.java (+2 lines)
Lines 51-56 Link Here
51
	 */
51
	 */
52
	public static final PruneHandler ALWAYS = new PruneHandler() {
52
	public static final PruneHandler ALWAYS = new PruneHandler() {
53
53
54
		@Override
54
		public boolean shouldPrune(EObject eObject) {
55
		public boolean shouldPrune(EObject eObject) {
55
			return true;
56
			return true;
56
		}
57
		}
Lines 63-68 Link Here
63
	 */
64
	 */
64
	public static final PruneHandler NEVER = new PruneHandler() {
65
	public static final PruneHandler NEVER = new PruneHandler() {
65
66
67
		@Override
66
		public boolean shouldPrune(EObject eObject) {
68
		public boolean shouldPrune(EObject eObject) {
67
			return false;
69
			return false;
68
		}
70
		}
(-)src/org/eclipse/emf/query/internal/EMFQueryPlugin.java (-14 / +15 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 128-134 Link Here
128
        super(new ResourceLocator[] {});
128
        super(new ResourceLocator[] {});
129
    }
129
    }
130
130
131
    public ResourceLocator getPluginResourceLocator() {
131
    @Override
132
	public ResourceLocator getPluginResourceLocator() {
132
        return plugin;
133
        return plugin;
133
    }
134
    }
134
135
Lines 160-166 Link Here
160
    	/**
161
    	/**
161
    	 * The cached debug options (for optimization).
162
    	 * The cached debug options (for optimization).
162
    	 */
163
    	 */
163
    	private static final Map cachedOptions = new HashMap();
164
    	private static final Map<String, Boolean> cachedOptions = new HashMap<String, Boolean>();
164
165
165
    	/**
166
    	/**
166
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
167
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 185-191 Link Here
185
    			Boolean value = null;
186
    			Boolean value = null;
186
    			
187
    			
187
    			synchronized (cachedOptions) {
188
    			synchronized (cachedOptions) {
188
    				value = (Boolean) cachedOptions.get(option);
189
    				value = cachedOptions.get(option);
189
    	
190
    	
190
    				if (null == value) {
191
    				if (null == value) {
191
    					value =
192
    					value =
Lines 302-308 Link Here
302
    	 */
303
    	 */
303
    	public static void changing(
304
    	public static void changing(
304
            String option,
305
            String option,
305
            Class clazz,
306
            Class<?> clazz,
306
            String methodName,
307
            String methodName,
307
            String valueDescription,
308
            String valueDescription,
308
            Object oldValue,
309
            Object oldValue,
Lines 341-347 Link Here
341
    	 */
342
    	 */
342
    	public static void catching(
343
    	public static void catching(
343
    		String option,
344
    		String option,
344
    		Class clazz,
345
    		Class<?> clazz,
345
    		String methodName,
346
    		String methodName,
346
    		Throwable throwable) {
347
    		Throwable throwable) {
347
348
Lines 374-380 Link Here
374
    	 */
375
    	 */
375
    	public static void throwing(
376
    	public static void throwing(
376
    		String option,
377
    		String option,
377
    		Class clazz,
378
    		Class<?> clazz,
378
    		String methodName,
379
    		String methodName,
379
    		Throwable throwable) {
380
    		Throwable throwable) {
380
381
Lines 404-410 Link Here
404
    	 */
405
    	 */
405
    	public static void entering(
406
    	public static void entering(
406
    		String option,
407
    		String option,
407
    		Class clazz,
408
    		Class<?> clazz,
408
    		String methodName) {
409
    		String methodName) {
409
410
410
    		if (shouldTrace(option)) {
411
    		if (shouldTrace(option)) {
Lines 429-435 Link Here
429
    	 */
430
    	 */
430
    	public static void entering(
431
    	public static void entering(
431
    		String option,
432
    		String option,
432
    		Class clazz,
433
    		Class<?> clazz,
433
    		String methodName,
434
    		String methodName,
434
    		Object parameter) {
435
    		Object parameter) {
435
436
Lines 458-464 Link Here
458
    	 */
459
    	 */
459
    	public static void entering(
460
    	public static void entering(
460
    		String option,
461
    		String option,
461
    		Class clazz,
462
    		Class<?> clazz,
462
    		String methodName,
463
    		String methodName,
463
    		Object[] parameters) {
464
    		Object[] parameters) {
464
465
Lines 485-491 Link Here
485
    	 */
486
    	 */
486
    	public static void exiting(
487
    	public static void exiting(
487
    		String option,
488
    		String option,
488
    		Class clazz,
489
    		Class<?> clazz,
489
    		String methodName) {
490
    		String methodName) {
490
491
491
    		if (shouldTrace(option)) {
492
    		if (shouldTrace(option)) {
Lines 510-516 Link Here
510
    	 */
511
    	 */
511
    	public static void exiting(
512
    	public static void exiting(
512
    		String option,
513
    		String option,
513
    		Class clazz,
514
    		Class<?> clazz,
514
    		String methodName,
515
    		String methodName,
515
    		Object returnValue) {
516
    		Object returnValue) {
516
517
Lines 527-537 Link Here
527
    	}
528
    	}
528
    }
529
    }
529
530
530
	public static void catching(Class class1, String functionName, Throwable exception) {
531
	public static void catching(Class<?> class1, String functionName, Throwable exception) {
531
		Tracing.catching(EMFQueryDebugOptions.EXCEPTIONS_CATCHING, class1, functionName, exception);
532
		Tracing.catching(EMFQueryDebugOptions.EXCEPTIONS_CATCHING, class1, functionName, exception);
532
	}
533
	}
533
	
534
	
534
	public static void throwing(Class class1, String functionName, Throwable exception) {
535
	public static void throwing(Class<?> class1, String functionName, Throwable exception) {
535
		Tracing.throwing(EMFQueryDebugOptions.EXCEPTIONS_THROWING, class1, functionName, exception);
536
		Tracing.throwing(EMFQueryDebugOptions.EXCEPTIONS_THROWING, class1, functionName, exception);
536
	}
537
	}
537
538
(-)src/org/eclipse/emf/query/statements/SET.java (-1 / +1 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
(-)src/org/eclipse/emf/query/statements/FROM.java (-11 / +12 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 101-111 Link Here
101
            eStructuralFeatureValueGetter);
101
            eStructuralFeatureValueGetter);
102
    }
102
    }
103
103
104
    public FROM(Collection eObjects) {
104
    public FROM(Collection<? extends EObject> eObjects) {
105
        this(eObjects, IteratorKind.HIERARCHICAL_LITERAL);
105
        this(eObjects, IteratorKind.HIERARCHICAL_LITERAL);
106
    }
106
    }
107
107
108
    public FROM(Collection eObjects, EObjectCondition filterCondition) {
108
    public FROM(Collection<? extends EObject> eObjects,
109
    		EObjectCondition filterCondition) {
109
        this(
110
        this(
110
            eObjects,
111
            eObjects,
111
            filterCondition,
112
            filterCondition,
Lines 113-124 Link Here
113
            null);
114
            null);
114
    }
115
    }
115
116
116
    public FROM(Collection eObjects, IteratorKind iteratorKind) {
117
    public FROM(Collection<? extends EObject> eObjects, IteratorKind iteratorKind) {
117
        this(eObjects, null, iteratorKind, null);
118
        this(eObjects, null, iteratorKind, null);
118
    }
119
    }
119
120
120
    public FROM(
121
    public FROM(
121
        Collection eObjects,
122
        Collection<? extends EObject> eObjects,
122
        EObjectCondition filterCondition,
123
        EObjectCondition filterCondition,
123
        IteratorKind iteratorKind,
124
        IteratorKind iteratorKind,
124
        IEStructuralFeatureValueGetter eStructuralFeatureValueGetter) {
125
        IEStructuralFeatureValueGetter eStructuralFeatureValueGetter) {
Lines 133-148 Link Here
133
        return canPrune;
134
        return canPrune;
134
    }
135
    }
135
136
136
    public TreeIterator iterator() {
137
    public TreeIterator<EObject> iterator() {
137
        return (iteratorKind == IteratorKind.HIERARCHICAL_LITERAL)
138
        return (iteratorKind == IteratorKind.HIERARCHICAL_LITERAL)
138
            ? (TreeIterator) (new EObjectContentIterator(getEObjects(),
139
            ? new EObjectContentIterator(getEObjects(),
139
                filterCondition,
140
                filterCondition,
140
                getEStructuralFeatureValueGetter()))
141
                getEStructuralFeatureValueGetter())
141
            : (TreeIterator) (new FlatEObjectContentIterator(getEObjects(),
142
            : new FlatEObjectContentIterator(getEObjects(),
142
                getEStructuralFeatureValueGetter()));
143
                getEStructuralFeatureValueGetter());
143
    }
144
    }
144
145
145
    private Set getEObjects() {
146
    private Set<? extends EObject> getEObjects() {
146
        return eObjectSource.getEObjects();
147
        return eObjectSource.getEObjects();
147
    }
148
    }
148
149
(-)src/org/eclipse/emf/query/statements/SELECT.java (-4 / +11 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 54-60 Link Here
54
54
55
	private int maximumResultSize;
55
	private int maximumResultSize;
56
56
57
	private TreeIterator it;
57
	private TreeIterator<EObject> it;
58
58
59
	public SELECT(FROM from, WHERE where) {
59
	public SELECT(FROM from, WHERE where) {
60
		this(true, from, where);
60
		this(true, from, where);
Lines 89-104 Link Here
89
	 * 
89
	 * 
90
	 * @see QueryStatement#execute()
90
	 * @see QueryStatement#execute()
91
	 */
91
	 */
92
	@Override
92
	protected void doExecute() {
93
	protected void doExecute() {
93
		it = getFromClause().iterator();
94
		it = getFromClause().iterator();
94
		doResume();
95
		doResume();
95
	}
96
	}
96
97
98
	@Override
97
	protected void handleException(Exception exception, String functionName) {
99
	protected void handleException(Exception exception, String functionName) {
98
		it = null;
100
		it = null;
99
		super.handleException(exception, functionName);
101
		super.handleException(exception, functionName);
100
	}
102
	}
101
103
104
	@Override
102
	public boolean canBeResumed() {
105
	public boolean canBeResumed() {
103
		try {
106
		try {
104
			return ((it != null) && (it.hasNext()));
107
			return ((it != null) && (it.hasNext()));
Lines 116-121 Link Here
116
	/**
119
	/**
117
	 * @see org.eclipse.emf.query.internal.statements.QueryStatement#doResume()
120
	 * @see org.eclipse.emf.query.internal.statements.QueryStatement#doResume()
118
	 */
121
	 */
122
	@Override
119
	protected void doResume() {
123
	protected void doResume() {
120
		EObject eObject = null;
124
		EObject eObject = null;
121
		//must set the newly created result-set
125
		//must set the newly created result-set
Lines 123-129 Link Here
123
		boolean canPrune = getFromClause().canBePruned();
127
		boolean canPrune = getFromClause().canBePruned();
124
		WHERE whereClause = getWhereClause();
128
		WHERE whereClause = getWhereClause();
125
		while (it.hasNext() && (isCancelled() == false)) {
129
		while (it.hasNext() && (isCancelled() == false)) {
126
			eObject = (EObject) it.next();
130
			eObject = it.next();
127
			if (whereClause.matches(eObject)) {
131
			if (whereClause.matches(eObject)) {
128
				addEObject(eObject);
132
				addEObject(eObject);
129
				if (getResultSet().size() == maximumResultSize) {
133
				if (getResultSet().size() == maximumResultSize) {
Lines 163-176 Link Here
163
		return where;
167
		return where;
164
	}
168
	}
165
169
170
	@Override
166
	public final IQueryResult execute() {		
171
	public final IQueryResult execute() {		
167
		return super.execute();
172
		return super.execute();
168
	}
173
	}
169
174
170
	public final Set getEObjects() {
175
	@Override
176
	public final Set<? extends EObject> getEObjects() {
171
		return super.getEObjects();
177
		return super.getEObjects();
172
	}
178
	}
173
179
180
	@Override
174
	public final IQueryResult resume(IProgressMonitor progressMon) {
181
	public final IQueryResult resume(IProgressMonitor progressMon) {
175
		return super.resume(progressMon);
182
		return super.resume(progressMon);
176
	}
183
	}
(-)src/org/eclipse/emf/query/statements/IteratorKind.java (-20 / +29 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-78 Link Here
17
17
18
package org.eclipse.emf.query.statements;
18
package org.eclipse.emf.query.statements;
19
19
20
import java.util.ArrayList;
21
import java.util.Collections;
20
import java.util.Collections;
22
import java.util.List;
21
import java.util.List;
23
22
24
import org.eclipse.emf.common.util.AbstractEnumerator;
23
import org.eclipse.emf.common.util.Enumerator;
25
24
26
/**
25
/**
27
 * An enumeration of iteration methodologies for EObjects.
26
 * An enumeration of iteration methodologies for EObjects.
28
 * 
27
 * 
29
 * @author Yasser Lulu 
28
 * @author Yasser Lulu 
30
 */
29
 */
31
public final class IteratorKind extends AbstractEnumerator {
30
public enum IteratorKind implements Enumerator {
32
    private static int value;
33
    private static final List values = new ArrayList();
34
35
    /**
31
    /**
36
     * Iterate in a &quot;flat&quot; fashion without traversing the contents
32
     * Iterate in a &quot;flat&quot; fashion without traversing the contents
37
     *  of the EObjects.
33
     *  of the EObjects.
38
     */
34
     */
39
    public static final IteratorKind FLAT_LITERAL = new IteratorKind("FLAT"); //$NON-NLS-1$
35
    FLAT_LITERAL("FLAT"), //$NON-NLS-1$
40
36
41
    /**
37
    /**
42
     * Iterate in a &quot;hierarchical&quot; fashion traversing the containment
38
     * Iterate in a &quot;hierarchical&quot; fashion traversing the containment
43
     *  subtree of each EObject.
39
     *  subtree of each EObject.
44
     */
40
     */
45
    public static final IteratorKind HIERARCHICAL_LITERAL = new IteratorKind("HIERARCHICAL"); //$NON-NLS-1$
41
    HIERARCHICAL_LITERAL("HIERARCHICAL"); //$NON-NLS-1$
46
42
47
    public static final int FLAT = FLAT_LITERAL.getValue();
43
    public static final int FLAT = FLAT_LITERAL.getValue();
48
    public static final int HIERARCHICAL = HIERARCHICAL_LITERAL.getValue();
44
    public static final int HIERARCHICAL = HIERARCHICAL_LITERAL.getValue();
49
45
50
    public static final List VALUES = Collections.unmodifiableList(values);
46
    private static final List<IteratorKind> values = java.util.Arrays.asList(values());
51
    private static final IteratorKind[] VALUES_ARRAY =
47
52
        (IteratorKind[]) VALUES.toArray(new IteratorKind[VALUES.size()]);
48
    public static final List<IteratorKind> VALUES = Collections.unmodifiableList(values);
53
49
50
    private final String name;
51
    
54
    private IteratorKind(String name) {
52
    private IteratorKind(String name) {
55
        super(value++, name);
53
        this.name = name;
56
        values.add(this);
57
    }
54
    }
58
55
59
    public static IteratorKind get(int val) {
56
    public static IteratorKind get(int val) {
60
        if (val >= VALUES_ARRAY.length || val < 0) {
57
        if (val >= values.size() || val < 0) {
61
            return null;
58
            return null;
62
        }
59
        }
63
        return VALUES_ARRAY[val];
60
        return values.get(val);
64
    }
61
    }
65
62
66
    public static IteratorKind get(String name) {
63
    public static IteratorKind get(String name) {
67
        for (int i = 0; i < VALUES_ARRAY.length; ++i) {
64
        for (IteratorKind next : values()) {
68
            if (VALUES_ARRAY[i].getName().equals(name)) {
65
            if (next.getName().equals(name)) {
69
                return VALUES_ARRAY[i];
66
                return next;
70
            }
67
            }
71
        }
68
        }
72
        return null;
69
        return null;
73
    }
70
    }
74
71
75
    public static int getTotalCount() {
72
    public static int getTotalCount() {
76
        return VALUES_ARRAY.length;
73
        return values.size();
74
    }
75
    
76
    public String getLiteral() {
77
    	return getName();
78
    }
79
    
80
    public String getName() {
81
    	return name;
82
    }
83
    
84
    public int getValue() {
85
    	return ordinal();
77
    }
86
    }
78
}
87
}
(-)src/org/eclipse/emf/query/statements/IQueryResult.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 19-24 Link Here
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
21
22
import org.eclipse.emf.ecore.EObject;
22
import org.eclipse.emf.query.conditions.eobjects.IEObjectSource;
23
import org.eclipse.emf.query.conditions.eobjects.IEObjectSource;
23
24
24
25
Lines 38-44 Link Here
38
 * @author Chris McGee (cmcgee)
39
 * @author Chris McGee (cmcgee)
39
 */
40
 */
40
public interface IQueryResult
41
public interface IQueryResult
41
	extends Collection, IEObjectSource {
42
	extends Collection<EObject>, IEObjectSource {
42
43
43
	/**
44
	/**
44
	 * Retrieve the exception (if any) that occurred during the execute
45
	 * Retrieve the exception (if any) that occurred during the execute
(-)src/org/eclipse/emf/query/statements/WHERE.java (-2 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 29-35 Link Here
29
 * 
29
 * 
30
 * @author Yasser Lulu 
30
 * @author Yasser Lulu 
31
 */
31
 */
32
public class WHERE extends QueryClause{
32
public class WHERE extends QueryClause {
33
	
33
	
34
	// IMPORTANT: never cache results to guarantee correctness of results when 
34
	// IMPORTANT: never cache results to guarantee correctness of results when 
35
	// re-executing the query, since eObject could change some of their 
35
	// re-executing the query, since eObject could change some of their 
(-)src/org/eclipse/emf/query/statements/UPDATE.java (-2 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 51-57 Link Here
51
        this.set = set;
51
        this.set = set;
52
    }
52
    }
53
53
54
    protected void addEObject(EObject eObject) {
54
    @Override
55
	protected void addEObject(EObject eObject) {
55
        if (getSetClause().set(eObject)) {
56
        if (getSetClause().set(eObject)) {
56
            super.addEObject(eObject);
57
            super.addEObject(eObject);
57
        }
58
        }
(-)src/org/eclipse/emf/query/conditions/booleans/BooleanCondition.java (-17 / +23 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-23 Link Here
17
17
18
package org.eclipse.emf.query.conditions.booleans;
18
package org.eclipse.emf.query.conditions.booleans;
19
19
20
import org.eclipse.emf.query.conditions.Condition;
20
import org.eclipse.emf.query.conditions.DataTypeCondition;
21
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
22
22
/**
23
/**
23
 * A <code>Condition</code> object that tests for <code>Boolean</code>
24
 * A <code>Condition</code> object that tests for <code>Boolean</code>
Lines 27-37 Link Here
27
 * It evaluates to <code>true</code> when values are equal
28
 * It evaluates to <code>true</code> when values are equal
28
 */
29
 */
29
public class BooleanCondition
30
public class BooleanCondition
30
	extends Condition {
31
	extends DataTypeCondition<Boolean> {
31
32
	private boolean booleanValue;
33
34
	private BooleanAdapter adapter;
35
32
36
	/**
33
	/**
37
	 * Constructs this <code>BooleanCondition</code> with a boolean value to
34
	 * Constructs this <code>BooleanCondition</code> with a boolean value to
Lines 57-78 Link Here
57
	 *            The initialization value of this <code>Condition</code> to
54
	 *            The initialization value of this <code>Condition</code> to
58
	 *            use in testing argument objects for equality.
55
	 *            use in testing argument objects for equality.
59
	 * @param adapter
56
	 * @param adapter
60
	 *            The <code>BooleanAdapter</code> to use to extract a
57
	 *            The generic <code>IDataTypeAdapter</code> to use to extract a
61
	 *            <code>Boolean</code> representation of the argument object
58
	 *            <code>Boolean</code> representation of the argument object
62
	 *            when evaluating it.
59
	 *            when evaluating it.
60
	 *            
61
	 * @since 1.2
63
	 */
62
	 */
64
	public BooleanCondition(boolean booleanValue, BooleanAdapter adapter) {
63
	public BooleanCondition(boolean booleanValue, IDataTypeAdapter<Boolean> adapter) {
65
		this.booleanValue = booleanValue;
64
		super(booleanValue, adapter);
66
		this.adapter = adapter;
67
	}
65
	}
68
66
69
	/*
67
	/**
70
	 * (non-Javadoc)
68
	 * Constructs this <code>BooleanCondition</code> with a boolean value to
69
	 * test for. It uses the argument <code>BooleanAdapter</code> adapter to
70
	 * adapt argument objects to <code>Boolean</code> objects in order to do
71
	 * the comparison
71
	 * 
72
	 * 
72
	 * @see org.eclipse.emf.query.conditions.Condition#isSatisfied(java.lang.Object)
73
	 * @param booleanValue
74
	 *            The initialization value of this <code>Condition</code> to
75
	 *            use in testing argument objects for equality.
76
	 * @param adapter
77
	 *            The <code>BooleanAdapter</code> to use to extract a
78
	 *            <code>Boolean</code> representation of the argument object
79
	 *            when evaluating it.
73
	 */
80
	 */
74
	public boolean isSatisfied(Object object) {
81
	public BooleanCondition(boolean booleanValue, BooleanAdapter adapter) {
75
		return adapter.getBoolean(object).booleanValue() == booleanValue;
82
		super(booleanValue, adapter);
76
	}
83
	}
77
78
}
84
}
(-)src/org/eclipse/emf/query/conditions/booleans/BooleanAdapter.java (-2 / +14 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002, 2006 IBM Corporation and others.
4
 * Copyright (c) 2002, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
17
18
package org.eclipse.emf.query.conditions.booleans;
18
package org.eclipse.emf.query.conditions.booleans;
19
19
20
import org.eclipse.emf.query.conditions.IDataTypeAdapter;
21
20
/**
22
/**
21
 * An Adapter class to be used to extract from -adapt- the argument object some
23
 * An Adapter class to be used to extract from -adapt- the argument object some
22
 * Boolean object (value) that would later be used in <code>Condition</code>
24
 * Boolean object (value) that would later be used in <code>Condition</code>
Lines 24-30 Link Here
24
 * 
26
 * 
25
 * @see BooleanCondition
27
 * @see BooleanCondition
26
 */
28
 */
27
public abstract class BooleanAdapter {
29
public abstract class BooleanAdapter implements IDataTypeAdapter<Boolean> {
28
30
29
	/**
31
	/**
30
	 * The simplest <code>BooleanAdapter</code> implementation that represents
32
	 * The simplest <code>BooleanAdapter</code> implementation that represents
Lines 33-41 Link Here
33
	 */
35
	 */
34
	public static final BooleanAdapter DEFAULT = new BooleanAdapter() {
36
	public static final BooleanAdapter DEFAULT = new BooleanAdapter() {
35
37
38
		@Override
36
		public Boolean getBoolean(Object object) {
39
		public Boolean getBoolean(Object object) {
37
			return (Boolean) object;
40
			return (Boolean) object;
38
		}
41
		}
42
		
43
		@Override
44
		public Boolean adapt(Object value) {
45
			return (Boolean) value;
46
		}
39
	};
47
	};
40
48
41
	/**
49
	/**
Lines 47-50 Link Here
47
	 * @return Boolean the <code>Boolean</code> object representation of the argument object
55
	 * @return Boolean the <code>Boolean</code> object representation of the argument object
48
	 */
56
	 */
49
	public abstract Boolean getBoolean(Object object);
57
	public abstract Boolean getBoolean(Object object);
58
	
59
	public Boolean adapt(Object value) {
60
		return getBoolean(value);
61
	}
50
}
62
}
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/emf/query/conditions/IDataTypeAdapter.java (+41 lines)
Added Link Here
1
/**
2
 * <copyright> 
3
 *
4
 * Copyright (c) 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
package org.eclipse.emf.query.conditions;
18
19
20
/**
21
 * An object that knows how to adapt objects to a given type.
22
 * 
23
 * @param <T> the type of object to which the adapter adapts values
24
 * 
25
 * @author Christian W. Damus (cdamus)
26
 * 
27
 * @since 1.2
28
 */
29
public interface IDataTypeAdapter<T> {
30
31
	/**
32
	 * Adapts the specified input value to the type that I provide.
33
	 * 
34
	 * @param value the input value
35
	 * 
36
	 * @return the corresponding output value
37
	 * 
38
	 * @since 1.2
39
	 */
40
	T adapt(Object value);
41
}
(-)src/org/eclipse/emf/query/conditions/DataTypeCondition.java (+57 lines)
Added Link Here
1
/**
2
 * <copyright> 
3
 *
4
 * Copyright (c) 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
12
 *
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
package org.eclipse.emf.query.conditions;
18
19
20
/**
21
 * A condition on data-type (primitive) values.
22
 * 
23
 * @param <T> the data type, of which values the condition tests
24
 * 
25
 * @author Christian W. Damus (cdamus)
26
 * 
27
 * @since 1.2
28
 */
29
public class DataTypeCondition<T>
30
	extends Condition {
31
32
	private static IDataTypeAdapter<?> DEFAULT_ADAPTER = new IDataTypeAdapter<Object>() {
33
		public Object adapt(Object value) {
34
			return value;
35
		}};
36
	
37
	protected final IDataTypeAdapter<? extends T> adapter;
38
	
39
	protected final T value;
40
	
41
	public DataTypeCondition(T value, IDataTypeAdapter<? extends T> adapter) {
42
		this.value = value;
43
		this.adapter = adapter;
44
	}
45
	
46
	@SuppressWarnings("unchecked")
47
	public DataTypeCondition(T value) {
48
		this(value, (IDataTypeAdapter<T>) DEFAULT_ADAPTER);
49
	}
50
	
51
	// Documentation copied from the inherited specification
52
	@Override
53
	public boolean isSatisfied(Object object) {
54
		return value.equals(adapter.adapt(object));
55
	}
56
57
}
(-)feature.xml (-7 / +8 lines)
Lines 18-24 Link Here
18
<feature
18
<feature
19
      id="org.eclipse.emf.query.examples"
19
      id="org.eclipse.emf.query.examples"
20
      label="%featureName"
20
      label="%featureName"
21
      version="1.1.100.qualifier"
21
      version="1.2.0.qualifier"
22
      provider-name="%providerName"
22
      provider-name="%providerName"
23
      image="modeling32.png">
23
      image="modeling32.png">
24
24
Lines 52-63 Link Here
52
      <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/>
52
      <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/>
53
      <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
53
      <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
54
      <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/>
54
      <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/>
55
      <import plugin="org.eclipse.emf.query.ocl" version="1.0.0" match="compatible"/>
55
      <import plugin="org.eclipse.emf.query.ocl" version="1.1.0" match="compatible"/>
56
      <import plugin="org.eclipse.emf.examples.library.editor" version="2.2.0" match="compatible"/>
56
      <import plugin="org.eclipse.ocl.ecore" version="1.1.0" match="compatible"/>
57
      <import plugin="org.eclipse.emf.query" version="1.0.0" match="compatible"/>
57
      <import plugin="org.eclipse.emf.query" version="1.2.0" match="compatible"/>
58
      <import plugin="org.eclipse.emf.examples.library" version="2.2.0" match="compatible"/>
58
      <import plugin="org.eclipse.emf.examples.library" version="2.3.0" match="compatible"/>
59
      <import plugin="org.eclipse.emf.examples.library.edit" version="2.2.0" match="compatible"/>
59
      <import plugin="org.eclipse.emf.examples.library.edit" version="2.3.0" match="compatible"/>
60
      <import plugin="org.eclipse.emf" version="2.2.0" match="compatible"/>
60
      <import plugin="org.eclipse.emf.examples.library.editor" version="2.3.0" match="compatible"/>
61
      <import plugin="org.eclipse.emf" version="2.3.0" match="compatible"/>
61
   </requires>
62
   </requires>
62
63
63
   <plugin
64
   <plugin
(-)src/org/eclipse/emf/query/examples/statements/QueryPlugin.java (+2 lines)
Lines 39-44 Link Here
39
	/**
39
	/**
40
	 * This method is called upon plug-in activation
40
	 * This method is called upon plug-in activation
41
	 */
41
	 */
42
	@Override
42
	public void start(BundleContext context) throws Exception {
43
	public void start(BundleContext context) throws Exception {
43
		super.start(context);
44
		super.start(context);
44
	}
45
	}
Lines 46-51 Link Here
46
	/**
47
	/**
47
	 * This method is called when the plug-in is stopped
48
	 * This method is called when the plug-in is stopped
48
	 */
49
	 */
50
	@Override
49
	public void stop(BundleContext context) throws Exception {
51
	public void stop(BundleContext context) throws Exception {
50
		super.stop(context);
52
		super.stop(context);
51
	}
53
	}
(-)src/org/eclipse/emf/query/examples/statements/actions/SelectBooksDelegate.java (-2 / +5 lines)
Lines 19-24 Link Here
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
21
22
import org.eclipse.emf.ecore.EObject;
22
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
23
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
23
import org.eclipse.emf.examples.extlibrary.Writer;
24
import org.eclipse.emf.examples.extlibrary.Writer;
24
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
25
import org.eclipse.emf.query.conditions.eobjects.EObjectCondition;
Lines 50-56 Link Here
50
			QueryStatementsMessages.selectBooks_message_notFound);
51
			QueryStatementsMessages.selectBooks_message_notFound);
51
	}
52
	}
52
53
53
	protected Collection performQuery(Object value)
54
	@Override
55
	protected Collection<EObject> performQuery(Object value)
54
		throws Exception {
56
		throws Exception {
55
		
57
		
56
		if (null == selectedEObjects) {
58
		if (null == selectedEObjects) {
Lines 87-93 Link Here
87
	 */
89
	 */
88
	public void run(IAction action) {
90
	public void run(IAction action) {
89
		try {
91
		try {
90
			Collection result = performQuery(selectedEObjects.iterator().next());
92
			Collection<EObject> result = performQuery(selectedEObjects.iterator().next());
91
			if (result.isEmpty()) {
93
			if (result.isEmpty()) {
92
				MessageDialog
94
				MessageDialog
93
					.openInformation(shell, title, notFoundMessage);
95
					.openInformation(shell, title, notFoundMessage);
Lines 105-110 Link Here
105
	/* (non-Javadoc)
107
	/* (non-Javadoc)
106
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
108
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
107
	 */
109
	 */
110
	@Override
108
	public void selectionChanged(IAction action, ISelection selection) {
111
	public void selectionChanged(IAction action, ISelection selection) {
109
		super.selectionChanged(action, selection);
112
		super.selectionChanged(action, selection);
110
		
113
		
(-)src/org/eclipse/emf/query/examples/statements/actions/AbstractQueryDelegate.java (-4 / +10 lines)
Lines 19-24 Link Here
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
21
22
import org.eclipse.emf.ecore.EObject;
22
import org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditor;
23
import org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditor;
23
import org.eclipse.emf.query.examples.statements.internal.l10n.QueryStatementsMessages;
24
import org.eclipse.emf.query.examples.statements.internal.l10n.QueryStatementsMessages;
24
import org.eclipse.jface.action.IAction;
25
import org.eclipse.jface.action.IAction;
Lines 41-47 Link Here
41
	implements IEditorActionDelegate, IActionDelegate2 {
42
	implements IEditorActionDelegate, IActionDelegate2 {
42
43
43
	/**
44
	/**
44
	 * Error message to display when an exception occured
45
	 * Error message to display when an exception occurred
45
	 */
46
	 */
46
	protected static final String MESSAGE_EXCEPTION = QueryStatementsMessages.message_exception;
47
	protected static final String MESSAGE_EXCEPTION = QueryStatementsMessages.message_exception;
47
48
Lines 58-64 Link Here
58
	/**
59
	/**
59
	 * Selected EObjects
60
	 * Selected EObjects
60
	 */
61
	 */
61
	protected Collection selectedEObjects = null;
62
	protected Collection<EObject> selectedEObjects = null;
62
63
63
	/**
64
	/**
64
	 * The InputDialog title
65
	 * The InputDialog title
Lines 91-97 Link Here
91
	 *            The value used to drive the query
92
	 *            The value used to drive the query
92
	 * @return The set of objects returned by the query
93
	 * @return The set of objects returned by the query
93
	 */
94
	 */
94
	protected abstract Collection performQuery(Object value)
95
	protected abstract Collection<EObject> performQuery(Object value)
95
		throws Exception;
96
		throws Exception;
96
97
97
	/*
98
	/*
Lines 103-109 Link Here
103
		try {
104
		try {
104
			if (selection instanceof IStructuredSelection) {
105
			if (selection instanceof IStructuredSelection) {
105
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
106
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
106
				this.selectedEObjects = structuredSelection.toList();
107
				this.selectedEObjects = new java.util.ArrayList<EObject>();
108
				for (Object next : structuredSelection.toList()) {
109
					if (next instanceof EObject) {
110
						selectedEObjects.add((EObject) next);
111
					}
112
				}
107
			}
113
			}
108
		} catch (Exception e) {
114
		} catch (Exception e) {
109
			// Exceptions are not expected
115
			// Exceptions are not expected
(-)src/org/eclipse/emf/query/examples/statements/actions/SelectWritersDelegate.java (-7 / +10 lines)
Lines 20-29 Link Here
20
20
21
import java.util.Collection;
21
import java.util.Collection;
22
import java.util.Collections;
22
import java.util.Collections;
23
import java.util.Iterator;
24
import java.util.List;
23
import java.util.List;
25
24
26
import org.eclipse.emf.common.util.Enumerator;
25
import org.eclipse.emf.common.util.Enumerator;
26
import org.eclipse.emf.ecore.EObject;
27
import org.eclipse.emf.examples.extlibrary.BookCategory;
27
import org.eclipse.emf.examples.extlibrary.BookCategory;
28
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
28
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
29
import org.eclipse.emf.examples.extlibrary.Library;
29
import org.eclipse.emf.examples.extlibrary.Library;
Lines 42-47 Link Here
42
import org.eclipse.jface.viewers.IStructuredContentProvider;
42
import org.eclipse.jface.viewers.IStructuredContentProvider;
43
import org.eclipse.jface.viewers.LabelProvider;
43
import org.eclipse.jface.viewers.LabelProvider;
44
import org.eclipse.jface.viewers.Viewer;
44
import org.eclipse.jface.viewers.Viewer;
45
import org.eclipse.jface.window.Window;
45
import org.eclipse.ui.dialogs.ListDialog;
46
import org.eclipse.ui.dialogs.ListDialog;
46
47
47
/**
48
/**
Lines 65-71 Link Here
65
			QueryStatementsMessages.selectWriters_message_notFound);
66
			QueryStatementsMessages.selectWriters_message_notFound);
66
	}
67
	}
67
68
68
	protected Collection performQuery(Object value)
69
	@Override
70
	protected Collection<EObject> performQuery(Object value)
69
		throws Exception {
71
		throws Exception {
70
		if (null == selectedEObjects) {
72
		if (null == selectedEObjects) {
71
			throw new NullPointerException("Argument 'context' is null"); //$NON-NLS-1$
73
			throw new NullPointerException("Argument 'context' is null"); //$NON-NLS-1$
Lines 103-109 Link Here
103
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#run(org.eclipse.jface.action.IAction)
105
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#run(org.eclipse.jface.action.IAction)
104
	 */
106
	 */
105
	public void run(IAction action) {
107
	public void run(IAction action) {
106
		final List contents = BookCategory.VALUES;
108
		final List<BookCategory> contents = BookCategory.VALUES;
107
		
109
		
108
		ListDialog dialog = new ListDialog(shell);
110
		ListDialog dialog = new ListDialog(shell);
109
		dialog.setTitle(title);
111
		dialog.setTitle(title);
Lines 126-131 Link Here
126
			}
128
			}
127
		});
129
		});
128
		dialog.setLabelProvider(new LabelProvider() {
130
		dialog.setLabelProvider(new LabelProvider() {
131
			@Override
129
			public String getText(Object element) {
132
			public String getText(Object element) {
130
				if (element instanceof Enumerator) {
133
				if (element instanceof Enumerator) {
131
					return ((Enumerator)element).getName();
134
					return ((Enumerator)element).getName();
Lines 137-145 Link Here
137
		dialog.setBlockOnOpen(true);
140
		dialog.setBlockOnOpen(true);
138
		
141
		
139
		
142
		
140
		if (ListDialog.OK == dialog.open()) {
143
		if (Window.OK == dialog.open()) {
141
			try {
144
			try {
142
				Collection result = performQuery(dialog.getResult()[0]);
145
				Collection<EObject> result = performQuery(dialog.getResult()[0]);
143
				if (result.isEmpty()) {
146
				if (result.isEmpty()) {
144
					MessageDialog
147
					MessageDialog
145
						.openInformation(shell, title, notFoundMessage);
148
						.openInformation(shell, title, notFoundMessage);
Lines 155-167 Link Here
155
	}
158
	}
156
	
159
	
157
160
161
	@Override
158
	public void selectionChanged(IAction action, ISelection selection) {
162
	public void selectionChanged(IAction action, ISelection selection) {
159
		super.selectionChanged(action, selection);
163
		super.selectionChanged(action, selection);
160
		
164
		
161
		if (action.isEnabled()) {
165
		if (action.isEnabled()) {
162
			// Ensure that the selection is a selection of library(ies).
166
			// Ensure that the selection is a selection of library(ies).
163
			for (Iterator i = selectedEObjects.iterator(); i.hasNext();) {
167
			for (EObject o : selectedEObjects) {
164
				Object o = i.next();
165
				if (!(o instanceof Library)) {
168
				if (!(o instanceof Library)) {
166
					action.setEnabled(false);
169
					action.setEnabled(false);
167
					return;
170
					return;
(-)src/org/eclipse/emf/query/examples/statements/actions/SelectLargeBooksDelegate.java (-8 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-25 Link Here
18
package org.eclipse.emf.query.examples.statements.actions;
18
package org.eclipse.emf.query.examples.statements.actions;
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.Iterator;
22
21
22
import org.eclipse.emf.ecore.EObject;
23
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
23
import org.eclipse.emf.examples.extlibrary.EXTLibraryPackage;
24
import org.eclipse.emf.examples.extlibrary.Library;
24
import org.eclipse.emf.examples.extlibrary.Library;
25
import org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectAttributeValueCondition;
25
import org.eclipse.emf.query.conditions.eobjects.structuralfeatures.EObjectAttributeValueCondition;
Lines 48-60 Link Here
48
	/* (non-Javadoc)
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#performQuery(java.lang.Object)
49
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#performQuery(java.lang.Object)
50
	 */
50
	 */
51
	protected Collection performQuery(Object value)
51
	@Override
52
	protected Collection<EObject> performQuery(Object value)
52
		throws Exception {
53
		throws Exception {
53
		
54
		
54
		SELECT select = new SELECT(
55
		SELECT select = new SELECT(
55
			new FROM(selectedEObjects),
56
			new FROM(selectedEObjects),
56
			new WHERE(new EObjectAttributeValueCondition(EXTLibraryPackage.eINSTANCE.getBook_Pages(),
57
			new WHERE(new EObjectAttributeValueCondition(
57
					new NumberCondition.IntegerValue(new Integer(500),new Integer(Integer.MAX_VALUE))
58
					EXTLibraryPackage.eINSTANCE.getBook_Pages(),
59
					NumberCondition.between(500, Integer.MAX_VALUE)
58
				)
60
				)
59
			)
61
			)
60
		);
62
		);
Lines 67-73 Link Here
67
	 */
69
	 */
68
	public void run(IAction action) {
70
	public void run(IAction action) {
69
		try {
71
		try {
70
			Collection result = performQuery(null);
72
			Collection<EObject> result = performQuery(null);
71
			if (result.isEmpty()) {
73
			if (result.isEmpty()) {
72
				MessageDialog
74
				MessageDialog
73
					.openInformation(shell, title, notFoundMessage);
75
					.openInformation(shell, title, notFoundMessage);
Lines 85-97 Link Here
85
	/* (non-Javadoc)
87
	/* (non-Javadoc)
86
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
88
	 * @see org.eclipse.emf.query.examples.statements.actions.AbstractQueryDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
87
	 */
89
	 */
90
	@Override
88
	public void selectionChanged(IAction action, ISelection selection) {
91
	public void selectionChanged(IAction action, ISelection selection) {
89
		super.selectionChanged(action, selection);
92
		super.selectionChanged(action, selection);
90
		
93
		
91
		if (action.isEnabled()) {
94
		if (action.isEnabled()) {
92
			// Ensure that the selection is a selection of library(ies).
95
			// Ensure that the selection is a selection of library(ies).
93
			for (Iterator i = selectedEObjects.iterator(); i.hasNext();) {
96
			for (EObject o : selectedEObjects) {
94
				Object o = i.next();
95
				if (!(o instanceof Library)) {
97
				if (!(o instanceof Library)) {
96
					action.setEnabled(false);
98
					action.setEnabled(false);
97
					return;
99
					return;
(-).settings/org.eclipse.jdt.ui.prefs (-3 lines)
Removed Link Here
1
#Wed Dec 20 11:37:45 EST 2006
2
eclipse.preferences.version=1
3
internal.default.compliance=user
(-).settings/org.eclipse.jdt.core.prefs (-6 / +10 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:37:45 EST 2006
1
#Sun Oct 21 00:23:19 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.5
7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
11
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
12
org.eclipse.jdt.core.compiler.source=1.5
(-)META-INF/MANIFEST.MF (-7 / +7 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.query.examples.statements; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.query.examples.statements; singleton:=true
5
Bundle-Version: 1.0.200.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.query.examples.statements.QueryPlugin
6
Bundle-Activator: org.eclipse.emf.query.examples.statements.QueryPlugin
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 11-20 Link Here
11
 org.eclipse.emf.query.examples.statements.internal.l10n;x-internal:=true
11
 org.eclipse.emf.query.examples.statements.internal.l10n;x-internal:=true
12
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
12
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.emf.query;bundle-version="[1.0.0,2.0.0)",
14
 org.eclipse.emf.query;bundle-version="[1.2.0,2.0.0)",
15
 org.eclipse.emf.examples.library;bundle-version="[2.2.0,3.0.0)",
15
 org.eclipse.emf.examples.library;bundle-version="[2.3.0,3.0.0)",
16
 org.eclipse.emf.examples.library.edit;bundle-version="[2.2.0,3.0.0)",
16
 org.eclipse.emf.examples.library.edit;bundle-version="[2.3.0,3.0.0)",
17
 org.eclipse.emf.examples.library.editor;bundle-version="[2.2.0,3.0.0)",
17
 org.eclipse.emf.examples.library.editor;bundle-version="[2.3.0,3.0.0)",
18
 org.eclipse.emf;bundle-version="[2.2.0,3.0.0)"
18
 org.eclipse.emf;bundle-version="[2.3.0,3.0.0)"
19
Eclipse-LazyStart: true
19
Eclipse-LazyStart: true
20
Bundle-RequiredExecutionEnvironment: J2SE-1.4
20
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/query/examples/ocl/wizards/ContextFreeQueryWizard.java (+1 lines)
Lines 31-36 Link Here
31
		super();
31
		super();
32
	}
32
	}
33
33
34
	@Override
34
	protected IOCLQueryWizardPage createOclQueryPage() {
35
	protected IOCLQueryWizardPage createOclQueryPage() {
35
		return new ContextFreeQueryWizardPage();
36
		return new ContextFreeQueryWizardPage();
36
	}
37
	}
(-)src/org/eclipse/emf/query/examples/ocl/wizards/QueryWithContextWizardPage.java (+3 lines)
Lines 129-138 Link Here
129
	private void fillContextCombo() {
129
	private void fillContextCombo() {
130
		contextCombo.setContentProvider(new ArrayContentProvider());
130
		contextCombo.setContentProvider(new ArrayContentProvider());
131
		contextCombo.setLabelProvider(new LabelProvider() {
131
		contextCombo.setLabelProvider(new LabelProvider() {
132
			@Override
132
			public String getText(Object element) {
133
			public String getText(Object element) {
133
				return ((EClassifier) element).getName();
134
				return ((EClassifier) element).getName();
134
			}});
135
			}});
135
		contextCombo.setSorter(new ViewerSorter() {
136
		contextCombo.setSorter(new ViewerSorter() {
137
			@Override
136
			public int compare(Viewer viewer, Object e1, Object e2) {
138
			public int compare(Viewer viewer, Object e1, Object e2) {
137
				return ((EClassifier) e1).getName().compareTo(
139
				return ((EClassifier) e1).getName().compareTo(
138
					((EClassifier) e2).getName());
140
					((EClassifier) e2).getName());
Lines 201-206 Link Here
201
	/* (non-Javadoc)
203
	/* (non-Javadoc)
202
	 * Redefines/Implements/Extends the inherited method.
204
	 * Redefines/Implements/Extends the inherited method.
203
	 */
205
	 */
206
	@Override
204
	public void dispose() {
207
	public void dispose() {
205
		super.dispose();
208
		super.dispose();
206
	}
209
	}
(-)src/org/eclipse/emf/query/examples/ocl/wizards/ContextFreeQueryWizardPage.java (+1 lines)
Lines 115-120 Link Here
115
	/* (non-Javadoc)
115
	/* (non-Javadoc)
116
	 * Redefines/Implements/Extends the inherited method.
116
	 * Redefines/Implements/Extends the inherited method.
117
	 */
117
	 */
118
	@Override
118
	public void dispose() {
119
	public void dispose() {
119
		super.dispose();
120
		super.dispose();
120
	}
121
	}
(-)src/org/eclipse/emf/query/examples/ocl/wizards/AbstractQueryWizard.java (+2 lines)
Lines 40-45 Link Here
40
		super();
40
		super();
41
	}
41
	}
42
42
43
	@Override
43
	public void addPages() {
44
	public void addPages() {
44
		super.addPages();
45
		super.addPages();
45
		
46
		
Lines 47-52 Link Here
47
		addPage(page);
48
		addPage(page);
48
	}
49
	}
49
	
50
	
51
	@Override
50
	public boolean performFinish() {
52
	public boolean performFinish() {
51
		condition = page.getCondition();
53
		condition = page.getCondition();
52
		
54
		
(-)src/org/eclipse/emf/query/examples/ocl/wizards/QueryWithContextWizard.java (+1 lines)
Lines 31-36 Link Here
31
		super();
31
		super();
32
	}
32
	}
33
33
34
	@Override
34
	protected IOCLQueryWizardPage createOclQueryPage() {
35
	protected IOCLQueryWizardPage createOclQueryPage() {
35
		return new QueryWithContextWizardPage();
36
		return new QueryWithContextWizardPage();
36
	}
37
	}
(-)src/org/eclipse/emf/query/examples/ocl/actions/OCLQueryDelegate.java (+1 lines)
Lines 55-60 Link Here
55
		super();
55
		super();
56
	}
56
	}
57
57
58
	@Override
58
	public void run(IAction action) {
59
	public void run(IAction action) {
59
		Collection<EObject> selection = getSelectedObjects();
60
		Collection<EObject> selection = getSelectedObjects();
60
		
61
		
(-)src/org/eclipse/emf/query/examples/ocl/actions/AbstractQueryDelegate.java (+1 lines)
Lines 111-116 Link Here
111
	/**
111
	/**
112
	 * Gets all of the {@link EObject}s in the current selection, if any.
112
	 * Gets all of the {@link EObject}s in the current selection, if any.
113
	 */
113
	 */
114
	@Override
114
	public void selectionChanged(IAction action, final ISelection selection) {
115
	public void selectionChanged(IAction action, final ISelection selection) {
115
		selectedEObjects = Collections.emptySet();
116
		selectedEObjects = Collections.emptySet();
116
		
117
		
(-)src/org/eclipse/emf/query/examples/ocl/actions/ContextFreeQueryDelegate.java (+1 lines)
Lines 55-60 Link Here
55
		super();
55
		super();
56
	}
56
	}
57
57
58
	@Override
58
	public void run(IAction action) {
59
	public void run(IAction action) {
59
		Collection<EObject> selection = getSelectedObjects();
60
		Collection<EObject> selection = getSelectedObjects();
60
		
61
		
(-)src/org/eclipse/emf/query/examples/ocl/OCLPlugin.java (+2 lines)
Lines 39-44 Link Here
39
	/**
39
	/**
40
	 * This method is called upon plug-in activation
40
	 * This method is called upon plug-in activation
41
	 */
41
	 */
42
	@Override
42
	public void start(BundleContext context) throws Exception {
43
	public void start(BundleContext context) throws Exception {
43
		super.start(context);
44
		super.start(context);
44
	}
45
	}
Lines 46-51 Link Here
46
	/**
47
	/**
47
	 * This method is called when the plug-in is stopped
48
	 * This method is called when the plug-in is stopped
48
	 */
49
	 */
50
	@Override
49
	public void stop(BundleContext context) throws Exception {
51
	public void stop(BundleContext context) throws Exception {
50
		super.stop(context);
52
		super.stop(context);
51
	}
53
	}
(-)feature.xml (-1 / +1 lines)
Lines 2-8 Link Here
2
<feature
2
<feature
3
      id="org.eclipse.emf.query.sdk"
3
      id="org.eclipse.emf.query.sdk"
4
      label="%featureName"
4
      label="%featureName"
5
      version="1.1.100.qualifier"
5
      version="1.2.0.qualifier"
6
      provider-name="%providerName"
6
      provider-name="%providerName"
7
      image="modeling32.png">
7
      image="modeling32.png">
8
8
(-)feature.xml (-1 / +1 lines)
Lines 18-24 Link Here
18
<feature
18
<feature
19
      id="org.eclipse.emf.query.doc"
19
      id="org.eclipse.emf.query.doc"
20
      label="%featureName"
20
      label="%featureName"
21
      version="1.1.100.qualifier"
21
      version="1.2.0.qualifier"
22
      provider-name="%providerName"
22
      provider-name="%providerName"
23
      image="modeling32.png">
23
      image="modeling32.png">
24
24

Return to bug 206812