/** * Removes a specific argument from the Location-Query options. * Returns the current OptionSet object for a fluent API. * @param argument the argument to remove * @return this OptionSet */ public OptionSet removeLocationQuery(String argument) { getLocationQuery().remove(argument); return this; }
/** * Removes a specific argument from the Location-Query options. * Returns the current OptionSet object for a fluent API. * @param argument the argument to remove * @return this OptionSet */ public OptionSet removeLocationQuery(String argument) { getLocationQuery().remove(argument); return this; }
/** * Returns the number of Location-Query options (i.e., arguments). * @return the count */ public int getLocationQueryCount() { return getLocationQuery().size(); }
/** * Removes all Location-Query options. * Returns the current OptionSet object for a fluent API. * @return this OptionSet */ public OptionSet clearLocationQuery() { getLocationQuery().clear(); return this; }
/** * Returns the number of Location-Query options (i.e., arguments). * @return the count */ public int getLocationQueryCount() { return getLocationQuery().size(); }
/** * Removes all Location-Query options. * Returns the current OptionSet object for a fluent API. * @return this OptionSet */ public OptionSet clearLocationQuery() { getLocationQuery().clear(); return this; }
/** * Adds an argument to the Location-Query options. * Returns the current OptionSet object for a fluent API. * @param argument the argument to add * @return this OptionSet */ public OptionSet addLocationQuery(String argument) { if (argument == null) throw new NullPointerException("Location-Query option must not be null"); if (argument.getBytes(CoAP.UTF8_CHARSET).length > 255) throw new IllegalArgumentException("Location-Query option must be smaller or euqal to 255 bytes (UTF-8 encoded): " + argument); getLocationQuery().add(argument); return this; }
/** * Adds an argument to the Location-Query options. * Returns the current OptionSet object for a fluent API. * @param argument the argument to add * @return this OptionSet */ public OptionSet addLocationQuery(String argument) { if (argument == null) throw new NullPointerException("Location-Query option must not be null"); if (argument.getBytes(CoAP.UTF8_CHARSET).length > 255) throw new IllegalArgumentException("Location-Query option must be smaller or euqal to 255 bytes (UTF-8 encoded): " + argument); getLocationQuery().add(argument); return this; }
/** * Returns the Location-Query options as &-separated list string. * @return the Location-Query as string */ public String getLocationQueryString() { StringBuilder builder = new StringBuilder(); for (String query:getLocationQuery()) builder.append(query).append("&"); if (builder.length() > 0) builder.delete(builder.length() - 1, builder.length()); return builder.toString(); }
/** * Returns the Location-Query options as &-separated list string. * @return the Location-Query as string */ public String getLocationQueryString() { StringBuilder builder = new StringBuilder(); for (String query:getLocationQuery()) builder.append(query).append("&"); if (builder.length() > 0) builder.delete(builder.length() - 1, builder.length()); return builder.toString(); }
protected boolean checkResponse(Request request, Response response) { boolean success = true; success &= checkType(Type.ACK, response.getType()); success &= checkInt(EXPECTED_RESPONSE_CODE.value, response.getCode().value, "code"); success &= hasLocationQuery(response); // List<Option> options = // response.getOptions(OptionNumberRegistry.LOCATION_QUERY); // success &= checkOption(new Option("first=1", // OptionNumberRegistry.LOCATION_QUERY), options.get(0)); // success &= checkOption(new Option("second=2", // OptionNumberRegistry.LOCATION_QUERY), options.get(1)); List<String> query = response.getOptions().getLocationQuery(); List<String> expec = Arrays.asList("first=1", "second=2"); success &= checkOption(expec, query, "Location Query"); return success; } }