Using Java
In some cases it may be useful to see what signatures/user agents in your 51Degrees data file are associated with specific content in a selected property.
The following snippet is written in Java and it implements the task in question. Essentially, what happens in this code is: "Hardware Model" properties in the data set are searched for values containing "HTC" or "Desire" or "Desire C". If one of these values is found, the corresponding signatures are fetched and printed.
try {
Dataset ds = StreamFactory.create(DATA_FILE);
System.out.println("Getting Signatures");
for(Property p : ds.properties) {
if (p.getName().equals("HardwareModel")) {
for(Value v : p.getValues()) {
if (v.getName().contains("HTC") ||
v.getName().contains("Desire") ||
v.getName().contains("Desire C")) {
for(Signature s : v.getSignatures())
{
System.out.println(s.toString());
}
}
}
}
}
System.out.println("Finished Getting Signatures");
} catch (IOException ex) {
When executed, this snippet produces result similar to the following:
This particular example uses the HardwareModel property that is available to Premium and Enterprise users. It can be altered to search for specific strings in any available property.