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
1 answer

Use C# DLL in Python

I have a driver which is written in C#, .NET 4.7.0 and build as DLL. I don't have sources from this driver. I want to use this driver in python application. I wrapped some functionality from driver into method of another C# project. Then I built it…
1
vote
2 answers

In this simple Docker wrapper script example, how may one correctly pass a current working directory path which contains spaces?

My Docker wrapper script works as intended when the current working directory does not contain spaces, however there is a bug when it does. I have simplified an example to make use of the smallest official Docker image I could find and a well known…
dnk8n
  • 675
  • 8
  • 21
1
vote
1 answer

Proportionally resizing divs with a wrapper

Basically I have a bunch of elements inside a div, lets say
. I want to be able to scale this outer div and have the elements inside scale properly along with it. For example, if this were a collection of SVGs all we would have…
user10162648
1
vote
2 answers

How to handle multiple major versions of dependency

I'm wondering how to handle multiple major versions of a dependency library. I have an open source library, Foo, at an early release stage. The library is a wrapper around another open source library, Bar. Bar has just launched a new major version.…
Andreas
  • 455
  • 3
  • 7
1
vote
3 answers

Practices regarding wrapper for setDataBuffer (OCCI)

I have an OracleConnection class that uses the OCCI Oracle API to access the database. I now need to go fetch multiple rows of records from the database and this is done with the ResultSet::getDataBuffer(...) function of the API. This function…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
1
vote
1 answer

Why is the object not being updated

I have written this code and I wanted to know why the value of the object being referenced is not being changed All calls in java are call by value. But when the call refers to the same object , why is the object not being updated class Main { …
1
vote
1 answer

How to bind the TreeList to a MVC model class using MVC wrappers

I am finding it difficult to understand how the hierarchy is binded in the TreeList. We are trying to achieve InCell editing and I am unable to do it using the HTML MVC wrappers. Please help me with the working solution as the one on the How to…
1
vote
1 answer

Closure variable undefined: How to access outer variables in JS?

I have an event listener that responds with a callback. This callback is a wrapper around the actual callback. I have defined a variable in the outermost function, blockNumber, and want to access it (read/write) from the innermost function. The code…
0TTT0
  • 1,288
  • 1
  • 13
  • 23
1
vote
2 answers

Class Organisation of Api Wrappers

I am trying to learn creating php wrappers for 3rd party apis. However I am confused on implementing multiple classes extended/implemented each other. class Api { protected $username; protected $password; protected $wsdl =…
senty
  • 12,385
  • 28
  • 130
  • 260
1
vote
1 answer

Wrapping Inherited Templates in Cython?

I'm trying to write a cython wrapper for some templated C++ code. I'm pretty familiar with wrapping something written like Bar. i.e. (with details removed) ctypedef enum enum_t "enum_t": OPT1 "OPT1", OPT2 "OPT2", OPT3 "OPT3" cdef…
1
vote
1 answer

Explain the working of user defined wrapper with malloc

Can someone explain me the working of a malloc wrapper for below code?? RTLD_NEXT should find the next syblo in search order, which means it should hit my malloc, where i haven't put any allocation scheme like original malloc. Then how come the…
RajSanpui
  • 11,556
  • 32
  • 79
  • 146
1
vote
0 answers

Generating wrappers for virtual functions

Context I am writing a program in rust which links into a c++ library, however rust is unable to generate bindings to virtual functions. While there are likely better approaches, the most straightforward solution is to write an extra layer of…
Locke
  • 7,626
  • 2
  • 21
  • 41
1
vote
0 answers

Task not serializable: java.io.NotSerializableException: org.apache.spark.unsafe.types.UTF8String$IntWrapper

I am currently working on migrating a hive table. The problem I am facing is, when I try to load it into a dataframe in spark and write back to the Hive, it gives me a serialization error like in the screen shot attached. However, when I try to…
1
vote
0 answers

C#/CLI wrapper "Could not load file or assembly"

I have a C++ main.dll with exported classes which is x86, a wrapper for it in C#/CLI which is x86 and has linked main.dll's lib and I have a C# Test.exe application that makes use of that wrapper (which is also set to 32bit in Properties -> Build ->…
thief
  • 11
  • 1
1
vote
2 answers

HTML Wrapper state update based on current page

I'm a complete beginner in HTML/CSS. I currently have a wrapper on my website with links which re-direct to different pages. My objective is to update the link to appear pressed when I am on the respective page. An example of this is if you're on…
mcdouble
  • 61
  • 9