text:
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.thesett</groupId>
    <artifactId>debuggerbuild</artifactId>
    <name>LoJix Debugger</name>
    <version>0.9.0-SNAPSHOT</version><!--debugger.version-->

    <packaging>pom</packaging>

    <description>Debugger for LoJiX.</description>
    <url>https://github.com/rupertlssmith/lojix</url>

    <prerequisites>
        <maven>2.0.8</maven>
    </prerequisites>

    <mailingLists>
    </mailingLists>

    <organization>
        <name>The Sett ltd.</name>
        <url>http://localhost/projects/</url>
    </organization>

    <developers>
        <developer>
            <name>Rupert Smith</name>
            <id>rupert</id>
            <email>rupertlssmith (contactable on g-m-a-i-l)</email>
            <organization />
        </developer>
    </developers>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/rupertlssmith/lojix.git</connection>
        <url>https://github.com/rupertlssmith/lojix.git</url>
    </scm>

    <properties>
        <projname>os_projects</projname>
        <topdir>${basedir}/.</topdir>

        <checkstyle.header.file>${topdir}/etc/license/license.txt</checkstyle.header.file>
        <checkstyle.config>${topdir}/etc/coding_standards.xml</checkstyle.config>
        <checkstyle.suppressions>${topdir}/etc/coding_standards_suppressions.xml</checkstyle.suppressions>

        <findbugs.exclude.file>${topdir}/etc/findbugs-exclude.xml</findbugs.exclude.file>

        <!-- Plugin versions. Attempting to standardize this for more repeatable builds. -->
        <maven.compiler.plugin.version>2.0.1</maven.compiler.plugin.version>
        <maven.dependency.plugin.version>2.0</maven.dependency.plugin.version>
        <maven.assembly.plugin.version>2.2-beta-1</maven.assembly.plugin.version>
        <maven.surefire.plugin.version>2.4.3</maven.surefire.plugin.version>
        <jalopy.maven.plugin.version>1.9.4-250</jalopy.maven.plugin.version>
        <maven.jaxb2.plugin.version>0.6.2</maven.jaxb2.plugin.version>
        <xdoclet.maven.plugin.version>1.0</xdoclet.maven.plugin.version>
        <maven.clover2.plugin.version>2.3.1</maven.clover2.plugin.version>
        <maven.run.plugin.version>0.9.0-SNAPSHOT</maven.run.plugin.version><!--base.version-->
        <maven.antrun.plugin.version>1.2-thesett</maven.antrun.plugin.version>
        <maven.idea.plugin.version>2.2</maven.idea.plugin.version>
        <maven.war.plugin.version>2.0</maven.war.plugin.version>
        <javacc.maven.plugin.version>2.1</javacc.maven.plugin.version>
        <maven.dashboard.plugin.version>0.9.0-SNAPSHOT</maven.dashboard.plugin.version><!--maven2_plugins.version-->
        <maven.pmd.plugin.version>2.4</maven.pmd.plugin.version>
        <maven.findbugs.plugin.version>2.5.3</maven.findbugs.plugin.version>
        <maven.javadoc.plugin.version>2.10.4</maven.javadoc.plugin.version>
        <maven.checkstyle.plugin.version>2.2</maven.checkstyle.plugin.version>
        <maven.jxr.plugin.version>2.1</maven.jxr.plugin.version>
        <taglist.maven.plugin.version>2.2</taglist.maven.plugin.version>
        <maven.surefire.report.plugin.version>2.4.3</maven.surefire.report.plugin.version>
        <javancss.maven.plugin.version>2.0-beta-2</javancss.maven.plugin.version>
        <maven.source.plugin.version>2.2.1</maven.source.plugin.version>
        <maven.build.helper.plugin.version>1.3</maven.build.helper.plugin.version>
        <jacoco.maven.plugin.version>0.7.4.201502262128</jacoco.maven.plugin.version>
        <jacoco.version>0.7.4.201502262128</jacoco.version>

        <jstl.jar.version>1.1.2</jstl.jar.version>

        <!--
           Clover does not set up ${project.build.finalName} with its 'clover' classifier. The 'final.classifier' property
           is empty by default, but should be included in the path of any custom modifications to final build artifacts,
           for example, in antrun scripts. This is used when specifying archives to run cactus on.
        -->
        <final.classifier></final.classifier>

        <pmd.ruleset.file>${topdir}/etc/pmd_rules.xml</pmd.ruleset.file>

        <!-- Default build platform, can be overriden to win32 on the command line: -Dplatform=win32 -->
        <platform>linux</platform>

        <log4j.configuration>file:${topdir}/etc/log4j.xml</log4j.configuration>
        <java.util.logging.config.file>${topdir}/etc/logging_to_log4j.properties</java.util.logging.config.file>
    </properties>

    <pluginRepositories>

        <!-- For the Xebia dashboard plugin. -->
        <!--
        <pluginRepository>
          <id>xebia-mojo-repo</id>
          <name>Xebia MOJO Repository</name>
          <url>http://mojo.os.xebia.com/repository/</url>
        </pluginRepository>
        -->

    </pluginRepositories>

    <!--
    <distributionManagement>
        <repository>
            <uniqueVersion>false</uniqueVersion>
            <id>release-repo</id>
            <name>The Sett Maven2 Repository</name>
            <url>file://${basedir}/../releases</url>
            <layout>default</layout>
        </repository>
        <snapshotRepository>
            <uniqueVersion>true</uniqueVersion>
            <id>snapshot-repo</id>
            <name>The Sett Maven2 Snapshot Repository</name>
            <url>file://${basedir}/../snapshots</url>
            <layout>default</layout>
        </snapshotRepository>
    </distributionManagement>
    -->

    <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Releases</name>
            <url>http://nexus.thesett.com/repository/maven-releases</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url>http://nexus.thesett.com/repository/maven-snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <modules>
        <module>enhanced_text_model</module>
        <module>swing_utils</module>
        <module>debug_ui_tools_api</module>
        <module>debug_ui_tools_swing</module>
        <module>wam_debugger</module>
        <module>wam_debugger_swing</module>
    </modules>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
            </dependency>

            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>[1.2.8,)</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <build>
        <sourceDirectory>src/main</sourceDirectory>
        <testSourceDirectory>src/unittests</testSourceDirectory>

        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <configuration>
                        <includes>
                            <include>com.thesett:*</include>
                        </includes>
                    </configuration>
                </plugin>

                <!-- Ensures the compiler plugin is set up for Java 1.5 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven.compiler.plugin.version}</version>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                        <fork>false</fork>
                    </configuration>
                </plugin>

                <!-- Ensure latest dependency plugin is used. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${maven.dependency.plugin.version}</version>
                </plugin>

                <!-- Fix the version of the assembly plugin. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${maven.assembly.plugin.version}</version>
                </plugin>

                <!-- Only run tests in files ending in Test.java, override the default set up. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <configuration>
                        <argLine>${surefireArgLine}</argLine>
                        <systemProperties>
                            <property>
                                <name>log4j.configuration</name>
                                <value>${log4j.configuration}</value>
                            </property>
                            <property>
                                <name>java.util.logging.config.file</name>
                                <value>${java.util.logging.config.file}</value>
                            </property>
                        </systemProperties>
                        <excludes>
                            <exclude>**/Test*.java</exclude>
                            <exclude>**/*TestCase.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>

                <!-- For source code beautification. -->
                <plugin>
                    <groupId>triemax</groupId>
                    <artifactId>jalopy-maven</artifactId>
                    <version>${jalopy.maven.plugin.version}</version>
                    <configuration>
                        <profile>open_source</profile>
                        <sources>
                            <source>${basedir}/src/main</source>
                            <source>${basedir}/src/unittests</source>
                        </sources>
                    </configuration>
                </plugin>

                <!-- Used to generate beans from XML schemas. -->
                <plugin>
                    <groupId>org.jvnet.jaxb2.maven2</groupId>
                    <artifactId>maven-jaxb2-plugin</artifactId>
                    <version>${maven.jaxb2.plugin.version}</version>
                    <configuration>
                        <schemaDirectory>${basedir}/src/resources</schemaDirectory>
                    </configuration>
                </plugin>

                <!-- Set up clover to aggregate results over the whole codebase for all modules. -->
                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>maven-clover2-plugin</artifactId>
                    <version>${maven.clover2.plugin.version}</version>
                    <configuration>
                        <licenseLocation>${clover.license.path}</licenseLocation>
                        <jdk>1.5</jdk>
                        <includesTestSourceRoots>false</includesTestSourceRoots>
                        <generateXml>true</generateXml>
                        <generateHtml>true</generateHtml>
                        <historyDir>${clover.history.path}</historyDir>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>pre-site</phase>
                            <goals>
                                <goal>instrument</goal>
                                <goal>aggregate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                   Set up the run plugin to generate run scripts or invoke main methods. This configuration will generate
                   a default run script called 'runj' in the target directory, that invoked java with the log4j.configuration
                   parameter passed to it, and the projects complete runtime classpath set up.
                -->
                <plugin>
                    <groupId>com.thesett</groupId>
                    <artifactId>run-maven-plugin</artifactId>
                    <version>${maven.run.plugin.version}</version>
                    <configuration>
                        <scriptOutDirectory>target</scriptOutDirectory>
                        <systemproperties>
                            <property>
                                <name>log4j.configuration</name>
                                <value>${log4j.configuration}</value>
                            </property>
                        </systemproperties>
                        <commands>
                            <runj/>
                        </commands>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>script</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                   Configure idea plugin to exclude a standard set of directories under target.
                   Prevents intellij scanning too much.
                  -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-idea-plugin</artifactId>
                    <version>${maven.idea.plugin.version}</version>
                    <configuration>
                        <jdkLevel>1.5</jdkLevel>
                        <downloadSources>true</downloadSources>
                        <downloadJavadocs>true</downloadJavadocs>
                        <!--<exclude>target/classes,target/site,target/clover,target/maven-archiver,target/surefire-reports,target/test-classes,aima,common,l0,l1,l2,prolog,vam,run-plugin</exclude>-->
                    </configuration>
                </plugin>

                <!-- Set up the war plugin version to use. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven.war.plugin.version}</version>
                </plugin>

                <!-- Set up the javacc plugin version to use. -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>javacc-maven-plugin</artifactId>
                    <version>${javacc.maven.plugin.version}</version>
                </plugin>

                <!-- Set up the build helper plugin version to use. -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${maven.build.helper.plugin.version}</version>
                </plugin>

            </plugins>
        </pluginManagement>

        <plugins>

            <!-- Set up the columns to display in the dashboard report. -->
            <plugin>
                <groupId>com.thesett</groupId>
                <artifactId>dashboard-maven-plugin</artifactId>
                <version>${maven.dashboard.plugin.version}</version>
                <configuration>
                    <destinationFile>${project.reporting.outputDirectory}/maven-dashboard-report.html</destinationFile>
                    <reports>
                        <report>maven-surefire-report-plugin</report>
                        <!--<report>maven-clover2-plugin</report>-->
                        <report>jacoco-maven-plugin</report>
                        <report>maven-checkstyle-plugin</report>
                        <report>maven-pmd-plugin</report>
                        <report>findbugs-maven-plugin</report>
                        <report>taglist-maven-plugin</report>
                        <report>javancss-maven-plugin</report>
                    </reports>
                    <columns>
                        <maven-surefire-report-plugin>tests,errors,failures,successrate</maven-surefire-report-plugin>
                        <maven-clover2-plugin>bar</maven-clover2-plugin>
                        <maven-checkstyle-plugin>errors,warnings</maven-checkstyle-plugin>
                        <maven-pmd-plugin>violations</maven-pmd-plugin>
                        <findbugs-maven-plugin>violations</findbugs-maven-plugin>
                        <javancss-maven-plugin>classes,ncss</javancss-maven-plugin>
                    </columns>
                </configuration>
            </plugin>

            <!-- Set the version of the findbugs plugin to use. Later versions get fussy with modules with no source. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>${maven.findbugs.plugin.version}</version>
            </plugin>

            <!-- Set up the source plugin to always generate sources. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven.source.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>site</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.3</version>
            </plugin>

        </plugins>

    </build>

    <reporting>
        <plugins>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>${maven.findbugs.plugin.version}</version>
                <configuration>
                    <xmlOutput>true</xmlOutput>
                    <threshold>Low</threshold>
                    <effort>Min</effort>
                    <visitors>FindDeadLocalStores,UnreadFields</visitors>
                    <excludeFilterFile>${findbugs.exclude.file}</excludeFilterFile>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>${maven.pmd.plugin.version}</version>
                <configuration>
                    <linkXref>true</linkXref>
                    <sourceEncoding>utf-8</sourceEncoding>
                    <minimumTokens>50</minimumTokens>
                    <targetJdk>1.5</targetJdk>
                    <rulesets>
                        <ruleset>${pmd.ruleset.file}</ruleset>
                    </rulesets>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>pmd</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven.javadoc.plugin.version}</version>
                <configuration>
                    <tags>
                        <tag>
                            <name>todo</name>
                            <placement>a</placement>
                            <head>To do:</head>
                        </tag>
                    </tags>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${maven.checkstyle.plugin.version}</version>
                <configuration>
                    <configLocation>${checkstyle.config}</configLocation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>${maven.jxr.plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>taglist-maven-plugin</artifactId>
                <version>${taglist.maven.plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>${maven.surefire.report.plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-clover2-plugin</artifactId>
                <version>${maven.clover2.plugin.version}</version>
                <configuration>
                    <licenseLocation>${clover.license.path}</licenseLocation>
                    <jdk>1.5</jdk>
                    <includesTestSourceRoots>false</includesTestSourceRoots>
                    <generateXml>true</generateXml>
                    <generateHtml>true</generateHtml>
                    <historyDir>${clover.history.path}</historyDir>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>javancss-maven-plugin</artifactId>
                <version>${javancss.maven.plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>com.thesett</groupId>
                <artifactId>dashboard-maven-plugin</artifactId>
                <version>${maven.dashboard.plugin.version}</version>
            </plugin>

        </plugins>
    </reporting>

    <profiles>
        <!-- Build profile to build quickly without running tests. -->
        <profile>
            <id>skip</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
        </profile>

        <!-- Build profile to ignore test failures. -->
        <profile>
            <id>ignore</id>
            <properties>
                <maven.test.failure.ignore>true</maven.test.failure.ignore>
                <maven.test.error.ignore>true</maven.test.error.ignore>
            </properties>
        </profile>

        <!--
           Build profile for running clover. Clover does not set up ${project.build.finalName} with its 'clover' classifier.
           When building with clover this profile must be active so that builds that need to refer to the clovered final build
           artifact can add in the needed classifier to refer to it. When this profile is not active the 'final.classifier'
           property is empty. This is used when specifying archives to run cactus on.
        -->
        <profile>
            <id>clover</id>
            <properties>
                <final.classifier>-clover</final.classifier>
            </properties>
        </profile>

        <!--
            Build profile to create the native libraries.
        -->
        <profile>
            <id>native</id>
            <modules>
                <module>aima-native</module>
            </modules>
        </profile>

        <!--
            Build profile to run the integration tests.
        -->
        <profile>
            <id>integration</id>
            <modules>
            </modules>
        </profile>

        <!--
            Build profile to create the application packages.
        -->
        <profile>
            <id>packages</id>
            <modules>
            </modules>
        </profile>

        <profile>
            <id>ossrh</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven.javadoc.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.5</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>sonar</id>
            <dependencies>
                <dependency>
                    <groupId>org.jacoco</groupId>
                    <artifactId>org.jacoco.agent</artifactId>
                    <classifier>runtime</classifier>
                    <version>${jacoco.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.jacoco</groupId>
                            <artifactId>jacoco-maven-plugin</artifactId>
                            <version>0.7.4.201502262128</version>
                        </plugin>
                    </plugins>
                </pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <configuration>
                            <destFile>${sonar.jacoco.reportPath}</destFile>
                            <append>true</append>
                        </configuration>
                        <executions>
                            <execution>
                                <id>agent-for-ut</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>agent-for-it</id>
                                <goals>
                                    <goal>prepare-agent-integration</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>jacoco-site</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.7.2</version>
                        <configuration>
                            <argLine>-javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath}</argLine>
                            <test>**/*Test.java</test>
                            <systemPropertyVariables>
                                <jacoco-agent.destfile>${basedir}/../code-coverage/jacoco.exec</jacoco-agent.destfile>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <sonar.jacoco.reportPath>${basedir}/../code-coverage/jacoco.exec</sonar.jacoco.reportPath>
                <sonar.jacoco.itReportPath>${basedir}/../code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
                <sonar.jacoco.jar>${topdir}/lib/jacocoagent.jar</sonar.jacoco.jar>
                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
                <failIfNoTests>false</failIfNoTests>
            </properties>
        </profile>

    </profiles>

</project>


text:
/**
 *
 */
package edu.berkeley.nlp.PCFGLA.smoothing;

import java.io.Serializable;
import java.util.List;

import edu.berkeley.nlp.PCFGLA.BinaryCounterTable;
import edu.berkeley.nlp.PCFGLA.BinaryRule;
import edu.berkeley.nlp.PCFGLA.UnaryCounterTable;
import edu.berkeley.nlp.PCFGLA.UnaryRule;

import edu.berkeley.nlp.syntax.Tree;
import edu.berkeley.nlp.util.ArrayUtil;

/**
 * @author leon
 *
 */
public class SmoothAcrossParentBits implements Smoother, Serializable  {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	double same;
	double[][][] diffWeights;
	double weightBasis = 0.5;
	double totalWeight;

	public SmoothAcrossParentBits copy(){
		return new SmoothAcrossParentBits(same,diffWeights,weightBasis,totalWeight);
	}

	public SmoothAcrossParentBits(double smooth, Tree<Short>[] splitTrees) {
		// does not smooth across top-level split, otherwise smooths uniformly

		same = 1-smooth;
		//int maxNBits = (int)Math.round(Math.log(maxSubstates)/Math.log(2));

		int nStates = splitTrees.length;
		diffWeights = new double [nStates][][];
		for (short state=0; state<nStates; state++){
			Tree<Short> splitTree = splitTrees[state];
			List<Short> allSubstates = splitTree.getYield();
			int nSubstates = 1;
			for (int i=0; i<allSubstates.size(); i++){
				if (allSubstates.get(i)>=nSubstates)
					nSubstates = allSubstates.get(i)+1;
			}
			diffWeights[state] = new double[nSubstates][nSubstates];
			if (nSubstates==1){
				// state has only one substate -> no smoothing
				diffWeights[state][0][0] = 1.0;
			}
			else {
				// smooth only with ones in the same top-level branch
				// TODO: weighted smoothing

				// descend down to first split first
				while (splitTree.getChildren().size()==1) { splitTree = splitTree.getChildren().get(0); }
//				for (short substate=0; substate<nSubstates; substate++){
//					for (int branch=0; branch<2; branch++){
//						List<Short> substatesInBranch = splitTree.getChildren().get(branch).getYield();
//						if (substatesInBranch.contains(substate)){
//							totalWeight = 0;
//							fillWeightsArray(state,substate,1.0,splitTree.getChildren().get(branch));
//							// normalize the weights
//							if (totalWeight==0) continue;
//							for (short substate2 = 0; substate2<nSubstates; substate2++){
//								if (substate==substate2) continue;
//								diffWeights[state][substate][substate2] /= totalWeight;
//								diffWeights[state][substate][substate2] *= smooth;
//							}
//						}
//					//else - dont smooth across top-level branch
//					}
//				}

				for (int branch=0; branch<2; branch++){
					// compute weights for substates in top-level branch
					List<Short> substatesInBranch = splitTree.getChildren().get(branch).getYield();
					int total = substatesInBranch.size();
					double normalizedSmooth = smooth/(total-1);

					for (short i : substatesInBranch) {
						for (short j : substatesInBranch) {
							if (i==j) { diffWeights[state][i][j] = same; }
							else { diffWeights[state][i][j] = normalizedSmooth; }
						}
					}
				}

			}
		}
/*		diffWeights = new double[maxNBits+1];
		for (int i=0; i<=maxNBits; i++) {
			diffWeights[i] = Math.pow(2,-i+1)*smooth/maxNBits;
		}*/
	}

	/**
	 * @param same2
	 * @param diffWeights2
	 * @param weightBasis2
	 * @param totalWeight2
	 */
	public SmoothAcrossParentBits(double same2, double[][][] diffWeights2, double weightBasis2, double totalWeight2) {
		this.same = same2;
		this.diffWeights = diffWeights2;
		this.weightBasis = weightBasis2;
		this.totalWeight = totalWeight2;
	}

	/* (non-Javadoc)
	 * @see edu.berkeley.nlp.PCFGLA.smoothing.Smoother#smooth(edu.berkeley.nlp.util.UnaryCounterTable, edu.berkeley.nlp.util.BinaryCounterTable)
	 */
	public void smooth(UnaryCounterTable unaryCounter, BinaryCounterTable binaryCounter) {
		for (UnaryRule r : unaryCounter.keySet()) {
			double[][] scores = unaryCounter.getCount(r);
			double[][] scopy = new double[scores.length][];
			short pState = r.parentState;
			for (int j=0; j<scores.length; j++) {
				if( scores[j]==null ) continue; // nothing to smooth

				scopy[j] = new double[scores[j].length];
				for (int i=0; i<scores[j].length; i++) {
					for (int k=0; k<scores[j].length; k++) {
						scopy[j][i] += diffWeights[pState][i][k] * scores[j][k];
					}
				}
			}
			unaryCounter.setCount(r,scopy);
		}
		for (BinaryRule r : binaryCounter.keySet()) {
			double[][][] scores = binaryCounter.getCount(r);
			double[][][] scopy = new double[scores.length][scores[0].length][];
			short pState = r.parentState;
			for (int j=0; j<scores.length; j++) {
				for (int l=0; l<scores[j].length; l++) {
					if (scores[j][l]==null)	continue; //nothing to smooth

					scopy[j][l] = new double[scores[j][l].length];
					for (int i=0; i<scores[j][l].length; i++) {
						for (int k=0; k<scores[j][l].length; k++) {
							scopy[j][l][i] += diffWeights[pState][i][k] * scores[j][l][k];
						}
					}
				}
			}
			binaryCounter.setCount(r,scopy);
		}
	}

	private void fillWeightsArray(short state, short substate, double weight, Tree<Short> subTree){
		if (subTree.isLeaf()){
			if (subTree.getLabel()==substate) diffWeights[state][substate][substate] = same;
			else { diffWeights[state][substate][subTree.getLabel()] = weight; totalWeight+=weight;}
			return;
		}
		if (subTree.getChildren().size()==1) {
			fillWeightsArray(state,substate,weight,subTree.getChildren().get(0));
			return;
		}
		for (int branch=0; branch<2; branch++) {
			Tree<Short> branchTree = subTree.getChildren().get(branch);
			List<Short> substatesInBranch = branchTree.getYield();
			//int nSubstatesInBranch = substatesInBranch.size();
			if (substatesInBranch.contains(substate)) fillWeightsArray(state,substate,weight,branchTree);
			else fillWeightsArray(state,substate,weight*weightBasis/2.0,branchTree);
		}
	}

	/* (non-Javadoc)
	 * @see edu.berkeley.nlp.PCFGLA.smoothing.Smoother#smooth(short, float[])
	 */
	public void smooth(short tag, double[] scores) {
		double[] scopy = new double[scores.length];
		for (int i=0; i<scores.length; i++) {
			for (int k=0; k<scores.length; k++) {
				scopy[i] += diffWeights[tag][i][k] * scores[k];
			}
		}
		for (int i=0; i<scores.length; i++) {
//			if (scores[i]==0) continue;
			scores[i] = scopy[i];
		}
	}

	/* (non-Javadoc)
	 * @see edu.berkeley.nlp.PCFGLA.smoothing.Smoother#updateWeights(int[][])
	 */
	public void updateWeights(int[][] toSubstateMapping) {
		double[][][] newWeights = new double[toSubstateMapping.length][][];
		for (int state=0; state<toSubstateMapping.length; state++){
			int nSub = toSubstateMapping[state][0];
			newWeights[state] = new double[nSub][nSub];
			if (nSub==1) {
				newWeights[state][0][0] = 1.0;
				continue;
			}
			double[] total = new double[nSub];
			for (int substate1=0; substate1<diffWeights[state].length; substate1++){
				for (int substate2=0; substate2<diffWeights[state].length; substate2++){
					newWeights[state][toSubstateMapping[state][substate1+1]][toSubstateMapping[state][substate2+1]] += diffWeights[state][substate1][substate2];
					total[toSubstateMapping[state][substate1+1]] += diffWeights[state][substate1][substate2];
				}
			}
			for (int substate1=0; substate1<nSub; substate1++){
				for (int substate2=0; substate2<nSub; substate2++){
					newWeights[state][substate1][substate2] /= total[substate1];
				}
			}
		}
		diffWeights = newWeights;
	}
}

redpajama_set_name: RedPajamaGithub


text:
var mongoose = require('../utils/mongoose');

var schema = new mongoose.Schema({
	email: String,
	provider: String,
	salt: String,
	hashPassword: String,
	created: Date,
	updated: Date,
	lastLoggedIn: Date
});

module.exports = mongoose.model('User', schema);


text:
#ifndef __EMITTER_GEOM_H__
#define __EMITTER_GEOM_H__

#include "NxApex.h"
#include "NxEmitterGeoms.h"
#include "PsArray.h"
#include "PsUserAllocated.h"
#include <PsShare.h>
#include "PxMat34Legacy.h"
#include "ApexRand.h"

namespace physx
{
namespace apex
{

class NxApexRenderDebug;
class NiApexRenderDebug;

namespace emitter
{

/* Implementation base class for all NxEmitterGeom derivations */

class EmitterGeom : public physx::UserAllocated
{
public:
	/* Asset callable functions */
	virtual NxEmitterGeom*				getNxEmitterGeom() = 0;
	virtual void						destroy() = 0;

	/* ApexEmitterActor runtime access methods */
	virtual physx::PxF32				computeEmitterVolume() const = 0;
	virtual void						computeFillPositions(physx::Array<physx::PxVec3>& positions,
	        physx::Array<physx::PxVec3>& velocities,
	        const physx::PxMat34Legacy&,
	        physx::PxF32,
	        physx::PxBounds3& outBounds,
	        QDSRand& rand) const = 0;

	virtual physx::PxVec3				randomPosInFullVolume(const physx::PxMat34Legacy&, QDSRand&) const = 0;

	/* AssetPreview methods */
	virtual void                        drawPreview(physx::PxF32 scale, NxApexRenderDebug* renderDebug) const = 0;

	/* Optional override functions */
	virtual void						visualize(const physx::PxMat34Legacy&, NiApexRenderDebug&) { }

	virtual physx::PxF32				computeNewlyCoveredVolume(const physx::PxMat34Legacy&, const physx::PxMat34Legacy&, QDSRand&) const;
	virtual physx::PxVec3				randomPosInNewlyCoveredVolume(const physx::PxMat34Legacy&, const physx::PxMat34Legacy&, QDSRand&) const;

protected:
	virtual bool						isInEmitter(const physx::PxVec3& pos, const physx::PxMat34Legacy& pose) const = 0;
};

}
}
} // end namespace physx::apex

#endif


text:
  Sermesse est
       un village
       géographiquement positionné dans le département de Saône-et-Loire en Bourgogne. Elle comptait 202 habitants en 2008.

À coté de Sermesse sont situées les villes de
Ciel à 3 km, 662 habitants,
Écuelles à 5 km, 209 habitants,
Bragny-sur-Saône localisée à 4 km, 560 habitants,
Saunières située à 0 km, 76 habitants,
Frontenard à 5 km, 227 habitants,
Toutenant à 3 km, 177 habitants,
 entre autres. De plus, Sermesse est située à seulement 21 km de Chalon-sur-Saône.

Si vous pensez demenager à Sermesse, vous pourrez aisément trouver une maison à acheter.

Le parc d'habitations, à Sermesse, était réparti en 2011 en zero appartements et 123 maisons soit
 un marché plutôt équilibré.


text:
/******************************************************************************

  USB POS Printer Definition File - Bixolon SRP-270

  Summary:
    This is a definition file for the Bixolon SRP-270 Point-of-sale USB
    Printer.

  Description:
    This is a definition file for the Bixolon SRP-270 Point-of-sale USB
    Printer.  This definition file may be used for other compatible printers,
    including the following printers.

    Manufacturer    Model       Tested
    ------------    -----       ------
    Bixolon         SRP-270       Yes
    Epson           TM-U220       No (based on spec review only)
    Epson           TM-U230       No (based on spec review only)

    Various POS printers that support the ESC/POS printer language have
    deviations or limitations from the language specification.  This file
    allows the ESC/POS printer language file to configure itself
    properly for the requirements and/or limitations of the particular printer.
    It will also allow the printer language support file to return an error
    (USB_PRINTER_UNKNOWN_COMMAND) if an unsupported command is issued.

    Some deviations are minor, and may have no effect on the printed output.
    Others, however, can result in printing failures if the configuration is
    incorrect.  For best results:
        * Determine either a single target printer or a set of compatible
            target printers when designing the application.
        * Specify those printers explicitly in the TPL.
        * Specify explicit printer language support for those printers.
        * Test the application on each specified printer.

  Remarks:
    This file should be specified as the "POS Printer Header File" on the
    "Printer" tab of the USB Configuration Tool (USBConfig.exe or MPLAB VDI)
    when ESC/POS support is enabled.

*******************************************************************************/
//DOM-IGNORE-BEGIN
/******************************************************************************

* FileName:        usb_printer_pos_bixolon_srp_270.h
* Dependencies:    None
* Processor:       PIC24/dsPIC30/dsPIC33/PIC32MX
* Compiler:        C30 v3.10b/C32 v0.00.18
* Company:         Microchip Technology, Inc.

Software License Agreement

The software supplied herewith by Microchip Technology Incorporated
(the "Company") for its PICmicro® Microcontroller is intended and
supplied to you, the Company's customer, for use solely and
exclusively on Microchip PICmicro Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.

THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Author          Date    Comments
--------------------------------------------------------------------------------
KO         ??-???-2008 First release

*******************************************************************************/
//DOM-IGNORE-END

#ifndef USB_PRINTER_POS_BIXOLON_SRP_270
#define USB_PRINTER_POS_BIXOLON_SRP_270

//------------------------------------------------------------------------------
// Bar Code Support Configuration

// If the printer supports bar code printing, uncomment the following
// definition.  This will provide support for UPC-A, UPC-E, JAN/EAN13, JAN/EAN8,
// CODE39, ITF, and CODABAR bar codes using Format A of the "Print Bar Code"
// command.  If only only bar code format is specified, it is Format A.
//#define USB_PRINTER_POS_BARCODE_SUPPORT

// If the printer supports both Format A and Format B of the "Print Bar Code"
// command, also uncomment this definition.  In addition to the bar codes listed
// above, CODE93 and CODE128 bar codes will be supported.
//#define USE_PRINTER_POS_EXTENDED_BARCODE_FORMAT

//------------------------------------------------------------------------------
// Bitmap Image Support Configuration

// If the printer supports 24-dot vertical density image printing, uncomment the
// following definition.
//#define USB_PRINTER_POS_24_DOT_IMAGE_SUPPORT

// If the printer supports 36-dot vertical density image printing, uncomment the
// following definition.  This support is not common.  Note that 36-dot vertical
// density image printing itself is not supported.  However, printers with this
// capability use different parameter values for other image printing, and must
// be configured appropriately.  If this is not configured correctly, 24-bit
// vertical density images will not print correctly.
//#define USB_PRINTER_POS_36_DOT_IMAGE_SUPPORT

// Set this label to the line spacing required between bit image lines.  Often,
// the value 0 (zero) can be used.  If the printer prints all image lines on
// top of each other, set this value to the height of the printed image line.
#define USB_PRINTER_POS_IMAGE_LINE_SPACING              16

//------------------------------------------------------------------------------
// Text Printing Support Configuration

// If the printer supports reverse text (white letters on a black background)
// printing, uncomment the following definition.
//#define USB_PRINTER_POS_REVERSE_TEXT_SUPPORT

//------------------------------------------------------------------------------
// Color Support Configuration

// If the printer supports two color printing, uncomment the following line.
// This is not common.
#define USB_PRINTER_POS_TWO_COLOR_SUPPORT

//------------------------------------------------------------------------------
// Mechanism Support Configuration

// If the printer has an automatic cutter, uncomment the following line.
#define USB_PRINTER_POS_CUTTER_SUPPORT

#endif


text:
<?php
	require_once __DIR__.'/../../vendor/autoload.php';
	$app = require __DIR__.'/../app.php';
	require_once( __DIR__."'/../Model/room.php");
	$usuario = $app['db'];
	//$conn2 = Doctrine_Manager::connection();

	//Decodificamos los datos pasados
	$input = file_get_contents("php://input");
	$input = base64_decode($input);
	$input = json_decode($input, true);

	print(1);

?>


text:
namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
namespace HttpConnectionManager {
namespace {

using envoy::extensions::filters::common::dependency::v3::Dependency;
using envoy::extensions::filters::common::dependency::v3::FilterDependencies;
using testing::HasSubstr;

TEST(DependencyManagerTest, RegisterFilter) {
  DependencyManager manager;

  FilterDependencies dependencies;
  manager.registerFilter("foobar", dependencies);
}

TEST(DependencyManagerTest, RegisterFilterWithDependency) {
  DependencyManager manager;

  FilterDependencies dependencies;
  auto provided = dependencies.add_decode_provided();
  provided->set_type(Dependency::FILTER_STATE_KEY);
  provided->set_name("potato");
  manager.registerFilter("ingredient", dependencies);
  auto result = manager.validDecodeDependencies();
  EXPECT_TRUE(result.ok());
}

TEST(DependencyManagerTest, Valid) {
  DependencyManager manager;

  FilterDependencies d1;
  auto provided = d1.add_decode_provided();
  provided->set_type(Dependency::FILTER_STATE_KEY);
  provided->set_name("potato");

  FilterDependencies d2;
  auto required = d2.add_decode_required();
  required->set_type(Dependency::FILTER_STATE_KEY);
  required->set_name("potato");

  manager.registerFilter("ingredient", d1);
  manager.registerFilter("chef", d2);

  auto result = manager.validDecodeDependencies();
  EXPECT_TRUE(result.ok());
}

TEST(DependencyManagerTest, MissingProvidencyInvalid) {
  DependencyManager manager;

  FilterDependencies dependencies;
  auto required = dependencies.add_decode_required();
  required->set_type(Dependency::FILTER_STATE_KEY);
  required->set_name("potato");
  manager.registerFilter("chef", dependencies);

  auto result = manager.validDecodeDependencies();
  EXPECT_FALSE(result.ok());
  EXPECT_THAT(result.message(),
              HasSubstr("filter 'chef' requires a FILTER_STATE_KEY named 'potato'"));
}

TEST(DependencyManagerTest, WrongProvidencyTypeInvalid) {
  DependencyManager manager;

  FilterDependencies d1;
  auto provided = d1.add_decode_provided();
  provided->set_type(Dependency::HEADER);
  provided->set_name("potato");

  FilterDependencies d2;
  auto required = d2.add_decode_required();
  required->set_type(Dependency::FILTER_STATE_KEY);
  required->set_name("potato");

  manager.registerFilter("ingredient", d1);
  manager.registerFilter("chef", d2);

  auto result = manager.validDecodeDependencies();
  EXPECT_FALSE(result.ok());
  EXPECT_THAT(result.message(),
              HasSubstr("filter 'chef' requires a FILTER_STATE_KEY named 'potato'"));
}

TEST(DependencyManagerTest, WrongProvidencyNameInvalid) {
  DependencyManager manager;

  FilterDependencies d1;
  auto provided = d1.add_decode_provided();
  provided->set_type(Dependency::FILTER_STATE_KEY);
  provided->set_name("tomato");

  FilterDependencies d2;
  auto required = d2.add_decode_required();
  required->set_type(Dependency::FILTER_STATE_KEY);
  required->set_name("potato");

  manager.registerFilter("ingredient", d1);
  manager.registerFilter("chef", d2);

  auto result = manager.validDecodeDependencies();
  EXPECT_FALSE(result.ok());
  EXPECT_THAT(result.message(),
              HasSubstr("filter 'chef' requires a FILTER_STATE_KEY named 'potato'"));
}

TEST(DependencyManagerTest, MisorderedFiltersInvalid) {
  DependencyManager manager;

  FilterDependencies d1;
  auto provided = d1.add_decode_provided();
  provided->set_type(Dependency::FILTER_STATE_KEY);
  provided->set_name("potato");

  FilterDependencies d2;
  auto required = d2.add_decode_required();
  required->set_type(Dependency::FILTER_STATE_KEY);
  required->set_name("potato");

  manager.registerFilter("chef", d2);
  manager.registerFilter("ingredient", d1);

  auto result = manager.validDecodeDependencies();
  EXPECT_FALSE(result.ok());
  EXPECT_THAT(result.message(),
              HasSubstr("filter 'chef' requires a FILTER_STATE_KEY named 'potato'"));
}

} // namespace
} // namespace HttpConnectionManager
} // namespace NetworkFilters
} // namespace Extensions
} // namespace Envoy


text:
package org.jaxen;

import java.io.Serializable;
import java.util.List;

import org.jaxen.expr.Expr;
import org.jaxen.expr.XPathExpr;
import org.jaxen.function.BooleanFunction;
import org.jaxen.function.NumberFunction;
import org.jaxen.function.StringFunction;
import org.jaxen.saxpath.SAXPathException;
import org.jaxen.saxpath.XPathReader;
import org.jaxen.saxpath.helpers.XPathReaderFactory;
import org.jaxen.util.SingletonList;

/** Base functionality for all concrete, implementation-specific XPaths.
 *
 *

 *  This class provides generic functionality for further-defined
 *  implementation-specific XPaths.
 *

 *
 *

 *  If you want to adapt the Jaxen engine so that it can traverse your own
 *  object model, then this is a good base class to derive from.
 *  Typically you only really need to provide your own
 *  {@link org.jaxen.Navigator} implementation.
 *

 *
 *  @see org.jaxen.dom4j.Dom4jXPath XPath for dom4j
 *  @see org.jaxen.jdom.JDOMXPath   XPath for JDOM
 *  @see org.jaxen.dom.DOMXPath     XPath for W3C DOM
 *
 *  @author bob mcwhirter
 *  @author James Strachan
 */
public class BaseXPath implements XPath, Serializable
{

    private static final long serialVersionUID = -1993731281300293168L;

    /** Original expression text. */
    private final String exprText;

    /** the parsed form of the XPath expression */
    private final XPathExpr xpath;

    /** the support information and function, namespace and variable contexts */
    private ContextSupport support;

    /** the implementation-specific Navigator for retrieving XML nodes **/
    private Navigator navigator;

    /** Construct given an XPath expression string.
     *
     *  @param xpathExpr the XPath expression
     *
     *  @throws JaxenException if there is a syntax error while
     *          parsing the expression
     */
    protected BaseXPath(String xpathExpr) throws JaxenException
    {
        try
        {
            XPathReader reader = XPathReaderFactory.createReader();
            JaxenHandler handler = new JaxenHandler();
            reader.setXPathHandler( handler );
            reader.parse( xpathExpr );
            this.xpath = handler.getXPathExpr();
        }
        catch (org.jaxen.saxpath.XPathSyntaxException e)
        {
            throw new org.jaxen.XPathSyntaxException( e );
        }
        catch (SAXPathException e)
        {
            throw new JaxenException( e );
        }

        this.exprText = xpathExpr;
    }

    /** Construct given an XPath expression string.
     *
     *  @param xpathExpr the XPath expression
     *
     *  @param navigator the XML navigator to use
     *
     *  @throws JaxenException if there is a syntax error while
     *          parsing the expression
     */
    public BaseXPath(String xpathExpr, Navigator navigator) throws JaxenException
    {
        this( xpathExpr );
        this.navigator = navigator;
    }

    /** Evaluate this XPath against a given context.
     *  The context of evaluation may be any object type
     *  the navigator recognizes as a node.
     *  The return value is either a String,
     *  Double, Boolean, or List
     *  of nodes.
     *
     *

     *  When using this method, one must be careful to
     *  test the class of the returned object.  If the returned
     *  object is a list, then the items in this
     *  list will be the actual Document,
     *  Element, Attribute, etc. objects
     *  as defined by the concrete XML object-model implementation,
     *  directly from the context document.  This method does
     *  not return copies of anything, but merely
     *  returns references to objects within the source document.
     *

     *
     * @param context the node, node-set or Context object for evaluation.
     *      This value can be null.
     *
     * @return the result of evaluating the XPath expression
     *          against the supplied context
     * @throws JaxenException if an XPath error occurs during expression evaluation
     * @throws ClassCastException if the context is not a node
     */
    public Object evaluate(Object context) throws JaxenException
    {
        List answer = selectNodes(context);

        if ( answer != null
             &&
             answer.size() == 1 )
        {
            Object first = answer.get(0);

            if ( first instanceof String
                 ||
                 first instanceof Number
                 ||
                 first instanceof Boolean )
            {
                return first;
            }
        }
        return answer;
    }

    /** Select all nodes that are selected by this XPath
     *  expression. If multiple nodes match, multiple nodes
     *  will be returned. Nodes will be returned
     *  in document-order, as defined by the XPath
     *  specification. If the expression selects a non-node-set
     *  (i.e. a number, boolean, or string) then a List
     *  containing just that one object is returned.
     *

     *
     * @param node the node, node-set or Context object for evaluation.
     *     This value can be null.
     *
     * @return the node-set of all items selected
     *          by this XPath expression
     * @throws JaxenException if an XPath error occurs during expression evaluation
     *
     * @see #selectNodesForContext
     */
    public List selectNodes(Object node) throws JaxenException
    {
        Context context = getContext( node );
        return selectNodesForContext( context );
    }

    /** Select only the first node selected by this XPath
     *  expression.  If multiple nodes match, only one node will be
     *  returned. The selected node will be the first
     *  selected node in document-order, as defined by the XPath
     *  specification.
     *

     *
     * @param node the node, node-set or Context object for evaluation.
     *     This value can be null.
     *
     * @return the node-set of all items selected
     *          by this XPath expression
     * @throws JaxenException if an XPath error occurs during expression evaluation
     *
     * @see #selectNodes
     */
    public Object selectSingleNode(Object node) throws JaxenException
    {
        List results = selectNodes( node );

        if ( results.isEmpty() )
        {
            return null;
        }

        return results.get( 0 );
    }

    /**
     * Returns the XPath string-value of the argument node.
     *
     * @param node the node whose value to take
     * @return the XPath string value of this node
     * @throws JaxenException if an XPath error occurs during expression evaluation
     * @deprecated replaced by {@link #stringValueOf}
     */
    public String valueOf(Object node) throws JaxenException
    {
        return stringValueOf( node );
    }

    /** Retrieves the string-value of the result of
     *  evaluating this XPath expression when evaluated
     *  against the specified context.
     *
     *

     *  The string-value of the expression is determined per
     *  the string(..) core function defined
     *  in the XPath specification.  This means that an expression
     *  that selects zero nodes will return the empty string,
     *  while an expression that selects one-or-more nodes will
     *  return the string-value of the first node.
     *

     *
     * @param node the node, node-set or Context object for evaluation. This value can be null.
     *
     * @return the string-value of the result of evaluating this expression with the specified context node
     * @throws JaxenException if an XPath error occurs during expression evaluation
     */
    public String stringValueOf(Object node) throws JaxenException
    {
        Context context = getContext( node );

        Object result = selectSingleNodeForContext( context );

        if ( result == null )
        {
            return "";
        }

        return StringFunction.evaluate( result,
                                        context.getNavigator() );
    }

    /** Retrieve a boolean-value interpretation of this XPath
     *  expression when evaluated against a given context.
     *
     *

     *  The boolean-value of the expression is determined per
     *  the boolean(..) function defined
     *  in the XPath specification.  This means that an expression
     *  that selects zero nodes will return false,
     *  while an expression that selects one or more nodes will
     *  return true.
     *

     *
     * @param node the node, node-set or Context object for evaluation. This value can be null.
     *
     * @return the boolean-value of the result of evaluating this expression with the specified context node
     * @throws JaxenException if an XPath error occurs during expression evaluation
     */
    public boolean booleanValueOf(Object node) throws JaxenException
    {
        Context context = getContext( node );
        List result = selectNodesForContext( context );
        if ( result == null ) return false;
        return BooleanFunction.evaluate( result, context.getNavigator() ).booleanValue();
    }

    /** Retrieve a number-value interpretation of this XPath
     *  expression when evaluated against a given context.
     *
     *

     *  The number-value of the expression is determined per
     *  the number(..) core function as defined
     *  in the XPath specification. This means that if this
     *  expression selects multiple nodes, the number-value
     *  of the first node is returned.
     *

     *
     * @param node the node, node-set or Context object for evaluation. This value can be null.
     *
     * @return a Double indicating the numeric value of
     *      evaluating this expression against the specified context
     * @throws JaxenException if an XPath error occurs during expression evaluation
     */
    public Number numberValueOf(Object node) throws JaxenException
    {
        Context context = getContext( node );
        Object result = selectSingleNodeForContext( context );
        return NumberFunction.evaluate( result,
                                        context.getNavigator() );
    }

    // Helpers

    /** Add a namespace prefix-to-URI mapping for this XPath
     *  expression.
     *
     *

     *  Namespace prefix-to-URI mappings in an XPath are independent
     *  of those used within any document.  Only the mapping explicitly
     *  added to this XPath will be available for resolving the
     *  XPath expression.
     *

     *
     *

     *  This is a convenience method for adding mappings to the
     *  default {@link NamespaceContext} in place for this XPath.
     *  If you have installed a custom NamespaceContext
     *  that is not a SimpleNamespaceContext,
     *  then this method will throw a JaxenException.
     *

     *
     *  @param prefix the namespace prefix
     *  @param uri the namespace URI
     *
     *  @throws JaxenException if the NamespaceContext
     *          used by this XPath is not a SimpleNamespaceContext
     */
    public void addNamespace(String prefix,
                             String uri) throws JaxenException
    {
        NamespaceContext nsContext = getNamespaceContext();
        if ( nsContext instanceof SimpleNamespaceContext )
        {
            ((SimpleNamespaceContext)nsContext).addNamespace( prefix,
                                                              uri );
            return;
        }

        throw new JaxenException("Operation not permitted while using a non-simple namespace context.");
    }

    // ------------------------------------------------------------
    // ------------------------------------------------------------
    //     Properties
    // ------------------------------------------------------------
    // ------------------------------------------------------------

    /** Set a NamespaceContext for use with this
     *  XPath expression.
     *
     *

     *  A NamespaceContext is responsible for translating
     *  namespace prefixes within the expression into namespace URIs.
     *

     *
     *  @param namespaceContext the NamespaceContext to
     *         install for this expression
     *
     *  @see NamespaceContext
     *  @see NamespaceContext#translateNamespacePrefixToUri
     */
    public void setNamespaceContext(NamespaceContext namespaceContext)
    {
        getContextSupport().setNamespaceContext(namespaceContext);
    }

    /** Set a FunctionContext for use with this XPath
     *  expression.
     *
     *

     *  A FunctionContext is responsible for resolving
     *  all function calls used within the expression.
     *

     *
     *  @param functionContext the FunctionContext to
     *         install for this expression
     *
     *  @see FunctionContext
     *  @see FunctionContext#getFunction
     */
    public void setFunctionContext(FunctionContext functionContext)
    {
        getContextSupport().setFunctionContext(functionContext);
    }

    /** Set a VariableContext for use with this XPath
     *  expression.
     *
     *

     *  A VariableContext is responsible for resolving
     *  all variables referenced within the expression.
     *

     *
     *  @param variableContext The VariableContext to
     *         install for this expression
     *
     *  @see VariableContext
     *  @see VariableContext#getVariableValue
     */
    public void setVariableContext(VariableContext variableContext)
    {
        getContextSupport().setVariableContext(variableContext);
    }

    /** Retrieve the NamespaceContext used by this XPath
     *  expression.
     *
     *

     *  A NamespaceContext is responsible for mapping
     *  prefixes used within the expression to namespace URIs.
     *

     *
     *

     *  If this XPath expression has not previously had a NamespaceContext
     *  installed, a new default NamespaceContext will be created,
     *  installed and returned.
     *

     *
     *  @return the NamespaceContext used by this expression
     *
     *  @see NamespaceContext
     */
    public NamespaceContext getNamespaceContext()
    {
        return getContextSupport().getNamespaceContext();
    }

    /** Retrieve the FunctionContext used by this XPath
     *  expression.
     *
     *

     *  A FunctionContext is responsible for resolving
     *  all function calls used within the expression.
     *

     *
     *

     *  If this XPath expression has not previously had a FunctionContext
     *  installed, a new default FunctionContext will be created,
     *  installed and returned.
     *

     *
     *  @return the FunctionContext used by this expression
     *
     *  @see FunctionContext
     */
    public FunctionContext getFunctionContext()
    {
        return getContextSupport().getFunctionContext();
    }

    /** Retrieve the VariableContext used by this XPath
     *  expression.
     *
     *

     *  A VariableContext is responsible for resolving
     *  all variables referenced within the expression.
     *

     *
     *

     *  If this XPath expression has not previously had a VariableContext
     *  installed, a new default VariableContext will be created,
     *  installed and returned.
     *

     *
     *  @return the VariableContext used by this expression
     *
     *  @see VariableContext
     */
    public VariableContext getVariableContext()
    {
        return getContextSupport().getVariableContext();
    }

    /** Retrieve the root expression of the internal
     *  compiled form of this XPath expression.
     *
     *

     *  Internally, Jaxen maintains a form of Abstract Syntax
     *  Tree (AST) to represent the structure of the XPath expression.
     *  This is normally not required during normal consumer-grade
     *  usage of Jaxen.  This method is provided for hard-core users
     *  who wish to manipulate or inspect a tree-based version of
     *  the expression.
     *

     *
     *  @return the root of the AST of this expression
     */
    public Expr getRootExpr()
    {
        return xpath.getRootExpr();
    }

    /** Return the original expression text.
     *
     *  @return the normalized XPath expression string
     */
    public String toString()
    {
        return this.exprText;
    }

    /** Returns a string representation of the parse tree.
     *
     *  @return a string representation of the parse tree.
     */
    public String debug()
    {
        return this.xpath.toString();
    }

    // ------------------------------------------------------------
    // ------------------------------------------------------------
    //     Implementation methods
    // ------------------------------------------------------------
    // ------------------------------------------------------------

    /** Create a {@link Context} wrapper for the provided
     *  implementation-specific object.
     *
     *  @param node the implementation-specific object
     *         to be used as the context
     *
     *  @return a Context wrapper around the object
     */
    protected Context getContext(Object node)
    {
        if ( node instanceof Context )
        {
            return (Context) node;
        }

        Context fullContext = new Context( getContextSupport() );

        if ( node instanceof List )
        {
            fullContext.setNodeSet( (List) node );
        }
        else
        {
            List list = new SingletonList(node);
            fullContext.setNodeSet( list );
        }

        return fullContext;
    }

    /** Retrieve the {@link ContextSupport} aggregation of
     *  NamespaceContext, FunctionContext,
     *  VariableContext, and {@link Navigator}.
     *
     *  @return aggregate ContextSupport for this
     *          XPath expression
     */
    protected ContextSupport getContextSupport()
    {
        if ( support == null )
        {
            support = new ContextSupport(
                createNamespaceContext(),
                createFunctionContext(),
                createVariableContext(),
                getNavigator()
            );
        }

        return support;
    }

    /** Retrieve the XML object-model-specific {@link Navigator}
     *  for us in evaluating this XPath expression.
     *
     *  @return the implementation-specific Navigator
     */
    public Navigator getNavigator()
    {
        return navigator;
    }

    // ------------------------------------------------------------
    // ------------------------------------------------------------
    //     Factory methods for default contexts
    // ------------------------------------------------------------
    // ------------------------------------------------------------

    /** Create a default FunctionContext.
     *
     *  @return a default FunctionContext
     */
    protected FunctionContext createFunctionContext()
    {
        return XPathFunctionContext.getInstance();
    }

    /** Create a default NamespaceContext.
     *
     *  @return a default NamespaceContext instance
     */
    protected NamespaceContext createNamespaceContext()
    {
        return new SimpleNamespaceContext();
    }

    /** Create a default VariableContext.
     *
     *  @return a default VariableContext instance
     */
    protected VariableContext createVariableContext()
    {
        return new SimpleVariableContext();
    }

    /** Select all nodes that match this XPath
     *  expression on the given Context object.
     *  If multiple nodes match, multiple nodes
     *  will be returned in document-order, as defined by the XPath
     *  specification. If the expression selects a non-node-set
     *  (i.e. a number, boolean, or string) then a List
     *  containing just that one object is returned.
     *

     *
     * @param context the Context which gets evaluated
     *
     * @return the node-set of all items selected
     *          by this XPath expression
     * @throws JaxenException if an XPath error occurs during expression evaluation
     *
     */
    protected List selectNodesForContext(Context context) throws JaxenException
    {
        List list = this.xpath.asList( context );
        return list;

    }

    /** Return only the first node that is selected by this XPath
     *  expression.  If multiple nodes match, only one node will be
     *  returned. The selected node will be the first
     *  selected node in document-order, as defined by the XPath
     *  specification. If the XPath expression selects a double,
     *  String, or boolean, then that object is returned.
     *

     *
     * @param context the Context against which this expression is evaluated
     *
     * @return the first node in document order of all nodes selected
     *          by this XPath expression
     * @throws JaxenException if an XPath error occurs during expression evaluation
     *
     *  @see #selectNodesForContext
     */
    protected Object selectSingleNodeForContext(Context context) throws JaxenException
    {
        List results = selectNodesForContext( context );

        if ( results.isEmpty() )
        {
            return null;
        }

        return results.get( 0 );
    }

}