/** * Get a canonical array of tokens from a String entry that may contain * zero or more tokens separated by common delimiters {@code " ,;\n"}. * * @param entry a String that may contain zero or more * {@link #COMMON_DELIMITERS common delimiters} separated tokens. * @return the array of tokens, each tokens is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String entry) { return tokenize(entry, COMMON_DELIMITERS); }
/** * Get a canonical array of tokens from a String entry that may contain * zero or more tokens separated by common delimiters {@code " ,;\n"}. * * @param entry a String that may contain zero or more * {@link #COMMON_DELIMITERS common delimiters} separated tokens. * @return the array of tokens, each tokens is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String entry) { return tokenize(entry, COMMON_DELIMITERS); }
/** * Get a canonical array of tokens from an array of String entries * where each entry may contain zero or more tokens separated by * common delimiters {@code " ,;\n"}. * * @param entries an array where each String entry may contain zero or more * {@link #COMMON_DELIMITERS common delimiters} separated tokens. * @return the array of tokens, each token is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String[] entries) { return tokenize(entries, COMMON_DELIMITERS); }
/** * Get a canonical array of tokens from an array of String entries * where each entry may contain zero or more tokens separated by * common delimiters {@code " ,;\n"}. * * @param entries an array where each String entry may contain zero or more * {@link #COMMON_DELIMITERS common delimiters} separated tokens. * @return the array of tokens, each token is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String[] entries) { return tokenize(entries, COMMON_DELIMITERS); }
/** * 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, "\" ")); } }
/** * 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, "\" ")); } }
private Set<String> getScopesForField(final String fieldName) { final Set<String> scopes = new HashSet<>(); // 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 String[] parsePropertyValue(final String propertyName) { String[] classNames = null; final Object o = state.getProperties().get(propertyName); if (o != null) { if (o instanceof String) { classNames = Tokenizer.tokenize((String) o); } else if (o instanceof String[]) { classNames = Tokenizer.tokenize((String[]) o); } } return classNames; }
private String[] parsePropertyValue(final String propertyName) { String[] classNames = null; final Object o = state.getProperties().get(propertyName); if (o != null) { if (o instanceof String) { classNames = Tokenizer.tokenize((String) o); } else if (o instanceof String[]) { classNames = Tokenizer.tokenize((String[]) o); } } return classNames; }
/** * Get a canonical array of tokens from a String entry * that may contain zero or more tokens separated by characters in * delimiters string. * * @param entry a String that may contain zero or more * delimiters separated tokens. * @param delimiters string with delimiters, every character represents one * delimiter. * @return the array of tokens, each tokens is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String entry, final String delimiters) { final Collection<String> tokens = tokenize(entry, delimiters, new LinkedList<String>()); return tokens.toArray(new String[tokens.size()]); }
/** * Get a canonical array of tokens from a String entry * that may contain zero or more tokens separated by characters in * delimiters string. * * @param entry a String that may contain zero or more * delimiters separated tokens. * @param delimiters string with delimiters, every character represents one * delimiter. * @return the array of tokens, each tokens is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String entry, final String delimiters) { final Collection<String> tokens = tokenize(entry, delimiters, new LinkedList<String>()); return tokens.toArray(new String[tokens.size()]); }
private static List<MediaType> extractMediaTypes(final String[] values) { if (values.length == 0) { return Collections.emptyList(); } final List<MediaType> types = new ArrayList<>(values.length); for (final String mtEntry : values) { for (final String mt : Tokenizer.tokenize(mtEntry, ",")) { types.add(MediaType.valueOf(mt)); } } return types; }
private static List<MediaType> extractMediaTypes(final String[] values) { if (values.length == 0) { return Collections.emptyList(); } final List<MediaType> types = new ArrayList<>(values.length); for (final String mtEntry : values) { for (final String mt : Tokenizer.tokenize(mtEntry, ",")) { types.add(MediaType.valueOf(mt)); } } return types; }
/** * Scan from a set of packages. * * @param fileNames an array of package names. * @param recursive flag indicating whether sub-directories of any directories in the list of * files should be included in the scanning ({@code true}) or not ({@code false}). */ public FilesScanner(final String[] fileNames, final boolean recursive) { this.recursive = recursive; this.files = new File[Tokenizer.tokenize(fileNames, Tokenizer.COMMON_DELIMITERS).length]; for (int i = 0; i < files.length; i++) { files[i] = new File(fileNames[i]); } init(); }
@GET @Path("runtimeRolesAllowed") public Response runtimeRolesAllowed(@QueryParam("roles") @DefaultValue("") final String roles) { return Response .ok() .entity(RestrictedEntity.instance(), new Annotation[] {SecurityAnnotations.rolesAllowed(Tokenizer.tokenize(roles))}) .build(); } }
/** * Scan from a set of packages. * * @param fileNames an array of package names. * @param recursive flag indicating whether sub-directories of any directories in the list of * files should be included in the scanning ({@code true}) or not ({@code false}). */ public FilesScanner(final String[] fileNames, final boolean recursive) { this.recursive = recursive; this.files = new File[Tokenizer.tokenize(fileNames, Tokenizer.COMMON_DELIMITERS).length]; for (int i = 0; i < files.length; i++) { files[i] = new File(fileNames[i]); } init(); }
/** * Scan a set of packages using a context {@link ClassLoader}. * * The {@code recursive} flag determines whether the packages will be scanned recursively * together with their nested packages ({@code true}) or if only the specified packages * shall be scanned ({@code false}). * * @param packages an array of package names. * @param recursive if ({@code true} the packages will be scanned recursively together with * any nested packages, if {@code false} only the explicitly listed packages * will be scanned. */ public PackageNamesScanner(final String[] packages, final boolean recursive) { this(AccessController.doPrivileged(ReflectionHelper.getContextClassLoaderPA()), Tokenizer.tokenize(packages, Tokenizer.COMMON_DELIMITERS), recursive); }
/** * Scan a set of packages using a context {@link ClassLoader}. * * The {@code recursive} flag determines whether the packages will be scanned recursively * together with their nested packages ({@code true}) or if only the specified packages * shall be scanned ({@code false}). * * @param packages an array of package names. * @param recursive if ({@code true} the packages will be scanned recursively together with * any nested packages, if {@code false} only the explicitly listed packages * will be scanned. */ public PackageNamesScanner(final String[] packages, final boolean recursive) { this(AccessController.doPrivileged(ReflectionHelper.getContextClassLoaderPA()), Tokenizer.tokenize(packages, Tokenizer.COMMON_DELIMITERS), recursive); }
/** * Get a canonical array of tokens from an array of String entries * where each entry may contain zero or more tokens separated by characters * in delimiters string. * * @param entries an array where each String entry may contain zero or more * delimiters separated tokens. * @param delimiters string with delimiters, every character represents one * delimiter. * @return the array of tokens, each token is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String[] entries, final String delimiters) { final List<String> tokens = new LinkedList<String>(); for (String entry : entries) { if (entry == null || entry.isEmpty()) { continue; } entry = entry.trim(); if (entry.isEmpty()) { continue; } tokenize(entry, delimiters, tokens); } return tokens.toArray(new String[tokens.size()]); }
/** * Get a canonical array of tokens from an array of String entries * where each entry may contain zero or more tokens separated by characters * in delimiters string. * * @param entries an array where each String entry may contain zero or more * delimiters separated tokens. * @param delimiters string with delimiters, every character represents one * delimiter. * @return the array of tokens, each token is trimmed, the array will * not contain any empty or {@code null} entries. */ public static String[] tokenize(final String[] entries, final String delimiters) { final List<String> tokens = new LinkedList<String>(); for (String entry : entries) { if (entry == null || entry.isEmpty()) { continue; } entry = entry.trim(); if (entry.isEmpty()) { continue; } tokenize(entry, delimiters, tokens); } return tokens.toArray(new String[tokens.size()]); }