Package com.iizix.selector
Class DeviceMatcher
java.lang.Object
com.iizix.selector.DeviceMatcher
Class that loads an external XML file for device matching.
The matching is done on one or more of:
id origin description -------- ------------------------- ----------------------------- ua env: navigator.userAgent User agent pua/os.family env: navigator.userAgent User agent (os.family: parsed with ua-parser) pua/os.major env: navigator.userAgent User agent (os.major: parsed with ua-parser) ptf: env: navigator.platform Platform dd: env: device.diagonal Device size sw: env: screen.width Screen width sh: env: screen.height Screen height saw: env: screen.availableWidth Screen available width sah: env: screen.availableHeight Screen available height cap: capability: name Capability name
- Matching topic is defined as:
{topic name="nnn"} ...devices... {/topic}
- Device tag as:
{device name="nnn"} ...match... {/device}
- Verification can be combined with "or" or "and":
{or [negate="true"]} {and [negate="true"]} {string id="nnn" match="iPad" type="equals"/} {value id="mmm" min="100" max="200"/} {/and} {value id="abc" min="10" max="20"/} {/or}
- String matching:
{string id="nnn" match="string" type="type" [case="false"] [negate="true"]/}
where type is "equals", "in" (like indexOf or contains), "wild" or "regexp".
case="false" means case insensitive match. - Value matching
{value id="nnn" [min="value"] [max="value"] [negate="true"]/}. - Negation of match
[negate="true"] on any tag means that the match is negated (boolean NOT).
- Author:
- Christopher Mindus
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionstatic DeviceMatcher
Gets the singleton.boolean
Verifies that a topic is present.boolean
isMatching
(String topic, IInfoProvider info) Matches a topic.
Constructor Details
DeviceMatcher
public DeviceMatcher()Constructs the device matcher.
Method Details
getInstance
Gets the singleton.hasTopic
Verifies that a topic is present.- Parameters:
topic
- The topic name.- Returns:
- true if topic is present in the DeviceMatcher.xml file.
isMatching
Matches a topic. A severe error is logged if the topic is not found.- Parameters:
topic
- The topic name.info
- The information provider.- Returns:
- The match flag.