alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lucene example source code file (build.xml)

This example Lucene source code file (build.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lucene tags/keywords

apache, asf, asf, conditions, license, license, parseexception, parseexception, parseexception\, see, software, string, string, you

The Lucene build.xml source code

<?xml version="1.0"?>

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 -->

<project name="queryparser" default="default">

  <description>
    Flexible Query Parser
  </description>

  <import file="../contrib-build.xml"/>
 
  <target name="compile-core" depends="javacc-notice, common.compile-core"/>

  <!--
    NOTE: see the README.javacc for details on how to fully regenerate the parser
  -->
  <target name="javacc" depends="javacc-flexible,javacc-surround"/>

  <target name="javacc-flexible" depends="javacc-check">
    <delete>
      <fileset dir="src/java/org/apache/lucene/queryParser/standard/parser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
    </delete>
    <invoke-javacc target="src/java/org/apache/lucene/queryParser/standard/parser/StandardSyntaxParser.jj"
                   outputDir="src/java/org/apache/lucene/queryParser/standard/parser"
    />
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="public class ParseException extends Exception"
                             replace="public class ParseException extends QueryNodeParseException"
                             flags="g"
                             byline="false"/>
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="package org.apache.lucene.queryParser.standard.parser;"
                             replace="package org.apache.lucene.queryParser.standard.parser;${line.separator}
${line.separator}
import org.apache.lucene.messages.Message;${line.separator}
import org.apache.lucene.messages.MessageImpl;${line.separator}
import org.apache.lucene.queryParser.core.*;${line.separator}
import org.apache.lucene.queryParser.core.messages.*;"
                             flags="g"
                             byline="false"/>
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="^  public ParseException\(Token currentTokenVal.*$(\s\s[^}].*\n)*  \}"
                             replace="  public ParseException(Token currentTokenVal,${line.separator}
    int[][] expectedTokenSequencesVal, String[] tokenImageVal) {${line.separator}
    super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, initialise(${line.separator}
    currentTokenVal, expectedTokenSequencesVal, tokenImageVal)));${line.separator}
    this.currentToken = currentTokenVal;${line.separator}
    this.expectedTokenSequences = expectedTokenSequencesVal;${line.separator}
    this.tokenImage = tokenImageVal;${line.separator}
  }"
                             flags="gm"
                             byline="false"/>
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="^  public ParseException\(String message.*$(\s\s[^}].*\n)*  \}"
                             replace="  public ParseException(Message message) {${line.separator}
    super(message);${line.separator}                      
  }"
                             flags="gm"
                             byline="false"/>
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="^  public ParseException\(\).*$(\s\s[^}].*\n)*  \}"
                             replace="  public ParseException() {${line.separator}
    super(new MessageImpl(QueryParserMessages.INVALID_SYNTAX, "Error"));${line.separator}
  }"
                             flags="gm"
                             byline="false"/>
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="^  public String getMessage\(\).*$(\s\s\s\s[^}].*\n)*    \}"
                             replace="  private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) {${line.separator}
    String eol = System.getProperty("line.separator", "\n");"
                             flags="gm"
                             byline="false"/>
        <replaceregexp file="src/java/org/apache/lucene/queryParser/standard/parser/ParseException.java"
                             match="\s*protected String add_escapes.*"
                             replace="  static private String add_escapes(String str) {"
                             flags="g"
                             byline="true"/>
  </target>

  <target name="javacc-surround" depends="javacc-check" description="generate surround query parser from jj (requires javacc 4.1">
  	<invoke-javacc target="src/java/org/apache/lucene/queryParser/surround/parser/QueryParser.jj"
                   outputDir="src/java/org/apache/lucene/queryParser/surround/parser"
    />
  </target>
</project>

Other Lucene examples (source code examples)

Here is a short list of links related to this Lucene build.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.