Examples of parseAndClose()


Examples of com.google.api.client.json.JsonObjectParser.parseAndClose()

        if (content == null) {
          // Throw explicitly rather than allow a later null reference as default mock
          // transports return success codes with empty contents.
          throw new IOException("Empty content from metadata token server request.");
        }
        return parser.parseAndClose(content, response.getContentCharset(), TokenResponse.class);
      }
      if (statusCode == HttpStatusCodes.STATUS_CODE_NOT_FOUND) {
        throw new IOException(String.format("Error code %s trying to get security access token from"
            + " Compute Engine metadata for the default service account. This may be because"
            + " the virtual machine instance does not have permission scopes specified.",
View Full Code Here

Examples of com.google.api.client.json.JsonObjectParser.parseAndClose()

    Preconditions.checkNotNull(credentialStream);
    Preconditions.checkNotNull(transport);
    Preconditions.checkNotNull(jsonFactory);

    JsonObjectParser parser = new JsonObjectParser(jsonFactory);
    GenericJson fileContents = parser.parseAndClose(
        credentialStream, OAuth2Utils.UTF_8, GenericJson.class);
    String fileType = (String) fileContents.get("type");
    if (fileType == null) {
      throw new IOException("Error reading credentials from stream, 'type' field not specified.");
    }
View Full Code Here

Examples of com.google.api.client.json.JsonParser.parseAndClose()

          // check for empty content
          if (currentToken != null) {
            // make sure there is an "error" key
            parser.skipToKey("error");
            if (parser.getCurrentToken() != JsonToken.END_OBJECT) {
              details = parser.parseAndClose(GoogleJsonError.class, null);
              detailString = details.toPrettyString();
            }
          }
        } catch (IOException exception) {
          // it would be bad to throw an exception while throwing an exception
View Full Code Here

Examples of com.google.api.client.util.ObjectParser.parseAndClose()

    }

    // Check if we have an ObjectParser that we can use
    ObjectParser objectParser = request.getParser();
    if (objectParser != null) {
      return objectParser.parseAndClose(getContent(), getContentCharset(), dataClass);
    }

    // Otherwise fall back to the deprecated implementation
    HttpParser parser = getParser();
    if (parser == null) {
View Full Code Here

Examples of com.google.api.client.util.ObjectParser.parseAndClose()

   */
  public Object parseAs(Type dataType) throws IOException {
    // Check if we have an ObjectParser that we can use
    ObjectParser objectParser = request.getParser();
    Preconditions.checkArgument(objectParser != null, "No ObjectParser defined for response");
    return objectParser.parseAndClose(getContent(), getContentCharset(), dataType);
  }

  /**
   * Parses the content of the HTTP response from {@link #getContent()} and reads it into a string.
   *
 
View Full Code Here

Examples of com.google.api.client.util.ObjectParser.parseAndClose()

    // TODO(mlinder): Remove the HttpResponse reference and directly parse the InputStream
    com.google.api.client.http.HttpParser oldParser = requestInfo.request.getParser(contentType);
    ObjectParser parser = requestInfo.request.getParser();
    A parsed = null;
    if (dataClass != Void.class) {
      parsed = parser != null ? parser.parseAndClose(
          response.getContent(), response.getContentCharset(), dataClass) : oldParser.parse(
          response, dataClass);
    }
    return parsed;
  }
View Full Code Here

Examples of com.google.api.client.xml.XmlObjectParser.parseAndClose()

    try {
      XmlNamespaceDictionary nameSpace = new XmlNamespaceDictionary().set("", "http://www.w3.org/2005/Atom").set("db", "http://www.douban.com/xmlns/").set("gd", "http://schemas.google.com/g/2005").set("openSearch", "http://a9.com/-/spec/opensearchrss/1.0/").set("opensearch", "http://a9.com/-/spec/opensearchrss/1.0/");
      XmlObjectParser parser = new XmlObjectParser(nameSpace);
      //JsonObjectParser parser = new JsonObjectParser(new JacksonFactory());
      fis = new FileInputStream("/home/zwei/doubantestxml");
      DoubanPeopleEntry result = parser.parseAndClose(fis, Charset.forName("utf-8"), DoubanPeopleEntry.class);
      System.out.println("result : " + result);
    } catch (FileNotFoundException ex) {
      Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
      Logger.getLogger(PlayGround.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.