wildcard

Java generics, Unbound wildcards <?> vs <Object>

ⅰ亾dé卋堺 提交于 2019-12-17 15:57:37
问题 I've read a few topics which cover certain questions about generics, such as their relationship with raw types. But I'd like an additional explanation on a certain line found in the Java SE tutorial on unbound generics . According to a sentence : The goal of printList is to print a list of any type, but it fails to achieve that goal — it prints only a list of Object instances; it cannot print List<Integer>, List<String>, List<Double>, and so on, because they are not subtypes of List<Object>.

What do double-asterisk wildcards mean?

允我心安 提交于 2019-12-17 15:36:50
问题 I've tried the following command but I am having trouble interpreting it: ls ** but I'm not sure exactly what it is outputting and why that is the result. 回答1: Keith's answer is the correct one. Refer there. Consider the following directory tree: folderA ├── file1 ├── file2 └── folderB ├── file3 └── folderC ls will list all objects in the current folder: $ ls file1 file2 folderB ls * will list all objects in the current folder and in addition one more level recursively $ ls * file1 file2

Is there a wildcard selector for identifiers (id)?

南笙酒味 提交于 2019-12-17 15:24:03
问题 If I have an unknown amount of identifiers sharing a specific naming-scheme, is there a way to grab them all at once using jQuery? // These are the IDs I'd like to select #instance1 #instance2 #instance3 #instance4 // What do I need to add or how do I need to modify this jQuery selector in order to select all the IDs above? ("#instanceWILDCARD").click(function(){} 回答1: The attribute starts-with selector ('^=) will work for your IDs, like this: $("[id^=instance]").click(function() { //do stuff

Generics, Type Parameters and Wildcards

不羁岁月 提交于 2019-12-17 10:45:13
问题 I am trying to understand java generics and they seem extremely difficult to understand. For example, this is fine... public class Main { public static void main(String[] args) { List<?> list = null; method(list); } public static <T> void method(List<T> list) { } } ... as is this... public class Main { public static void main(String[] args) { List<List<?>> list = null; method(list); } public static <T> void method(List<T> list) { } } ... and this ... public class Main { public static void

How do I pass a wildcard parameter to a bash file

筅森魡賤 提交于 2019-12-17 09:38:27
问题 I'm trying to write a bash script that allows the user to pass a directory path using wildcards. For example, bash show_files.sh * when executed within this directory drw-r--r-- 2 root root 4.0K Sep 18 11:33 dir_a -rw-r--r-- 1 root root 223 Sep 18 11:33 file_b.txt -rw-rw-r-- 1 root root 106 Oct 18 15:48 file_c.sql would output: dir_a file_b.txt file_c.sql The way it is right now, it outputs: dir_a contents of show_files.sh : #!/bin/bash dirs="$1" for dir in $dirs do echo $dir done 回答1: The

What expands to all files in current directory recursively?

北城以北 提交于 2019-12-17 04:52:12
问题 I know **/*.ext expands to all files in all subdirectories matching *.ext , but what is a similar expansion that includes all such files in the current directory as well? 回答1: This will work in Bash 4: ls -l {,**/}*.ext In order for the double-asterisk glob to work, the globstar option needs to be set (default: on): shopt -s globstar From man bash : globstar If set, the pattern ** used in a filename expansion con‐ text will match a files and zero or more directories and subdirectories. If the

Optimization of MySQL search using “like” and wildcards

孤街浪徒 提交于 2019-12-17 04:34:29
问题 How can queries like SELECT * FROM sometable WHERE somefield LIKE '%value%' be optimized? The main issue here is the first wildcard which prevents DBMS from using index. Edit: What is more, somefield value is solid string (not a piece of text) so fulltext search could not be performed. 回答1: Two ways: (1) use an in-memory table so it goes very fast. (2) cook up a better index and search algorithm than foo LIKE '%bar%' . It's not possible to make any suggestions about this without knowing more

How to skip the for loop when there are no matching files?

眉间皱痕 提交于 2019-12-17 03:21:29
问题 When I loop through all the files starting by foo I do for f in foo* ; do echo "result = $f" ; done The problem is when no file start by foo I get: result = foo* Meaning that the loop is executed once, even if no file start by foo . How is this possible? How can I loop through all files (and not loop at all if there is no file)? 回答1: You can stop this behaviour by setting nullglob: shopt -s nullglob From the linked page: nullglob is a Bash shell option which modifies [[glob]] expansion such

How to skip the for loop when there are no matching files?

雨燕双飞 提交于 2019-12-17 03:20:01
问题 When I loop through all the files starting by foo I do for f in foo* ; do echo "result = $f" ; done The problem is when no file start by foo I get: result = foo* Meaning that the loop is executed once, even if no file start by foo . How is this possible? How can I loop through all files (and not loop at all if there is no file)? 回答1: You can stop this behaviour by setting nullglob: shopt -s nullglob From the linked page: nullglob is a Bash shell option which modifies [[glob]] expansion such

Searching using MySQL: How to escape wildcards

空扰寡人 提交于 2019-12-14 04:19:45
问题 I am currently searching my database with a query (using JDBC) like this: "... AND LCASE(Items.Name) LIKE '%" + searchString.toLowerCase() + "%';" Now, this is obviously very bad, because it allows for SQL injection as well as insertion of wildcard symbols such as % and _. My question is, how can I do a query such that even if the searchString contains any of these characters, they will be treated literally? 回答1: First, don't use LCASE with LIKE unless you're using a case-sensitive locale