KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > internal > resolver > ResolverErrorImpl


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.osgi.internal.resolver;
12
13 import org.eclipse.osgi.service.resolver.*;
14 import org.eclipse.osgi.util.NLS;
15
16 public class ResolverErrorImpl implements ResolverError {
17     private BundleDescriptionImpl bundle;
18     private int type;
19     private String JavaDoc data;
20     private VersionConstraint unsatisfied;
21     public ResolverErrorImpl(BundleDescriptionImpl bundle, int type, String JavaDoc data, VersionConstraint unsatisfied) {
22         this.bundle = bundle;
23         this.data = data;
24         this.type = type;
25         this.unsatisfied = unsatisfied;
26     }
27
28     public BundleDescription getBundle() {
29         return bundle;
30     }
31
32     public int getType() {
33         return type;
34     }
35
36     public String JavaDoc getData() {
37         return data;
38     }
39
40     public VersionConstraint getUnsatisfiedConstraint() {
41         return unsatisfied;
42     }
43
44     public String JavaDoc toString() {
45         switch (getType()) {
46             case ResolverError.EXPORT_PACKAGE_PERMISSION :
47             case ResolverError.IMPORT_PACKAGE_PERMISSION :
48             case ResolverError.REQUIRE_BUNDLE_PERMISSION :
49             case ResolverError.PROVIDE_BUNDLE_PERMISSION :
50             case ResolverError.FRAGMENT_BUNDLE_PERMISSION :
51             case ResolverError.HOST_BUNDLE_PERMISSION :
52                 return NLS.bind(StateMsg.RES_ERROR_MISSING_PERMISSION, getData());
53             case ResolverError.MISSING_IMPORT_PACKAGE :
54             case ResolverError.MISSING_REQUIRE_BUNDLE :
55             case ResolverError.MISSING_FRAGMENT_HOST :
56             case ResolverError.MISSING_EXECUTION_ENVIRONMENT :
57             case ResolverError.MISSING_GENERIC_CAPABILITY :
58                 return NLS.bind(StateMsg.RES_ERROR_MISSING_CONSTRAINT, getData());
59             case ResolverError.FRAGMENT_CONFLICT :
60                 return NLS.bind(StateMsg.RES_ERROR_FRAGMENT_CONFLICT, getData());
61             case ResolverError.IMPORT_PACKAGE_USES_CONFLICT :
62             case ResolverError.REQUIRE_BUNDLE_USES_CONFLICT :
63                 return NLS.bind(StateMsg.RES_ERROR_USES_CONFLICT, getData());
64             case ResolverError.SINGLETON_SELECTION :
65                 return NLS.bind(StateMsg.RES_ERROR_SINGLETON_CONFLICT, getData());
66             case ResolverError.PLATFORM_FILTER :
67                 return NLS.bind(StateMsg.RES_ERROR_PLATFORM_FILTER, getData());
68             default :
69                 return StateMsg.RES_ERROR_UNKNOWN;
70         }
71     }
72 }
73
Popular Tags