| Line 15... |
Line 15... |
| 15 |
object that returns \code{TRUE} or a description of the non-validity.
|
15 |
object that returns \code{TRUE} or a description of the non-validity.
|
| 16 |
}
|
16 |
}
|
| 17 |
\usage{
|
17 |
\usage{
|
| 18 |
validObject(object, test)
|
18 |
validObject(object, test)
|
| 19 |
|
19 |
|
| 20 |
setValidity(Class, method, where = 1 )
|
20 |
setValidity(Class, method, where = topenv(parent.frame()) )
|
| 21 |
}
|
21 |
}
|
| 22 |
\arguments{
|
22 |
\arguments{
|
| 23 |
\item{object}{ Any object, but not much will happen unless the
|
23 |
\item{object}{ Any object, but not much will happen unless the
|
| 24 |
object's class has a formal definition.}
|
24 |
object's class has a formal definition.}
|
| 25 |
\item{test}{ If \code{test} is \code{TRUE}, and validity fails the
|
25 |
\item{test}{ If \code{test} is \code{TRUE}, and validity fails the
|
| 26 |
function returns a vector of strings describing the problems. If
|
26 |
function returns a vector of strings describing the problems. If
|
| 27 |
\code{test} is \code{FALSE} (the default) validity failure generates
|
27 |
\code{test} is \code{FALSE} (the default) validity failure generates
|
| 28 |
an error.}
|
28 |
an error.}
|
| 29 |
\item{Class}{The name or class definition of the class whose validity method is to be
|
29 |
\item{Class}{the name or class definition of the class whose validity
|
| 30 |
set.}
|
30 |
method is to be set.}
|
| 31 |
\item{method}{A validity method; that is, either \code{NULL} or a
|
31 |
\item{method}{a validity method; that is, either \code{NULL} or a
|
| 32 |
function of one argument (the \code{object}). Like
|
32 |
function of one argument (the \code{object}). Like
|
| 33 |
\code{validObject}, the function should return \code{TRUE} if the
|
33 |
\code{validObject}, the function should return \code{TRUE} if the
|
| 34 |
object is valid, and one or more descriptive strings if any problems
|
34 |
object is valid, and one or more descriptive strings if any problems
|
| 35 |
are found. Unlike \code{validObject}, it should never generate an
|
35 |
are found. Unlike \code{validObject}, it should never generate an
|
| 36 |
error.
|
36 |
error.
|
| 37 |
}
|
37 |
}
|
| 38 |
\item{where}{ The modified class definition will be stored in this
|
38 |
\item{where}{the modified class definition will be stored in this
|
| 39 |
position on the search list.
|
39 |
environment.}
|
| 40 |
}
|
- |
|
| 41 |
|
40 |
|
| 42 |
Note that validity methods do not have to check validity of any
|
41 |
Note that validity methods do not have to check validity of any
|
| 43 |
slots or superclasses: the logic of \code{validObject} ensures
|
42 |
slots or superclasses: the logic of \code{validObject} ensures
|
| 44 |
these tests are done once only. As a consequence, if one validity
|
43 |
these tests are done once only. As a consequence, if one validity
|
| 45 |
method wants to use another, it should extract and call the method
|
44 |
method wants to use another, it should extract and call the method
|
| 46 |
from the other definition of the other class by calling
|
45 |
from the other definition of the other class by calling
|
| 47 |
\code{\link{getValidity}}: it should \emph{not} call
|
46 |
\code{\link{getValidity}}: it should \emph{not} call
|
| 48 |
\code{validObject}.
|
47 |
\code{validObject}.
|
| 49 |
}
|
48 |
}
|
| 50 |
\details{
|
49 |
\details{
|
| 51 |
Validity testing takes place \dQuote{bottom up}: first the validity
|
50 |
Validity testing takes place \dQuote{bottom up}: first the validity
|
| 52 |
of the object's slots, if any, is tested. Then for each of the
|
51 |
of the object's slots, if any, is tested. Then for each of the
|
| 53 |
classes that this class extends (the \dQuote{superclasses}), the
|
52 |
classes that this class extends (the \dQuote{superclasses}), the
|
| Line 74... |
Line 73... |
| 74 |
While the programming interface for the \pkg{methods} package follows
|
73 |
While the programming interface for the \pkg{methods} package follows
|
| 75 |
the reference, the R software is an original implementation, so
|
74 |
the reference, the R software is an original implementation, so
|
| 76 |
details in the reference that reflect the S4 implementation may appear
|
75 |
details in the reference that reflect the S4 implementation may appear
|
| 77 |
differently in R. Also, there are extensions to the programming
|
76 |
differently in R. Also, there are extensions to the programming
|
| 78 |
interface developed more recently than the reference. For a
|
77 |
interface developed more recently than the reference. For a
|
| 79 |
discussion of details and ongoing development, see the web page
|
78 |
discussion of details and ongoing development, see the web page
|
| 80 |
\url{http://developer.r-project.org/methodsPackage.html} and the
|
79 |
\url{http://developer.r-project.org/methodsPackage.html} and the
|
| 81 |
pointers from that page.
|
80 |
pointers from that page.
|
| 82 |
}
|
81 |
}
|
| 83 |
\seealso{ \code{\link{setClass}}. }
|
82 |
\seealso{ \code{\link{setClass}}. }
|
| 84 |
|
83 |
|