001/**
002 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
003 *   This file is part of the LDP4j Project:
004 *     http://www.ldp4j.org/
005 *
006 *   Center for Open Middleware
007 *     http://www.centeropenmiddleware.com/
008 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
009 *   Copyright (C) 2014-2016 Center for Open Middleware.
010 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
011 *   Licensed under the Apache License, Version 2.0 (the "License");
012 *   you may not use this file except in compliance with the License.
013 *   You may obtain a copy of the License at
014 *
015 *             http://www.apache.org/licenses/LICENSE-2.0
016 *
017 *   Unless required by applicable law or agreed to in writing, software
018 *   distributed under the License is distributed on an "AS IS" BASIS,
019 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020 *   See the License for the specific language governing permissions and
021 *   limitations under the License.
022 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
023 *   Artifact    : org.ldp4j.framework:ldp4j-application-api:0.2.1
024 *   Bundle      : ldp4j-application-api-0.2.1.jar
025 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
026 */
027package org.ldp4j.application.ext;
028
029/**
030 * This exception may be thrown when a query is not understood by a resource
031 * handler that supports querying.
032 *
033 * @see Queryable
034 */
035public class InvalidQueryException extends ApplicationUsageException {
036
037  private static final long serialVersionUID = 954186954933177035L;
038
039  private final Query query;
040
041  /**
042   * Create a new instance with a message, a cause, and a query.
043   *
044   * @param message
045   *            the description of the failure
046   * @param cause
047   *            the underlying cause of the exception
048   * @param query
049   *            the query that caused the failure
050   */
051  public InvalidQueryException(String message, Throwable cause, Query query) {
052    super(message, cause);
053    this.query = query;
054  }
055
056  /**
057   * Create a new instance with a message and a query.
058   *
059   * @param message
060   *            the description of the failure
061   * @param query
062   *            the query that caused the failure
063   */
064  public InvalidQueryException(String message, Query query) {
065    this(message,null,query);
066  }
067
068  /**
069   * Create a new instance with a cause and a query.
070   *
071   * @param cause
072   *            the underlying cause of the exception
073   * @param query
074   *            the query that caused the failure
075   */
076  public InvalidQueryException(Throwable cause, Query query) {
077    this("Invalid query",cause,query);
078  }
079
080
081  /**
082   * Return the {@code Query} instance that caused the exception.
083   *
084   * @return the {@code Query} instance that caused the exception
085   */
086  public Query getQuery() {
087    return query;
088  }
089
090}