Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 1 | /* |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 2 | * Copyright (c) OSGi Alliance (2000, 2008). All Rights Reserved. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 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 | |
| 17 | package org.osgi.framework; |
| 18 | |
| 19 | /** |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame] | 20 | * A Framework exception used to indicate that a filter string has an invalid |
| 21 | * syntax. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 22 | * |
| 23 | * <p> |
| 24 | * An <code>InvalidSyntaxException</code> object indicates that a filter |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame] | 25 | * string parameter has an invalid syntax and cannot be parsed. See |
| 26 | * {@link Filter} for a description of the filter string syntax. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 27 | * |
| 28 | * <p> |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 29 | * This exception conforms to the general purpose exception chaining mechanism. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 30 | * |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 31 | * @version $Revision: 6083 $ |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | public class InvalidSyntaxException extends Exception { |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame] | 35 | static final long serialVersionUID = -4295194420816491875L; |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 36 | /** |
| 37 | * The invalid filter string. |
| 38 | */ |
Richard S. Hall | 53e70d3 | 2008-08-01 19:31:32 +0000 | [diff] [blame] | 39 | private final String filter; |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Creates an exception of type <code>InvalidSyntaxException</code>. |
| 43 | * |
| 44 | * <p> |
| 45 | * This method creates an <code>InvalidSyntaxException</code> object with |
| 46 | * the specified message and the filter string which generated the |
| 47 | * exception. |
| 48 | * |
| 49 | * @param msg The message. |
| 50 | * @param filter The invalid filter string. |
| 51 | */ |
| 52 | public InvalidSyntaxException(String msg, String filter) { |
| 53 | super(msg); |
| 54 | this.filter = filter; |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Creates an exception of type <code>InvalidSyntaxException</code>. |
| 59 | * |
| 60 | * <p> |
| 61 | * This method creates an <code>InvalidSyntaxException</code> object with |
| 62 | * the specified message and the filter string which generated the |
| 63 | * exception. |
| 64 | * |
| 65 | * @param msg The message. |
| 66 | * @param filter The invalid filter string. |
| 67 | * @param cause The cause of this exception. |
| 68 | * @since 1.3 |
| 69 | */ |
| 70 | public InvalidSyntaxException(String msg, String filter, Throwable cause) { |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 71 | super(msg, cause); |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 72 | this.filter = filter; |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Returns the filter string that generated the |
| 77 | * <code>InvalidSyntaxException</code> object. |
| 78 | * |
| 79 | * @return The invalid filter string. |
| 80 | * @see BundleContext#getServiceReferences |
| 81 | * @see BundleContext#addServiceListener(ServiceListener,String) |
| 82 | */ |
| 83 | public String getFilter() { |
| 84 | return filter; |
| 85 | } |
| 86 | |
| 87 | /** |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 88 | * Returns the cause of this exception or <code>null</code> if no cause was |
| 89 | * set. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 90 | * |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 91 | * @return The cause of this exception or <code>null</code> if no cause was |
| 92 | * set. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 93 | * @since 1.3 |
| 94 | */ |
| 95 | public Throwable getCause() { |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 96 | return super.getCause(); |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | /** |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 100 | * Initializes the cause of this exception to the specified value. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 101 | * |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 102 | * @param cause The cause of this exception. |
| 103 | * @return This exception. |
| 104 | * @throws IllegalArgumentException If the specified cause is this |
| 105 | * exception. |
| 106 | * @throws IllegalStateException If the cause of this exception has already |
| 107 | * been set. |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 108 | * @since 1.3 |
| 109 | */ |
| 110 | public Throwable initCause(Throwable cause) { |
Richard S. Hall | f28d676 | 2009-06-08 19:31:06 +0000 | [diff] [blame] | 111 | return super.initCause(cause); |
Richard S. Hall | c88fca3 | 2006-10-18 22:01:22 +0000 | [diff] [blame] | 112 | } |
| 113 | } |