text:
<?php

#
# Copyright 2013 Zynga Inc.
#
# Licensed 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.
#

/*
 @ Author : nalam@zynga.com
*/
//html parser
function get_game_name_in_report($html){
 // Find the table
        preg_match_all("/<table.*?>.*?<\/[\s]*table>/s", $html, $table_html);
        //find tr
        foreach($table_html as $values){
                foreach($values as $value){
                        preg_match_all("/<tr.*?>(.*?)<\/[\s]*tr>/i",$value,$tr_match);
                        array_pop($tr_match);
                        $tr_matches[] = $tr_match;
                }
        }
        //remove the headers
	for($i = 0; $i<count($tr_matches); $i++){
	        array_shift($tr_matches[$i][0]);
	}
        //find td
        foreach($tr_matches as $values){
                for($i=0;$i<count($values);$i++){
                        for($j=0;$j<count($values[$i]);$j++){
                                preg_match_all("/<td.*?>(.*?)<\/[\s]*td>/", $values[$i][$j], $td_match);
                                array_pop($td_match);
                                $td_matches[] = $td_match;
                        }
                }
        }
        //parse the values
        $return_table_values = array();
        for($i=0;$i<count($td_matches);$i++)
        for($j=0;$j<count($td_matches[$i]);$j++)
                for($k = 0;$k<count($td_matches[$i][$j]);$k++){
                        $a = $td_matches[$i][$j][$k];
                        if(preg_match('/<td.*(left|right)>.*.html.*\'>/',$a)){
                                $a =  preg_replace('/<td.*(left|right)>.*.html.*\'>/','',$a);
                                $a = preg_replace('/<.*/','',$a);

                        }
                        else if(preg_match('/<td.*(left|right)>.*background-color:/',$a)){
                                $a = preg_replace('/<td.*(left|right)>.*background-color:/','',$a);
                                $a = preg_replace('/;.*/','',$a);
                        }
                        else if(preg_match('/<td.*color=(\w+).*<b>/',$a)){
                                $a = preg_replace('/<td.*color=(\w+).*<b>/','',$a);
                                $a = preg_replace('/<.*/','',$a);
                        }
                        else if(preg_match('/<td.*(left|right)>/',$a)){
                                $a = preg_replace('/<td.*(left|right)>/','',$a);
                                $a = preg_replace('/<.*/','',$a);

                        }
                        $td_matches[$i][$j][$k] = trim($a);
                        $return_table_values[$i] = $td_matches[$i][$j];
                }
	foreach($return_table_values as $values)
		$games_in_report[] = $values[0];
        return $games_in_report;

}
function get_duplicated_games($array){
	$duplicates = array();
        $unique = array_unique($array);
        if(count($array) > count($unique))
                for($i = 0; $i < count($array); $i++)
                        if(!array_key_exists($i, $unique))
                                $duplicates[] = $array[$i];
        $duplicate_games = array_unique($duplicates);
        return $duplicate_games;

}
function main($server_cfg){
	$summary_report_url = $server_cfg["instance_summary_report_url"];
	$html = file_get_contents($summary_report_url);
	$games_in_report = get_game_name_in_report($html);
	$report_games_in_server_cfg = $server_cfg["instance_report_games"];
	$games_duplicated_in_report = get_duplicated_games($games_in_report);
	$games_duplicated_in_server_cfg = get_duplicated_games($report_games_in_server_cfg);
	$games_missing_in_report = array_unique(array_diff($report_games_in_server_cfg,$games_in_report));
	$games_missing_in_server_cfg = array_unique(array_diff($games_in_report,$report_games_in_server_cfg));
	$body = "";
	$status = 0;
	if($games_duplicated_in_server_cfg && $games_duplicated_in_report){
		$status = 1;
		$subject = "[WARNING] Games duplicated in report and server_cfg";
		$body .= "\n"."[WARNING] Games duplicated in report:".implode(",",$games_duplicated_in_report)."\n"."[WARNING] games duplicated in server_cfg:".implode(",",$games_duplicated_in_server_cfg);
	}else if($games_duplicated_in_server_cfg){
		$status = 1;
		$subject = "[WARNING] Games duplicated in server_cfg";
		$body = "[WARNING] Games duplicated in server_cfg :".implode(", ",$games_duplicated_in_server_cfg);
	}else if($games_duplicated_in_report){
		$status = 1;
		$subject = "[WARNING] games duplicated in report";
		$body = "[WARNING] Games duplicated in report :".implode(", ",$games_duplicated_in_report);
	}
	if($games_missing_in_report){
		$status = 2;
		$subject = "[ERROR] Games Missing in Report";
		$body .= "\n"."[ERROR] Games missing in Report :".implode(",",$games_missing_in_report);
	}
	else if($games_missing_in_server_cfg){
		$status = 2;
		$subject = "[ERROR] Games missing in server_cfg";
		$body .= "\n"."[ERROR] Games missing in server_cfg:".implode(",",$games_missing_in_server_cfg);
	}
	if($status > 0){
		$to = "xxx@xxxx.xxx";
		mail($to,$subject,$body);

	}
	else return;

}
include_once("/etc/zperfmon/server.cfg");
main($server_cfg);

?>


text:
package simpledb.remote;

import java.sql.*;

/**
 * An adapter class that wraps RemoteConnection.
 * Its methods do nothing except transform RemoteExceptions
 * into SQLExceptions.
 * @author Edward Sciore
 */
public class SimpleConnection extends ConnectionAdapter {
   private RemoteConnection rconn;

   public SimpleConnection(RemoteConnection c) {
      rconn = c;
   }

   public Statement createStatement() throws SQLException {
      try {
         RemoteStatement rstmt = rconn.createStatement();
         return new SimpleStatement(rstmt);
      }
      catch(Exception e) {
         throw new SQLException(e);
      }
   }

   public void close() throws SQLException {
      try {
         rconn.close();
      }
      catch(Exception e) {
         throw new SQLException(e);
      }
   }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Core\Library\EntityBundle\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;

class CountValidator extends ConstraintValidator
{
    protected $translatorService;

    public function __construct(Translator $translatorService)
    {
        $this->translatorService = $translatorService;
    }

    public function isValid($value, Constraint $constraint)
    {
        if ($value == null) {
            $this->setMessage($this->translatorService->trans($constraint->minMessage, array("{{ min }}" => $constraint->min), 'validators'));
            return false;
        }

        if ($constraint->min && count($value) < $constraint->min) {
            $this->setMessage($this->translatorService->trans($constraint->minMessage, array("{{ min }}" => $constraint->min), 'validators'));
            return false;
        }

        if ($constraint->max && count($value) > $constraint->max) {
            $this->setMessage($this->translatorService->trans($constraint->maxMessage, array("{{ max }}" => $constraint->max), 'validators'));
            return false;
        }

        if ($constraint->size && count($value) != $constraint->size) {
            $this->setMessage($this->translatorService->trans($constraint->sizeMessage, array("{{ size }}" => $constraint->size), 'validators'));
            return false;
        }

        return true;
    }
}


text:
using std::make_pair;

namespace views {
namespace corewm {

namespace {

ShadowType GetShadowTypeFromWindow(aura::Window* window) {
  switch (window->type()) {
    case aura::client::WINDOW_TYPE_NORMAL:
    case aura::client::WINDOW_TYPE_PANEL:
    case aura::client::WINDOW_TYPE_MENU:
    case aura::client::WINDOW_TYPE_TOOLTIP:
      return SHADOW_TYPE_RECTANGULAR;
    default:
      break;
  }
  return SHADOW_TYPE_NONE;
}

bool ShouldUseSmallShadowForWindow(aura::Window* window) {
  switch (window->type()) {
    case aura::client::WINDOW_TYPE_MENU:
    case aura::client::WINDOW_TYPE_TOOLTIP:
      return true;
    default:
      break;
  }
  return false;
}

// Returns the shadow style to be applied to |losing_active| when it is losing
// active to |gaining_active|. |gaining_active| may be of a type that hides when
// inactive, and as such we do not want to render |losing_active| as inactive.
Shadow::Style GetShadowStyleForWindowLosingActive(
    aura::Window* losing_active,
    aura::Window* gaining_active) {
  if (gaining_active && aura::client::GetHideOnDeactivate(gaining_active)) {
    aura::Window::Windows::const_iterator it =
        std::find(losing_active->transient_children().begin(),
                  losing_active->transient_children().end(),
                  gaining_active);
    if (it != losing_active->transient_children().end())
      return Shadow::STYLE_ACTIVE;
  }
  return Shadow::STYLE_INACTIVE;
}

}  // namespace

ShadowController::ShadowController(aura::RootWindow* root_window)
    : ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)),
      root_window_(root_window) {
  aura::Env::GetInstance()->AddObserver(this);
  // Watch for window activation changes.
  aura::client::GetActivationClient(root_window_)->AddObserver(this);
}

ShadowController::~ShadowController() {
  aura::client::GetActivationClient(root_window_)->RemoveObserver(this);
  aura::Env::GetInstance()->RemoveObserver(this);
}

void ShadowController::OnWindowInitialized(aura::Window* window) {
  observer_manager_.Add(window);
  SetShadowType(window, GetShadowTypeFromWindow(window));
  HandlePossibleShadowVisibilityChange(window);
}

void ShadowController::OnWindowPropertyChanged(aura::Window* window,
                                               const void* key,
                                               intptr_t old) {
  if (key == kShadowTypeKey) {
    HandlePossibleShadowVisibilityChange(window);
    return;
  }
}

void ShadowController::OnWindowBoundsChanged(aura::Window* window,
                                             const gfx::Rect& old_bounds,
                                             const gfx::Rect& new_bounds) {
  Shadow* shadow = GetShadowForWindow(window);
  if (shadow)
    shadow->SetContentBounds(gfx::Rect(new_bounds.size()));
}

void ShadowController::OnWindowDestroyed(aura::Window* window) {
  window_shadows_.erase(window);
  observer_manager_.Remove(window);
}

void ShadowController::OnWindowActivated(aura::Window* gaining_active,
                                         aura::Window* losing_active) {
  if (gaining_active) {
    Shadow* shadow = GetShadowForWindow(gaining_active);
    if (shadow && !ShouldUseSmallShadowForWindow(gaining_active))
      shadow->SetStyle(Shadow::STYLE_ACTIVE);
  }
  if (losing_active) {
    Shadow* shadow = GetShadowForWindow(losing_active);
    if (shadow && !ShouldUseSmallShadowForWindow(losing_active)) {
      shadow->SetStyle(GetShadowStyleForWindowLosingActive(losing_active,
                                                           gaining_active));
    }
  }
}

bool ShadowController::ShouldShowShadowForWindow(aura::Window* window) const {
  const ShadowType type = GetShadowType(window);
  switch (type) {
    case SHADOW_TYPE_NONE:
      return false;
    case SHADOW_TYPE_RECTANGULAR:
      return true;
    default:
      NOTREACHED() << "Unknown shadow type " << type;
      return false;
  }
}

Shadow* ShadowController::GetShadowForWindow(aura::Window* window) {
  WindowShadowMap::const_iterator it = window_shadows_.find(window);
  return it != window_shadows_.end() ? it->second.get() : NULL;
}

void ShadowController::HandlePossibleShadowVisibilityChange(
    aura::Window* window) {
  const bool should_show = ShouldShowShadowForWindow(window);
  Shadow* shadow = GetShadowForWindow(window);
  if (shadow)
    shadow->layer()->SetVisible(should_show);
  else if (should_show && !shadow)
    CreateShadowForWindow(window);
}

void ShadowController::CreateShadowForWindow(aura::Window* window) {
  linked_ptr<Shadow> shadow(new Shadow());
  window_shadows_.insert(make_pair(window, shadow));

  shadow->Init(ShouldUseSmallShadowForWindow(window) ?
               Shadow::STYLE_SMALL : Shadow::STYLE_ACTIVE);
  shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
  shadow->layer()->SetVisible(ShouldShowShadowForWindow(window));
  window->layer()->Add(shadow->layer());
}

}  // namespace corewm
}  // namespace views


text: HTML5 Canvas Game Prototype at https://cfanguy.github.io/adventure_game/


text:
import React from 'react';

import { compose, withState, withHandlers } from 'recompose';
import styles from './styles.css';
import SearchIcon from '../icons/Search';
import CrosshIcon from '../icons/cross';
import cx from 'classnames';
import Events from '../../lib/EventBus';

export default compose(
  withState('value', 'setValue', ''),
  withHandlers({
    update: props => value => {
      Events.emit('getRooms', value);
      props.setValue(value);
    }
  }),
  withHandlers({
    reset: props => e => {
      e.preventDefault();
      props.update('')
    },
    handleChange: props => event => props.update(event.target.value)
  })
)(({ handleChange, reset, value }) => (
  <form className={cx(styles.wrap, !!value && styles.active)}>
    <SearchIcon className={cx(styles.icon, !!value && styles.active)} />
    <input
      type='search'
      value={value}
      className={styles.input}
      onChange={handleChange}
      placeholder='Find something' />
    {
      !!value &&
        <button className={styles.cross} onClick={reset}>
          <CrosshIcon className={styles.crossIcon} />
        </button>
    }
  </form>
));


text:
<!doctype html>

	<meta charset="utf-8">

	<link rel="stylesheet" href="../../../../docs/style.css">

timelinefx:timelinefx.tlEffectsLibrary.AddShape

Method AddShape:Bool( shape:tlShape )

Add a shape to the library

Parameters


text:
package com.fionapet.business.service;

import com.fionapet.business.entity.Service;
import org.dubbo.x.service.CURDService;
/**
 * 服务主表
* Created by tom on 2016-07-18 11:56:11.
 */
public interface ServiceService extends CURDService<Service> {

}


text:
	; JSONNode procedures

	.model flat, stdcall
	option casemap: none

	include json.inc

	public json_node_alloc
	public json_node_free

	.code
json_node_alloc PROC
	mov	rdi, 1
	mov	rsi, sizeof JSONNode
	call	calloc
	ret
json_node_alloc ENDP

json_node_free PROC node: Ptr JSONNode
	LOCAL array: Ptr Ptr JSONNode

	ret
	mov rax, node
	mov array, 0
	.if [rax + JSONNode.d_str] != 0
		mov	rdi, [rax + JSONNode.d_str]
		call	free
	.elseif [rax + JSONNode.a] != 0
		mov rax, [rax + JSONNode.a]
		mov array, rax
	.endif

	.if array != 0
		mov rax, node
		mov rcx, [rax + JSONNode.n]
		mov rax, array
@1:
		push	rax
		push	rcx
		invoke json_node_free, [rax]
		pop	rcx
		pop	rax

		add rax, 8
		loop @1
	.endif

	mov	rdi, node
	call	free
	ret
json_node_free ENDP

json_node_set_name PROC node: Ptr JSONNode, nam: Ptr BYTE
	mov rax, node
	mov rdi, nam
	mov [rax + JSONNode.nam], rdi
	ret
json_node_set_name ENDP

	END


text:
Groove Basin organizes your music, lets you collaboratively construct playlists, and
provides a smooth listening experience with loudness compensation and gapless playback.
It supports a wide variety of codecs, including mp3, flac, ogg, m4a, aif, wav, and wma.


text:
using namespace UnitTesting;

//-----------------------------------------------------------------------------
// This unit test will blow up without thread static support
#ifdef TORQUE_ENABLE_THREAD_STATICS

// Declare a test thread static
DITTS( U32, gUnitTestFoo, 42 );
DITTS( F32, gUnitTestF32, 1.0 );

CreateUnitTest( TestThreadStatic, "Core/ThreadStatic" )
{
   void run()
   {
      MemoryTester m;
      m.mark();

      // ThreadStatic list should be initialized right now, so lets see if it has
      // any entries.
      test( !_TorqueThreadStaticReg::getStaticList().empty(), "Self-registration has failed, or no statics declared" );

      // Spawn a new copy.
      TorqueThreadStaticListHandle testInstance = _TorqueThreadStaticReg::spawnThreadStaticsInstance();

      // Test the copy
      test( _TorqueThreadStaticReg::getStaticList( 0 ).size() == testInstance->size(), "Spawned static list has a different size from master copy." );

      // Make sure the size test passed before this is attempted
      if( lastTestPassed() )
      {
         // Traverse the list and compare it to the initial value copy (index 0)
         for( int i = 0; i < _TorqueThreadStaticReg::getStaticList().size(); i++ )
         {
            _TorqueThreadStatic *master = _TorqueThreadStaticReg::getStaticList()[i];
            _TorqueThreadStatic *cpy = (*testInstance)[i];

            // Make sure it is not the same memory
            test( master != cpy, "Copy not spawned properly." );

            // Make sure the sizes are the same
            test( master->getMemInstSize() == cpy->getMemInstSize(), "Size mismatch between master and copy" );

            // Make sure the initialization occurred properly
            if( lastTestPassed() )
               test( dMemcmp( master->getMemInstPtr(), cpy->getMemInstPtr(), master->getMemInstSize() ) == 0, "Initial value for spawned list is not correct" );
         }
      }

      // Test metrics if enabled
#ifdef TORQUE_ENABLE_THREAD_STATIC_METRICS
      U32 fooHitCount = (*testInstance)[_gUnitTestFooTorqueThreadStatic::getListIndex()]->getHitCount();
#endif

      // Set/get some values (If we test static metrics, this is hit 1)
      ATTS_(gUnitTestFoo, 1) = 55;

      // Test to see that the master copy and the spawned copy differ
      // (If we test metrics, this is hit 2, for the instance, and hit 1 for the master)
      test( ATTS_(gUnitTestFoo, 0) != ATTS_(gUnitTestFoo, 1 ) , "Assignment for spawned instanced memory failed" );

#ifdef TORQUE_ENABLE_THREAD_STATIC_METRICS
      U32 fooHitCount2 = (*testInstance)[_gUnitTestFooTorqueThreadStatic::getListIndex()]->getHitCount();
      test( fooHitCount2 == ( fooHitCount + 2 ), "Thread static metric hit count failed" );
#endif

      // Destroy instances
      _TorqueThreadStaticReg::destroyInstance( testInstance );

      // Now test the cleanup
      test( m.check(), "Memory leak in dynamic static allocation stuff." );
   }
};

#endif // TORQUE_ENABLE_THREAD_STATICS


text:
@interface OEXCourse (OEXTestDataFactory)

+ (instancetype)freshCourse;

@end


text:
package com.jivesoftware.jivesdk.api.tiles;

/**
 */
public class ListItem extends TileContentItem {
	private String text;

	public ListItem() {
	}

	public ListItem(String text) {
		this.text = text;
		this.linkDescription = text;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

}


text:
var $ = require("jquery");
var React = require("react");

var PodView = require("./_podView");
var SelectedPodView = require("./_selectedPodView");

module.exports = React.createClass({

	podsPerRowCalc: function(){
		var siteWidth = $("body").width();

		if(siteWidth > 1180){
			return 4
		}else if(siteWidth > 767){
			return 3
		}else if(siteWidth > 510){
			return 2
		}else{
			return 1
		}
	},

	componentDidMount: function(){
		var _this = this;
		$(window).on("resize", function(){
			_this.setState({
				podsPerRow: _this.podsPerRowCalc()
			});
		})
	},

	getInitialState: function(){

		return {
			podsPerRow: this.podsPerRowCalc(),
			selectedPod: -1
		};
	},

	selectedAPod: function(i){
		if(this.state.selectedPod == i){
			this.setState({selectedPod: -1})
		}else{
			this.setState({selectedPod: i});
		}
	},

	render: function(){
		var _this = this;
		var PPR = this.state.podsPerRow

		//All the podViews.
		var podList = this.props.data.map(function(pod, i){
			//Has this pod been selected?
			var selected = _this.state.selectedPod == i ? true : false;
			return <PodView onClick={_this.selectedAPod} index={i} data={pod} selected={selected} />
		})

		//All the SelectedPodViews.
		var selectedPodList = this.props.data.map(function(pod, i){
			//Has this pod been selected?
			var selected = _this.state.selectedPod == i ? true : false;
			return <SelectedPodView data={pod} selected={selected} />
		})

		insertList = [];
		for(var i = 0; i < podList.length; i++){
			//Add a podview.
			insertList.push(podList[i]);

			//Every time i has incremented by this.state.podsPerRow..
			//..all selectedPodView are to be appended.
			if((i+1) % PPR == 0){

				//From latest checkpoint to i.
				for(var n = i + 1 - PPR; n <= i; n++){

					insertList.push(selectedPodList[n]);
				}

			//If it reached end of postList there are some SelectedPodView left
			//Since the last checkpoint
			//Append all the missing selectedPodView.
			}else if(i == podList.length -1){
				for(var n = i - (i%PPR); n < podList.length; n++){
					insertList.push(selectedPodList[n]);
				}
			}

		}

		return(
			<ul className="unstyled">
				{insertList}
			</ul>);
	}
});


text:
@interface KPHProtocol : NSObject
+ (BOOL) verifyRequestt:(KPHRequest *) request aes:(KPHAes*)aes;
+ (BOOL) testRequestVerifier: (KPHRequest *) request aes:(KPHAes*)aes key:(NSString *) key;
+ (void) setResponseVerifier: (KPHResponse *) response aes:(KPHAes*) aes;
+ (void) encryptResponse:(KPHResponse*)response aes:(KPHAes*)aes;
@end


text:
#if FEATURE_BREAKITERATOR
using Lucene.Net.Analysis;
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Lucene.Net.Search;
using Lucene.Net.Search.Spans;
using Lucene.Net.Store;
using Lucene.Net.Support;
using Lucene.Net.Util;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IndexOptions = Lucene.Net.Index.IndexOptions;

namespace Lucene.Net.Search.PostingsHighlight
{

    ///
    /// Some tests that override <see cref="PostingsHighlighter.GetIndexAnalyzer(string)"/> to
    /// highlight wilcard, fuzzy, etc queries.
    ///
    [SuppressCodecs("MockFixedIntBlock", "MockVariableIntBlock", "MockSep", "MockRandom", "Lucene3x")]
    public class TestMultiTermHighlighting : LuceneTestCase
    {
        internal class PostingsHighlighterAnalyzerHelper : PostingsHighlighter
        {
            private readonly Analyzer analyzer;

            public PostingsHighlighterAnalyzerHelper(Analyzer analyzer)
            {
                this.analyzer = analyzer;
            }

            protected override Analyzer GetIndexAnalyzer(string field)
            {
                return analyzer;
            }
        }

        [Test]
        public void TestWildcards()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //    PostingsHighlighter highlighter = new PostingsHighlighter() {
            //  @Override
            //  protected Analyzer getIndexAnalyzer(String field)
            //    {
            //        return analyzer;
            //    }
            //};
            Query query = new WildcardQuery(new Term("body", "te*"));
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // wrong field
            BooleanQuery bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(new WildcardQuery(new Term("bogus", "te*")), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestOnePrefix()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            Query query = new PrefixQuery(new Term("body", "te"));
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // wrong field
            BooleanQuery bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(new PrefixQuery(new Term("bogus", "te")), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestOneRegexp()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            Query query = new RegexpQuery(new Term("body", "te.*"));
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // wrong field
            BooleanQuery bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(new RegexpQuery(new Term("bogus", "te.*")), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestOneFuzzy()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            Query query = new FuzzyQuery(new Term("body", "tets"), 1);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // with prefix
            query = new FuzzyQuery(new Term("body", "tets"), 1, 2);
            topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // wrong field
            BooleanQuery bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(new FuzzyQuery(new Term("bogus", "tets"), 1), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestRanges()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            Query query = TermRangeQuery.NewStringRange("body", "ta", "tf", true, true);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // null start
            query = TermRangeQuery.NewStringRange("body", null, "tf", true, true);
            topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // null end
            query = TermRangeQuery.NewStringRange("body", "ta", null, true, true);
            topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // exact start inclusive
            query = TermRangeQuery.NewStringRange("body", "test", "tf", true, true);
            topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // exact end inclusive
            query = TermRangeQuery.NewStringRange("body", "ta", "test", true, true);
            topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // exact start exclusive
            BooleanQuery bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(TermRangeQuery.NewStringRange("body", "test", "tf", false, true), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // exact end exclusive
            bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(TermRangeQuery.NewStringRange("body", "ta", "test", true, false), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // wrong field
            bq = new BooleanQuery();
            bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            bq.Add(TermRangeQuery.NewStringRange("bogus", "ta", "tf", true, true), Occur.SHOULD);
            topDocs = searcher.Search(bq, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", bq, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestWildcardInBoolean()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            BooleanQuery query = new BooleanQuery();
            query.Add(new WildcardQuery(new Term("body", "te*")), Occur.SHOULD);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            // must not
            query = new BooleanQuery();
            query.Add(new MatchAllDocsQuery(), Occur.SHOULD);
            query.Add(new WildcardQuery(new Term("bogus", "te*")), Occur.MUST_NOT);
            topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestWildcardInDisjunctionMax()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            DisjunctionMaxQuery query = new DisjunctionMaxQuery(0);
            query.Add(new WildcardQuery(new Term("body", "te*")));
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestSpanWildcard()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            Query query = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestSpanOr()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            SpanQuery childQuery = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
            Query query = new SpanOrQuery(new SpanQuery[] { childQuery });
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestSpanNear()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            SpanQuery childQuery = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
            Query query = new SpanNearQuery(new SpanQuery[] { childQuery }, 0, true);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestSpanNot()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            SpanQuery include = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
            SpanQuery exclude = new SpanTermQuery(new Term("body", "bogus"));
            Query query = new SpanNotQuery(include, exclude);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        [Test]
        public void TestSpanPositionCheck()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("This is a test.");
            iw.AddDocument(doc);
            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            SpanQuery childQuery = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
            Query query = new SpanFirstQuery(childQuery, 1000000);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(2, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(2, snippets.Length);
            assertEquals("This is a test.", snippets[0]);
            assertEquals("Test a one sentence document.", snippets[1]);

            ir.Dispose();
            dir.Dispose();
        }

        internal class PostingsHighlighterAnalyzerAndFormatterHelper : PostingsHighlighterAnalyzerHelper
        {
            private readonly PassageFormatter formatter;

            public PostingsHighlighterAnalyzerAndFormatterHelper(Analyzer analyzer, PassageFormatter formatter)
                : base(analyzer)
            {
                this.formatter = formatter;
            }

            protected override PassageFormatter GetFormatter(string field)
            {
                return formatter;
            }
        }

        internal class PassageFormatterHelper : PassageFormatter
        {
            public override object Format(Passage[] passages, string content)
            {
                // Copied from DefaultPassageFormatter, but
                // tweaked to include the matched term:
                StringBuilder sb = new StringBuilder();
                int pos = 0;
                foreach (Passage passage in passages)
                {
                    // don't add ellipsis if its the first one, or if its connected.
                    if (passage.StartOffset > pos && pos > 0)
                    {
                        sb.append("... ");
                    }
                    pos = passage.StartOffset;
                    for (int i = 0; i < passage.NumMatches; i++)
                    {
                        int start = passage.matchStarts[i];
                        int end = passage.matchEnds[i];
                        // its possible to have overlapping terms
                        if (start > pos)
                        {
                            sb.Append(content, pos, start - pos);
                        }
                        if (end > pos)
                        {
                            sb.Append("");
                            int startPos = Math.Max(pos, start);
                            sb.Append(content, startPos, end - startPos);
                            sb.Append('(');
                            sb.Append(passage.MatchTerms[i].Utf8ToString());
                            sb.Append(')');
                            sb.Append("");
                            pos = end;
                        }
                    }
                    // its possible a "term" from the analyzer could span a sentence boundary.
                    sb.Append(content, pos, Math.Max(pos, passage.EndOffset) - pos);
                    pos = passage.EndOffset;
                }
                return sb.toString();
            }
        }

        /** Runs a query with two MTQs and confirms the formatter
         *  can tell which query matched which hit. */
        [Test]
        public void TestWhichMTQMatched()
        {
            Directory dir = NewDirectory();
            // use simpleanalyzer for more natural tokenization (else "test." is a token)
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.SIMPLE, true);
            IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
            iwc.SetMergePolicy(NewLogMergePolicy());
            RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, iwc);

            FieldType offsetsType = new FieldType(TextField.TYPE_STORED);
            offsetsType.IndexOptions = (IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
            Field body = new Field("body", "", offsetsType);
            Document doc = new Document();
            doc.Add(body);

            body.SetStringValue("Test a one sentence document.");
            iw.AddDocument(doc);

            IndexReader ir = iw.Reader;
            iw.Dispose();

            IndexSearcher searcher = NewSearcher(ir);
            PostingsHighlighter highlighter = new PostingsHighlighterAnalyzerHelper(analyzer);
            //PostingsHighlighter highlighter = new PostingsHighlighter() {
            //      @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}
            //    };
            BooleanQuery query = new BooleanQuery();
            query.Add(new WildcardQuery(new Term("body", "te*")), Occur.SHOULD);
            query.Add(new WildcardQuery(new Term("body", "one")), Occur.SHOULD);
            query.Add(new WildcardQuery(new Term("body", "se*")), Occur.SHOULD);
            TopDocs topDocs = searcher.Search(query, null, 10, Sort.INDEXORDER);
            assertEquals(1, topDocs.TotalHits);
            String[] snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(1, snippets.Length);

            // Default formatter just bolds each hit:
            assertEquals("Test a one sentence document.", snippets[0]);

            // Now use our own formatter, that also stuffs the
            // matching term's text into the result:
            highlighter = new PostingsHighlighterAnalyzerAndFormatterHelper(analyzer, new PassageFormatterHelper());

            //highlighter = new PostingsHighlighter()
            //{
            //    @Override
            //      protected Analyzer getIndexAnalyzer(String field)
            //{
            //    return analyzer;
            //}

            //@Override
            //      protected PassageFormatter getFormatter(String field)
            //{
            //    return new PassageFormatter() {

            //          @Override
            //          public Object format(Passage passages[], String content)
            //{
            //    // Copied from DefaultPassageFormatter, but
            //    // tweaked to include the matched term:
            //    StringBuilder sb = new StringBuilder();
            //    int pos = 0;
            //    for (Passage passage : passages)
            //    {
            //        // don't add ellipsis if its the first one, or if its connected.
            //        if (passage.startOffset > pos && pos > 0)
            //        {
            //            sb.append("... ");
            //        }
            //        pos = passage.startOffset;
            //        for (int i = 0; i < passage.numMatches; i++)
            //        {
            //            int start = passage.matchStarts[i];
            //            int end = passage.matchEnds[i];
            //            // its possible to have overlapping terms
            //            if (start > pos)
            //            {
            //                sb.append(content, pos, start);
            //            }
            //            if (end > pos)
            //            {
            //                sb.append("");
            //                sb.append(content, Math.max(pos, start), end);
            //                sb.append('(');
            //                sb.append(passage.getMatchTerms()[i].utf8ToString());
            //                sb.append(')');
            //                sb.append("");
            //                pos = end;
            //            }
            //        }
            //        // its possible a "term" from the analyzer could span a sentence boundary.
            //        sb.append(content, pos, Math.max(pos, passage.endOffset));
            //        pos = passage.endOffset;
            //    }
            //    return sb.toString();
            //}
            //        };
            //      }
            //    };

            assertEquals(1, topDocs.TotalHits);
            snippets = highlighter.Highlight("body", query, searcher, topDocs);
            assertEquals(1, snippets.Length);

            // Default formatter bolds each hit:
            assertEquals("Test(body:te*) a one(body:one) sentence(body:se*) document.", snippets[0]);

            ir.Dispose();
            dir.Dispose();
        }
    }
}
#endif


text:
<!DOCTYPE html>
<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
  <title>L'orge sucrée</title>

  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link href="../assets/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
  <link href="../assets/css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
  <link href="../assets/css/moncss.css" type="text/css" rel="stylesheet" media="screen,projection"/>
</head>


text:
namespace Smi.Sample.AppCore.GameBoard.Events
{
	using System;
	using System.Collections.Generic;
	using Commands;
	using Smi.Infra.Messages;

	[Serializable]
	public class PlayerAddedEvent : DomainEvent<IAddPlayerToBoardGame>
	{
		public PlayerAddedEvent(IDictionary<string, object> parameters)
			: base(parameters)
		{ }
	}
}


text:
function Get-PrimeDeviceConfigsVersions{
    Param(
        [Parameter(Mandatory = $true,Position = 0,HelpMessage = 'Credential')]
        [ValidateNotNullorEmpty()]
        [Parameter(Mandatory = $true, Position = 1, HelpMessage ='Hostname')]
        [ValidateNotNullOrEmpty()]
        [String]$Hostname,
        [System.Management.Automation.PSCredential]$Credential,
        [Parameter(Mandatory = $false,Position = 2,HelpMessage = 'name')]
        [ValidateNotNullorEmpty()]
        [String]$name,
        [Parameter(Mandatory = $false,Position = 3,HelpMessage = 'id')]
        [ValidateNotNullorEmpty()]
        [String]$id
    )
 Process {
    $Headers = Get-BasicAuthorization -Credential $Credential
    if($name)
        {
        $UriAdress =  BuildURL -Hostname $Hostname -CallURL "/data/ConfigVersions?deviceName=contains(`"$name`")"
        }
    [xml]$Respones = Invoke-WebRequest -Uri $UriAdress -Method get -Body $xmlPost -Headers $Headers -ContentType "text/xml" -DisableKeepAlive
    $ConfigVersions = ($Respones.queryResponse.entityId)."#text"
    $Return = @()
    Foreach ($ConfigVersion in $ConfigVersions)
        {
        sleep -Milliseconds 50
        $UriAdress2 =  BuildURL -Hostname $Hostname -CallURL "/data/ConfigVersions/$ConfigVersion.json"
        $Respones2 = Invoke-WebRequest -Uri $UriAdress2 -Method get -Body $xmlPost -Headers $Headers -ContentType "text/xml" -DisableKeepAlive
        $data = ($Respones2.Content | ConvertFrom-Json).queryResponse.entity.configVersionsDTO.fileInfos

        $Return += $data.fileInfo
        }
    return $Return
    }
    }


text:
/*
 * META Doc
 * Documentation generator
 *
 * @author META Platform <www.meta-platform.com>
 * @license See LICENSE file distributed with this source code
 */

var messageConfig = function(classname, icon){

	return {
		render: function(tokens, idx, _options, env, self){

		    // add a class to the opening tag
		    if (tokens[idx].nesting === 1) {

		    	tokens[idx].attrPush([ 'class', "message " + classname]);

		    	return self.renderToken(tokens, idx, _options, env, self) + '';

		    }

		    return self.renderToken(tokens, idx, _options, env, self);

		}
	};

};

var sidecodeConfig = function(classname){

	return {

		render: function (tokens, idx, _options, env, self) {

			if (tokens[idx].nesting === 1) {

				tokens[idx].attrPush([ 'class', classname ]);
				return self.renderToken(tokens, idx, _options, env, self) + '
\n';

			} else {

				return '
\n' + self.renderToken(tokens, idx, _options, env, self);

			}

			return self.renderToken(tokens, idx, _options, env, self);
		}

 	};

};

var blockConfig = function(classname, prefix, postfix){

	return {
		render: function(tokens, idx, _options, env, self){

		    // add a class to the opening tag
		    if (tokens[idx].nesting === 1) {

		    	tokens[idx].attrPush([ 'class', "block-" + classname]);

		    	return self.renderToken(tokens, idx, _options, env, self) + ( prefix || "" );

		    } else {

				return ( postfix || "" ) + self.renderToken(tokens, idx, _options, env, self);

		    }

		    return self.renderToken(tokens, idx, _options, env, self);

		}
	};

};

module.exports = {

	atts: 			[ require('markdown-it-attrs') ],
	highlight: 		[ require('markdown-it-highlightjs') ],

	message: 		[ require('markdown-it-container'), "message" ],
	info: 	 		[ require('markdown-it-container'), "info", messageConfig("info", "information") ],
 	warning: 		[ require('markdown-it-container'), "warning", messageConfig("warn", "alert-circle") ],
 	alert: 			[ require('markdown-it-container'), "alert", messageConfig("alert", "alert") ],
 	success: 		[ require('markdown-it-container'), "success", messageConfig("success", "checkbox-marked-circle") ],

 	clear: 			[ require('markdown-it-container'), "clear" ],

 	sidecode: 		[ require('markdown-it-container'), "sidecode", sidecodeConfig("sidecode") ],
 	sidecode_h3: 	[ require('markdown-it-container'), "sidecode-h3", sidecodeConfig("sidecode h3") ],

 	_block: 		function(name, prefix, postfix){

 		return [ require('markdown-it-container'), name, blockConfig(name, prefix, postfix) ];

 	}

};


text:
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings

class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='TrackedPosition',
            fields=[
                ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)),
                ('time', models.DateTimeField()),
                ('latitude', models.FloatField()),
                ('longitude', models.FloatField()),
                ('altitude', models.FloatField()),
                ('accuracy', models.FloatField()),
            ],
            options={
                'ordering': ['id'],
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='TrackingKey',
            fields=[
                ('key', models.CharField(max_length=32, primary_key=True, serialize=False)),
                ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
            ],
            options={
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='TrackingSession',
            fields=[
                ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)),
                ('start_time', models.DateTimeField()),
                ('end_time', models.DateTimeField(null=True, blank=True)),
                ('active', models.BooleanField(default=True)),
                ('viewkey', models.CharField(max_length=32)),
                ('is_cleaned', models.BooleanField(default=False)),
                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
            ],
            options={
            },
            bases=(models.Model,),
        ),
        migrations.AddField(
            model_name='trackedposition',
            name='session',
            field=models.ForeignKey(to='tracker.TrackingSession'),
            preserve_default=True,
        ),
    ]


text:
<?xml version="1.0" encoding="UTF-8"?>
<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>
    <parent>
        <groupId>org.optaplanner</groupId>
        <artifactId>optaplanner</artifactId>
        <version>6.2.0-SNAPSHOT</version>
    </parent>

    <artifactId>ders-program</artifactId>
    <packaging>war</packaging>

    <name>OptaPlanner webexamples</name>
    <description>
        OptaPlanner solves planning problems.
        This lightweight, embeddable planning engine implements powerful and scalable algorithms
        to optimize business resource scheduling and planning.

        This module contains the web examples which demonstrate how to use it in a war file.
    </description>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>

                    <!-- Container configuration -->
                    <container>
                        <containerId>tomcat7x</containerId>
                        <type>remote</type>
                    </container>

                    <!-- Configuration to use with the container -->
                    <configuration>
                        <type>runtime</type>
                        <properties>
                            <cargo.hostname>178.62.73.224</cargo.hostname>
                            <cargo.servlet.port>8080</cargo.servlet.port>
                            <cargo.remote.username>kazablanka</cargo.remote.username>
                            <cargo.remote.password>#dna.32.nS</cargo.remote.password>
                        </properties>
                    </configuration>

                    <!-- Deployer configuration -->
                    <deployer>
                        <type>remote</type>
                    </deployer>

                    <!-- Deployables configuration -->
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <type>war</type>
                            <properties>
                                <context>/${project.artifactId}</context>
                            </properties>
                        </deployable>
                    </deployables>

                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <!-- Internal dependencies -->
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-benchmark</artifactId>
        </dependency>
        <dependency>
            <groupId>org.optaplanner</groupId>
            <artifactId>optaplanner-examples</artifactId>
            <type>jar</type>
        </dependency>
        <!-- External dependencies -->
        <!-- Commons -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>
        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- Xstream -->
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.0_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet.jsp</groupId>
            <artifactId>jboss-jsp-api_2.2_spec</artifactId>
        </dependency>

        <!-- External -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
        </dependency>
    </dependencies>

</project>


text:
package alluxio.client.lineage.options;

import alluxio.CommonTestUtils;

import org.junit.Assert;
import org.junit.Test;

/**
 * Tests for {@link DeleteLineageOptions}.
 */
public final class DeleteLineageOptionsTest {

  /**
   * Tests that building a {@link DeleteLineageOptions} works.
   */
  @Test
  public void builder() {
    DeleteLineageOptions options = DeleteLineageOptions.defaults().setCascade(true);
    Assert.assertTrue(options.isCascade());
  }

  /**
   * Tests that building a {@link DeleteLineageOptions} with the defaults works.
   */
  @Test
  public void defaults() {
    DeleteLineageOptions options = DeleteLineageOptions.defaults();
    Assert.assertFalse(options.isCascade());
  }

  @Test
  public void equalsTest() throws Exception {
    CommonTestUtils.testEquals(DeleteLineageOptions.class);
  }
}


text:
using NBatch.Main.Core;
using NBatch.Main.Readers.FileReader.Services;

namespace NBatch.Main.Readers.FileReader.Extensions
{
    public static class FlatFileItemReaderExt
    {
        public static Step<TInput, TOutput> UseFlatFileItemReader<TInput, TOutput>(this Step<TInput, TOutput> step,
            string resourceUrl, IFieldSetMapper<TInput> fieldMapper, char token = DelimitedLineTokenizer.DEFAULT_TOKEN)
        {
            IReader<TInput> flatFileItemReader = CreateFlatFileReader(resourceUrl, fieldMapper, new DelimitedLineTokenizer(token));
            return step.SetReader(flatFileItemReader);
        }

        public static Step<TInput, TOutput> UseFlatFileItemReader<TInput, TOutput>(this Step<TInput, TOutput> step,
            string resourceUrl, IFieldSetMapper<TInput> fieldMapper, int linesToSkip, string[] headers, char token = DelimitedLineTokenizer.DEFAULT_TOKEN)
        {
            FlatFileItemReader<TInput> flatFileItemReader = CreateFlatFileReader(resourceUrl, fieldMapper, new DelimitedLineTokenizer(headers, token));
            flatFileItemReader.LinesToSkip = linesToSkip;
            return step.SetReader(flatFileItemReader);
        }

        private static FlatFileItemReader<TInput> CreateFlatFileReader<TInput>(string resourceUrl, IFieldSetMapper<TInput> fieldSetMapper, ILineTokenizer tokenizer)
        {
            var lineMapper = new DefaultLineMapper<TInput>(tokenizer, fieldSetMapper);
            return new FlatFileItemReader<TInput>(lineMapper, new FileService(resourceUrl));
        }
    }
}


text:
<?php

/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$customerTaxClass1 = $objectManager->create(
    'Magento\Tax\Model\ClassModel'
)->setClassName(
    'CustomerTaxClass1'
)->setClassType(
    \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER
)->save();

$customerTaxClass2 = $objectManager->create(
    'Magento\Tax\Model\ClassModel'
)->setClassName(
    'CustomerTaxClass2'
)->setClassType(
    \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_CUSTOMER
)->save();

$productTaxClass1 = $objectManager->create(
    'Magento\Tax\Model\ClassModel'
)->setClassName(
    'ProductTaxClass1'
)->setClassType(
    \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT
)->save();

$productTaxClass2 = $objectManager->create(
    'Magento\Tax\Model\ClassModel'
)->setClassName(
    'ProductTaxClass2'
)->setClassType(
    \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT
)->save();

$taxRate = [
    'tax_country_id' => 'US',
    'tax_region_id' => '12',
    'tax_postcode' => '*',
    'code' => '*',
    'rate' => '7.5',
];
$rate = $objectManager->create('Magento\Tax\Model\Calculation\Rate')->setData($taxRate)->save();

/** @var Magento\Framework\Registry $registry */
$registry = $objectManager->get('Magento\Framework\Registry');
$registry->unregister('_fixture/Magento_Tax_Model_Calculation_Rate');
$registry->register('_fixture/Magento_Tax_Model_Calculation_Rate', $rate);

$ruleData = [
    'code' => 'Test Rule',
    'priority' => '0',
    'position' => '0',
    'customer_tax_class_ids' => [$customerTaxClass1->getId(), $customerTaxClass2->getId()],
    'product_tax_class_ids' => [$productTaxClass1->getId(), $productTaxClass2->getId()],
    'tax_rate_ids' => [$rate->getId()],
];

$taxRule = $objectManager->create('Magento\Tax\Model\Calculation\Rule')->setData($ruleData)->save();

$registry->unregister('_fixture/Magento_Tax_Model_Calculation_Rule');
$registry->register('_fixture/Magento_Tax_Model_Calculation_Rule', $taxRule);

$ruleData['code'] = 'Test Rule Duplicate';

$objectManager->create('Magento\Tax\Model\Calculation\Rule')->setData($ruleData)->save();


text:
package swt6.orm.domain;

import javax.persistence.metamodel.SetAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
import java.util.Date;

@StaticMetamodel(Module.class)
public class Module_ {
    public static volatile SingularAttribute<Module, Project> project;
}


text:
package com.intellij.pom.tree.events.impl;

import com.intellij.lang.ASTNode;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.Pair;
import com.intellij.pom.tree.events.ChangeInfo;
import com.intellij.pom.tree.events.ReplaceChangeInfo;
import com.intellij.pom.tree.events.TreeChange;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.impl.source.tree.TreeElement;
import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;

import java.util.*;

public class TreeChangeImpl implements TreeChange {
  private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.events.impl.TreeChangeImpl");
  private final Map<ASTNode, ChangeInfo> myChanges = new THashMap<ASTNode, ChangeInfo>();
  private final List<Pair<ASTNode,Integer>> mySortedChanges = new ArrayList<Pair<ASTNode, Integer>>(); // change, oldoffset
  private final ASTNode myParent;

  @SuppressWarnings("FieldMayBeFinal")
  private static boolean ourDoChecks = ApplicationManager.getApplication().isEAP();

  public TreeChangeImpl(ASTNode parent) {
    myParent = parent;
  }

  @Override
  public void addChange(ASTNode child, @NotNull ChangeInfo changeInfo) {
    LOG.assertTrue(child.getTreeParent() == myParent);

    final ChangeInfo current = myChanges.get(child);

    if(current != null && changeInfo.getChangeType() == ChangeInfo.CONTENTS_CHANGED){
      return;
    }

    if(changeInfo.getChangeType() == ChangeInfo.REPLACE){
      final ReplaceChangeInfoImpl replaceChangeInfo = (ReplaceChangeInfoImpl)changeInfo;
      final ASTNode replaced = replaceChangeInfo.getReplaced();
      final ChangeInfo replacedInfo = myChanges.get(replaced);

      if(replacedInfo == null){
        addChangeInternal(child, changeInfo);
      }
      else{
        switch(replacedInfo.getChangeType()){
          case ChangeInfo.REPLACE:
            replaceChangeInfo.setOldLength(replacedInfo.getOldLength());
            replaceChangeInfo.setReplaced(((ReplaceChangeInfo)replacedInfo).getReplaced());
            break;
          case ChangeInfo.ADD:
            changeInfo = ChangeInfoImpl.create(ChangeInfo.ADD, replaced);
            removeChangeInternal(replaced);
            break;
        }
        addChangeInternal(child, changeInfo);
      }
      return;
    }

    if(current != null && current.getChangeType() == ChangeInfo.REMOVED){
      if(changeInfo.getChangeType() == ChangeInfo.ADD){
        if (!(child instanceof LeafElement)) {
          // remove/add -> changed
          changeInfo = ChangeInfoImpl.create(ChangeInfo.CONTENTS_CHANGED, child);
          ((ChangeInfoImpl)changeInfo).setOldLength(current.getOldLength());
          myChanges.put(child, changeInfo);
        }
        else {
          removeChangeInternal(child);
        }

      }
      return;
    }

    // add + remove == no op
    if(current != null && current.getChangeType() == ChangeInfo.ADD){
      if(changeInfo.getChangeType() == ChangeInfo.REMOVED){
        removeChangeInternal(child);
      }
      return;
    }

    if(changeInfo.getChangeType() == ChangeInfo.REMOVED){
      if(child instanceof LeafElement){
        final CharSequence charTabIndex = child.getChars();
        if(checkLeaf(child.getTreeNext(), charTabIndex) || checkLeaf(child.getTreePrev(), charTabIndex)) return;
      }
      addChangeInternal(child, changeInfo);
      if (current != null) {
        ((ChangeInfoImpl)changeInfo).setOldLength(current.getOldLength());
      }
      return;
    }

    if(current == null){
      addChangeInternal(child, changeInfo);
    }
  }

  private void addChangeInternal(ASTNode child, ChangeInfo info){
    if(!myChanges.containsKey(child)){
      final int nodeOffset = getNodeOldOffset(child, info);
      addChangeAtOffset(child, nodeOffset);
    }
    myChanges.put(child, info);
  }

  private static boolean ourReportedDifferentAddChangeAtOffsetOptimization = false;

  private void addChangeAtOffset(final ASTNode child, final int nodeOffset) {
    int optimizedIndex = haveNotCalculated;

    Pair<ASTNode, Integer> element = Pair.create(child, Integer.valueOf(nodeOffset));

    if (mySortedChanges.size() > 0) { // check adding at end
      Pair<ASTNode, Integer> pair = mySortedChanges.get(mySortedChanges.size() - 1);
      if (pair.getFirst() == child.getTreePrev() && pair.getSecond() <= nodeOffset) {
        optimizedIndex = mySortedChanges.size();
        if (!ourDoChecks) {
          mySortedChanges.add(element);
          return;
        }
      }
    }

    int index = 0;

    for (Pair<ASTNode, Integer> pair : mySortedChanges) {
      if(child == pair.getFirst()) return;
      if(nodeOffset < pair.getSecond().intValue() || nodeOffset == pair.getSecond().intValue() && isAfter(pair.getFirst(), child)){
        break;
      }
      index++;
    }

    int insertionIndex = optimizedIndex != haveNotCalculated ? optimizedIndex:index;

    if (insertionIndex == mySortedChanges.size()) mySortedChanges.add(element);
    else mySortedChanges.add(insertionIndex, element);

    if (optimizedIndex != haveNotCalculated && index != optimizedIndex && !ourReportedDifferentAddChangeAtOffsetOptimization) {
      ASTNode prev = child.getTreePrev();
      Pair<ASTNode, Integer> pair = mySortedChanges.get(index);
      ChangeInfo prevChange = myChanges.get(prev);
      ChangeInfo prevChange2 = myChanges.get(pair.getFirst());
      LOG.error("Failed to calculate optimized index for add change at offset: prev node:"+prev + ", prev change:" + prevChange +
                ",prev change length:" + (prevChange != null ? prevChange.getOldLength() : null) + ", prev text length:" + prev.getTextLength() +
                ",prev offset:" + mySortedChanges.get(mySortedChanges.size() - 1).getSecond() +  ", node:" + child + ", nodeOffset:" +
                nodeOffset + ", optimizedIndex:"+optimizedIndex + ", real index:" + index + ", same node:" + (pair.getFirst() == child) +
                ", at place:"+ pair.getSecond() + ", node:" +pair.getFirst() + ", change:"+prevChange2 + ", prevChange oldLength:" +
                (prevChange2 != null ? prevChange2.getOldLength():null) + ", prevchange length2:" + pair.getFirst().getTextLength() + "," +
                toString());
      ourReportedDifferentAddChangeAtOffsetOptimization = true;
    }
  }

  private static boolean isAfter(final ASTNode what, final ASTNode afterWhat) {
    ASTNode previous = afterWhat;
    ASTNode current = previous.getTreeNext();

    while(current != null){
      if(current == what) {
        // afterWhat can be replaced during reparse and in old tree it can reference 'what' so check they are in same tree
        return what.getTreePrev() == previous;
      }
      previous = current;
      current = previous.getTreeNext();
      if(current != null && current.getTextLength() != 0) break;
    }
    return false;
  }

  private void removeChangeInternal(ASTNode child){
    myChanges.remove(child);
    for(int i = 0, n = mySortedChanges.size(); i < n; i++){
      if(child ==  mySortedChanges.get(i).getFirst()){
        mySortedChanges.remove(i);
        break;
      }
    }
  }

  private boolean checkLeaf(final ASTNode treeNext, final CharSequence charTabIndex) {
    if(!(treeNext instanceof LeafElement)) return false;
    final ChangeInfo right = myChanges.get(treeNext);
    if(right != null && right.getChangeType() == ChangeInfo.ADD){
      if(charTabIndex == treeNext.getChars()){
        removeChangeInternal(treeNext);
        return true;
      }
    }
    return false;
  }

  @Override
  @NotNull
  public TreeElement[] getAffectedChildren() {
    final TreeElement[] treeElements = new TreeElement[myChanges.size()];
    int index = 0;
    for (final Pair<ASTNode, Integer> pair : mySortedChanges) {
      treeElements[index++] = (TreeElement)pair.getFirst();
    }
    return treeElements;
  }

  @Override
  public ChangeInfo getChangeByChild(ASTNode child) {
    return myChanges.get(child);
  }

  @Override
  public int getChildOffsetInNewTree(@NotNull ASTNode child) {
    return myParent.getStartOffset() + getNewOffset(child);
  }

  @Override
  public void composite(@NotNull TreeChange treeChange) {
    final TreeChangeImpl change = (TreeChangeImpl)treeChange;
    final Set<Map.Entry<ASTNode,ChangeInfo>> entries = change.myChanges.entrySet();
    for (final Map.Entry<ASTNode, ChangeInfo> entry : entries) {
      addChange(entry.getKey(), entry.getValue());
    }
  }

  @Override
  public boolean isEmpty() {
    return false;
  }

  @Override
  public void removeChange(ASTNode beforeEqualDepth) {
    removeChangeInternal(beforeEqualDepth);
  }

  @Override
  public void add(@NotNull final TreeChange value) {
    final TreeChangeImpl impl = (TreeChangeImpl)value;
    LOG.assertTrue(impl.myParent == myParent);

    for (final Pair<ASTNode, Integer> pair : impl.mySortedChanges) {
      final ASTNode child = pair.getFirst();
      ChangeInfo change = impl.myChanges.get(child);

      if (change.getChangeType() == ChangeInfo.REMOVED) {
        final ChangeInfo oldChange = myChanges.get(child);
        if (oldChange != null) {
          switch (oldChange.getChangeType()) {
            case ChangeInfo.ADD:
              removeChangeInternal(child);
              break;
            case ChangeInfo.REPLACE:
              final ASTNode replaced = ((ReplaceChangeInfo)oldChange).getReplaced();
              removeChangeInternal(child);
              myChanges.put(replaced, ChangeInfoImpl.create(ChangeInfo.REMOVED, replaced));
              addChangeAtOffset(replaced, getOldOffset(pair.getSecond().intValue()));
              break;
            case ChangeInfo.CONTENTS_CHANGED:
              ((ChangeInfoImpl)change).setOldLength(oldChange.getOldLength());
              myChanges.put(child, change);
              break;
          }
        }
        else {
          myChanges.put(child, change);
          addChangeAtOffset(child, getOldOffset(pair.getSecond().intValue()));
        }
      }
      else if (change.getChangeType() == ChangeInfo.REPLACE) {
        ReplaceChangeInfo replaceChangeInfo = (ReplaceChangeInfo)change;
        final ASTNode replaced = replaceChangeInfo.getReplaced();
        final ChangeInfo oldChange = myChanges.get(replaced);
        if (oldChange != null) {
          switch (oldChange.getChangeType()) {
            case ChangeInfo.ADD:
              change = ChangeInfoImpl.create(ChangeInfo.ADD, child);
              break;
            case ChangeInfo.CONTENTS_CHANGED:
              ((ChangeInfoImpl)change).setOldLength(oldChange.getOldLength());
              break;
            case ChangeInfo.REPLACE:
              final ASTNode oldReplaced = ((ReplaceChangeInfo)oldChange).getReplaced();
              ReplaceChangeInfoImpl rep = new ReplaceChangeInfoImpl(child);
              rep.setReplaced(oldReplaced);
              change = rep;

              break;
          }
          removeChangeInternal(replaced);
        }
        addChange(child, change);
      }
      else {
        addChange(child, change);
      }
    }
  }

  @Override
  public int getOldLength() {
    int oldLength = ((TreeElement)myParent).getNotCachedLength();
    for (final Map.Entry<ASTNode, ChangeInfo> entry : myChanges.entrySet()) {
      final ASTNode key = entry.getKey();
      final ChangeInfo change = entry.getValue();
      final int length = ((TreeElement)key).getNotCachedLength();
      switch (change.getChangeType()) {
        case ChangeInfo.ADD:
          oldLength -= length;
          break;
        case ChangeInfo.REMOVED:
          oldLength += length;
          break;
        case ChangeInfo.REPLACE:
        case ChangeInfo.CONTENTS_CHANGED:
          oldLength += change.getOldLength() - length;
          break;
      }
    }
    return oldLength;
  }

  private static int getNewLength(ChangeInfo change, ASTNode node){
    if(change.getChangeType() == ChangeInfo.REMOVED) return 0;
    return node.getTextLength();
  }

  private static final int haveNotCalculated = -1;

  private static boolean ourReportedDifferentOptimizedNodeOldOffset = false;

  private int getOptimizedNodeOldOffset(ASTNode child, ChangeInfo changeInfo) {
    // we usually add / remove ranges so old offset can be tried to calculate from change with previous sibling
    ASTNode prevSibling = child.getTreePrev();
    if (prevSibling != null) {
      if (mySortedChanges.size() > 0) {
        Pair<ASTNode, Integer> pair = mySortedChanges.get(mySortedChanges.size() - 1);

        if (pair.getFirst() == prevSibling) {
          ChangeInfo prevSiblingChange = myChanges.get(prevSibling);
          if ((prevSiblingChange.getChangeType() == ChangeInfo.REMOVED &&
               changeInfo.getChangeType() == ChangeInfo.REMOVED
              ) ||
              (prevSiblingChange.getChangeType() == ChangeInfo.ADD &&
               changeInfo.getChangeType() == ChangeInfo.ADD
              )
             ) {
            int optimizedResult = pair.getSecond() + prevSiblingChange.getOldLength();
            if (ourDoChecks && !ourReportedDifferentOptimizedNodeOldOffset) {
              int oldOffset = calculateOldOffsetLinearly(child);
              if (optimizedResult != oldOffset) {
                LOG.error("Failed optimized node old offset check:"+changeInfo + ", previous:" + prevSibling + "," + prevSiblingChange);
                ourReportedDifferentOptimizedNodeOldOffset = true;
                optimizedResult = oldOffset;
              }
            }
            return optimizedResult;
          }
        }
      }
    }
    return haveNotCalculated;
  }

  private int getNodeOldOffset(ASTNode child, ChangeInfo changeInfo){
    LOG.assertTrue(child.getTreeParent() == myParent);

    int oldOffsetInParent = getOptimizedNodeOldOffset(child, changeInfo);

    if (oldOffsetInParent == haveNotCalculated) {
      oldOffsetInParent = calculateOldOffsetLinearly(child);
    }

    return oldOffsetInParent;
  }

  private int calculateOldOffsetLinearly(ASTNode child) {
    int oldOffsetInParent = 0;
    // find last changed element before child
    ASTNode current = myParent.getFirstChildNode();
    // calculate not changed elements
    while(current != child) {
      if (!myChanges.containsKey(current)) {
        oldOffsetInParent += current.getTextLength();
      }
      current = current.getTreeNext();
    }

    for (Pair<ASTNode, Integer> offset : mySortedChanges) {
      if(offset.getSecond() > oldOffsetInParent) break;

      final ChangeInfo change = myChanges.get(offset.getFirst());
      oldOffsetInParent += change.getOldLength();
    }

    return oldOffsetInParent;
  }

  private int getOldOffset(int offset){
    for (Pair<ASTNode, Integer> pair : mySortedChanges) {
      if(pair.getSecond() > offset) break;

      final ChangeInfo change = myChanges.get(pair.getFirst());
      offset += change.getOldLength() - getNewLength(change, pair.getFirst());
    }

    return offset;
  }

  private int myLastOffsetInNewTree;
  private ASTNode myLastNode;
  private static boolean ourReportedDifferentEnableGetNewOffset = false;

  private int getNewOffset(ASTNode node){
    int optimizedResult = haveNotCalculated;

    ASTNode prev = node.getTreePrev();
    if (myLastNode == prev) {
      ChangeInfo prevChangeInfo = myChanges.get(prev);
      ChangeInfo changeInfo = myChanges.get(node);

      // newoffset of removed element is the same of removed previous sibling
      if (prevChangeInfo != null &&
          changeInfo != null &&
          prevChangeInfo.getChangeType() == ChangeInfo.REMOVED &&
          changeInfo.getChangeType() == ChangeInfo.REMOVED
         ) {
        optimizedResult = myLastOffsetInNewTree;

        myLastNode = node;
        myLastOffsetInNewTree = optimizedResult;
        if (!ourDoChecks) return optimizedResult;
      }
    }

    int currentOffsetInNewTree = 0;
    try {
      ASTNode current = myParent.getFirstChildNode();
      int i = 0;
      Pair<ASTNode, Integer> currentChange = i < mySortedChanges.size() ? mySortedChanges.get(i) : null;
      int currentOldOffset = 0;

      while(current != null) {
        boolean counted = false;

        while(currentChange != null && currentOldOffset == currentChange.getSecond().intValue()){
          if(currentChange.getFirst() == node) {
            myLastNode = node;
            myLastOffsetInNewTree = currentOffsetInNewTree;
            return currentOffsetInNewTree;
          }
          if(current == currentChange.getFirst()){
            final int textLength = current.getTextLength();
            counted = true;
            current = current.getTreeNext();
            currentOffsetInNewTree += textLength;
          }
          final ChangeInfo changeInfo = myChanges.get(currentChange.getFirst());
          currentOldOffset += changeInfo.getOldLength();
          ++i;
          currentChange = i < mySortedChanges.size() ? mySortedChanges.get(i) : null;
        }

        if(current == null) break;

        if(!counted){
          final int textLength = current.getTextLength();
          currentOldOffset += textLength;
          current = current.getTreeNext();
          currentOffsetInNewTree += textLength;
        }
      }
    }
    finally {
      if (optimizedResult != haveNotCalculated &&
          optimizedResult != currentOffsetInNewTree &&
          !ourReportedDifferentEnableGetNewOffset
        ) {
        LOG.error("Failed to calculate optimized getNewOffset:"+myChanges.get(node) + "," + prev + "," + myChanges.get(prev));
        ourReportedDifferentEnableGetNewOffset = true;
        currentOffsetInNewTree = optimizedResult; // always use optimized result
      }
    }

    return currentOffsetInNewTree;
  }

  @SuppressWarnings({"HardCodedStringLiteral"})
  public String toString(){
    final StringBuilder buffer = new StringBuilder();
    final Iterator<Pair<ASTNode, Integer>> iterator = mySortedChanges.iterator();
    while (iterator.hasNext()) {
      final Pair<ASTNode, Integer> pair = iterator.next();
      final ASTNode node = pair.getFirst();
      buffer.append("(");
      buffer.append(node.getElementType().toString());
      buffer.append(" at ").append(pair.getSecond()).append(", ");
      ChangeInfo child = getChangeByChild(node);
      buffer.append(child != null ? child.toString():"null");
      buffer.append(")");
      if(iterator.hasNext()) buffer.append(", ");
    }
    return buffer.toString();
  }
}