private Set<String> getScopesForField(final String fieldName) {
    final Set<String> scopes = Sets.newHashSet();

    // add specific scope in case of specific request
    final String[] fields = Tokenizer.tokenize(fieldName, ",");
    for (final String field : fields) {
      final String[] subfields = Tokenizer.tokenize(field, ".");
      // in case of nested path, add first level as stand-alone to ensure subgraph is added
      scopes.add(SelectableScopeResolver.PREFIX + subfields[0]);
      if (subfields.length > 1) {
        scopes.add(SelectableScopeResolver.PREFIX + field);
      }
    }

    return scopes;
  }
  private static List<MediaType> extractMediaTypes(final String[] values) {
    if (values.length == 0) {
      return Collections.emptyList();
    }

    final List<MediaType> types = new ArrayList<MediaType>(values.length);
    for (final String mtEntry : values) {
      for (final String mt : Tokenizer.tokenize(mtEntry, ",")) {
        types.add(MediaType.valueOf(mt));
      }
    }

    return types;
  }
Exemple #3
0
 /**
  * Extract the list of link relations from the string value of a {@link Link#REL} attribute.
  *
  * @param rel string value of the link {@code "rel"} attribute.
  * @return list of relations in the {@code "rel"} attribute string value.
  */
 static List<String> getLinkRelations(final String rel) {
   return (rel == null) ? null : Arrays.asList(Tokenizer.tokenize(rel, "\" "));
 }