Questions tagged [wrapper]

A wrapper is an OOP technique where an object encapsulates (wraps) another object, resource (dynamically allocated memory, OS file/widow handle, socket, thread mutex, etc) or a set of subroutines, hiding/protecting it and providing another (possibly easier to use) interface. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

A Wrapper is an Object which contains another data type, Object, resources, or subroutines for the purpose of encapsulation. The corresponding class of that Wrapper is the wrapper class.

Often when we refer to a wrapper class we often refer to a primitive wrapper class, where instances of that class encapsulate a primitive type.

Many object-oriented languages, such as Java, differentiate between primitive types (such as char) and Objects (such as String), for example that primitive values are passed on by value and are the simplest data types, whereas Objects are passed on by reference and that it includes their own fields and methods. The names of primitive data types are also usually keywords, as opposed to Objects.

In some cases, you may need an instance of a wrapper class for these primitives to perform boxing, treat these primitives as Objects due to OOP reasons, converting a primitive to another Object type, or when using an otherwise primitive value when polymorphism is required. The name of the corresponding primitive wrapper class for a given primitive data type are written in full and follow naming conventions for classes (such as beginning with an uppercase in Java).

Java wrapper classes:

Java offers these wrapper classes which you can use without importing anything. Note that their names begin with an uppercase, and are written in full.

  • Boolean for booleans
  • Character for char
  • Integer for int
  • Long for 64-bit int
  • Double for boudle
  • Byte for byte
  • Short for short
  • Float for float

Tags related to wrapper operations:

Link to Wikipedia page

3619 questions
1
vote
2 answers

How to customize json wrapped key for class if I am not able to mark that class with annotation JsonTypeInfo?

I have code like this: import org.codehaus.jackson.map.*; public class MyPojo { int id; public int getId() { return this.id; } public void setId(int id) { this.id = id; } public static void main(String[] args) throws…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
1
vote
0 answers

Is it possible in VB6 to hold its execution for getting a response?

I have a .NET web client which calls the VB dll through a wrapper. The VB dll holds a message box that needs to go to the .NET client and come back with a response. The VB6 dll should hold its execution until it receives a response and continue its…
1
vote
0 answers

variadic param method wrapper ios objective-c

I am creating a framework and stuck while making a wrapper for the class logger.h which has below method -(void) logError:(nonnull NSString *) info, ...; I made a wrapper of logger.h file name Mlogger.h The wrapper file Mlogger.h is having same…
utkal patel
  • 1,321
  • 1
  • 15
  • 24
1
vote
1 answer

How to distinguishes between different parent classes in React Native

Say I have this wrapper component: export class WrapperComponent extends React.Component { constructor(props) { super(props); this.opacity = 1 this.editable = true this.placeholder = '' this.state = { …
aejhyun
  • 612
  • 1
  • 6
  • 19
1
vote
2 answers

Wrapper for open() and open64() and see that system calls by vi uses open64()

I have written wrappers for both open() and open64(). Now I run vi by preloading my wrapper library using LD_PRELOAD environment variable and I see that the open64() wrapper is used instead of the open(). But when I strace vi I see that the system…
Lipika Deka
  • 3,774
  • 6
  • 43
  • 56
1
vote
1 answer

Reassigning constants when creating wrapper library in Go

So I want to create my own wrapper library from already existing lib A. Library A has some functions and also some constants, example: package lib const( HeaderA = "headerA" HeaderB = "headerB" ) func doWork(string header) { // some…
Schidu Luca
  • 3,897
  • 1
  • 12
  • 27
1
vote
3 answers

Background CSS NOT SHOWING behind wrapper

I've tried the background-image tag in my CSS and also in a tag in my HTML. I can't get anything to appear behind my wrapper. I can get my wrapper background to appear with color, but that it. html, body { background-image:…
1
vote
2 answers

JNA How to wrap interface written in C++

I already know how to wrap an Structure , but I need some help with interfaces. The interface I want to wrap is the IImageList. But I have now clue how to create an java class out of it.
MrMarnic
  • 23
  • 6
1
vote
1 answer

How to instantiate an abstract class with one of the concrete classes?

I would like to know what the following paragraph means and how do I implement it. I asked a question yesterday related to the same issue here. In yesterday's question, I was told this is not possible but I think the following paragraph indicates it…
Papa Delta
  • 267
  • 3
  • 12
1
vote
1 answer

How to query actual markets with Python Wrapper for Pinnacle Sports API

I would like to use rozzac90/pinnacle API python wrapper github project for placing automated bet on Pinnacle. I would like to know, what is the best method for getting the actual main market for an event, if I know the home and away team names. I'm…
Levente
  • 43
  • 1
  • 8
1
vote
1 answer

I have a C library of related functions with different prefixes. How can derived C++ classes call them without repeating code?

I am working with a driver library talking to hardware with different model numbers. The API that comes with this hardware has a different library for different major versions, even though many of the interactions are the same. For example, if I am…
thegreatemu
  • 495
  • 2
  • 11
1
vote
2 answers

React - Create connected provider arround default provider, that will take data from store and pass it as props to default provider

Assume I use desired provider in my app, let name it MyProvider and wrapp my app with it. And that provider must take data1 and data2 as props: const data1 = store.getState().data1; const data2 = "some data";
1
vote
1 answer

The Wrapper Constructors get NumberFormatException:

Float f1 = new Float("12.6f"); In this above code I didn't get any exception. But the below code I got NumberFormatException: Long l1= new Long("200L"); I know all of the wrapper classes except Character provide two constructors Integer i1 = new…
Poorna Senani Gamage
  • 1,246
  • 2
  • 19
  • 30
1
vote
2 answers

redefine python function inside other function

I can figure out the behaviour of python. Here is code example: def foo(): print('hello from initial foo') def using_foo(): foo() def wrapper(func): def foo(): print('Now is overload foo') print('Hello from wrapper') …
1
vote
1 answer

C++ base vector refer to derived vector

Why is this code not working? There are two vectors. The base vector elements should refer to the derived vector elements as a reference (not a copy). The output is random numbers, so, for some reason, the reference_wrapper elements doesn't refer…