What's Covered
This tutorial covers:
- How to iterate through all available properties in the data file.
- How to iterate through all possible values for each property.
- How to access the description for each property.
- How to access the description for each value.
Code and Explanation
Example of listing properties and possible values from a Dataset
The example illustrates:
-
Loading a memory-resident Pattern Dataset
dataset = MemoryFactory.create(Shared.getLitePatternV32(), true);
-
Enumerating properties contained in the dataset loaded
for(Property property : dataset.getProperties()) {
-
Accessing description for each property.
property.getDescription();
-
Enumerating values that the property may have
for (Value value : property.getValues().getAll()) {
-
Accessing description of each value
if (value.getDescription() != null) {
Summary
Metadata is essentially a short description for an entity in the 51Degrees device data model. Metadata is used to provide a meaningful description for an entity such as property or value and can be useful in a variety of situations:
- When generating reports using 51Degrees data it can aid the reader to have a short description alongside each property listed.
- When exposing part of the API to the end user it can help to know what the property definition is, or what the value definitions are before they make a choice. E.G. An advertising agency that lets their clients' target specific devices can benefit if every choice is provided with a description.
The Property Dictionary page is an example that uses our metadata. The page is generated dynamically using the metadata and entities of the 51Degrees Enterprise data file. The following table shows just a few of the available properties.
Property | Description | Values |
---|---|---|
IsMobile | Indicates if the device's primary data connection is wireless and is designed to operate mostly from battery power (ie a mobile phone, smart phone or tablet). | True, False |
PlatformName | The name of the software platform (operating system) the device is using. | Android, Windows, PS4 Software, ... |
BrowserName | The name of the browser. Many mobile browsers come default with the OS. Unless specifically named, these browsers are named after the accompanying OS | Firefox, Safari, Chrome Mobile, ... |
Enterprise and Premium Only
Property | Description | Values |
---|---|---|
HardwareVendor | The company that manufactures the device or primarily sells it. May return 'Unknown'. | Samsumg, Asus, Panasonic, ... |
ScreenInchesDiagonal | The diagonal size of the device's screen in inches. May return 'N/A' or 'Unknown'. | 5, 5.1, 7, ... |
IsTv | Indicates if the device is a smart TV. | True, False |