1 // REngine - generic Java/R API
3 // Copyright (C) 2007,2008 Simon Urbanek
4 // --- for licensing information see LICENSE file in the distribution ---
8 // Created by Simon Urbanek on 2007/05/03
10 // $Id: REngineException.java 2555 2006-06-21 20:36:42Z urbaneks $
13 package org.rosuda.REngine;
15 /** This exception is thrown whenever the operation requested is not supported by the given R object type, e.g. using <tt>asStrings</tt> on an S4 object. Most {@link REXP} methods throw this exception. Previous R/Java interfaces were silently returning <code>null</code> in those cases, but using exceptions helps to write more robust code. */
16 public class REXPMismatchException extends Exception {
20 /** primary constructor. The exception message will be formed as "attempt to access <REXP-class> as <access-string>"
21 * @param sender R object that triggered this exception (cannot be <code>null</code>!)
22 * @param access assumed type of the access that was requested. It should be a simple name of the assumed type (e.g. <tt>"vector"</tt>). The type name can be based on R semantics beyond basic types reflected by REXP classes. In cases where certain assertions were not satisfied, the string should be of the form <tt>"type (assertion)"</tt> (e.g. <tt>"data frame (must have dim>0)"</tt>). */
23 public REXPMismatchException(REXP sender, String access) {
24 super("attempt to access "+sender.getClass().getName()+" as "+access);
29 /** retrieve the exception sender/origin
30 * @return REXP object that triggered the exception */
31 public REXP getSender() {
35 /** get the assumed access type that was violated by the sender.
36 * @return string describing the access type. See {@link #REXPMismatchException} for details. */
37 public String getAccess() {