/** * Parses the namespaces declared on the current element into the namespace dictionary. * * @param parser XML pull parser * @param namespaceDictionary namespace dictionary */ private static void parseNamespacesForElement( XmlPullParser parser, XmlNamespaceDictionary namespaceDictionary) throws XmlPullParserException { int eventType = parser.getEventType(); Preconditions.checkState( eventType == XmlPullParser.START_TAG, "expected start of XML element, but got something else (event type %s)", eventType); int depth = parser.getDepth(); int nsStart = parser.getNamespaceCount(depth - 1); int nsEnd = parser.getNamespaceCount(depth); for (int i = nsStart; i < nsEnd; i++) { String namespace = parser.getNamespaceUri(i); // if namespace isn't already in our dictionary, add it now if (namespaceDictionary.getAliasForUri(namespace) == null) { String prefix = parser.getNamespacePrefix(i); String originalAlias = prefix == null ? "" : prefix; // find an available alias String alias = originalAlias; int suffix = 1; while (namespaceDictionary.getUriForAlias(alias) != null) { suffix++; alias = originalAlias + suffix; } namespaceDictionary.set(alias, namespace); } } }
// Note: Leave this static initializer at the top of the file. static { com.google.api.client.util.Preconditions.checkState( com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1 && com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 15, "You are currently running with version %s of google-api-client. " + "You need at least version 1.15 of google-api-client to run version " + "1.16.0-rc of the employeeendpoint library.", com.google.api.client.googleapis.GoogleUtils.VERSION); }
public HeaderCacheElement(AccessToken token) { this.exception = null; this.header = "Bearer " + token.getTokenValue(); Date expirationTime = token.getExpirationTime(); if (expirationTime != null) { long tokenExpiresTime = expirationTime.getTime(); this.staleTimeMs = tokenExpiresTime - TOKEN_STALENESS_MS; // Block until refresh at this point. this.expiresTimeMs = tokenExpiresTime - TOKEN_EXPIRES_MS; Preconditions.checkState(staleTimeMs < expiresTimeMs); } else { this.staleTimeMs = null; this.expiresTimeMs = null; } }