In computer science, a wrapper is any entity that encapsulates (wraps around) another item. Wrappers are used for two primary purposes: to convert data to a compatible format or to hide the complexity of the underlying entity using abstraction. Examples include object wrappers, function wrappers, and driver wrappers.
1. Object Wrapper
An object wrapper is a class that encapsulates a primitive data type or another object. It may be used in Java, for example, to convert a char primitive to a character class. By converting the primitive to a class, a developer can use a method, such as toUpperCase() to modify the data. An object wrapper may also be used to convert the properties of a legacy class to ones that are compatible with newer code.
2. Function Wrapper
A function wrapper encapsulates one or more functions. For example, a website's "send mail" function may wrap multiple functions that process form data, check the submission for spam, and send the message using a mail server. A function wrapper may also wrap a single function to allow it to work with newer or older code. For example, it may change or add parameters to make a function compatible with a newer API.
3. Driver Wrapper
A driver wrapper allows a driver to function with an otherwise incompatible operating system. For example, an older graphics card may only support drivers designed for Windows 7. If a Windows 10 driver is not available, a driver wrapper may serve as an adapter, allowing the graphics card to use the Windows 7 driver in Windows 10. Driver wrappers may be provided by either the original equipment manufacturer (OEM) or a third-party developer.