The applet model is a good example of how the Java platform provides power. The fact that the same code
runs on all systems in the same way allows a single piece of code (an applet) to run in a variety of browsers on
a variety of windowing systems running on a larger variety of operating systems. The portability of Java
bytecodes allows you to execute part of your application on the server and another part on the client system
via downloaded code, whichever is appropriate. It is the same platform on both sides: the Java virtual
machine. The ability to move code from one place to another and execute it in a secure environment enables
new ways of thinking about where to execute what part of your design.
25.3. java.beans Components
The JavaBeans™ component architecture helps independent vendors write classes that can be treated as
components of larger systems assembled by users. The java.beans package provides necessary and useful
classes for writing such beans. A bean exports properties, generates events, and implements methods. By
following certain design patterns or by implementing methods that provide a description of these facets of
behavior, you can compose beans by using interactive tools to build a system the user needs.
Much of a bean's behavior is simplified if you follow expected design patterns. For example, if your bean
class is called Ernest and you provide a class named ErnestBeanInfo that implements the BeanInfo
interface, the JavaBeans tools will use ErnestBeanInfo as a source of information about the behavior of
the bean: the events it supports, the icons it uses, and so on.
Providing a BeanInfo object is itself optionalthe JavaBeans system will use reflection to infer events and
properties. For example, if a class Ernest has methods named getImportance and setImportance,
the JavaBeans system will assume that you have an importance property that can be set, either directly or
via another bean. Builder tools are expected to present the properties and events to users, who can use them to
connect beans as components to build custom applications.
AWT components are beans, and the event model described earlier for AWT components is also the JavaBeans
event model.
The JavaBeans component architecture is designed to interoperate with existing component architectures,
extending the "Write Once, Run Anywhere" capability to create a homogeneous component platform.
The subpackage java.beans.beancontext defines interfaces and classes that are used to talk about the
context in which a bean or set of beans is executing. Bean contexts can be nested.
25.4. java.math Mathematics
The package java.math is destined for classes that help with mathematical calculations. Currently, it has
three classesBigInteger, BigDecimal and MathContextand an enum, RoundingMode, that defines
different rounding modes.
The class BigInteger provides arbitrary-precision integer arithmetic, providing analogous operations for
all integer operations except >>>, which is equivalent to >> because there is no sign bit to copy in an
arbitrary-precision integer. Neither will the provided single-bit operations (clearBit and setBit) change
the sign of the number on which they operate. BigInteger behaves as if it were defined in
two's-complement notationthe same notation used by the primitive integer types. Binary bitwise operations
start by extending the sign of the smaller number and then executing the operation, just as operations on
primitive values do. BigInteger objects are immutable, so all operations on them produce new
BigInteger objects. The following simple method returns an iterator over the prime factors of a number: