blob: 15a8c5fc6737377870e6ff6f94cd66f1abcf8d0f [file] [log] [blame]
Richard S. Hall930fecc2005-08-16 18:33:34 +00001/*
2 * Copyright 2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.apache.osgi.moduleloader.search;
18
19import org.apache.osgi.moduleloader.Module;
20
21/**
22 * <p>
23 * This exception is thrown if a module cannot be validated. The module
24 * that failed to be validated is recorded, along with the failed import target
25 * identifier and version number. If the error was a result of a propagation
26 * conflict, then the propagation error flag is set.
27 * </p>
28 * @see org.apache.osgi.moduleloader.search.ImportSearchPolicy#validate(org.apache.osgi.moduleloader.Module)
29**/
30public class ValidationException extends Exception
31{
32 private Module m_module = null;
33 private Object m_identifier = null;
34 private Object m_version = null;
35 private boolean m_isPropagation = false;
36
37 /**
38 * Constructs an exception with the specified message, module,
39 * import identifier, import version number, and propagation flag.
40 **/
41 public ValidationException(String msg, Module module,
42 Object identifier, Object version, boolean isPropagation)
43 {
44 super(msg);
45 m_module = module;
46 m_identifier = identifier;
47 m_version = version;
48 m_isPropagation = isPropagation;
49 }
50
51 /**
52 * Returns the module that was being validated.
53 * @return the module that was being validated.
54 **/
55 public Module getModule()
56 {
57 return m_module;
58 }
59
60 /**
61 * Returns the identifier of the import target that could not be resolved.
62 * @return the identifier of the import target that could not be resolved.
63 **/
64 public Object getIdentifier()
65 {
66 return m_identifier;
67 }
68
69 /**
70 * Returns the version number of the import target that could not be resolved.
71 * @return the version number of the import target that could not be resolved.
72 **/
73 public Object getVersion()
74 {
75 return m_version;
76 }
77
78 /**
79 * Returns a flag indicating whether the exception was caused by a
80 * a propagation conflict.
81 * @return <tt>true</tt> if the exception was thrown due to a propagation
82 * conflict, <tt>false</tt> otherwise.
83 **/
84 public boolean isPropagationError()
85 {
86 return m_isPropagation;
87 }
88}