blob: 8d1782dc2935c8cb15e47d4f52254e3232c52211 [file] [log] [blame]
Richard S. Hall930fecc2005-08-16 18:33:34 +00001/*
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/InvalidSyntaxException.java,v 1.10 2005/05/13 20:32:55 hargrave Exp $
3 *
4 * Copyright (c) OSGi Alliance (2000, 2005). All Rights Reserved.
5 *
6 * This program and the accompanying materials are made available under the
7 * terms of the Eclipse Public License v1.0 which accompanies this
8 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
9 */
10
11package org.osgi.framework;
12
13/**
14 * A Framework exception.
15 *
16 * <p>
17 * An <code>InvalidSyntaxException</code> object indicates that a filter string
18 * parameter has an invalid syntax and cannot be parsed.
19 *
20 * <p>
21 * See {@link Filter} for a description of the filter string syntax.
22 *
23 * @version $Revision: 1.10 $
24 */
25
26public class InvalidSyntaxException extends Exception {
27 static final long serialVersionUID = -4295194420816491875L;
28 /**
29 * The invalid filter string.
30 */
31 private String filter;
32 /**
33 * Nested exception.
34 */
35 private Throwable cause;
36
37 /**
38 * Creates an exception of type <code>InvalidSyntaxException</code>.
39 *
40 * <p>
41 * This method creates an <code>InvalidSyntaxException</code> object with the
42 * specified message and the filter string which generated the exception.
43 *
44 * @param msg The message.
45 * @param filter The invalid filter string.
46 */
47 public InvalidSyntaxException(String msg, String filter) {
48 super(msg);
49 this.filter = filter;
50 this.cause = null;
51 }
52
53 /**
54 * Creates an exception of type <code>InvalidSyntaxException</code>.
55 *
56 * <p>
57 * This method creates an <code>InvalidSyntaxException</code> object with the
58 * specified message and the filter string which generated the exception.
59 *
60 * @param msg The message.
61 * @param filter The invalid filter string.
62 * @param cause The cause of this exception.
63 * @since 1.3
64 */
65 public InvalidSyntaxException(String msg, String filter, Throwable cause) {
66 super(msg);
67 this.filter = filter;
68 this.cause = cause;
69 }
70
71 /**
72 * Returns the filter string that generated the
73 * <code>InvalidSyntaxException</code> object.
74 *
75 * @return The invalid filter string.
76 * @see BundleContext#getServiceReferences
77 * @see BundleContext#addServiceListener(ServiceListener,String)
78 */
79 public String getFilter() {
80 return filter;
81 }
82
83 /**
84 * Returns the cause of this exception or <code>null</code> if no cause was
85 * specified when this exception was created.
86 *
87 * @return The cause of this exception or <code>null</code> if no cause was
88 * specified.
89 * @since 1.3
90 */
91 public Throwable getCause() {
92 return cause;
93 }
94
95 /**
96 * The cause of this exception can only be set when constructed.
97 *
98 * @throws java.lang.IllegalStateException This method will always throw an
99 * <code>IllegalStateException</code> since the cause of this
100 * exception can only be set when constructed.
101 * @since 1.3
102 */
103 public Throwable initCause(Throwable cause) {
104 throw new IllegalStateException();
105 }
106}
107