<!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-google-v4) on Wed Feb 01 12:16:00 PST 2012 -->
<TITLE>
NamespaceManager
</TITLE>

<META NAME="date" CONTENT="2012-02-01">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../dev_javadoc.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="NamespaceManager";
    }
}
</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>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/google/appengine/api/LifecycleManager.ShutdownHook.html" title="interface in com.google.appengine.api"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/google/appengine/api/ThreadManager.html" title="class in com.google.appengine.api"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?com/google/appengine/api/NamespaceManager.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="NamespaceManager.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<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:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<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">
com.google.appengine.api</FONT>
<BR>
Class NamespaceManager</H2>
<PRE>
java.lang.Object
  <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.appengine.api.NamespaceManager</B>
</PRE>
<HR>
<DL>
<DT><PRE>public final class <B>NamespaceManager</B><DT>extends java.lang.Object</DL>
</PRE>

<P>
Provides functions for manipulating the current namespace used for App Engine
 APIs.

 <p>
 The "current namespace" is the string that is returned by <A HREF="../../../../com/google/appengine/api/NamespaceManager.html#get()"><CODE>get()</CODE></A> and
 used by a number of APIs including Datatore, Memcache and Task Queue.

 <p>
 When a namespace aware class (e.g.,
 <A HREF="../../../../com/google/appengine/api/datastore/Key.html" title="class in com.google.appengine.api.datastore"><CODE>Key</CODE></A>,
 <A HREF="../../../../com/google/appengine/api/datastore/Query.html" title="class in com.google.appengine.api.datastore"><CODE>Query</CODE></A> and
 <A HREF="../../../../com/google/appengine/api/memcache/MemcacheService.html" title="interface in com.google.appengine.api.memcache"><CODE>MemcacheService</CODE></A>) is constructed, it
 determines which namespace will be used by calling
 <A HREF="../../../../com/google/appengine/api/NamespaceManager.html#get()"><CODE>get()</CODE></A> if it is otherwise unspecified. If
 <A HREF="../../../../com/google/appengine/api/NamespaceManager.html#get()"><CODE>get()</CODE></A> returns null, the current namespace is unset
 and these APIs will use the empty ("") namespace in its place.

 <p>
 Example: <code><pre>
 <A HREF="../../../../com/google/appengine/api/NamespaceManager.html" title="class in com.google.appengine.api"><CODE>NamespaceManager</CODE></A>.<A HREF="../../../../com/google/appengine/api/NamespaceManager.html#set(java.lang.String)"><CODE>set(java.lang.String)</CODE></A>("a-namespace");
 MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();
 // Store record in namespace "a-namespace"
 memcache.put("key1", "value1");

 <A HREF="../../../../com/google/appengine/api/NamespaceManager.html" title="class in com.google.appengine.api"><CODE>NamespaceManager</CODE></A>.<A HREF="../../../../com/google/appengine/api/NamespaceManager.html#set(java.lang.String)"><CODE>set(java.lang.String)</CODE></A>("other-namespace");
 // Store record in namespace "other-namespace"
 memcache.put("key2", "value2");

 MemcacheService boundMemcache =
     MemcacheServiceFactory.getMemcacheService("specific-namespace");
 <A HREF="../../../../com/google/appengine/api/NamespaceManager.html" title="class in com.google.appengine.api"><CODE>NamespaceManager</CODE></A>.<A HREF="../../../../com/google/appengine/api/NamespaceManager.html#set(java.lang.String)"><CODE>set(java.lang.String)</CODE></A>("whatever-namespace");
 // The record is still stored in namespace "specific-namespace".
 boundMemcache.put("key3", "value3");
 </pre></code>

 <p>
 MemcacheService <code>memcache</code> (in the above example) uses the current
 namespace and <code>key1</code> will be stored in namespace <code>"a-namespace"</code>,
 while <code>key2</code> is stored in namespace <code>"other-namespace"</code>. It is
 possible to override the current namespace and store data in specific
 namespace. In the above example <code>key3</code> is stored in namespace
 <code>"specific-namespace"</code>.

 <p>
 The Task Queue <A HREF="../../../../com/google/appengine/api/taskqueue/Queue.html#add()"><CODE>Queue.add()</CODE></A>
 methods will forward the <A HREF="../../../../com/google/appengine/api/NamespaceManager.html" title="class in com.google.appengine.api"><CODE>NamespaceManager</CODE></A> settings into the task
 being added causing the added task to be executed with the same current
 namespace as the task creator. The exception is that an unset current
 namespace (i.e. <A HREF="../../../../com/google/appengine/api/NamespaceManager.html#get()"><CODE>get()</CODE></A> returns null) will be
 forwarded as an empty ("") namespace to the created task's requests.
<P>

<P>
<HR>

<P>

<!-- ========== 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&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/appengine/api/NamespaceManager.html#get()">get</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the current namespace setting or <code>null</code> if not set.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/appengine/api/NamespaceManager.html#getGoogleAppsNamespace()">getGoogleAppsNamespace</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the Google Apps domain referring this request or
 otherwise the empty string ("").</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/appengine/api/NamespaceManager.html#set(java.lang.String)">set</A></B>(java.lang.String&nbsp;newNamespace)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the value used to initialize the namespace of namespace-aware services.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/appengine/api/NamespaceManager.html#validateNamespace(java.lang.String)">validateNamespace</A></B>(java.lang.String&nbsp;namespace)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Validate the format of a namespace string.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="set(java.lang.String)"><!-- --></A><H3>
set</H3>
<PRE>
public static void <B>set</B>(java.lang.String&nbsp;newNamespace)</PRE>
<DL>
<DD>Set the value used to initialize the namespace of namespace-aware services.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>newNamespace</CODE> - the new namespace.
<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if namespace string is invalid.</DL>
</DD>
</DL>
<HR>

<A NAME="get()"><!-- --></A><H3>
get</H3>
<PRE>
public static java.lang.String <B>get</B>()</PRE>
<DL>
<DD>Returns the current namespace setting or <code>null</code> if not set.

 <p>If the current namespace is unset, callers should assume
 the use of the "" (empty) namespace in all namespace-aware services.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="getGoogleAppsNamespace()"><!-- --></A><H3>
getGoogleAppsNamespace</H3>
<PRE>
public static java.lang.String <B>getGoogleAppsNamespace</B>()</PRE>
<DL>
<DD>Returns the Google Apps domain referring this request or
 otherwise the empty string ("").
<P>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="validateNamespace(java.lang.String)"><!-- --></A><H3>
validateNamespace</H3>
<PRE>
public static void <B>validateNamespace</B>(java.lang.String&nbsp;namespace)</PRE>
<DL>
<DD>Validate the format of a namespace string.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - If the format of the namespace string
     is invalid.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" 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_bottom_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>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/google/appengine/api/LifecycleManager.ShutdownHook.html" title="interface in com.google.appengine.api"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/google/appengine/api/ThreadManager.html" title="class in com.google.appengine.api"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?com/google/appengine/api/NamespaceManager.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="NamespaceManager.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<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:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>

</BODY>
</HTML>