Java Question [solved] Wrapped object does have a ".tag" Value which i need

DonManfred

Expert
Licensed User
Longtime User
I´m doing a wrap for the Dropbox V2 SDK.

When i request a filelist for ex. i get an Metadata object for each file.

B4X:
public class MetadataWrapper extends AbsObjectWrapper<Metadata> {
    private BA ba;
    private String eventName;

    @Hide
    public void Initialize(final BA ba, Metadata meta) {
        this.ba = ba;
        final Metadata _obj = meta;
        setObject(_obj);
    }
    public String getName(){
        return getObject().getName();
    }
    public String getParentSharedFolderId(){
        return getObject().getParentSharedFolderId();
    }
    public String getPathLower(){
        return getObject().getPathLower();
    }
    public String getPathDisplay(){
        return getObject().getPathDisplay();
    }
    public String toString(){
        return getObject().toString();
    }
    public String toStringMultiline(){
        return getObject().toStringMultiline();
    }

  
      
}

So far ok and works... But if i do a log(meta.tostring) in B4A i get the following log...
{".tag":"folder","name":"Manfred","id":"id:qn6VkEYC6_gAAAAAAAAq7Q","path_lower":"/manfred","path_display":"/Manfred","shared_folder_id":"1295544397","sharing_info":{"read_only":false,"shared_folder_id":"1295544397","traverse_only":false,"no_access":false}}

As you can see there is a ".tag" inside the output...

tostring is a method i wrapped... the lib behind will send a json result with it.

For now i use this and take a jsonparser to get the result of the .tag... It is working but i think it should be better to do this step inside the wrapper.

How can i access this tag?


Here i can distinguish files from folders in theresultlist... The .tag is "file" or "folder"
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that there shouldn't be instance variables in ObjectWrapper classes.
They will be removed if the class instance will be converted to Object and back:
B4X:
Dim m As Metadata
List1.Add(m)
Dim m2 As Metadata = List1.Get(0)
'm2.ba and m2.eventName are null now.

How can i access this tag?
It depends on Metadata API. Maybe it is not exposed at all.
 

DonManfred

Expert
Licensed User
Longtime User
It depends on Metadata API. Maybe it is not exposed at all.
I found the solution.

Dropbox s using different Metadata-Implementations. Metatadate, Filemetadata and Foldermetadata.
The last two extends the first one.
The List i retrieved is adding all as Metadata.
But if it is a Folder than Dropbox will add a Foldermetadata as Metadata to the list.
Same for files. Dropbox uses a FileMetadata.

i now do check in b4a

B4X:
 If Value Is FileMetadata Then
        Dim fle As FileMetadata = Value
      
    else if Value Is FolderMetadata Then
        Dim fld As FolderMetadata = Value

And surely i did wrapper for all Three. Metadata, Filemetadata and FolderMetadata.

This works fine.
 
Last edited:
Top