Android Question Wrapper and private access

popeyes44

Member
Hi everybody,

I have an issue with a wrapper.
I found a java library (jotp) and have 1 jar from it.
I create a small xml file to manage it (no fucntion, just a test for the moment):

XML wrapper:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <doclet-version-NOT-library-version>1.00</doclet-version-NOT-library-version>
    <class>
        <name>com.amdelamar.jotp.OTP</name>
        <shortname>OTP</shortname>
        <comment>OTP</comment>
    </class>  
    <version>1.0</version>
</root>

But when I use a line like that on my B4a application :

Declaration OTP:
Dim myotp As OTP

I receive an error :

OTP() has private access in OTP

After checke in the jotp.jar file, I found that :

Jar file:
public final class OTP {

    public static final int BYTES = 20; // 160 bit

    private OTP() {
        // prevent instantiation
    }
[...]
}

On the same JAR there is a "type.TOTP" class that I could use but there are less functions than in the "OTP" class and my test are always bad with the "type.TOTP" so I would like to know if it's possible to have the "OTP" class working without this error ?

JAR file is attached

Regards and have a nice day
 

Attachments

  • jotp-1.3.0.jar
    15.5 KB · Views: 77

Daestrum

Expert
Licensed User
Longtime User
Maybe you need something similar to this in the xml
B4X:
<class b4a_type="StaticCode">
 
Upvote 0

popeyes44

Member
Maybe you need something similar to this in the xml
B4X:
<class b4a_type="StaticCode">
Hi Daestrum,

I tryed by modify the XML like that :
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <doclet-version-NOT-library-version>1.00</doclet-version-NOT-library-version>
    <class b4a_type="StaticCode">
        <name>com.amdelamar.jotp.OTP</name>
        <shortname>OTP</shortname>
        <comment>OTP</comment>
        <owner>process</owner>
        <field>
            <name>timeInHex</name>
            <comment>Return actual timestamp</comment>
            <returntype>string</returntype>
        </field>     
        <method>
            <name>timeInHex2</name>
            <comment>Return actual timestamp</comment>
            <returntype>string</returntype>
        </method>         
    </class>
    <class>
        <name>com.amdelamar.jotp.type.TOTP</name>
        <shortname>TOTP</shortname>
        <comment>TOTP type</comment>
        <owner>process</owner>
        <method>
            <name>timeInHex</name>
            <comment>Return actual timestamp</comment>
            <returntype>string</returntype>
        </method>     
    </class> 
    <version>1.0</version>
</root>

I can use the second class with :
B4X:
Dim totp_var As TOTP
log (totp_var.timeInHex)

But that don't work for the first class (OTP) :
B4X:
OTP. <nothing appear here so I can't see function of the OTP but OTP is valid to be created like that
log(OTP) < return "null" value
 
Upvote 0
Top