  A novel theoretical approach to the problem of the compositeness ($X$) of a
resonance or bound state is developed on the basis of the expectation values of
the number operators of the free particles in the continuum. This formalism is
specially suitable for effective field theories in which the bare elementary
states are integrated out but that give rise to resonance and bound states when
implemented in nonperturbative calculations. We demonstrate that $X=1$ for
finite-range energy-independent potentials, either regular or singular. A
non-trivial example for an energy-dependent potential is discussed where it is
shown that $X$ is independent of any type of cutoff regulator employed. The
generalization of these techniques to relativistic states is developed. We also
explain how to obtain a meaningful compositeness with respect to the open
channels for resonances, even if it is complex in a first turn, by making use
of suitable phase-factor transformations. Defining elementariness as $X=0$, we
derive a new universal criterion for the elementariness of a bound state. Along
the same lines, a necessary condition for a resonance to be qualified as
elementary is given. The application of the formalism here developed might be
of considerable practical interest.
