B4A Library Dummy Data for prototyping database apps

Discussion in 'Additional libraries, classes and official updates' started by Jaames, Jun 29, 2015.

  1. Jaames

    Jaames Active Member Licensed User

    Hi.
    I want to share this library I wrote for quick prototyping database apps.
    All data is hardcoded in to the library, no external files, you just add library as a reference and you are ready to go.

    All fields contains 500 records of real people, addresses,etc. and source of data is free downloaded from the internet. (the lib do not require internet connection)
    You have to keep it in mind that the only unsorted records across the fields match, but if you sort any field, it wont match , because there is no id that connects the data rows, but who cares, this is just example data for quick prototype.

    There is 11 Fields in the library: First Name, Last Name, Company, Address,
    City, Country, Postal Code, Phone1, Phone2, Email and Web address.

    There is xml2bb:

    DummyDataLibrary
    Version:
    1
    Author: Jaames

    Fields:

    • SORT_ASCENDING As Int
    • SORT_DESCENDING As Int
    • SORT_NONE As Int
    Methods:
    • GetAddresses (SortingMode As Int) As List
      returns all the data Addresses sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetCities (SortingMode As Int) As List
      returns all the data Cities sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetCompanies (SortingMode As Int) As List
      returns all the data Companies sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetCountries (SortingMode As Int) As List
      returns all the data Countries sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetDummyData (Data As String, SortingMode As Int) As List
      returns all the data from selected Field
      You can select which field you want by passing one of the string parameters:
      FirstNames LastNames Companies Addresses Cities
      Countries Postal Phones1 Phones2 Emails Webs
      And you can sort the data by passing one of the SortingMode parameters:
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data
      Example:
      <code>Dim Data as DummyData
      Dim l As List = Data.GetDummyData("FirstNames", Data.SORT_ASCENDING)
      For x = 0 To Data.Size -1
      Log(Data.Get(x))
      Next</code>
      You can access the fields also individually


    • GetEmails (SortingMode As Int) As List
      returns all the data Emails sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetFirstNames (SortingMode As Int) As List
      returns all the data First Names sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetLastNames (SortingMode As Int) As List
      returns all the data Last Names sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetPhones1 (SortingMode As Int) As List
      returns all the data Phones1 sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetPhones2 (SortingMode As Int) As List
      returns all the data Phones2 sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetPostal (SortingMode As Int) As List
      returns all the data Postal sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data


    • GetWebs (SortingMode As Int) As List
      returns all the data Webs sorted by the given SortingMode parameter
      SORT_ASCENDING - will sort the data in ascending order
      SORT_DESCENDING - will sort the data in descending order
      SORT_NONE - will return unsorted data

    Example of usage:
    Copy both fils DummyDataLibrary.jar and DummyDataLibrary.xml to your additional libraries folder, add DummyDataLibrary as a reference to your project and write next code :

    Code:
    Dim DummyData As DummyData
    Dim l As List = DummyData.GetFirstNames(DummyData.SORT_ASCENDING)
    Log(l)
    Log(DummyData.GetDummyData("Cities",DummyData.SORT_NONE))
    Check your Log output and you should see the list of all "First Names" field sorted ascending
    and list of Cities unsorted.

    There are three attached zip files:
    • DummyDataExample.zip - B4A example on how to use the lib.
    • DummyDataJavaSource.zip the java sources of the lib, so you can extend it.
    • Library.zip folder with compiled library (jar and xml) file.

    ss.jpg

    Have a good time! :)
    Jaames
     

    Attached Files:

    Last edited: Jul 2, 2015
    susu, somed3v3loper, walt61 and 4 others like this.
  2. LucaMs

    LucaMs Expert Licensed User

    Thanks, it can be useful :)
     
    Jaames likes this.
  3. susu

    susu Well-Known Member Licensed User

    Nice! Could you please share how to "hardcoded all data into the library"? Is it safe to protect the data from hacker/cracker? Thank you.
     
  4. Jaames

    Jaames Active Member Licensed User

    Actually it is not protected at all, it can be decompiled, and inside is just string arrays. Did you see java source?
     
    susu likes this.
  5. susu

    susu Well-Known Member Licensed User

    Thank you for your answer. I used phone to browse this forum so I didn't test your code.
     
    Jaames likes this.
  6. NJDude

    NJDude Expert Licensed User

    I didn't know there was a little demand for this kind of lib, I have released one HERE.
     
Loading...