blob: f67fd431c02967ecf4f6161764599fe1fdaf9feb [file] [log] [blame]
Richard S. Hallc88fca32006-10-18 22:01:22 +00001/*
Richard S. Hallf28d6762009-06-08 19:31:06 +00002 * Copyright (c) OSGi Alliance (2000, 2008). All Rights Reserved.
Richard S. Hallc88fca32006-10-18 22:01:22 +00003 *
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.osgi.framework;
18
19/**
Richard S. Hall53e70d32008-08-01 19:31:32 +000020 * A Framework exception used to indicate that a filter string has an invalid
21 * syntax.
Richard S. Hallc88fca32006-10-18 22:01:22 +000022 *
23 * <p>
24 * An <code>InvalidSyntaxException</code> object indicates that a filter
Richard S. Hall53e70d32008-08-01 19:31:32 +000025 * string parameter has an invalid syntax and cannot be parsed. See
26 * {@link Filter} for a description of the filter string syntax.
Richard S. Hallc88fca32006-10-18 22:01:22 +000027 *
28 * <p>
Richard S. Hallf28d6762009-06-08 19:31:06 +000029 * This exception conforms to the general purpose exception chaining mechanism.
Richard S. Hallc88fca32006-10-18 22:01:22 +000030 *
Richard S. Hallf28d6762009-06-08 19:31:06 +000031 * @version $Revision: 6083 $
Richard S. Hallc88fca32006-10-18 22:01:22 +000032 */
33
34public class InvalidSyntaxException extends Exception {
Richard S. Hall53e70d32008-08-01 19:31:32 +000035 static final long serialVersionUID = -4295194420816491875L;
Richard S. Hallc88fca32006-10-18 22:01:22 +000036 /**
37 * The invalid filter string.
38 */
Richard S. Hall53e70d32008-08-01 19:31:32 +000039 private final String filter;
Richard S. Hallc88fca32006-10-18 22:01:22 +000040
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. Hallc88fca32006-10-18 22:01:22 +000055 }
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. Hallf28d6762009-06-08 19:31:06 +000071 super(msg, cause);
Richard S. Hallc88fca32006-10-18 22:01:22 +000072 this.filter = filter;
Richard S. Hallc88fca32006-10-18 22:01:22 +000073 }
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. Hallf28d6762009-06-08 19:31:06 +000088 * Returns the cause of this exception or <code>null</code> if no cause was
89 * set.
Richard S. Hallc88fca32006-10-18 22:01:22 +000090 *
Richard S. Hallf28d6762009-06-08 19:31:06 +000091 * @return The cause of this exception or <code>null</code> if no cause was
92 * set.
Richard S. Hallc88fca32006-10-18 22:01:22 +000093 * @since 1.3
94 */
95 public Throwable getCause() {
Richard S. Hallf28d6762009-06-08 19:31:06 +000096 return super.getCause();
Richard S. Hallc88fca32006-10-18 22:01:22 +000097 }
98
99 /**
Richard S. Hallf28d6762009-06-08 19:31:06 +0000100 * Initializes the cause of this exception to the specified value.
Richard S. Hallc88fca32006-10-18 22:01:22 +0000101 *
Richard S. Hallf28d6762009-06-08 19:31:06 +0000102 * @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. Hallc88fca32006-10-18 22:01:22 +0000108 * @since 1.3
109 */
110 public Throwable initCause(Throwable cause) {
Richard S. Hallf28d6762009-06-08 19:31:06 +0000111 return super.initCause(cause);
Richard S. Hallc88fca32006-10-18 22:01:22 +0000112 }
113}