text:
<?xml version="1.0"?>

<?dlps id="CheMire"?>
<?dlps page-images="none" figure-images="no"?>
<?dlps transcription="other"?>

<!DOCTYPE TEI.2 SYSTEM "http://text.lib.virginia.edu/dtd/tei/tei-p4/tei2.dtd" [
<!ENTITY % POSTKB "INCLUDE">
<!ENTITY % TEI.extensions.ent SYSTEM "http://text.lib.virginia.edu/dtd/tei/uva-dl-tei/uva-dl-tei.ent">
<!ENTITY % TEI.extensions.dtd SYSTEM "http://text.lib.virginia.edu/dtd/tei/uva-dl-tei/uva-dl-tei.dtd">
<!ENTITY % ISOnum SYSTEM "http://text.lib.virginia.edu/charent/iso-num.ent"> %ISOnum;
<!ENTITY % ISOlat1 SYSTEM "http://text.lib.virginia.edu/charent/iso-lat1.ent"> %ISOlat1;
<!ENTITY % ISOlat2 SYSTEM "http://text.lib.virginia.edu/charent/iso-lat2.ent"> %ISOlat2;
<!ENTITY % ISOpub SYSTEM "http://text.lib.virginia.edu/charent/iso-pub.ent"> %ISOpub;

]>

<TEI.2 id="CheMire">
<teiHeader type="migrated" creator="Etext">
<fileDesc>
<titleStmt>
<title type="main">Mire</title>
<title type="sort">mire</title>
<author>Chekhov, Anton</author>
<respStmt>
<resp>Creation of machine-readable version:</resp>
<name>Judy Boss</name>
<resp>Creation of digital images:</resp>
<name/>
<resp>Conversion to TEI.2-conformant markup:</resp>
<name>University of Virginia Library Electronic Text Center.</name>
</respStmt>
</titleStmt>
<extent>ca. <num type="kilobytes">45</num> kilobytes</extent>
<publicationStmt>
<publisher>University of Virginia Library</publisher>
<pubPlace>Charlottesville, Virginia</pubPlace>
<idno type="ETC">CheMire</idno>
<date value="1997">1997</date>
<availability status="public">

Copyright © 1997 by the Rector and Visitors of the University of Virginia

Publicly accessible

</availability>
<idno type="uva-pid">uva-lib:475808</idno>
</publicationStmt>
<seriesStmt>
<title>University of Virginia Library, Text collection</title>
<idno type="uva-set">UVA-LIB-Text</idno>
</seriesStmt>
<sourceDesc>
<biblFull>
<titleStmt>
<title type="main">Mire</title>
<title level="m">The Dual and Other Stories</title>
<title type="sort">mire</title>
<author>Anton Chekhov</author>
<respStmt>
<resp>Translator</resp>
<name>Constance Garnett</name>
</respStmt>
</titleStmt>
<extent>pp. 195-224</extent>
<publicationStmt>
<publisher>MacMillan Company</publisher>
<pubPlace>New York</pubPlace>
<date value="1916">1916</date>
<idno type="callNo">Print copy consulted: UVa library, Call No: PG 3456.A15G3 1984 V.2</idno>
</publicationStmt>
</biblFull>
</sourceDesc>
</fileDesc>
<encodingDesc>
<projectDesc>

Prepared for the University of Virginia Library Electronic Text Center.

</projectDesc>
<editorialDecl>

All quotation marks retained as data.

All unambiguous end-of-line hyphens have been removed, and the trailing part of a word has been joined to the preceding line.

The images exist as archived TIFF images, one or more JPEG versions for general use, and thumbnail GIFs.

Keywords in the header are a local Electronic Text Center scheme to aid in establishing analytical groupings.

</editorialDecl>
</encodingDesc>
<profileDesc>
<creation>
<date value="1916">1916</date>
</creation>
<langUsage>
<language id="eng" usage="main">English</language>
<language id="fr">French</language>
</langUsage>
<textClass>
<keywords>
<term>prose; fiction</term>
<term>Literature in Translation</term>
</keywords>
</textClass>
</profileDesc>
<revisionDesc>
<change>
<date value="1997-08">August, 1997</date>
<respStmt>
<resp>corrector</resp>
<name>Carolyn Fay</name>
</respStmt>
<item>Added TEI header and tags.</item>
</change>
<change>
<date value="2005-06">June 2005</date>
<respStmt>
<resp>corrector</resp>
<name>John Ivor Carlson</name>
</respStmt>
<item>Converted sgml to xml.</item>
</change>
<change>
<date value="2007-09">September 2007</date>
<respStmt>
<resp>Migration</resp>
<name>Ethan Gruber, University of Virginia Library</name>
</respStmt>
<item>Converted XML markup from TEI Lite to uva-dl-tei (TEI P4 with local customizations).</item>
</change>
<change>
<date value="2008-01">January 2008</date>
<respStmt>
<resp>Migration</resp>
<name>Greg Murray, University of Virginia Library</name>
</respStmt>
<item>Programmatically updated TEI header markup (but not header content) for minimal compliance with current QA requirements.</item>
</change>
</revisionDesc>
</teiHeader>

<text id="d1">

<div1 type="section" n="1" id="d3"> <pb n="195"/>
MIRE <lb/> I

GRACEFULLY swaying in the saddle, a young man wearing the snow-white
tunic of an officer rode into the great yard of the vodka distillery
belonging to the heirs of M. E. Rothstein.  The sun smiled carelessly on
the lieutenant's little stars, on the white trunks of the birch-trees,
on the heaps of broken glass scattered here and there in the yard.  The
radiant, vigorous beauty of a summer day lay over everything, and
nothing hindered the snappy young green leaves from dancing gaily and
winking at the clear blue sky.  Even the dirty and soot-begrimed
appearance of the bricksheds and the stifling fumes of the distillery
did not spoil the general good impression.  The lieutenant sprang gaily
out of the saddle, handed over his horse to a man who ran up, and
stroking with his finger his delicate black moustaches, went in at the
front door.  On the top step of the old but light and softly carpeted
staircase he was met by a maidservant with a haughty, not very youthful
face.  The lieutenant gave her his card without speaking.

As she went through the rooms with the card,
the maid could see on it the name "Alexandr Grigoryevitch

   <pb n="196"/>

Sokolsky."  A minute later she came back and told the
lieutenant that her mistress could not see him, as she was not feeling
quite well.  Sokolsky looked at the ceiling and thrust out his lower
lip.

"How vexatious!" he said.  "Listen, my dear," he said eagerly.
"Go and tell Susanna Moiseyevna, that it is very necessary for me to
speak to her — very.  I will only keep her one minute.  Ask her to
excuse me."

The maid shrugged one shoulder and went off
languidly to her mistress.

"Very well!" she sighed, returning after a brief
interval.  "Please walk in!"

The lieutenant went with her through five or six
large, luxuriously furnished rooms and a corridor,
and finally found himself in a large and lofty square
room, in which from the first step he was impressed
by the abundance of flowers and plants and the sweet,
almost revoltingly heavy fragrance of jasmine.
Flowers were trained to trellis-work along the walls,
screening the windows, hung from the ceiling, and
were wreathed over the corners, so that the room
was more like a greenhouse than a place to live in.
Tits, canaries, and goldfinches chirruped among the
green leaves and fluttered against the window-panes.

"Forgive me for receiving you here," the lieutenant heard in a
mellow feminine voice with a burr on the letter <hi rend="italic">r</hi> which was not
without charm.  "Yesterday I had a sick headache, and I'm trying to keep

   <pb n="197"/>

still to prevent its coming on again.  What do you
want?"

Exactly opposite the entrance, he saw sitting in
a big low chair, such as old men use, a woman in
an expensive Chinese dressing-gown, with her head
wrapped up, leaning back on a pillow.  Nothing
could be seen behind the woollen shawl in which she
was muffled but a pale, long, pointed, somewhat
aquiline nose, and one large dark eye.  Her ample
dressing-gown concealed her figure, but judging
from her beautiful hand, from her voice, her nose,
and her eye, she might be twenty-six or twenty-eight.

"Forgive me for being so persistent . . ." began
the lieutenant, clinking his spurs.  "Allow me to
introduce myself: Sokolsky!  I come with a message from my cousin, your neighbour, Alexey Ivanovitch Kryukov, who . . ."

"I know!" interposed Susanna Moiseyevna.  "I
know Kryukov.  Sit down; I don't like anything big
standing before me."

"My cousin charges me to ask you a favour," the lieutenant went
on, clinking his spurs once more and sitting down.  "The fact is, your
late father made a purchase of oats from my cousin last winter, and a
small sum was left owing.  The payment only becomes due next week, but
my cousin begs you most particularly to pay him — if possible, to-day."

As the lieutenant talked, he stole side-glances
about him.

"Surely I'm not in her bedroom?" he thought.

   <pb n="198"/>

In one corner of the room, where the foliage was thickest and
tallest, under a pink awning like a funeral canopy, stood a bed not yet
made, with the bed-clothes still in disorder.  Close by on two
arm-chairs lay heaps of crumpled feminine garments.  Petticoats and
sleeves with rumpled lace and flounces were trailing on the carpet, on
which here and there lay bits of white tape, cigarette-ends, and the
papers of caramels. . . .  Under the bed the toes, pointed and square,
of slippers of all kinds peeped out in a long row.  And it seemed to the
lieutenant that the scent of the jasmine came not from the flowers, but
from the bed and the slippers.

"And what is the sum owing?" asked Susanna
Moiseyevna.

"Two thousand three hundred."

"Oho!" said the Jewess, showing another large black eye.  "And
you call that — a small sum!  However, it's just the same paying it
to-day or paying it in a week, but I've had so many payments to make in
the last two months since my father's death. . . .  Such a lot of stupid
business, it makes my head go round!  A nice idea!  I want to go abroad,
and they keep forcing me to attend to these silly things.  Vodka, oats .
. ." she muttered, half closing her eyes, "oats, bills, percentages, or,
as my head-clerk says, 'percentage.' . . .  It's awful.  Yesterday I
simply turned the excise officer out.  He pesters me with his Tralles.
I said to him: 'Go to the devil with your Tralles!  I can't see any
one!'

   <pb n="199"/>

He kissed my hand and went away.  I tell you what:
can't your cousin wait two or three months?"

"A cruel question!" laughed the lieutenant.  "My cousin can wait
a year, but it's I who cannot wait!  You see, it's on my own account I'm
acting, I ought to tell you.  At all costs I must have money, and by
ill-luck my cousin hasn't a rouble to spare.  I'm forced to ride about
and collect debts.  I've just been to see a peasant, our tenant; here
I'm now calling on you; from here I shall go on to somewhere else, and
keep on like that until I get together five thousand roubles.  I need
money awfully!"

"Nonsense!  What does a young man want with
money?  Whims, mischief.  Why, have you been
going in for dissipation?  Or losing at cards?  Or
are you getting married?"

"You've guessed!" laughed the lieutenant, and
rising slightly from his seat, he clinked his spurs.
"I really am going to be married."

Susanna Moiseyevna looked intently at her visitor,
made a wry face, and sighed.

"I can't make out what possesses people to get married!" she
said, looking about her for her pocket-handkerchief.  "Life is so short,
one has so little freedom, and they must put chains on themselves!"

"Every one has his own way of looking at
things. . . ."

"Yes, yes, of course; every one has his own way
of looking at things. . . .  But, I say, are you really

   <pb n="200"/>

going to marry some one poor?  Are you passionately in love?  And why
must you have five thousand?  Why won't four do, or three?"

"What a tongue she has!" thought the lieutenant, and answered:
"The difficulty is that an officer is not allowed by law to marry till
he is twenty-eight; if you choose to marry, you have to leave the
Service or else pay a deposit of five thousand."

"Ah, now I understand.  Listen.  You said just now that every one
has his own way of looking at things. . . .  Perhaps your fiancée
is some one special and remarkable, but . . . but I am utterly unable to
understand how any decent man can live with a woman.  I can't for the
life of me understand it.  I have lived, thank the Lord, twenty-seven
years, and I have never yet seen an endurable woman.  They're all
affected minxes, immoral, liars. . . .  The only ones I can put up with
are cooks and house-maids, but so-called ladies I won't let come within
shooting distance of me.  But, thank God, they hate me and don't force
themselves on me!  If one of them wants money she sends her husband, but
nothing will induce her to come herself, not from pride — no, but from
cowardice; she's afraid of my making a scene.  Oh, I understand their
hatred very well!  Rather!  I openly display what they do their very
utmost to conceal from God and man.  How can they help hating me?  No
doubt you've heard bushels of scandal about me already. . . ."

"I only arrived here so lately . . ."

   <pb n="201"/>

"Tut, tut, tut! . . .  I see from your eyes!  But
your brother's wife, surely she primed you for this
expedition?  Think of letting a young man come to
see such an awful woman without warning him —
how could she?  Ha, ha! . . .  But tell me, how is
your brother?  He's a fine fellow, such a handsome
man! . . .  I've seen him several times at mass.
Why do you look at me like that?  I very often go
to church!  We all have the same God.  To an
educated person externals matter less than the idea.
. . .  That's so, isn't it?"

"Yes, of course . . ." smiled the lieutenant.

"Yes, the idea. . . .  But you are not a bit like your brother.
You are handsome, too, but your brother is a great deal better-looking.
There's wonderfully little likeness!"

"That's quite natural; he's not my brother, but
my cousin."

"Ah, to be sure!  So you must have the money
to-day?  Why to-day?"

"My furlough is over in a few days."

"Well, what's to be done with you!" sighed Susanna Moiseyevna.
"So be it.  I'll give you the money, though I know you'll abuse me for
it afterwards.  You'll quarrel with your wife after you are married, and
say: 'If that mangy Jewess hadn't given me the money, I should perhaps
have been as free as a bird to-day!"  Is your fiancée pretty?"

"Oh yes. . . ."

"H'm! . . .  Anyway, better something, if it's

   <pb n="202"/>

only beauty, than nothing.  Though however beautiful a woman is, it can
never make up to her husband for her silliness."

"That's original!" laughed the lieutenant.
"You are a woman yourself, and such a woman-hater!"

"A woman . . ." smiled Susanna.  "It's not my fault that God has
cast me into this mould, is it?  I'm no more to blame for it than you
are for having moustaches.  The violin is not responsible for the choice
of its case.  I am very fond of myself, but when any one reminds me that
I am a woman, I begin to hate myself.  Well, you can go away, and I'll
dress.  Wait for me in the drawing-room."

The lieutenant went out, and the first thing he did
was to draw a deep breath, to get rid of the heavy
scent of jasmine, which had begun to irritate his
throat and to make him feel giddy.

"What a strange woman!" he thought, looking
about him.  "She talks fluently, but . . . far too
much, and too freely.  She must be neurotic."

The drawing-room, in which he was standing now, was richly
furnished, and had pretensions to luxury and style.  There were dark
bronze dishes with patterns in relief, views of Nice and the Rhine on
the tables, old-fashioned sconces, Japanese statuettes, but all this
striving after luxury and style only emphasised the lack of taste which
was glaringly apparent in the gilt cornices, the gaudy wall-paper, the
bright velvet table-cloths, the common oleographs in

   <pb n="203"/>

heavy frames.  The bad taste of the general effect
was the more complete from the lack of finish and
the overcrowding of the room, which gave one a
feeling that something was lacking, and that a great
deal should have been thrown away.  It was evident
that the furniture had not been bought all at once,
but had been picked up at auctions and other favourable opportunities.

Heaven knows what taste the lieutenant could boast of, but even
he noticed one characteristic peculiarity about the whole place, which
no luxury or style could efface — a complete absence of all trace of
womanly, careful hands, which, as we all know, give a warmth, poetry,
and snugness to the furnishing of a room.  There was a chilliness about
it such as one finds in waiting-rooms at stations, in clubs, and foyers
at the theatres.

There was scarcely anything in the room definitely Jewish,
except, perhaps, a big picture of the meeting of Jacob and Esau.  The
lieutenant looked round about him, and, shrugging his shoulders, thought
of his strange, new acquaintance, of her free-and-easy manners, and her
way of talking.  But then the door opened, and in the doorway appeared
the lady herself, in a long black dress, so slim and tightly laced that
her figure looked as though it had been turned in a lathe.  Now the
lieutenant saw not only the nose and eyes, but also a thin white face, a
head black and as curly as lamb's-wool.  She did not attract him, though
she did not strike him as

   <pb n="204"/>

ugly.  He had a prejudice against un-Russian faces
in general, and he considered, too, that the lady's
white face, the whiteness of which for some reason
suggested the cloying scent of jasmine, did not go
well with her little black curls and thick eyebrows;
that her nose and ears were astoundingly white, as
though they belonged to a corpse, or had been
moulded out of transparent wax.  When she smiled
she showed pale gums as well as her teeth, and he
did not like that either.

"Anæmic debility . . ." he thought; "she's probably as
nervous as a turkey."

"Here I am!  Come along!" she said, going on
rapidly ahead of him and pulling off the yellow
leaves from the plants as she passed.

"I'll give you the money directly, and if you like I'll give you
some lunch.  Two thousand three hundred roubles!  After such a good
stroke of business you'll have an appetite for your lunch.  Do you like
my rooms?  The ladies about here declare that my rooms always smell of
garlic.  With that culinary gibe their stock of wit is exhausted.  I
hasten to assure you that I've no garlic even in the cellar.  And one
day when a doctor came to see me who smelt of garlic, I asked him to
take his hat and go and spread his fragrance elsewhere.  There is no
smell of garlic here, but the place does smell of drugs.  My father lay
paralyzed for a year and a half, and the whole house smelt of medicine.
A year and a

   <pb n="205"/>

half!  I was sorry to lose him, but I'm glad he's
dead: he suffered so!"

She led the officer through two rooms similar to
the drawing-room, through a large reception hall,
and came to a stop in her study, where there was a
lady's writing-table covered with little knick-knacks.
On the carpet near it several books lay strewn about,
opened and folded back.  Through a small door
leading from the study he saw a table laid for lunch.

Still chatting, Susanna took out of her pocket a
bunch of little keys and unlocked an ingeniously
made cupboard with a curved, sloping lid.  When
the lid was raised the cupboard emitted a plaintive
note which made the lieutenant think of an Æolian
harp.  Susanna picked out another key and clicked
another lock.

"I have underground passages here and secret doors," she said,
taking out a small morocco portfolio.  "It's a funny cupboard, isn't it?
And in this portfolio I have a quarter of my fortune.  Look how podgy it
is!  You won't strangle me, will you?"

Susanna raised her eyes to the lieutenant and
laughed good-naturedly.  The lieutenant laughed
too.

"She's rather jolly," he thought, watching the
keys flashing between her fingers.

"Here it is," she said, picking out the key of the
portfolio.  "Now, Mr. Creditor, trot out the IOU.

   <pb n="206"/>

What a silly thing money is really!  How paltry it is, and yet how women
love it!  I am a Jewess, you know, to the marrow of my bones.  I am
passionately fond of Shmuls and Yankels, but how I loathe that passion
for gain in our Semitic blood.  They hoard and they don't know what they
are hoarding for.  One ought to live and enjoy oneself, but they're
afraid of spending an extra farthing.  In that way I am more like a
hussar than a Shmul.  I don't like money to be kept long in one place.
And altogether I fancy I'm not much like a Jewess.  Does my accent give
me away much, eh?"

"What shall I say?" mumbled the lieutenant.
"You speak good Russian, but you do roll your <hi rend="italic">r</hi>s."

Susanna laughed and put the little key in the lock
of the portfolio.  The lieutenant took out of his
pocket a little roll of IOUs and laid them with a
notebook on the table.

"Nothing betrays a Jew as much as his accent,"
Susanna went on, looking gaily at the lieutenant.
"However much he twists himself into a Russian or
a Frenchman, ask him to say 'feather' and he will
say 'fedder' . . . but I pronounce it correctly:
'Feather! feather! feather!'"

Both laughed.

"By Jove, she's very jolly!" thought Sokolsky.

Susanna put the portfolio on a chair, took a step
towards the lieutenant, and bringing her face close
to his, went on gaily:

"Next to the Jews I love no people so much as

   <pb n="207"/>

the Russian and the French.  I did not do much at school and I know no
history, but it seems to me that the fate of the world lies in the hands
of those two nations.  I lived a long time abroad. . . .  I spent six
months in Madrid. . . .  I've gazed my fill at the public, and the
conclusion I've come to is that there are no decent peoples except the
Russian and the French.  Take the languages, for instance.
. . .  The German language is like the neighing
of horses; as for the English . . . you can't imagine anything stupider.
Fight — feet — foot!  Italian is only pleasant when they speak it
slowly.  If you listen to Italians gabbling, you get the effect of the
Jewish jargon.  And the Poles?  Mercy on us!  There's no language so
disgusting!  'Nie pieprz, Pietrze, pieprzem wieprza bo možeoz
prze-pieprzyé wieprza pieprzem.'  That means: 'Don't pepper a
sucking pig with pepper, Pyotr, or perhaps you'll over-pepper the
sucking pig with pepper.'  Ha, ha, ha!"

Susanna Moiseyevna rolled her eyes and broke into such a
pleasant, infectious laugh that the lieutenant, looking at her, went off
into a loud and merry peal of laughter.  She took the visitor by the
button, and went on:

"You don't like Jews, of course . . . they've
many faults, like all nations.  I don't dispute that.
But are the Jews to blame for it?  No, it's not the
Jews who are to blame, but the Jewish women!
They are narrow-minded, greedy; there's no sort of

   <pb n="208"/>

poetry about them, they're dull. . . .  You have never lived with a
Jewess, so you don't know how charming it is!"  Susanna Moiseyevna
pronounced the last words with deliberate emphasis and with no eagerness
or laughter.  She paused as though frightened at her own openness, and
her face was suddenly distorted in a strange, unaccountable way.  Her
eyes stared at the lieutenant without blinking, her lips parted and
showed clenched teeth.  Her whole face, her throat, and even her bosom,
seemed quivering with a spiteful, catlike expression.  Still keeping her
eyes fixed on her visitor, she rapidly bent to one side, and swiftly,
like a cat, snatched something from the table.  All this was the work of
a few seconds.  Watching her movements, the lieutenant saw five fingers
crumple up his IOUs and caught a glimpse of the white rustling paper as
it disappeared in her clenched fist.  Such an extraordinary transition
from good-natured laughter to crime so appalled him that he turned pale
and stepped back. . . .

And she, still keeping her frightened, searching eyes upon him,
felt along her hip with her clenched fist for her pocket.  Her fist
struggled convulsively for the pocket, like a fish in the net, and could
not find the opening.  In another moment the IOUs would have vanished in
the recesses of her feminine garments, but at that point the lieutenant
uttered a faint cry, and, moved more by instinct than reflection, seized
the Jewess by her arm above the

   <pb n="209"/>

clenched fist.  Showing her teeth more than ever,
she struggled with all her might and pulled her hand
away.  Then Sokolsky put his right arm firmly
round her waist, and the other round her chest and
a struggle followed.  Afraid of outraging her sex
or hurting her, he tried only to prevent her moving, and to get hold of the fist with the IOUs; but
she wriggled like an eel in his arms with her supple,
flexible body, struck him in the chest with her elbows,
and scratched him, so that he could not help touching her all over, and was forced to hurt her and disregard her modesty.

"How unusual this is!  How strange! he
thought, utterly amazed, hardly able to believe his
senses, and feeling rather sick from the scent of
jasmine.

In silence, breathing heavily, stumbling against the furniture,
they moved about the room.  Susanna was carried away by the struggle.
She flushed, closed her eyes, and forgetting herself, once even pressed
her face against the face of the lieutenant, so that there was a
sweetish taste left on his lips.  At last he caught hold of her clenched
hand. . . .  Forcing it open, and not finding the papers in it, he let
go the Jewess.  With flushed faces and dishevelled hair, they looked at
one another, breathing hard.  The spiteful, catlike expression on the
Jewess's face was gradually replaced by a good-natured smile.  She burst
out laughing, and turning on one foot, went towards the room where lunch
was ready.

   <pb n="210"/>

The lieutenant moved slowly after her.  She sat
down to the table, and, still flushed and breathing
hard, tossed off half a glass of port.

"Listen" — the lieutenant broke the silence —
"I hope you are joking?"

"Not a bit of it," she answered, thrusting a piece
of bread into her mouth.

"H'm! . . .  How do you wish me to take all
this?"

"As you choose.  Sit down and have lunch!"

"But . . . it's dishonest!"

"Perhaps.  But don't trouble to give me a sermon; I have my own
way of looking at things."

"Won't you give them back?"

"Of course not!  If you were a poor unfortunate man, with nothing
to eat, then it would be a different matter.  But — he wants to get
married!"

"It's not my money, you know; it's my cousin's!"

"And what does your cousin want with money?  To get fashionable
clothes for his wife?  But I really don't care whether your
<hi rend="italic"><foreign lang="fr">belle-sœur</foreign></hi> has dresses or not."

The lieutenant had ceased to remember that he was in a strange
house with an unknown lady, and did not trouble himself with decorum.
He strode up and down the room, scowled and nervously fingered his
waistcoat.  The fact that the Jewess had lowered herself in his eyes by
her dishonest action, made him feel bolder and more free-and-easy.

"The devil knows what to make of it!" he

   <pb n="211"/>

muttered.  "Listen.  I shan't go away from here
until I get the IOUs."

"Ah, so much the better," laughed Susanna.
"If you stay here for good, it will make it livelier
for me."

Excited by the struggle, the lieutenant looked at Susanna's
laughing, insolent face, at her munching mouth, at her heaving bosom,
and grew bolder and more audacious.  Instead of thinking about the IOU
he began for some reason recalling with a sort of relish his cousin's
stories of the Jewess's romantic adventures, of her free way of life,
and these reminiscences only provoked him to greater audacity.
Impulsively he sat down beside the Jewess and thinking no more of the
IOUs began to eat. . . .

"Will you have vodka or wine?" Susanna asked
with a laugh.  "So you will stay till you get the
IOUs?  Poor fellow!  How many days and nights
you will have to spend with me, waiting for those
IOUs!  Won't your fiancée have something to say
about it?"

</div1><div1 type="section" n="2" id="d4">
II

Five hours had passed.  The lieutenant's cousin,
Alexey Ivanovitch Kryukov was walking about the
rooms of his country-house in his dressing-gown and
slippers, and looking impatiently out of window.
He was a tall, sturdy man, with a large black beard
and a manly face; and as the Jewess had truly said,

   <pb n="212"/>

he was handsome, though he had reached the age when men are apt to grow
too stout, puffy, and bald.  By mind and temperament he was one of those
natures in which the Russian intellectual classes are so rich:
warm-hearted, good-natured, well-bred, having some knowledge of the arts
and sciences, some faith, and the most chivalrous notions about honour,
but indolent and lacking in depth.  He was fond of good eating and
drinking, was an ideal whist-player, was a connoisseur in women and
horses, but in other things he was apathetic and sluggish as a seal, and
to rouse him from his lethargy something extraordinary and quite
revolting was needed, and then he would forget everything in the world
and display intense activity; he would fume and talk of a duel, write a
petition of seven pages to a Minister, gallop at breakneck speed about
the district, call some one publicly "a scoundrel," would go to law, and
so on.

"How is it our Sasha's not back yet?" he kept
asking his wife, glancing out of window.  "Why,
it's dinner-time!"

After waiting for the lieutenant till six o'clock,
they sat down to dinner.  When supper-time came,
however, Alexey Ivanovitch was listening to every
footstep, to every sound of the door, and kept shrugging his shoulders.

"Strange!" he said.  "The rascally dandy must
have stayed on at the tenant's."

As he went to bed after supper, Kryukov made

   <pb n="213"/>

up his mind that the lieutenant was being entertained
at the tenant's, where after a festive evening he
was staying the night.

Alexandr Grigoryevitch only returned next morning.  He looked
extremely crumpled and confused.

"I want to speak to you alone . . ." he said
mysteriously to his cousin.

They went into the study.  The lieutenant shut
the door, and he paced for a long time up and down
before he began to speak.

"Something's happened, my dear fellow," he began, "that I don't
know how to tell you about.  You wouldn't believe it . . ."

And blushing, faltering, not looking at his cousin, he told what
had happened with the IOUs.  Kryukov, standing with his feet wide apart
and his head bent, listened and frowned.

"Are you joking?" he asked.

"How the devil could I be joking?  It's no joking matter!"

"I don't understand!" muttered Kryukov, turning crimson and
flinging up his hands.  "It's positively . . . immoral on your part.
Before your very eyes a hussy is up to the devil knows what, a serious
crime, plays a nasty trick, and you go and kiss her!"

"But I can't understand myself how it happened!" whispered the
lieutenant, blinking guiltily.  "Upon my honour, I don't understand it!
It's the first time in my life I've come across such a monster!

   <pb n="214"/>

It's not her beauty that does for you, not her mind,
but that . . . you understand . . . insolence, cynicism. . . ."

"Insolence, cynicism . . . it's unclean!  If
you've such a longing for insolence and cynicism, you
might have picked a sow out of the mire and have
devoured her alive.  It would have been cheaper,
anyway!  Instead of two thousand three hundred!"

"You do express yourself elegantly!" said the
lieutenant, frowning.  "I'll pay you back the two
thousand three hundred!"

"I know you'll pay it back, but it's not a question of money!
Damn the money!  What revolts me is your being such a limp rag . . .
such filthy feebleness!  And engaged!  With a fiancée!"

"Don't speak of it . . ." said the lieutenant,
blushing.  "I loathe myself as it is.  I should like
to sink into the earth.  It's sickening and vexatious
that I shall have to bother my aunt for that five thousand. . . ."

Kryukov continued for some time longer expressing his indignation
and grumbling, then, as he grew calmer, he sat down on the sofa and
began to jeer at his cousin.

"You young officers!" he said with contemptuous irony.  "Nice
bridegrooms."

Suddenly he leapt up as though he had been stung,
stamped his foot, and ran about the study.

"No, I'm not going to leave it like that!" he
said, shaking his fist.  "I will have those IOUs, I

   <pb n="215"/>

will!  I'll give it her!  One doesn't beat women,
but I'll break every bone in her body. . . .  I'll
pound her to a jelly!  I'm not a lieutenant!  You
won't touch me with insolence or cynicism!  No-o-o,
damn her!  Mishka!" he shouted, "run and tell
them to get the racing droshky out for me!"

Kryukov dressed rapidly, and, without heeding the agitated
lieutenant, got into the droshky, and with a wave of his hand resolutely
raced off to Susanna Moiseyevna.  For a long time the lieutenant gazed
out of window at the clouds of dust that rolled after his cousin's
droshky, stretched, yawned, and went to his own room.  A quarter of an
hour later he was sound asleep.

At six o'clock he was waked up and summoned
to dinner.

"How nice this is of Alexey!" his cousin's wife
greeted him in the dining-room.  "He keeps us
waiting for dinner."

"Do you mean to say he's not come back yet?"
yawned the lieutenant.  "H'm! . . . he's probably
gone round to see the tenant."

But Alexey Ivanovitch was not back by supper
either.  His wife and Sokolsky decided that he was
playing cards at the tenant's and would most likely
stay the night there.  What had happened was not
what they had supposed, however.

Kryukov returned next morning, and without
greeting any one, without a word, dashed into his
study.

   <pb n="216"/>

"Well?" whispered the lieutenant, gazing at him
round-eyed.

Kryukov waved his hand and gave a snort.

"Why, what's the matter?  What are you laughing at?"

Kryukov flopped on the sofa, thrust his head in
the pillow, and shook with suppressed laughter.  A
minute later he got up, and looking at the surprised
lieutenant, with his eyes full of tears from laughing,
said:

"Close the door.  Well . . . she <hi rend="italic">is</hi> a fe-e-male,
I beg to inform you!"

"Did you get the IOUs?"

Kryukov waved his hand and went off into a peal
of laughter again.

"Well! she is a female!" he went on.
<hi rend="italic">"<foreign lang="fr">Merci</foreign></hi> for the
acquaintance, my boy!  She's a devil in petticoats.  I arrived; I walked
in like such an avenging Jove, you know, that I felt almost afraid of
myself. . . .  I frowned, I scowled, even clenched my fists to be more
awe-inspiring. . . .  'Jokes don't pay with me, madam!' said I, and more
in that style.  And I threatened her with the law and with the Governor.
To begin with she burst into tears, said she'd been joking with you, and
even took me to the cupboard to give me the money.  Then she began
arguing that the future of Europe lies in the hands of the French, and
the Russians, swore at women. . . .  Like you, I listened, fascinated,
ass that I was. . . .  She kept singing the praises of my

   <pb n="217"/>

beauty, patted me on the arm near the shoulder, to
see how strong I was, and . . . and as you see, I've
only just got away from her!  Ha, ha!  She's enthusiastic about you!"

"You're a nice fellow!" laughed the lieutenant.
"A married man! highly respected. . . .  Well,
aren't you ashamed?  Disgusted?  Joking apart
though, old man, you've got your Queen Tamara in
your own neighbourhood. . . ."

"In my own neighbourhood!  Why, you wouldn't find another such
chameleon in the whole of Russia!  I've never seen anything like it in
my life, though I know a good bit about women, too.  I have known
regular devils in my time, but I never met anything like this.  It is,
as you say, by insolence and cynicism she gets over you.  What is so
attractive in her is the diabolical suddenness, the quick transitions,
the swift shifting hues. . . .  Brrr!  And the IOU — phew!  Write it
off for lost.  We are both great sinners, we'll go halves in our sin.  I
shall put down to you not two thousand three hundred, but half of it.
Mind, tell my wife I was at the tenant's."

Kryukov and the lieutenant buried their heads in
the pillows, and broke into laughter; they raised
their heads, glanced at one another, and again subsided into their pillows.

"Engaged!  A lieutenant!" Kryukov jeered.

"Married!" retorted Sokolsky.  "Highly respected!  Father of a family!"

   <pb n="218"/>

At dinner they talked in veiled allusions, winked at one another,
and, to the surprise of the others, were continually gushing with
laughter into their dinner-napkins.  After dinner, still in the best of
spirits, they dressed up as Turks, and, running after one another with
guns, played at soldiers with the children.  In the evening they had a
long argument.  The lieutenant maintained that it was mean and
contemptible to accept a dowry with your wife, even when there was
passionate love on both sides.  Kryukov thumped the table with his fists
and declared that this was absurd, and that a husband who did not like
his wife to have property of her own was an egoist and a despot.  Both
shouted, boiled over, did not understand each other, drank a good deal,
and in the end, picking up the skirts of their dressing-gowns, went to
their bedrooms.  They soon fell asleep and slept soundly.

Life went on as before, even, sluggish and free from sorrow.  The
shadows lay on the earth, thunder pealed from the clouds, from time to
time the wind moaned plaintively, as though to prove that nature, too,
could lament, but nothing troubled the habitual tranquillity of these
people.  Of Susanna Moiseyevna and the IOUs they said nothing.  Both of
them felt, somehow, ashamed to speak of the incident aloud.  Yet they
remembered it and thought of it with pleasure, as of a curious farce,
which life had unexpectedly and casually played upon them, and which it
would be pleasant to recall in old age.

   <pb n="219"/>

On the sixth or seventh day after his visit to the Jewess,
Kryukov was sitting in his study in the morning writing a congratulatory
letter to his aunt.  Alexandr Grigoryevitch was walking to and fro near
the table in silence.  The lieutenant had slept badly that night; he
woke up depressed, and now he felt bored.  He paced up and down,
thinking of the end of his furlough, of his fiancée, who was
expecting him, of how people could live all their lives in the country
without feeling bored.  Standing at the window, for a long time he
stared at the trees, smoked three cigarettes one after another, and
suddenly turned to his cousin.

"I have a favour to ask you, Alyosha," he said.
"Let me have a saddle-horse for the day. . . ."

Kryukov looked searchingly at him and continued
his writing with a frown.

"You will, then?" asked the lieutenant.

Kryukov looked at him again, then deliberately
drew out a drawer in the table, and taking out a
thick roll of notes, gave it to his cousin.

"Here's five thousand . . ." he said.  "Though
it's not my money, yet, God bless you, it's all the
same.  I advise you to send for post-horses at once
and go away.  Yes, really!"

The lieutenant in his turn looked searchingly at
Kryukov and laughed.

"You've guessed right, Alyosha," he said, reddening.  "It was
to her I meant to ride.  Yesterday evening when the washerwoman gave me
that

   <pb n="220"/>

damned tunic, the one I was wearing then, and it
smelt of jasmine, why . . . I felt I must go!"

"You must go away."

"Yes, certainly.  And my furlough's just over.
I really will go to-day!  Yes, by Jove!  However
long one stays, one has to go in the end. . . .  I'm
going!"

The post-horses were brought after dinner the same day; the
lieutenant said good-bye to the Kryukovs and set off, followed by their
good wishes.

Another week passed.  It was a dull but hot and heavy day.  From
early morning Kryukov walked aimlessly about the house, looking out of
window, or turning over the leaves of albums, though he was sick of the
sight of them already.  When he came across his wife or children, he
began grumbling crossly.  It seemed to him, for some reason that day,
that his children's manners were revolting, that his wife did not know
how to look after the servants, that their expenditure was quite
disproportionate to their income.  All this meant that "the master" was
out of humour.

After dinner, Kryukov, feeling dissatisfied with
the soup and the roast meat he had eaten, ordered
out his racing droshky.  He drove slowly out of the
courtyard, drove at a walking pace for a quarter of
a mile, and stopped.

"Shall I . . . drive to her . . . that devil?" he
thought, looking at the leaden sky.

And Kryukov positively laughed, as though it

   <pb n="221"/>

were the first time that day he had asked himself
that question.  At once the load of boredom was
lifted from his heart, and there rose a gleam of
pleasure in his lazy eyes.  He lashed the horse. . . .

All the way his imagination was picturing how
surprised the Jewess would be to see him, how he
would laugh and chat, and come home feeling refreshed. . . .

"Once a month one needs something to brighten one up . . .
something out of the common round," he thought, "something that would
give the stagnant organism a good shaking up, a reaction . . .  whether
it's a drinking bout, or . . . Susanna.  One can't get on without it."

It was getting dark when he drove into the yard
of the vodka distillery.  From the open windows
of the owner's house came sounds of laughter and
singing:

"'Brighter than lightning, more burning than flame. . . .'"

sang a powerful, mellow, bass voice.

"Aha! she has visitors," thought Kryukov.

And he was annoyed that she had visitors.

"Shall I go back?" he thought with his hand on the bell, but he
rang all the same, and went up the familiar staircase.  From the entry
he glanced into the reception hall.  There were about five men there —
all landowners and officials of his acquaintance; one, a tall, thin
gentleman, was sitting at the piano, singing, and striking the keys with
his long,

   <pb n="222"/>

thin fingers.  The others were listening and grinning with enjoyment.
Kryukov looked himself up and down in the looking-glass, and was about
to go into the hall, when Susanna Moiseyevna herself darted into the
entry, in high spirits and wearing the same black dress. . . .  Seeing
Kryukov, she was petrified for an instant, then she uttered a little
scream and beamed with delight.

"Is it you?" she said, clutching his hand.
"What a surprise!"

"Here she is!" smiled Kryukov, putting his arm
round her waist.  "Well!  Does the destiny of
Europe still lie in the hands of the French and the
Russians?"

"I'm so glad," laughed the Jewess, cautiously removing his arm.
"Come, go into the hall; they're all friends there. . . .  I'll go and
tell them to bring you some tea.  Your name's Alexey, isn't it?  Well,
go in, I'll come directly. . . ."

She blew him a kiss and ran out of the entry,
leaving behind her the same sickly smell of jasmine.
Kryukov raised his head and walked into the hall.
He was on terms of friendly intimacy with all the
men in the room, but scarcely nodded to them; they,
too, scarcely responded, as though the places in
which they met were not quite decent, and as though
they were in tacit agreement with one another that
it was more suitable for them not to recognise one
another.

From the hall Kryukov walked into the drawing-room,

   <pb n="223"/>

and from it into a second drawing-room.  On the way he met three
or four other guests, also men whom he knew, though they barely
recognised him.  Their faces were flushed with drink and merriment.
Alexey Ivanovitch glanced furtively at them and marvelled that these
men, respectable heads of families, who had known sorrow and privation,
could demean themselves to such pitiful, cheap gaiety!  He shrugged his
shoulders, smiled, and walked on.

"There are places," he reflected, "where a sober man feels sick,
and a drunken man rejoices.  I remember I never could go to the operetta
or the gipsies when I was sober: wine makes a man more good-natured and
reconciles him with vice. . . ."

Suddenly he stood still, petrified, and caught hold of the
door-post with both hands.  At the writing-table in Susanna's study was
sitting Lieutenant Alexandr Grigoryevitch.  He was discussing something
in an undertone with a fat, flabby-looking Jew, and seeing his cousin,
flushed crimson and looked down at an album.

The sense of decency was stirred in Kryukov and
the blood rushed to his head.  Overwhelmed with
amazement, shame, and anger, he walked up to the
table without a word.  Sokolsky's head sank lower
than ever.  His face worked with an expression of
agonising shame.

"Ah, it's you, Alyosha!" he articulated, making
a desperate effort to raise his eyes and to smile.

   <pb n="224"/>

"I called here to say good-bye, and, as you see. . . .
But to-morrow I am certainly going."

"What can I say to him?  What?" thought
Alexey Ivanovitch.  "How can I judge him since
I'm here myself?"

And clearing his throat without uttering a word,
he went out slowly.

"'Call her not heavenly, and leave her on earth. . . .'"

The bass was singing in the hall.  A little while
after, Kryukov's racing droshky was bumping along
the dusty road.

<hi rend="italic">1886</hi>

</div1>

</text>
</TEI.2>


text:
"""
Module for building poison related objects
"""
from mockito import mock
from pyherc.data.effects import Poison

class PoisonBuilder():
    """
    Class for building poison
    """
    def __init__(self):
        """
        Default constructor
        """
        super().__init__()
        self.duration = 1
        self.frequency = 1
        self.tick = 0
        self.damage = 5
        self.target = mock()
        self.icon = 101
        self.title = 'poison'
        self.description = 'causes damage'

    def with_duration(self, duration):
        """
        Set duration of poison

        :param duration: duration
        :type duration: int
        """
        self.duration = duration
        return self

    def with_frequency(self, frequency):
        """
        Set frequency of poison
        """
        self.frequency = frequency
        return self

    def with_tick(self, tick):
        """
        Set internal clock of poison
        """
        self.tick = tick
        return self

    def with_damage(self, damage):
        """
        Set damage caused by poison
        """
        self.damage = damage
        return self

    def with_target(self, target):
        """
        Set target of the poison
        """
        self.target = target
        return self

    def build(self):
        """
        Builds poison object
        """
        return Poison(duration=self.duration,
                      frequency=self.frequency,
                      tick=self.tick,
                      damage=self.damage,
                      target=self.target,
                      icon=self.icon,
                      title=self.title,
                      description=self.description)

redpajama_set_name: RedPajamaGithub


text:
@implementation TestProximityProfile

- (id) init {
    self = [super init];

    if (self) {
        __weak TestProximityProfile *weakSelf = self;

        // API登録(didReceiveGetOnDeviceProximityRequest相当)
        NSString *getOnDeviceProximityRequestApiPath =
        [self apiPath: nil
        attributeName: DConnectProximityProfileAttrOnDeviceProximity];
        [self addGetPath: getOnDeviceProximityRequestApiPath api: ^BOOL(DConnectRequestMessage *request, DConnectResponseMessage *response) {

            NSString *serviceId = [request serviceId];

            CheckDID(response, serviceId) {
                response.result = DConnectMessageResultTypeOk;

                [weakSelf setDeviceProximity:response];
            }
            return YES;
        }];

        // API登録(didReceiveGetOnUserProximityRequest相当)
        NSString *getOnUserProximityRequestApiPath =
        [self apiPath: nil
        attributeName: DConnectProximityProfileAttrOnUserProximity];
        [self addGetPath: getOnUserProximityRequestApiPath api: ^BOOL(DConnectRequestMessage *request, DConnectResponseMessage *response) {

            NSString *serviceId = [request serviceId];

            CheckDID(response, serviceId) {
                response.result = DConnectMessageResultTypeOk;

                [weakSelf setUserProximity:response];
            }
            return YES;
        }];

        // API登録(didReceivePutOnDeviceProximityRequest相当)
        NSString *putOnDeviceProximityRequestApiPath =
        [self apiPath: nil
        attributeName: DConnectProximityProfileAttrOnDeviceProximity];
        [self addPutPath: putOnDeviceProximityRequestApiPath api: ^BOOL(DConnectRequestMessage *request, DConnectResponseMessage *response) {

            NSString *serviceId = [request serviceId];
            NSString *accessToken = [request accessToken];

            CheckDIDAndSK(response, serviceId, accessToken) {
                response.result = DConnectMessageResultTypeOk;

                DConnectMessage *event = [DConnectMessage message];
                [event setString:serviceId forKey:DConnectMessageServiceId];
                [event setString:accessToken forKey:DConnectMessageAccessToken];
                [event setString:weakSelf.profileName forKey:DConnectMessageProfile];
                [event setString:DConnectProximityProfileAttrOnDeviceProximity forKey:DConnectMessageAttribute];
                [weakSelf setDeviceProximity:event];
                [weakSelf.plugin asyncSendEvent:event];
            }

            return YES;
        }];

        // API登録(didReceivePutOnUserProximityRequest相当)
        NSString *putOnUserProximityRequestApiPath =
        [self apiPath: nil
        attributeName: DConnectProximityProfileAttrOnUserProximity];
        [self addPutPath: putOnUserProximityRequestApiPath api: ^BOOL(DConnectRequestMessage *request, DConnectResponseMessage *response) {

            NSString *serviceId = [request serviceId];
            NSString *accessToken = [request accessToken];

            CheckDIDAndSK(response, serviceId, accessToken) {
                response.result = DConnectMessageResultTypeOk;

                DConnectMessage *event = [DConnectMessage message];
                [event setString:serviceId forKey:DConnectMessageServiceId];
                [event setString:accessToken forKey:DConnectMessageAccessToken];
                [event setString:weakSelf.profileName forKey:DConnectMessageProfile];
                [event setString:DConnectProximityProfileAttrOnUserProximity forKey:DConnectMessageAttribute];
                [weakSelf setUserProximity:event];
                [weakSelf.plugin asyncSendEvent:event];
            }

            return YES;
        }];

        // API登録(didReceiveDeleteOnDeviceProximityRequest相当)
        NSString *deleteOnDeviceProximityRequestApiPath =
        [self apiPath: nil
        attributeName: DConnectProximityProfileAttrOnDeviceProximity];
        [self addDeletePath: deleteOnDeviceProximityRequestApiPath api: ^BOOL(DConnectRequestMessage *request, DConnectResponseMessage *response) {

            NSString *serviceId = [request serviceId];
            NSString *accessToken = [request accessToken];

            CheckDIDAndSK(response, serviceId, accessToken) {
                response.result = DConnectMessageResultTypeOk;
            }

            return YES;
        }];

        // API登録(didReceiveDeleteOnUserProximityRequest相当)
        NSString *deleteOnUserProximityRequestApiPath =
        [self apiPath: nil
        attributeName: DConnectProximityProfileAttrOnUserProximity];
        [self addDeletePath: deleteOnUserProximityRequestApiPath api: ^BOOL(DConnectRequestMessage *request, DConnectResponseMessage *response) {

            NSString *serviceId = [request serviceId];
            NSString *accessToken = [request accessToken];

            CheckDIDAndSK(response, serviceId, accessToken) {
                response.result = DConnectMessageResultTypeOk;
            }
            return YES;
        }];
    }

    return self;
}

- (void) setDeviceProximity:(DConnectMessage *)message
{
    DConnectMessage *proximity = [DConnectMessage message];
    [DConnectProximityProfile setValue:0 target:proximity];
    [DConnectProximityProfile setMax:0 target:proximity];
    [DConnectProximityProfile setMin:0 target:proximity];
    [DConnectProximityProfile setThreshold:0 target:proximity];
    [DConnectProximityProfile setProximity:proximity target:message];
}

- (void) setUserProximity:(DConnectMessage *)message
{
    DConnectMessage *proximity = [DConnectMessage message];
    [DConnectProximityProfile setNear:true target:proximity];
    [DConnectProximityProfile setProximity:proximity target:message];
}

@end


text:
require 'English'

module S3Repo
  ##
  # Base object, used to provide common attributes
  class Base
    def initialize(params = {})
      @options = params
    end

    private

    def run(cmd)
      results = `#{cmd} 2>&1`
      return results if $CHILD_STATUS.success?
      raise "Failed running #{cmd}:\n#{results}"
    end

    def bucket
      @options[:bucket] || raise('No bucket given')
    end

    def client
      @options[:client] ||= Client.new(@options)
    end

    def file_cache
      @file_cache ||= @options[:file_cache] || Cache.new(@options)
    end
  end
end


text:
package com.gitblit.wicket.pages;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;

import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.utils.DiffUtils;
import com.gitblit.utils.DiffUtils.DiffOutputType;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.CommitHeaderPanel;
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;

public class BlobDiffPage extends RepositoryPage {

	public BlobDiffPage(PageParameters params) {
		super(params);

		final String blobPath = WicketUtils.getPath(params);
		final String baseObjectId = WicketUtils.getBaseObjectId(params);

		Repository r = getRepository();
		RevCommit commit = getCommit();

		DiffOutputType diffType = DiffOutputType.forName(GitBlit.getString(Keys.web.diffStyle,
				DiffOutputType.GITBLIT.name()));

		String diff;
		if (StringUtils.isEmpty(baseObjectId)) {
			// use first parent
			diff = DiffUtils.getDiff(r, commit, blobPath, diffType);
			add(new BookmarkablePageLink<Void>("patchLink", PatchPage.class,
					WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
		} else {
			// base commit specified
			RevCommit baseCommit = JGitUtils.getCommit(r, baseObjectId);
			diff = DiffUtils.getDiff(r, baseCommit, commit, blobPath, diffType);
			add(new BookmarkablePageLink<Void>("patchLink", PatchPage.class,
					WicketUtils.newBlobDiffParameter(repositoryName, baseObjectId, objectId,
							blobPath)));
		}

		add(new BookmarkablePageLink<Void>("commitLink", CommitPage.class,
				WicketUtils.newObjectParameter(repositoryName, objectId)));
		add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,
				WicketUtils.newObjectParameter(repositoryName, objectId)));

		// diff page links
		add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
				WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
		add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
				WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));

		add(new CommitHeaderPanel("commitHeader", repositoryName, commit));

		add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));

		add(new Label("diffText", diff).setEscapeModelStrings(false));
	}

	@Override
	protected String getPageName() {
		return getString("gb.diff");
	}

	@Override
	protected Class<? extends BasePage> getRepoNavPageClass() {
		return TreePage.class;
	}
}


text:
package org.ethereum.config;

import org.ethereum.net.rlpx.Node;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by Anton Nashatyrev on 14.01.2016.
 */
public class NodeFilter {
    private List<Entry> entries = new ArrayList<>();

    public void add(byte[] nodeId, String hostIpPattern) {
        entries.add(new Entry(nodeId, hostIpPattern));
    }

    public boolean accept(Node node) {
        for (Entry entry : entries) {
            if (entry.accept(node)) return true;
        }
        return false;
    }

    public boolean accept(InetAddress nodeAddr) {
        for (Entry entry : entries) {
            if (entry.accept(nodeAddr)) return true;
        }
        return false;
    }

    private class Entry {
        byte[] nodeId;
        String hostIpPattern;

        public Entry(byte[] nodeId, String hostIpPattern) {
            this.nodeId = nodeId;
            if (hostIpPattern != null) {
                int idx = hostIpPattern.indexOf("*");
                if (idx > 0) {
                    hostIpPattern = hostIpPattern.substring(0, idx);
                }
            }
            this.hostIpPattern = hostIpPattern;
        }

        public boolean accept(InetAddress nodeAddr) {
            String ip = nodeAddr.getHostAddress();
            return hostIpPattern != null && ip.startsWith(hostIpPattern);
        }

        public boolean accept(Node node) {
            try {
                return (nodeId == null || Arrays.equals(node.getId(), nodeId))
                        && (hostIpPattern == null || accept(InetAddress.getByName(node.getHost())));
            } catch (UnknownHostException e) {
                return false;
            }
        }
    }
}


text:
<?php

namespace Jstewmc\Api\Exception;

/**
 * Tests for the Exception\BadResponseStatus class
 */
class BadResponseStatusTest extends \PHPUnit_Framework_TestCase
{
	// nothing yet

	public function test_foo()
	{
		return new BadResponseStatus();
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/progress_relativelayout"
    style="@style/ExoPlaybackControlView">

    <com.quickblox.ui.kit.chatmessage.adapter.media.view.TimeProgressBar
        android:id="@id/exo_progress"
        style="@style/TimeProgressBarView" />

    <LinearLayout
        android:id="@+id/exo_linear_frame"
        style="@style/ExoLinearFrame">

        <ImageView
            android:id="@id/icon_play_pause"
            style="@style/IconPlayPauseView"/>

        <TextView
            android:id="@+id/msg_attach_duration"
            style="@style/AudioAttachDurationView"/>

        <TextView
            android:id="@id/exo_position"
            style="@style/AudioAttachPositionView"/>

    </LinearLayout>

</RelativeLayout>


text:
import React from 'react';
import ReactDOM from 'react-dom';
import Button from './Button';

describe('Button', () => {

    it('renders without error', () => {
        const div = document.createElement('div');
        ReactDOM.render(<Button label="foo" />, div);
    });
});


text:
require 'mysql2'
require 'set'

Given(/^the following "(.*?)" exists$/) do |name, table|
  @con = Mysql2::Client.new(host: 'localhost', username: '27skauti_testing', password: 'dominika', database: '27skauti_testing')
  @sql =  "INSERT INTO `" +  @con.escape(name) + "` (`"
  @columns = table.column_names.each {|x| @con.escape(x)}
  @columns = @columns.join("`, `")
  @sql = @sql + @columns + '`) VALUES '
  @values = []
  table.hashes.each do |member| # this is the tabel row
     @value = member.values.each {|value| @con.escape(value)} # get values from row
     @value = @value.join('", "')
     @value = '("' + @value + '")'
     @values = @values.push(@value)
  end
  @values = @values.join(', ')
  @sql = @sql + @values
  @con.query(@sql)
end

Then(/^the following "(.*?)" should exist$/) do |name, table|
  @con = Mysql2::Client.new(host: 'localhost', username: '27skauti_testing', password: 'dominika', database: '27skauti_testing')
  @sql =  "SELECT `"
  @columns = table.column_names.each {|x| @con.escape(x)}
  @columns = @columns.join("`, `")
  @sql = @sql + @columns + '` FROM `' +  @con.escape(name) + '`'
  @result = @con.query(@sql).to_a
  # converts all values to Strings
  @result.map! do |obj|
    obj.each do |k, v|
        obj[k] = "#{v}"
    end
  end
  @result = @result.to_a.to_set
  @input = table.hashes.to_set
  assert @input.subset?(@result)
end


text:
<?php
class EditPage extends RunnerPage
{
	protected $cachedRecord = null;

	public $keys = array();
	public $oldKeys = array();
	protected $keysChanged = false;

	public $jsKeys = array();

	public $keyFields = array();

	/**
	 * An array of edit page's fields
	 */
	public $editFields = array();
	public $readEditValues = false;
	/**
	 *	Values to be displayed in Edit controls
	 */
	protected $controlsDisabled = false;

	public $action = "";

	public $lockingAction = "";
	public $lockingSid = null;
	public $lockingKeys = null;
	public $lockingStart = null;

	protected $lockingMessageStyle = "display:none;";
	protected $lockingMessageText = "";

	protected $message = "";
	protected $messageType = MESSAGE_ERROR;

	protected $auditObj = null;

	protected $oldRecordData = null;
	protected $newRecordData = array();
	protected $newRecordBlobFields = array();

	protected $updatedSuccessfully = false;

	/**
	 * It's set up in inline edit mode only
	 */
	public $screenWidth = 0;
	/**
	 * It's set up in inline edit mode only
	 */
	public $screenHeight = 0;
	/**
	 * It's set up in inline edit mode only
	 */
	public $orientation = '';

	/**
	 * The name of the dashboard element where the page is displayed on
	 * It's set up correctly in dash mode only
	 */
	public $dashElementName = "";

	/**
	 * The corresponding dashboard name
	 * It's set up correctly in dash mode only
	 */
	public $dashTName = "";

	/**
	 * @constructor
	 */
	function EditPage(&$params)
	{

		parent::RunnerPage($params);

		$this->setKeysForJs();

		$this->auditObj = GetAuditObject($this->tName);

		$this->editFields = $this->getPageFields();

		$this->formBricks["header"] = "editheader";
		$this->formBricks["footer"] = "editbuttons";
		$this->assignFormFooterAndHeaderBricks( true );
	}

	/**
	 * Assign session prefix
	 */
	protected function assignSessionPrefix()
	{
		if( $this->mode == EDIT_DASHBOARD || ( $this->mode == EDIT_POPUP || $this->mode == EDIT_INLINE ) && $this->dashTName )
		{
			$this->sessionPrefix = $this->dashTName."_".$this->tName;
			return;
		}

		parent::assignSessionPrefix();
	}

	/**
	 * Set session variables
	 */
	public function setSessionVariables()
	{
		parent::setSessionVariables();

		$_SESSION[ $this->sessionPrefix.'_advsearch' ] = serialize($this->searchClauseObj);
	}

	/**
	 * Get the page's fields list
	 * @return Array
	 */
	protected function getPageFields()
	{
		if( $this->mode == EDIT_INLINE )
			return $this->pSet->getInlineEditFields();

		return $this->pSet->getEditFields();
	}

	/**
	 * Set keys values
	 * @param Array keys
	 */
	public function setKeys($keys)
	{
		$this->cachedRecord = null;
		$this->keys = $keys;
		$this->setKeysForJs();
	}

	public function setKeysForJs()
	{
		$i = 0;
		foreach($this->keys as $field => $value)
		{
			$this->keyFields[ $i ] = $field;
			$this->jsKeys[ $i++ ] = $value;
		}
	}

	/**
	 * Tell whether the page was called to update locking state only
	 */
	public function isLockingRequest()
	{
		return $this->lockingObj && ($this->lockingAction != "");
	}

	/**
	 * Perform locking action the page was called for
	 */
	public function doLockingAction()
	{
		$arrkeys = explode("&", urldecode( $this->lockingKeys ));

		foreach(array_keys($arrkeys) as $ind)
			$arrkeys[$ind] = urldecode($arrkeys[$ind]);

		if($this->lockingAction == "unlock")
		{
			$this->lockingObj->UnlockRecord($this->tName, $arrkeys, $this->lockingSid);
		}
		else if($this->lockingAction == "lockadmin" && (IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP))
		{
			$this->lockingObj->UnlockAdmin($this->tName, $arrkeys, $this->lockingStart == "yes");
			if($this->lockingStart == "no")
				echo "unlock";
			else if($this->lockingStart == "yes")
				echo "lock";
		}
		else if($this->lockingAction == "confirm")
		{
			$lockMessage = "";
			if( !$this->lockingObj->ConfirmLock($this->tName, $arrkeys, $lockMessage) )
				echo $lockMessage;
		}
	}

	/**
	 * Set template file if it empty
	 */
	public function setTemplateFile()
	{
		if($this->mode == EDIT_INLINE)
			$this->templatefile = GetTemplateName($this->shortTableName, "inline_edit");
		parent::setTemplateFile();
	}

	public function init()
	{
		parent::init();

		if( $this->eventsObject->exists("BeforeProcessEdit") )
			$this->eventsObject->BeforeProcessEdit( $this );
	}

	public function process()
	{
		if( $this->captchaExists() )
		{
			$this->doCaptchaCode();
		}

		if( $this->action == "edited" )
		{
			$this->processDataInput();

			$this->readEditValues = !$this->updatedSuccessfully;

			if( $this->mode == EDIT_INLINE || $this->mode == EDIT_POPUP )
			{
				$this->reportInlineSaveStatus();
				return;
			}

			if( $this->prgRedirect() )
				return;
		}
		$this->prgReadMessage();

		//	get the record to edit
		if( !$this->readRecord() )
			return;

		if( !$this->IsRecordEditable( false ) )
			return $this->SecurityRedirect();

		if( !$this->lockRecord() )
			return;

		$this->prepareReadonlyFields();

		$this->doCommonAssignments();
		$this->prepareButtons();
		$this->prepareEditControls();
		$this->fillCntrlTabGroups();

		$this->prepareJsSettings();

		$this->prepareDetailsTables();

		if( $this->mode != EDIT_INLINE )
			$this->addButtonHandlers();

		$this->addCommonJs();

		$this->fillSetCntrlMaps();

		$this->displayEditPage();
	}

	/**
	 * Add table settings
	 */
	protected function prepareJsSettings()
	{
		$this->jsSettings['tableSettings'][ $this->tName ]["keys"] = $this->jsKeys;
		$this->jsSettings['tableSettings'][ $this->tName ]['keyFields'] = $this->keyFields;

		if($this->lockingObj)
		{
			// $keys, $savedKeys could not be set properly if editid params were not passed, so use $this->keys instead
			$this->jsSettings['tableSettings'][ $this->tName ]["sKeys"] = implode("&", $this->keys);
			$this->jsSettings['tableSettings'][ $this->tName ]["enableCtrls"] = !$this->controlsDisabled;
			$this->jsSettings['tableSettings'][ $this->tName ]["confirmTime"] = $this->lockingObj->ConfirmTime;
		}
	}

	/**
	 * Assign basic page's xt variables
	 */
	protected function doCommonAssignments()
	{
		$this->xt->assign( "id", $this->id );

		//	display message
		$this->xt->assign("message_block", true);
		if( strlen($this->message) )
		{
			$mesClass = $this->messageType == MESSAGE_ERROR ? "message rnr-error" : "message" ;
			$this->xt->assign("message", "
" . $this->message . "
" );
		}
		else
		{
			$this->xt->displayBrickHidden("message");
		}

		//	display legacy page caption - key values
		$data = $this->getCurrentRecordInternal();
		foreach( $this->keyFields as $i => $k )
		{
			$viewFormat = $this->pSet->getViewFormat( $k );
			if( $viewFormat == FORMAT_HTML || $viewFormat == FORMAT_FILE_IMAGE || $viewFormat == FORMAT_FILE ||
				$viewFormat == FORMAT_HYPERLINK || $viewFormat == FORMAT_HYPERLINK || $viewFormat == FORMAT_EMAILHYPERLINK ||
				$viewFormat == FORMAT_CHECKBOX )
			{
				$this->xt->assign( "show_key" . ($i+1), runner_htmlspecialchars( $data[ $k ] ) );
			}
			else
			{
				$this->xt->assign( "show_key" . ($i+1), $this->showDBValue( $k, $data ) );
			}
		}
		//	labels
		$this->assignEditFieldsBlocksAndLabels();

		//	body["end"]	- this assignment is very important
		if($this->mode == EDIT_SIMPLE)
		{
			$this->assignBody();
			// assign body end
			$this->xt->assign("flybody", true);
		}
	}

	/**
	 * Display the edit page
	 */
	protected function displayEditPage()
	{
		// beforeshow event
		$templateFile = $this->templatefile;
		if( $this->eventsObject->exists("BeforeShowEdit") )
			$this->eventsObject->BeforeShowEdit($this->xt, $templateFile, $this->getCurrentrecordInternal(), $this);

		if( $this->mode == EDIT_SIMPLE )
		{
			$this->display($templateFile);
			return;
		}

		if( $this->mode == EDIT_POPUP || $this->mode == EDIT_DASHBOARD )
		{
			$this->xt->assign("footer", false);
			$this->xt->assign("header", false);
			$this->xt->assign("body", $this->body);
			$this->displayAJAX($templateFile, $this->flyId + 1);
			exit();
		}

		if( $this->mode == EDIT_INLINE )
		{
			$returnJSON = array();
			$returnJSON["settings"] = $this->jsSettings;
			$returnJSON["controlsMap"] = $this->controlsHTMLMap;
			$returnJSON["viewControlsMap"] = $this->viewControlsHTMLMap;

			$this->xt->load_template($templateFile);
			$returnJSON["html"] = array();
			foreach($this->editFields as $f)
			{
				if( $this->detailKeysByM && in_array($f, $this->detailKeysByM) )
					continue;
				$returnJSON["html"][ $f ] = $this->xt->fetchVar(GoodFieldName($f)."_editcontrol");
			}
			$returnJSON["additionalJS"] = $this->grabAllJsFiles();
			$returnJSON["additionalCSS"] = $this->grabAllCSSFiles();
			echo printJSON($returnJSON);
			exit();
		}
	}

	/**
	 * Get extra JSON params to display the page on AJAX-like request
	 * @return Array
	 */
	protected function getExtraAjaxPageParams()
	{
		return $this->getSaveStatusJSON();
	}

	/**
	 * Set details preview on the edit master page
	 */
	protected function prepareDetailsTables()
	{
		if( !$this->isShowDetailTables || $this->mode == EDIT_DASHBOARD || $this->mode == EDIT_INLINE )
			return;

		$dpParams = $this->getDetailsParams( $this->id );
		$this->jsSettings['tableSettings'][ $this->tName ]['dpParams'] = array('tableNames' => $dpParams['strTableNames'], 'ids' => $dpParams['ids']);

		if( !count($dpParams['ids']) )
			return;

		$this->xt->assign("detail_tables", true);
		$this->flyId = $dpParams['ids'][ count($dpParams['ids']) - 1 ] + 1;
		for($d = 0; $d < count($dpParams['ids']); $d++)
		{
			$this->setDetailPreview( $dpParams['type'][ $d ], $dpParams['strTableNames'][ $d ], $dpParams['ids'][ $d ], $this->getCurrentRecordInternal() );
		}
	}

	/**
	 * Assign buttons xt variables
	 */
	protected function prepareButtons()
	{
		if( $this->mode == EDIT_INLINE )
			return;

		$this->prepareNextPrevButtons();

		if( $this->mode == EDIT_SIMPLE)
		{
			//	back to list/menu buttons
			if( $this->pSet->hasListPage() )
			{
				$this->xt->assign("back_button", true);
				$this->xt->assign("backbutton_attrs", "id=\"backButton".$this->id."\"");
				$this->xt->assign("mbackbutton_attrs", "id=\"extraBackButton".$this->id."\"");
			}
			else if( $this->isShowMenu() )
			{
				$this->xt->assign("back_button", true);
				$this->xt->assign("backbutton_attrs", "id=\"backToMenuButton".$this->id."\"");
			}
		}

		if($this->mode == EDIT_POPUP)
		{
			$this->xt->assign("close_button", true);
			$this->xt->assign("closebutton_attrs", "id=\"closeButton".$this->id."\"");
		}

		$this->xt->assign("save_button", true);
		if( $this->controlsDisabled )
			$this->xt->assign("savebutton_attrs", "id=\"saveButton".$this->id."\" type=\"disabled\" ");
		else
			$this->xt->assign("savebutton_attrs", "id=\"saveButton".$this->id."\"");

		$this->xt->assign("resetbutton_attrs", 'id="resetButton'.$this->id.'"');
		$this->xt->assign("reset_button", true);

		if( $this->mode == EDIT_DASHBOARD )
			return;

		if( $this->pSet->hasViewPage() && $this->permis[ $this->tName ]['search'] )
		{
			$this->xt->assign("view_page_button", true);
			$this->xt->assign("view_page_button_attrs", "id=\"viewPageButton".$this->id."\"");
		}
	}

	protected function prepareNextPrevButtons()
	{
		if( !$this->pSet->useMoveNext() )
			return;

		$next = array();
		$prev = array();

		$this->getNextPrevRecordKeys( $this->getCurrentRecordInternal(), "Edit", $next, $prev, $this->mode == EDIT_DASHBOARD );

		//show Prev/Next buttons
		$this->assignPrevNextButtons( count( $next ) > 0, count( $prev ) > 0 );

		$this->jsSettings['tableSettings'][ $this->tName] ["prevKeys"] = $prev;
		$this->jsSettings['tableSettings'][ $this->tName ]["nextKeys"] = $next;
	}

	protected function readRecord()
	{
		if( $this->getCurrentRecordInternal() )
			return true;
		if($this->mode == EDIT_SIMPLE)
		{
			HeaderRedirect($this->pSet->getShortTableName(), "list", "a=return");
			exit();
		}
		//	nothing to edit.
		//	TODO: add some report or message
		exit();
		return false;
	}

	/**
	 *	Format and prepare readonly field values
	 */
	protected function prepareReadonlyFields()
	{
		$fields = $this->pSet->getFieldsList();
		$data = $this->getCurrentRecordInternal();

		//	prepare field values
		//	keys
		$keyParams = array();
		foreach( $this->keyFields as $i => $k )
		{
			$keyParams[] = "key" . ($i + 1) . "=" . rawurldecode( $this->keys[ $k ] );
		}
		$keylink = "&" . implode("&", $keyParams);

		foreach( $fields as $f )
		{
			if( $this->pSet->getEditFormat( $f ) == EDIT_FORMAT_READONLY &&
				( $this->pSet->appearOnEditPage( $f ) || $this->pSet->appearOnInlineEdit( $f ) ) )
				$this->readOnlyFields[ $f ] = $this->showDBValue( $f , $data, $keylink );
		}
	}

	/**
	 *	Locks record for editing.
	 * Returns false if the page can not continue processing. True otherwise.
	 */
	protected function lockRecord()
	{
		if( !$this->lockingObj )
			return true;

		//	locked OK
		if( $this->lockingObj->LockRecord( $this->tName, $this->keys) )
		{
			$this->body["begin"].= '
lockingMessageStyle. '">' .$this->lockingMessageText. '
';
			return true;
		}

		//	NOT locked
		//	inline mode
		if($this->mode == EDIT_INLINE)
		{
			if(IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP)
				$lockmessage = $this->lockingObj->GetLockInfo($this->tName, $this->keys, false, $this->id);
			else
				$lockmessage = $this->lockingObj->LockUser;

			$returnJSON = array();
			$returnJSON['success'] = false;
			$returnJSON['message'] = $lockmessage;
			$returnJSON['enableCtrls'] = false;
			$returnJSON['confirmTime'] = $this->lockingObj->ConfirmTime;
			echo printJSON($returnJSON);
			exit();
		}

		//	other modes
		$this->controlsDisabled = true;
		$this->lockingMessageStyle = "style='display:block;'";
		$this->lockingMessageText = $this->lockingObj->LockUser;

		if(IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP)
		{
			$ribbonMessage = $this->lockingObj->GetLockInfo($this->tName, $this->keys, true, $this->id);
			if($ribbonMessage != "")
				$this->lockingMessageText = $ribbonMessage;
		}

		$this->body["begin"].= '
lockingMessageStyle. '">' .
			$this->lockingMessageText .
			'
';
		return true;
	}

	/**
	 * Print JSON containing a saved record data on ajax-like request
	 */
	protected function reportInlineSaveStatus()
	{
		echo printJSON( $this->getSaveStatusJSON() );
		exit();
	}

	/**
	 * Get an array containing the record save status
	 * @return Array
	 */
	protected function getSaveStatusJSON()
	{
		$returnJSON = array();

		if( $this->action != "edited" || $this->mode == EDIT_SIMPLE )
			return $returnJSON;

		$returnJSON['success'] = $this->updatedSuccessfully;
		$returnJSON['message'] = $this->message;
		$returnJSON['lockMessage'] = $this->lockingMessageText;

		if( !$this->isCaptchaOk )
			$returnJSON['captcha'] = false;

		if( !$this->updatedSuccessfully )
			return $returnJSON;

		//	successful update. Return new keys and field values
		$data = $this->getCurrentRecordInternal();
		if( !$data )
			$data = $this->newRecordData;

		//	details tables keys
		$returnJSON['detKeys'] = array();
		foreach( $this->pSet->getDetailTablesArr() as $dt )
		{
			$dkeys = array();
			foreach( $dt["masterKeys"] as $idx => $mk )
			{
				$dkeys[ "masterkey".($idx + 1) ] = $data[ $mk ];
			}
			$returnJSON['detKeys'][ $dt['dDataSourceTable'] ] = $dkeys;
		}

		//	prepare field values
		//	keys
		$keyParams = array();
		foreach( $this->keyFields as $i => $k )
		{
			$keyParams[] = "key" . ($i + 1) . "=" . rawurldecode( $this->keys[ $k ] );
		}
		$keylink = "&" . implode("&", $keyParams);

		//	values
		$values = array();
		$rawValues = array();
		$fields = $this->pSet->getFieldsList();
		foreach( $fields as $f )
		{
			$value = $this->showDBValue( $f, $data, $keylink );
			$values[ $f ] = $value;
			if( IsBinaryType( $this->pSet->getFieldType( $f ) ) )
				$rawValues[ $f ] = "";
			else
				$rawValues[ $f ] = substr($data[ $f ], 0, 100);

		}

		$returnJSON['keys'] = $this->jsKeys;
		$returnJSON['keyFields'] = $this->keyFields;
		$returnJSON['vals'] = $values;
		$returnJSON['fields'] = $fields;
		$returnJSON['rawVals'] = $rawValues;
		$returnJSON['hrefs'] = $this->buildDetailGridLinks( $returnJSON['detKeys'] );

		//	the record might become non-editable after updating
		if( !$this->IsRecordEditable( false ) )
			$returnJSON['nonEditable'] = true;

		return $returnJSON;
	}

	/**
	 *	POST-REDIRECT-GET
	 *	Redirect after saving the data to avoid saving again on refresh.
	 */
	protected function prgRedirect()
	{
		if( !$this->updatedSuccessfully || $this->mode != EDIT_SIMPLE || !no_output_done() )
			return false;

		$_SESSION["message_edit"] = $this->message . "";
		$keyParams = array();
		foreach( $this->keyFields as $i => $k )
		{
			$keyParams[] = "editid" . ($i + 1) . "=" . rawurldecode( $this->keys[ $k ] );
		}
		HeaderRedirect( $this->pSet->getShortTableName(), $this->getPageType(), implode("&", $keyParams) );
		exit();
		return true;
	}

	/**
	 *	POST-REDIRECT-GET
	 *	Read the saved message on the GET step.
	 */
	protected function prgReadMessage()
	{
		if( $this->mode != EDIT_SIMPLE || ! isset($_SESSION["message_edit"]) )
			return;
		$this->setMessage( $_SESSION["message_edit"] );
		$this->messageType = MESSAGE_INFO;
		unset($_SESSION["message_edit"]);
	}

	/**
	 * @return Array
	 */
	public function getCurrentRecord()
	{
		$data = $this->getCurrentRecordInternal();
		$newData = array();

		foreach($data as $fName => $val)
		{
			$editFormat = $this->pSet->getEditFormat($fName);
			if( $editFormat == EDIT_FORMAT_DATABASE_FILE || $editFormat==EDIT_FORMAT_DATABASE_IMAGE )
			{
				if( $data[ $fName ] )
					$newData[ $fName ] = true;
				else
					$newData[ $fName ] = false;
			}
		}

		foreach($newData as $fName => $val) // .net compatibility issue
		{
			$data[ $fName ] = $val;
		}

		return $data;
	}

	/**
	 * @param Boolean useOldKeys
	 * @return String
	 */
	public function getWhereClause( $useOldKeys )
	{
		$strWhereClause = "";

		if( $useOldKeys )
			$strWhereClause = KeyWhere( $this->oldKeys );
		else if( $this->checkKeysSet() )
			$strWhereClause = KeyWhere( $this->keys );
		elseif( $this->mode == EDIT_DASHBOARD )
		{
			$whereComponents = $this->getWhereComponents();
			$strWhereClause = $whereComponents["searchWhere"];
		}
		else
		{
			$strWhereClause = $_SESSION[ $this->sessionPrefix."_where" ];
		}

		if( $this->pSet->getAdvancedSecurityType() != ADVSECURITY_ALL )
		{
			// select only owned records
			$strWhereClause = whereAdd($strWhereClause, SecuritySQL("Edit", $this->tName));
		}
		return $strWhereClause;
	}

	/**
	 * Read current values from the database
	 * @return Array 		The current record data
	 */
	public function getCurrentRecordInternal()
	{
		if( !is_null($this->cachedRecord) )
			return $this->cachedRecord;

		$keysSet = $this->checkKeysSet();

		$orderClause = "";
		$havingClause = "";
		if( !$keysSet )
		{
			$orderClause = $this->getOrderByClause();
			if( $this->mode == EDIT_DASHBOARD )
			{
				$whereComponents = $this->getWhereComponents();
				$havingClause = $whereComponents["searchHaving"];
			}
		}

		$strWhereClause = $this->getWhereClause( false );
		$strSQL = $this->gQuery->gSQLWhere( $strWhereClause, $havingClause );

		if( !$keysSet )
			$strSQL = applyDBrecordLimit($strSQL.$orderClause, 1, $this->connection->dbType);

		$strSQLbak = $strSQL;
		$strWhereClauseBak = $strWhereClause;
		//	Before Query event
		if( $this->eventsObject->exists("BeforeQueryEdit") )
			$this->eventsObject->BeforeQueryEdit($strSQL, $strWhereClause, $this);

		if( $strSQLbak == $strSQL && $strWhereClauseBak != $strWhereClause )
		{
			$strSQL = $this->gQuery->gSQLWhere( $strWhereClause, $havingClause );
			if( !$keysSet )
				$strSQL = applyDBrecordLimit($strSQL.$orderClause, 1, $this->connection->dbType);
		}

		LogInfo($strSQL);

		$fetchedArray = $this->connection->query( $strSQL )->fetchAssoc();
		$this->cachedRecord = $this->cipherer->DecryptFetchedArray( $fetchedArray );

		if( !$keysSet )
		{
			$this->keys = $this->getKeysFromData( $this->cachedRecord );
			$this->setKeysForJs();
		}

		if( !$this->cachedRecord && $this->mode == EDIT_SIMPLE )
			return $this->cachedRecord;

		foreach($this->getPageFields() as $fName)
		{
			if( @$_POST["a"]!= "edited" && $this->pSet->getAutoUpdateValue($fName) !== "" )
				$this->cachedRecord[ $fName ] = $this->pSet->getAutoUpdateValue($fName);
		}

		if($this->readEditValues)
		{
			foreach($this->getPageFields() as $fName)
			{
				$editFormat = $this->pSet->getEditFormat($fName);
				if( $editFormat == EDIT_FORMAT_DATABASE_FILE && $editFormat != EDIT_FORMAT_DATABASE_IMAGE && $editFormat != EDIT_FORMAT_FILE && !$this->pSet->isReadonly($fName) )
					$this->cachedRecord[ $fName ] = $this->newRecordData[ $fName ];
			}
		}

		if( $this->eventsObject->exists("ProcessValuesEdit") )
			$this->eventsObject->ProcessValuesEdit($this->cachedRecord, $this);

		return $this->cachedRecord;
	}

	/**
	 * Check if the keys values were set through GET/POST 'editid' params
	 * or by using the setKeys method directly
	 * @return Boolean
	 */
	protected function checkKeysSet()
	{
		foreach($this->keys as $kValue)
		{
			if( strlen($kValue) )
				return true;
		}
		return false;
	}

	/**
	 * Prepare edit controls
	 */
	public function prepareEditControls( )
	{
		global $locale_info;
		if( $this->mode == EDIT_INLINE )
		{
			$fields = $this->editFields;
			$this->removeHiddenColumnsFromInlineFields( $fields, $this->screenWidth, $this->screenHeight, $this->orientation );
			$this->editFields = $fields;
		}

		//	prepare values
		$data = $this->getCurrentRecordInternal();
		if( $this->readEditValues )
		{
			foreach($this->editFields as $f)
			{
				if( !isset( $this->newRecordData[ $f ] ) )
					continue;
				$editFormat = $this->pSet->getEditFormat( $f );
				if( $editFormat != EDIT_FORMAT_DATABASE_FILE &&
					$editFormat != EDIT_FORMAT_DATABASE_IMAGE &&
					$editFormat != EDIT_FORMAT_READONLY )

					$data[ $f ] = $this->newRecordData[ $f ];
			}
		}

		$control = array();

		foreach($this->editFields as $fName)
		{
			$gfName = GoodFieldName($fName);
			$isDetKeyField = in_array($fName, $this->detailKeysByM);

			$control[ $gfName ] = array();

			$controls = array();
			$controls["controls"] = array();
			$controls["controls"]['ctrlInd'] = 0;
			$controls["controls"]['id'] = $this->id;
			$controls["controls"]['fieldName'] = $fName;

			$parameters = array();
			$parameters["id"] = $this->id;
			$parameters["ptype"] = PAGE_EDIT;
			$parameters["field"] = $fName;
			$parameters["pageObj"] = $this;
			$parameters["value"] = @$data[ $fName ];

			if( !$isDetKeyField )
			{
				if( IsFloatType( $this->pSet->getFieldType($fName) ) && !is_null( @$data[ $fName ] ) )
				{
					if( $this->pSet->getHTML5InputType( $fName ) == "number" )
					{
						//	no thousand delimiters, only dot as decimal delimiter
						$parameters["value"] = formatNumberForHTML5( @$data[ $fName ] );
					}
					else
						$parameters["value"] = str_replace(".", $locale_info["LOCALE_SDECIMAL"], @$data[ $fName ]);
				}

				$parameters["validate"] = $this->pSet->getValidation($fName);

				$additionalCtrlParams = array();
				$additionalCtrlParams["disabled"] = $this->controlsDisabled;
				$parameters["additionalCtrlParams"] = $additionalCtrlParams;
			}

			$controlMode = $this->mode == EDIT_INLINE ? "inline_edit" : "edit";
			$parameters["mode"] = $controlMode;
			$controls["controls"]['mode'] = $controlMode;

			if( $this->pSet->isUseRTE($fName) && $this->pSet->isAutoUpdatable($fName) )
			{
				$_SESSION[ $this->sessionPrefix."_".$fName."_rte" ] = GetAutoUpdateValue($fName, PAGE_EDIT);
				$control[ $gfName ]["params"]["mode"] = "add";
			}

			if( $isDetKeyField )
			{
				$controls["controls"]['value'] = @$data[ $fName ];

				$parameters["extraParams"] = array();
				$parameters["extraParams"]["getDetKeyReadOnlyCtrl"] = true;

				// to the ReadOnly control show the detail key cotnrol's value
				$this->readOnlyFields[ $fName ] = $this->showDBValue($fName, $data);
			}

			AssignFunction($control[ $gfName ], "xt_buildeditcontrol", $parameters);
			$this->xt->assignbyref($gfName."_editcontrol", $control[ $gfName ]);

			// category control field
			$strCategoryControl = $this->getMainLookupFieldNameForDependant($fName);

			if( strlen($strCategoryControl) && in_array($strCategoryControl, $this->editFields) )
				$vals = array($fName => @$data[ $fName ], $strCategoryControl => @$data[ $strCategoryControl ]);
			else
				$vals = array($fName => @$data[ $fName ]);

			$preload = $this->fillPreload($fName, $vals);
			if( $preload !== false )
				$controls["controls"]['preloadData'] = $preload;

			$this->fillControlsMap( $controls );
			$this->fillFieldToolTips( $fName );

			// fill special settings for timepicker
			if( $this->pSet->getEditFormat($fName) == 'Time' )
				$this->fillTimePickSettings($fName, $data[ $fName ]);

			if( $this->pSet->getViewFormat($fName) == FORMAT_MAP )
				$this->googleMapCfg['isUseGoogleMap'] = true;
		}
	}

	/**
	 * Assign edit fields' blocks and labels variables
	 */
	public function assignEditFieldsBlocksAndLabels()
	{
		$editFields = $this->pSet->getEditFields();

		foreach($editFields as $fName)
		{
			$gfName = GoodFieldName($fName);

			if( !$this->isAppearOnTabs($fName) )
				$this->xt->assign($gfName."_fieldblock", true);
			else
				$this->xt->assign($gfName."_tabfieldblock", true);

			$this->xt->assign($gfName."_label", true);
			if( $this->is508 )
				$this->xt->assign_section($gfName."_label","getInputElementId( $fName ) . "\">","");
		}
	}

	public static function readEditModeFromRequest()
	{
		if(postvalue("editType") == "inline")
			return EDIT_INLINE;
		elseif(postvalue("editType") == EDIT_POPUP)
			return EDIT_POPUP;
		elseif(postvalue("mode") == "dashrecord")
			return EDIT_DASHBOARD;
		else
			return EDIT_SIMPLE;

	}

	public static function processEditPageSecurity( $table )
	{
		//	user has necessary permissions
		if( Security::checkPagePermissions( $table, "E" ) )
			return true;

		// display entered data. Give the user chance to relogin. Do nothing for now.
		if( postvalue("a") == "edited" )
			return true;

		//	page can not be displayed. Redirect or return error

		$pageMode = EditPage::readEditModeFromRequest();

		//	return error if the page is requested by AJAX
		if( $pageMode != EDIT_SIMPLE )
		{
			Security::sendPermissionError();
			return false;
		}

		// The user is logged in but lacks necessary permissions
		// redirect to List page or Menu.
		if( isLogged() && !isLoggedAsGuest() )
		{
			Security::redirectToList( $table );
			return false;
		}

		//	Not logged in
		// 	redirect to Login
		//	Save current URL in session
		$keyParams = array();
		$i = 1;
		while( postvalue("editid".$i) )
		{
			$keyParams[] = "editid".$i."=".rawurlencode( postvalue("editid".$i) );
			$i++;
		}
		$_SESSION["MyURL"] = $_SERVER["SCRIPT_NAME"]."?".implode("&", $keyParams);
		redirectToLogin();
		return false;
	}

	/**
	 * Handle broken POST request.
	 */
	public static function handleBrokenRequest()
	{
		if( sizeof($_POST) != 0 || !postvalue('submit') )
			return;
		if( !postvalue("editid1") )
		{
			$returnJSON = array();
			$returnJSON['success'] = false;
			$returnJSON['message'] = "Error occurred";
			$returnJSON['fatalError'] = true;
			echo printJSON($returnJSON);
			exit();
		}
		else
		{
			if( postvalue('fly') )
			{
				echo -1;
				exit();
			}
			else
				$_SESSION["message_edit"] = "<< "."Error occurred"." >>";
		}
	}

	protected function buildNewRecordData()
	{
		// define temporary arrays. These are required for ASP conversion
		$evalues = array();
		$efilename_values = array();
		$blobfields = array();
		$keys = $this->keys;

		foreach($this->editFields as $f)
		{
			$control = $this->getControl( $f, $this->id);
			$control->readWebValue($evalues, $blobfields, NULL, NULL, $efilename_values);
			if( isset($keys[ $f ]) )
			{
				//	ASP conversion requires this separate "if".
				if( $keys[ $f ] != $control->getWebValue() )
				{
					$keys[ $f ] = $control->getWebValue();
					$this->keysChanged = true;
				}
			}
		}
		if( $this->keysChanged )
			$this->setKeys( $keys );

		foreach($efilename_values as $ekey => $value)
		{
			$evalues[ $ekey ] = $value;
		}
		$this->newRecordData = $evalues;
		$this->newRecordBlobFields = $blobfields;

	}

	/**
	 * Process user data input and save it to the database table
	 */
	public function processDataInput()
	{
		//	get prepared for the data saving
		$this->oldKeys = $this->keys;

		$this->buildNewRecordData();

		if( !$this->recheckUserPermissions() )
		{
			//	prevent the page from reading database values
			$this->oldRecordData = $this->newRecordData;
			$this->cachedRecord = $this->newRecordData;
			return false;
		}

		if( !$this->checkCaptcha() )
			return false;

		if( !$this->isRecordEditable( true ) )
			return $this->SecurityRedirect();

		if( !$this->callBeforeEditEvent() )
			return false;

		$this->addGeoValues();

		if( !$this->checkDeniedDuplicatedValues() )
			return false;

		if( !$this->confirmLockingBeforeSaving() )
			return false;

		//	do save the record
		if( $this->callCustomEditEvent() )
		{
			$this->updatedSuccessfully = DoUpdateRecord( $this );
		}

		$this->unlockNewRecord();

		if( !$this->updatedSuccessfully )
		{
			$this->setKeys( $this->oldKeys );
			return false;
		}
		//	after save steps

		$this->ProcessFiles();

		$this->setMessage( "<<< "."Record updated". ">>>" );
		$this->messageType = MESSAGE_INFO;

		$this->callAfterSuccessfulSave();

		$this->unlockOldRecord();

		$this->mergeNewRecordData();

		$this->callAfterEditEvent();

		$this->auditLogEdit();

		$this->setKeys( $this->keys );

		return true;
	}

	/**
	 * Check if updated data contains duplicated values
	 * @return Boolean
	 */
	protected function checkDeniedDuplicatedValues()
	{
		$oldData = $this->getOldRecordData();

		foreach($this->newRecordData as $f => $value)
		{
			if( $this->pSet->allowDuplicateValues($f) )
				continue;

			if( $oldData[ $f ] == $value )
				continue;

			if( !$this->hasDuplicateValue($f, $value) )
				continue;

			$this->setMessage( $this->pSet->label( $f ) . " " . "Field should not contain a duplicate value" );
			return false;
		}
		return true;
	}

	protected function auditLogEdit()
	{
		if( $this->auditObj )
			$this->auditObj->LogEdit($this->tName, $this->newRecordData, $this->getOldRecordData(), $this->keys);
	}

	/**
	 *	Add missing values from oldRecordData to newRecordData
	 *	This is required for the Audit and the AfterEdit event
	 */
	protected function mergeNewRecordData()
	{
		if( !$this->auditObj && !$this->eventsObject->exists("AfterEdit") )
			return;

		foreach($this->getOldRecordData() as $f => $v)
		{
			if( !isset( $this->newRecordData[ $f ] ) )
				$this->newRecordData[ $f ] = $v;
		}
	}

	/**
	 *	Call After Record Updated event
	 */
	protected function callAfterEditEvent()
	{
		if( !$this->eventsObject->exists("AfterEdit") )
			return;

		$this->eventsObject->AfterEdit( $this->newRecordData,
			$this->getWhereClause( false ),
			$this->getOldRecordData(),
			$this->keys,
			$this->mode == EDIT_INLINE,
			$this );
	}

	/**
	 *	Unlock the record not existing anymore after successful updating.
	 */
	protected function unlockOldRecord()
	{
		if( $this->lockingObj && $this->keysChanged )
			$this->lockingObj->UnlockRecord($this->tName, $this->oldKeys , "");
	}

	/**
	 *	Unlock the record to be created after unsuccessful updating.
	 */
	protected function unlockNewRecord()
	{
		if( $this->lockingObj )
			$this->lockingObj->UnlockRecord($this->tName, $this->keys , "");
	}

	/**
	 *	Call each control's afterSuccessfulSave method
	 */
	protected function callAfterSuccessfulSave()
	{
		foreach($this->editFields as $f)
		{
			$this->getControl($f, $this->id)->afterSuccessfulSave();
		}
	}

	/**
	 *	Call Before Record Updated event
	 */
	protected function callBeforeEditEvent()
	{
		if( !$this->eventsObject->exists("BeforeEdit") )
			return true;
		$usermessage = "";
		$ret = $this->eventsObject->BeforeEdit( $this->newRecordData,
			$this->getWhereClause( true ),
			$this->getOldRecordData(),
			$this->oldKeys,
			$usermessage,
			$this->mode == EDIT_INLINE,
			$this );

		//	this is required for the ASP conversion
		if( !$ret )
			$this->setMessage( $usermessage );

		return $ret;
	}

	/**
	 *	Call Custom Edit event
	 */
	protected function callCustomEditEvent()
	{
		if( !$this->eventsObject->exists("CustomEdit") )
			return true;
		$usermessage = "";
		$ret = $this->eventsObject->CustomEdit( $this->newRecordData,
			$this->getWhereClause( true ),
			$this->getOldRecordData(),
			$this->oldKeys,
			$usermessage,
			$this->mode == EDIT_INLINE,
			$this );

		//	this is required for the ASP conversion
		if( !$ret )
		{
			$this->setMessage( $usermessage );
			$this->updatedSuccessfully = ( 0 == strlen( $this->message ) );
		}
		return $ret;
	}

	/**
	 * Check whether the user have passed CAPTCHA test
	 * @return Boolean
	 */
	protected function checkCaptcha()
	{
		if( $this->mode == EDIT_INLINE || !$this->captchaExists() )
			return true;

		if( !$this->isCaptchaOk )
			return false;

		$_SESSION[ $this->tName."_count_captcha" ] = $_SESSION[ $this->tName."_count_captcha" ] + 1;
		return true;
	}

	protected function addGeoValues()
	{
		if( $this->isTableGeoUpdatable() )
			$this->setUpdatedLatLng( $this->getNewRecordData(), $this->getOldRecordData() );
	}

	protected function recheckUserPermissions()
	{
		if( CheckTablePermissions($this->tName, "E") )
			return true;
		if( isLoggedAsGuest() || !isLogged() )
		{
			$this->setMessage( "Your session has expired." .
				"id . "'>" .
				"Login" . "" .
				" to save data." );
		}
		else
		{
			$this->setMessage( 'You have no permissions to complete this action.' );
		}

		return false;
	}

	/**
	 *	Do locking stuff before saving the data.
	 *	Returns false if locking was unsuccessful and the saving action is impossible
	 */
	protected function confirmLockingBeforeSaving()
	{
		if( !$this->lockingObj )
			return true;
		$lockmessage = "";
		if( $this->keysChanged )
		{
			//	confirm and acquire locks on both old and new sets of keys
			$lockConfirmed = $this->lockingObj->ConfirmLock($this->tName, $this->oldKeys, $lockmessage);
			if( $lockConfirmed )
				$lockConfirmed = $this->lockingObj->LockRecord($this->tName, $this->keys);
		}
		else
		{
			//	confirm lock on the edited record
			$lockConfirmed = $this->lockingObj->ConfirmLock($this->tName, $this->oldKeys, $lockmessage);
		}

		if( !$lockConfirmed )
		{
			$this->lockingMessageStyle = "display:block";
			if( $this->mode == EDIT_INLINE )
			{
				if( IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP )
					$lockmessage = $this->lockingObj->GetLockInfo($this->tName, $this->oldKeys, false, $this->id);

				$returnJSON['success'] = false;
				$returnJSON['message'] = $lockmessage;
				$returnJSON['enableCtrls'] = false;
				$returnJSON['confirmTime'] = $this->lockingObj->ConfirmTime;
				echo printJSON($returnJSON);
				exit();
			}
			else
			{
				if( IsAdmin() || $_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMINGROUP )
					$this->lockingMessageText = $this->lockingObj->GetLockInfo($this->tName, $this->oldKeys, true, $id);
				else
					$this->lockingMessageText = $lockmessage;
			}
			$this->readEditValues = true;
			return false;
		}
		return true;
	}

	/**
	 *	Redirect the user from the page due to security reasons.
	 */
	protected function SecurityRedirect()
	{
		if($this->mode == EDIT_INLINE)
		{
			echo printJSON(array("success" => false, "message" => "The record is not editable"));
			exit();
		}
		Security::redirectToList( $this->tName );
		return;
	}

	/**
	 * @param Boolean useOldData
	 * @return Boolean
	 */
	protected function isRecordEditable( $useOldData )
	{
		global $globalEvents;
		if( $globalEvents->exists("IsRecordEditable", $this->tName) )
		{
			if( !$globalEvents->IsRecordEditable($useOldData ? $this->getOldRecordData() : $this->getCurrentRecordInternal(), true, $this->tName) )
				return false;
		}

		return true;
	}

	/**
	 * @return Array
	 */
	public function getOldRecordData()
	{
		if( $this->oldRecordData === null )
		{
			$strSQL = $this->gQuery->gSQLWhere( $this->getWhereClause( true ) );
			LogInfo($strSQL);
			$fetchedArray = $this->connection->query( $strSQL )->fetchAssoc();
			$this->oldRecordData = $this->cipherer->DecryptFetchedArray( $fetchedArray );
		}

		return $this->oldRecordData;
	}

	public function getBlobFields()
	{
		return $this->newRecordBlobFields;
	}

	public function & getNewRecordData()
	{
		return $this->newRecordData;
	}

	public function setMessage( $message )
	{
		$this->message = $message;
	}

	public function setDatabaseError( $message )
	{
		if( $this->mode != EDIT_INLINE )
		{
			$this->message = "<<< "."Record was NOT edited"." >>>

".$message;
		}
		else
			$this->message = "Record was NOT edited".". ".$message;

		$this->messageType = MESSAGE_ERROR;
	}

	/**
	 * Get the current record data to build correct edit controls (xt_buildeditcontrol)
	 * @return Array
	 */
	public function getFieldControlsData()
	{
		return $this->getCurrentRecordInternal();
	}
}
?>