Rev 48218 | 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, inherits = TRUE)}\arguments{\item{Class}{ the character-string name of the class, often with a\code{"package"} attribute as noted below under \code{package}.}\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. If it is a non-empty string it is used instead of\code{where}, as the first place to look for the class.Note that the package must be loaded but need not be attached. Bydefault, the package attribute of the \code{Class} argument isused, if any. There will usually be a package attribute if\code{Class} comes from \code{class(x)} for some object.}\item{inherits}{ Should the class definition be retrieved from anyenclosing environment and also from the cache? If \code{FALSE}only a definition in the environment \code{where} will be returned.}}\details{Class definitions are stored in metadata objects in a packagenamespace or other environment where they are defined. Whenpackages are loaded, the class definitions in the package are cached in an internaltable. Therefore, most calls to \code{getClassDef} will find theclass in the cache or fail to find it at all, unless \code{inherits}is \code{FALSE}, in which case only the environment(s) defined by\code{package} or \code{where} are searched.The class cache allows for multiple definitions of thesame class name in separate environments, with of course thelimitation that the package attribute or package name must beprovided in the call to}\value{The object defining the class. If the class definition is not found,\code{getClassDef} returns \code{NULL}, while \code{getClass}, whichcalls \code{getClassDef}, either generates an error or, if\code{.Force} is \code{TRUE}, returns a simple definition for theclass. The latter case is used internally, but is not typicallysensible in user code.The non-null returned value is an object of class\code{\linkS4class{classRepresentation}}. For all reasonablepurposes, use this object only to extract information, rather than tryingto modify it: Use functions such as \code{\link{setClass}} and\code{\link{setIs}} to create or modify class definitions.}\references{Chambers, John M. (2008)\emph{Software for Data Analysis: Programming with R}Springer. (For the R version.)Chambers, John M. (1998)\emph{Programming with Data}Springer (For the original S4 version.)}\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}