当前位置: 首页>>代码示例>>Java>>正文


Java GenericData.put方法代码示例

本文整理汇总了Java中com.google.api.client.util.GenericData.put方法的典型用法代码示例。如果您正苦于以下问题:Java GenericData.put方法的具体用法?Java GenericData.put怎么用?Java GenericData.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.util.GenericData的用法示例。


在下文中一共展示了GenericData.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loginUser

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Login an exiting Kickflip User and make it active.
 *
 * @param username The Kickflip user's username
 * @param password The Kickflip user's password
 * @param cb       This callback will receive a User in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
 *                 or an Exception {@link io.kickflip.sdk.api.KickflipCallback#onError(io.kickflip.sdk.exception.KickflipException)}.
 */
public void loginUser(String username, final String password, final KickflipCallback cb) {
    GenericData data = new GenericData();
    data.put("username", username);
    data.put("password", password);

    post(GET_USER_PRIVATE, new UrlEncodedContent(data), User.class, new KickflipCallback() {
        @Override
        public void onSuccess(final Response response) {
            if (VERBOSE)
                Log.i(TAG, "loginUser response: " + response);
            storeNewUserResponse((User) response, password);
            postResponseToCallback(cb, response);
        }

        @Override
        public void onError(final KickflipException error) {
            Log.w(TAG, "loginUser Error: " + error);
            postExceptionToCallback(cb, error);
        }
    });
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:30,代码来源:KickflipApiClient.java

示例2: getUserInfo

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Get public user info
 *
 * @param username The Kickflip user's username
 * @param cb       This callback will receive a User in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
 *                 or an Exception {@link io.kickflip.sdk.api.KickflipCallback#onError(io.kickflip.sdk.exception.KickflipException)}.
 */
public void getUserInfo(String username, final KickflipCallback cb) {
    if (!assertActiveUserAvailable(cb)) return;
    GenericData data = new GenericData();
    data.put("username", username);

    post(GET_USER_PUBLIC, new UrlEncodedContent(data), User.class, new KickflipCallback() {
        @Override
        public void onSuccess(final Response response) {
            if (VERBOSE)
                Log.i(TAG, "getUserInfo response: " + response);
            postResponseToCallback(cb, response);
        }

        @Override
        public void onError(final KickflipException error) {
            Log.w(TAG, "getUserInfo Error: " + error);
            postExceptionToCallback(cb, error);
        }
    });
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:28,代码来源:KickflipApiClient.java

示例3: startStreamWithUser

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Start a new Stream owned by the given User. Must be called after
 * {@link io.kickflip.sdk.api.KickflipApiClient#createNewUser(KickflipCallback)}
 * Delivers stream endpoint destination data via a {@link io.kickflip.sdk.api.KickflipCallback}.
 *
 * @param user The Kickflip User on whose behalf this request is performed.
 * @param cb   This callback will receive a Stream subclass in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
 *             depending on the Kickflip account type. Implementors should
 *             check if the response is instanceof HlsStream, StartRtmpStreamResponse, etc.
 */
private void startStreamWithUser(User user, Stream stream, final KickflipCallback cb) {
    checkNotNull(user);
    checkNotNull(stream);
    GenericData data = new GenericData();
    data.put("uuid", user.getUUID());
    data.put("private", stream.isPrivate());
    if (stream.getTitle() != null) {
        data.put("title", stream.getTitle());
    }
    if (stream.getDescription() != null) {
        data.put("description", stream.getDescription());
    }
    if (stream.getExtraInfo() != null) {
        data.put("extra_info", new Gson().toJson(stream.getExtraInfo()));
    }
    post(START_STREAM, new UrlEncodedContent(data), HlsStream.class, cb);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:28,代码来源:KickflipApiClient.java

示例4: sendGCMSync

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
public static boolean sendGCMSync(String userId, String senderId) {
    if(Constants.GCM_API_KEY == null) {
        log.info("GCM not set up, see readme for how to configure");
        return false;
    }
    try {
        GCMMessage message = new GCMMessage(userId);
        log.info("message:" + message);
        log.info("gson:" + gson.toJson(message));
        GenericData body = new GenericData();
        GenericData data = new GenericData();
        body.put("to", "/topics/" + userId);
        if(senderId != null) {
            data.put("senderId",senderId);
            body.put("data", data);
        }

        //why does this only take a generic map?
        HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(GCM_HOST),
                new JsonHttpContent(gsonFactory, body))
                .setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()))
                .setHeaders(new HttpHeaders().setAuthorization("key=" + Constants.GCM_API_KEY));
        request.getContent().writeTo(System.out);
        HttpResponse response = request.execute();
        log.info("response" + response);
        return true;
    } catch(IOException e) {
        log.info("could not send http message:");
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:saucenet,项目名称:sync,代码行数:33,代码来源:Networker.java

示例5: setUserInfo

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Set the current active user's meta info. Pass a null argument to leave it as-is.
 *
 * @param newPassword the user's new password
 * @param email       the user's new email address
 * @param displayName The desired display name
 * @param extraInfo   Arbitrary String data to associate with this user.
 * @param cb          This callback will receive a User in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
 *                    or an Exception {@link io.kickflip.sdk.api.KickflipCallback#onError(io.kickflip.sdk.exception.KickflipException)}.
 */
public void setUserInfo(final String newPassword, String email, String displayName, Map extraInfo, final KickflipCallback cb) {
    if (!assertActiveUserAvailable(cb)) return;
    GenericData data = new GenericData();
    final String finalPassword;
    if (newPassword != null){
        data.put("new_password", newPassword);
        finalPassword = newPassword;
    } else {
        finalPassword = getPasswordForActiveUser();
    }
    if (email != null) data.put("email", email);
    if (displayName != null) data.put("display_name", displayName);
    if (extraInfo != null) data.put("extra_info", new Gson().toJson(extraInfo));

    post(EDIT_USER, new UrlEncodedContent(data), User.class, new KickflipCallback() {
        @Override
        public void onSuccess(final Response response) {
            if (VERBOSE)
                Log.i(TAG, "setUserInfo response: " + response);
            storeNewUserResponse((User) response, finalPassword);
            postResponseToCallback(cb, response);
        }

        @Override
        public void onError(final KickflipException error) {
            Log.w(TAG, "setUserInfo Error: " + error);
            postExceptionToCallback(cb, error);
        }
    });
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:41,代码来源:KickflipApiClient.java

示例6: stopStream

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Stop a Stream owned by the given Kickflip User.
 *
 * @param cb This callback will receive a Stream subclass in #onSuccess(response)
 *           depending on the Kickflip account type. Implementors should
 *           check if the response is instanceof HlsStream, etc.
 */
private void stopStream(User user, Stream stream, final KickflipCallback cb) {
    checkNotNull(stream);
    // TODO: Add start / stop lat lon to Stream?
    GenericData data = new GenericData();
    data.put("stream_id", stream.getStreamId());
    data.put("uuid", user.getUUID());
    if (stream.getLatitude() != 0) {
        data.put("lat", stream.getLatitude());
    }
    if (stream.getLongitude() != 0) {
        data.put("lon", stream.getLongitude());
    }
    post(STOP_STREAM, new UrlEncodedContent(data), HlsStream.class, cb);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:22,代码来源:KickflipApiClient.java

示例7: setStreamInfo

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Send Stream Metadata for a {@link io.kickflip.sdk.api.json.Stream}.
 * The target Stream must be owned by the User created with {@link io.kickflip.sdk.api.KickflipApiClient#createNewUser(KickflipCallback)}
 * from this KickflipApiClient.
 *
 * @param stream the {@link io.kickflip.sdk.api.json.Stream} to get Meta data for
 * @param cb     A callback to receive the updated Stream upon request completion
 */
public void setStreamInfo(Stream stream, final KickflipCallback cb) {
    if (!assertActiveUserAvailable(cb)) return;
    GenericData data = new GenericData();
    data.put("stream_id", stream.getStreamId());
    data.put("uuid", getActiveUser().getUUID());
    if (stream.getTitle() != null) {
        data.put("title", stream.getTitle());
    }
    if (stream.getDescription() != null) {
        data.put("description", stream.getDescription());
    }
    if (stream.getExtraInfo() != null) {
        data.put("extra_info", new Gson().toJson(stream.getExtraInfo()));
    }
    if (stream.getLatitude() != 0) {
        data.put("lat", stream.getLatitude());
    }
    if (stream.getLongitude() != 0) {
        data.put("lon", stream.getLongitude());
    }
    if (stream.getCity() != null) {
        data.put("city", stream.getCity());
    }
    if (stream.getState() != null) {
        data.put("state", stream.getState());
    }
    if (stream.getCountry() != null) {
        data.put("country", stream.getCountry());
    }

    if (stream.getThumbnailUrl() != null) {
        data.put("thumbnail_url", stream.getThumbnailUrl());
    }

    data.put("private", stream.isPrivate());
    data.put("deleted", stream.isDeleted());

    post(SET_META, new UrlEncodedContent(data), Stream.class, cb);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:48,代码来源:KickflipApiClient.java

示例8: getStreamsByUsername

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Get a List of {@link io.kickflip.sdk.api.json.Stream} objects created by the given Kickflip User.
 *
 * @param username the target Kickflip username
 * @param cb       A callback to receive the resulting List of Streams
 */
public void getStreamsByUsername(String username, int pageNumber, int itemsPerPage, final KickflipCallback cb) {
    if (!assertActiveUserAvailable(cb)) return;
    GenericData data = new GenericData();
    addPaginationData(pageNumber, itemsPerPage, data);
    data.put("uuid", getActiveUser().getUUID());
    data.put("username", username);
    post(SEARCH_USER, new UrlEncodedContent(data), StreamList.class, cb);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:15,代码来源:KickflipApiClient.java

示例9: getStreamsByKeyword

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Get a List of {@link io.kickflip.sdk.api.json.Stream}s containing a keyword.
 * <p/>
 * This method searches all public recordings made by Users of your Kickflip app.
 *
 * @param keyword The String keyword to query
 * @param cb      A callback to receive the resulting List of Streams
 */
public void getStreamsByKeyword(String keyword, int pageNumber, int itemsPerPage, final KickflipCallback cb) {
    if (!assertActiveUserAvailable(cb)) return;
    GenericData data = new GenericData();
    addPaginationData(pageNumber, itemsPerPage, data);
    data.put("uuid", getActiveUser().getUUID());
    if (keyword != null) {
        data.put("keyword", keyword);
    }
    post(SEARCH_KEYWORD, new UrlEncodedContent(data), StreamList.class, cb);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:19,代码来源:KickflipApiClient.java

示例10: getStreamsByLocation

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Get a List of {@link io.kickflip.sdk.api.json.Stream}s near a geographic location.
 * <p/>
 * This method searches all public recordings made by Users of your Kickflip app.
 *
 * @param location The target Location
 * @param radius   The target Radius in meters
 * @param cb       A callback to receive the resulting List of Streams
 */
public void getStreamsByLocation(Location location, int radius, int pageNumber, int itemsPerPage, final KickflipCallback cb) {
    if (!assertActiveUserAvailable(cb)) return;
    GenericData data = new GenericData();
    data.put("uuid", getActiveUser().getUUID());
    data.put("lat", location.getLatitude());
    data.put("lon", location.getLongitude());
    if (radius != 0) {
        data.put("radius", radius);
    }
    post(SEARCH_GEO, new UrlEncodedContent(data), StreamList.class, cb);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:21,代码来源:KickflipApiClient.java

示例11: addUrlEncodedContent

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
public MultipartFormDataContent addUrlEncodedContent(String name, String value) {
    GenericData data = new GenericData();
    data.put(value, "");

    Part part = new Part();
    part.setContent(new UrlEncodedContent(data));
    part.setName(name);

    this.addPart(part);

    return this;
}
 
开发者ID:kmonaghan,项目名称:Broadsheet.ie-Android,代码行数:13,代码来源:MultipartFormDataContent.java

示例12: createNewUser

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Create a new Kickflip User.
 * The User created as a result of this request is cached and managed by this KickflipApiClient
 * throughout the life of the host Android application installation.
 * <p/>
 * The other methods of this client will be performed on behalf of the user created by this request,
 * unless noted otherwise.
 *
 * @param username    The desired username for this Kickflip User. Will be altered if not unique for this Kickflip app.
 * @param password    The password for this Kickflip user.
 * @param email       The email address for this Kickflip user.
 * @param displayName The display name for this Kickflip user.
 * @param extraInfo   Map data to be associated with this Kickflip User.
 * @param cb          This callback will receive a User in {@link io.kickflip.sdk.api.KickflipCallback#onSuccess(io.kickflip.sdk.api.json.Response)}
 *                    or an Exception {@link io.kickflip.sdk.api.KickflipCallback#onError(io.kickflip.sdk.exception.KickflipException)}.
 */
public void createNewUser(String username, String password, String email, String displayName, Map extraInfo, final KickflipCallback cb) {
    GenericData data = new GenericData();
    if (username != null) {
        data.put("username", username);
    }

    final String finalPassword;
    if (password != null) {
        finalPassword = password;
    } else {
        finalPassword = generateRandomPassword();
    }
    data.put("password", finalPassword);

    if (displayName != null) {
        data.put("display_name", displayName);
    }
    if (email != null) {
        data.put("email", email);
    }
    if (extraInfo != null) {
        data.put("extra_info", new Gson().toJson(extraInfo));
    }

    post(NEW_USER, new UrlEncodedContent(data), User.class, new KickflipCallback() {
        @Override
        public void onSuccess(final Response response) {
            if (VERBOSE)
                Log.i(TAG, "createNewUser response: " + response);
            storeNewUserResponse((User) response, finalPassword);
            postResponseToCallback(cb, response);
        }

        @Override
        public void onError(final KickflipException error) {
            Log.w(TAG, "createNewUser Error: " + error);
            postExceptionToCallback(cb, error);
        }
    });
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:57,代码来源:KickflipApiClient.java

示例13: addPaginationData

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
private void addPaginationData(int pageNumber, int itemsPerPage, GenericData target) {
    target.put("results_per_page", itemsPerPage);
    target.put("page", pageNumber);
}
 
开发者ID:Kickflip,项目名称:kickflip-android-sdk,代码行数:5,代码来源:KickflipApiClient.java

示例14: setUp

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Sets all instance variables to values for a successful request. Tests that require failed
 * requests or null/empty values should mutate the instance variables accordingly.
 */
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);

  requestMethod = "POST";
  url = "http://www.foo.com/bar";
  reportServiceLogger = new ReportServiceLogger(loggerDelegate);

  requestFactory = new NetHttpTransport().createRequestFactory();
  // Constructs the request headers.
  rawRequestHeaders = new HashMap<>();
  // Adds headers that should be scrubbed.
  for (String scrubbedHeader : ReportServiceLogger.SCRUBBED_HEADERS) {
    rawRequestHeaders.put(scrubbedHeader, "foo" + scrubbedHeader);
  }
  // Adds headers that should not be scrubbed.
  rawRequestHeaders.put("clientCustomerId", "123-456-7890");
  rawRequestHeaders.put("someOtherHeader", "SomeOtherValue");

  GenericData postData = new GenericData();
  postData.put("__rdquery", "SELECT CampaignId FROM CAMPAIGN_PERFORMANCE_REPORT");

  httpRequest =
      requestFactory.buildPostRequest(new GenericUrl(url), new UrlEncodedContent(postData));

  for (Entry<String, String> rawHeaderEntry : rawRequestHeaders.entrySet()) {
    String key = rawHeaderEntry.getKey();
    if ("authorization".equalsIgnoreCase(key)) {
      httpRequest
          .getHeaders()
          .setAuthorization(Collections.<String>singletonList(rawHeaderEntry.getValue()));
    } else {
      httpRequest.getHeaders().put(key, rawHeaderEntry.getValue());
    }
  }

  httpRequest.getResponseHeaders().setContentType("text/csv; charset=UTF-8");
  httpRequest.getResponseHeaders().put("someOtherResponseHeader", "foo");
  httpRequest
      .getResponseHeaders()
      .put("multiValueHeader", Arrays.<String>asList("value1", "value2"));
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:47,代码来源:ReportServiceLoggerTest.java

示例15: addMediaFiles

import com.google.api.client.util.GenericData; //导入方法依赖的package包/类
/**
 * Add Media Files to a CustomPlaylist.
 * <p>
 * Shallow action that requires a list of media files tokens to be added to this custom playlist.
 * Media files can be added manually only to custom playlists.
 *
 * @param audioBoxClient the {@link fm.audiobox.core.AudioBoxClient} to use for the request
 * @param tokens         the list of the tokens string to add to this playlist
 *
 * @return the playlist instance in order to chain other operations on it if needed.
 *
 * @throws java.lang.IllegalStateException                       if the playlist is not persisted yet.
 * @throws fm.audiobox.core.exceptions.ResourceNotFoundException if the playlist not found or not of type CustomPlaylist.
 * @throws fm.audiobox.core.exceptions.AudioBoxException         if any of the remote error exception is detected.
 * @throws java.io.IOException                                   if any connection problem occurs.
 * @see fm.audiobox.core.exceptions.AudioBoxException
 */
public Playlist addMediaFiles(AudioBoxClient audioBoxClient, List<String> tokens) throws IOException {

  ensurePlaylistForRequest();

  GenericData d = new GenericData();
  for ( String token : tokens ) {
    d.put( MediaFiles.PARAM_TOKENS, token );
  }
  JsonHttpContent data = new JsonHttpContent( audioBoxClient.getConf().getJsonFactory(), d );
  audioBoxClient.doPOST( ModelUtil.interpolate( ADD_MEDIA_FILES_PATH, getToken() ), data, null, null );
  return this;
}
 
开发者ID:icoretech,项目名称:audiobox-jlib,代码行数:30,代码来源:Playlist.java


注:本文中的com.google.api.client.util.GenericData.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。