Rev 42333 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/methods/man/getClass.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2007 R Core Development Team% Distributed under GPL 2 or later\name{getClass}\alias{getClass}\alias{getClassDef}\title{Get Class Definition }\description{Get the definition of a class.}\usage{getClass(Class, .Force = FALSE, where)getClassDef(Class, where, package)}\arguments{\item{Class}{ the character-string name of the class.}\item{.Force}{ if \code{TRUE}, return \code{NULL} if the class isundefined; otherwise, an undefined class results in an error.}\item{where}{ environment from which to begin the search for the definition; by default,start at the top-level (global) environment and proceed throughthe search list.}\item{package}{ the name of the package asserted to hold thedefinition. Supplied instead of \code{where}, with thedistinction that the package need not be currently attached.}}\details{A call to \code{getClass} returns the complete definition of the classsupplied as a string, including all slots, etc. in classes that thisclass extends. A call to \code{getClassDef} returns the definition ofthe class from the environment \code{where}, unadorned. It's usually \code{getClass}you want.If you really want to know whether a class is formallydefined, call \code{\link{isClass}}.}\value{The object defining the class. This is an object of class\code{"classRepEnvironment"}. However, \emph{do not} deal with thecontents of the object directly unless you are very sure you know whatyou're doing. Even then, it is nearly always better practice to usefunctions such as \code{\link{setClass}} and \code{\link{setIs}}.Messing up a class object will cause great confusion.}\references{The R package \pkg{methods} implements, with a few exceptions, theprogramming interface for classes and methods in the book\emph{Programming with Data} (John M. Chambers, Springer, 1998), inparticular sections 1.6, 2.7, 2.8, and chapters 7 and 8.While the programming interface for the methods package follows thereference, the R software is an original implementation, so details inthe reference that reflect the S4 implementation may appeardifferently in R. Also, there are extensions to the programminginterface developed more recently than the reference. For adiscussion of details see \code{?\link{Methods}}and the links from that documentation.}\seealso{\link{Classes},\code{\link{setClass}},\code{\link{isClass}}.}\examples{getClass("numeric") ## a built in classcld <- getClass("thisIsAnUndefinedClass", .Force = TRUE)cld ## a NULL prototype## If you are really curious:utils::str(cld)## Whereas these generate errors:try(getClass("thisIsAnUndefinedClass"))try(getClassDef("thisIsAnUndefinedClass"))}\keyword{programming}\keyword{classes}