posts - 431,  comments - 344,  trackbacks - 0
          JQL is an extension for Java that provides support for querying collections of objects. These queries can be run over objects in collections in your program, or even used to check expressions on all instances of specific types at runtime.

          Queries provide a powerful abstraction for dealing with sets of objects, allowing the query engine to take care of the implementation details. This allows for shorter, clearer code, and permits the query engine to dynamically optimize query evaluation strategies as the runtime context changes.

          Queries can also be cached and that cache incrementally maintained - this greatly increases their efficiency, and can offer improved performance for many common collection operations.

          A brief example!

          Say we're building a crossword puzzle. We've got a list of candidate words for our puzzle, and a list of the lengths of the gaps we need to fill:
          ArrayList<String> words = dict.getWords(Puzzle.MEDIUM);
          ArrayList<Integer> gaplengths = puzzle.getGapLengths();

          Now we've got a truly marvelous algorithm for building a crossword puzzle (that this webpage is too narrow to contain), which relies on having a list of pairs of [length, word].
          Using a JQL query, we can build this list with ease:
          List<Object[]> matches = selectAll(String w : words,
                                             Integer i : gaplengths |
                                             w.length() == i);
          Contrast with how we could do this in normal Java:
          List<Object[]> matches = new ArrayList<Object[]>();
          for(String w : words){
            for(Integer i : gaplengths){
              if(w.length() == i)
                matches.add(new Object[i,w]);
            }
          }
          The JQL query and the Java code will produce the same list of results - but the JQL version is shorter, neater, and abstracts away the exact method of finding the matches. For a more in-depth look on why this can be helpful, please look at our Examples page.

          下載地址:http://homepages.mcs.vuw.ac.nz/~djp/jql/download.html
          posted on 2009-08-06 09:11 周銳 閱讀(297) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 大港区| 邵武市| 弥渡县| 灯塔市| 庆安县| 阜城县| 潜江市| 子长县| 浮山县| 新巴尔虎右旗| 余江县| 南木林县| 阿瓦提县| 华阴市| 麟游县| 许昌县| 郧西县| 仁寿县| 威远县| 德安县| 沧源| 平阳县| 准格尔旗| 宜君县| 永丰县| 河北区| 若尔盖县| 沙洋县| 鄯善县| 始兴县| 翁牛特旗| 威远县| 教育| 常德市| 丰宁| 永清县| 洪洞县| 乌拉特后旗| 利辛县| 湖口县| 武城县|