<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_20) on Tue Aug 24 14:58:50 IST 2010 -->
<TITLE>
Api
</TITLE>
<META NAME="date" CONTENT="2010-08-24">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Api";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV CLASS
<A HREF="../../../mobi/mtld/da/Json.html" title="class in mobi.mtld.da"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html?mobi/mtld/da/Api.html" target="_top"><B>FRAMES</B></A>
<A HREF="Api.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
mobi.mtld.da</FONT>
<BR>
Class Api</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>mobi.mtld.da.Api</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>Api</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Used to load the recognition tree and perform lookups of all properties, or
individual properties. Typical usage is as follows: <br />
<code>
<br /> HashMap tree = Api.getTreeFromFile("sample/DeviceAtlas.json");
<br /> HashMap prps = Api.getProperties(tree, "Nokia6680...");
<br /> Object prop = Api.getProperty(tree, "Nokia6680...", "displayWidth");
</code>
<br />
<br />
Note that you should normally use the user-agent that was received in the
device's HTTP request. In a JSP environment, you would do this as follows:
<br />
<code>
<br />String ua = request.getHeader("User-Agent");
<br />int displayWidth = Api.getPropertyAsInteger(tree, ua, "displayWidth");
</code>
<br />
<br />
(Also note the use of the strongly typed property accessor) <br />
In some contexts, the user-agent you want to recognise may have been provided
in a different header. Opera's mobile browser, for example, makes requests
via an HTTP proxy, which rewrites the headers. in that case, the original
device's user-agent is in the "X-OperaMini-Phone-UA" header, and the
following code could be used: <br />
<code>
<br />String ua;
<br />String operaHeader = "X-OperaMini-Phone-UA";
<br />if (request.getHeader(operaHeader) != null) {
<br /> ua = request.getHeader(operaHeader);
<br />} else {
<br /> ua = request.getHeader("User-Agent");
<br />}
<br />int displayWidth = Api.getPropertyAsInteger(tree, ua, "displayWidth");
</code>
<P>
<P>
<DL>
<DT><B>Version:</B></DT>
<DD>$Id: Api.java 13794 2010-08-12 21:13:35Z ahopebailie $</DD>
<DT><B>Author:</B></DT>
<DD>MTLD (dotMobi)</DD>
</DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../mobi/mtld/da/Api.html#Api()">Api</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../mobi/mtld/da/Api.html#getApiRevision()">getApiRevision</A></B>()</CODE>
<BR>
Returns the revision number of this API</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.util.HashMap</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../mobi/mtld/da/Api.html#getProperties(java.util.HashMap, java.lang.String)">getProperties</A></B>(java.util.HashMap tree,
java.lang.String userAgent)</CODE>
<BR>
Returns a HashMap of known properties (as strings) for the user agent</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.util.HashMap</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../mobi/mtld/da/Api.html#getPropertiesAsTyped(java.util.HashMap, java.lang.String)">getPropertiesAsTyped</A></B>(java.util.HashMap tree,
java.lang.String userAgent)</CODE>
<BR>
Returns a HashMap of known properties (as typed) for the user agent</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../mobi/mtld/da/Api.html#getProperty(java.util.HashMap, java.lang.String, java.lang.String)">getProperty</A></B>(java.util.HashMap tree,
java.lang.String userAgent,
java.lang.String property)</CODE>
<BR>
Returns a value for the named pro
- 1
- 2
前往页