text:
<?php

namespace Adriatic\PHPAkademija\DesignPattern\Decorator;

class WhippedCream extends CondimentDecorator
{
    public function getDescription() : string
    {
        return $this->beverage->getDescription() . ', šlag';
    }

    public function getCost() : float
    {
        return $this->beverage->getCost() + 0.29;
    }
}

redpajama_set_name: RedPajamaGithub


text:
"""remove primary key from biobank_order_identifier_history
Revision ID: 7d63fbc6d9ca
Revises: d06e4e1d124d
Create Date: 2019-08-20 10:33:02.458709
"""
from alembic import op

# revision identifiers, used by Alembic.
revision = '7d63fbc6d9ca'
down_revision = 'd06e4e1d124d'
branch_labels = None
depends_on = None

def upgrade(engine_name):
    globals()["upgrade_%s" % engine_name]()

def downgrade(engine_name):
    globals()["downgrade_%s" % engine_name]()

def upgrade_rdr():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute('ALTER TABLE biobank_order_identifier_history DROP PRIMARY KEY;')
    # ### end Alembic commands ###

def downgrade_rdr():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute('ALTER TABLE biobank_order_identifier_history ADD CONSTRAINT contacts_pk PRIMARY KEY (`system`, `value`, `version`);')
    # ### end Alembic commands ###

def upgrade_metrics():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###

def downgrade_metrics():
    # ### commands auto generated by Alembic - please adjust! ###
    pass
    # ### end Alembic commands ###


text:
package cfvbaibai.cardfantasy.engine.skill;

import cfvbaibai.cardfantasy.GameUI;
import cfvbaibai.cardfantasy.data.Skill;
import cfvbaibai.cardfantasy.engine.*;

import java.util.List;

public final class ReturnCardAndDelay {
    public static void apply(SkillResolver resolver, Skill cardSkill, CardInfo attacker, Player defenderHero,int delay) throws HeroDieSignal {
        if (attacker == null) {
            return;
        }
        List<CardInfo> defenderList =defenderHero.getField().getAliveCards();
        GameUI ui = resolver.getStage().getUI();
        for(CardInfo defender :defenderList) {
            if (defender == null || defender.isBoss()) {
                continue;
            }
            OnAttackBlockingResult result = resolver.resolveAttackBlockingSkills(attacker, defender, cardSkill, 1);
            if (!result.isAttackable()) {
                continue;
            }
            if (defenderHero.getHand().isFull()) {
                ui.useSkill(attacker, defender, cardSkill, true);
                Return.returnCard2(resolver, cardSkill, attacker, defender, true);
                if (!defender.getStatus().containsStatus(CardStatusType.召唤)) {
                    resolver.getStage().getUI().increaseSummonDelay(defender, delay);
                    defender.setAddDelay(2);
                }
                continue;
            }
            ui.useSkill(attacker, defender, cardSkill, true);
            Return.returnHand(resolver, cardSkill, attacker, defender);
            int summonDelay = defender.getSummonDelay();
            if (!defender.getStatus().containsStatus(CardStatusType.召唤)) {
                resolver.getStage().getUI().increaseSummonDelay(defender, delay);
                defender.setSummonDelay(summonDelay + delay);
            }
        }
    }
}


text:
<?php

namespace Hoa\Iterator\Recursive;

/**
 * Class \Hoa\Iterator\Recursive\Directory.
 *
 * Extending the SPL RecursiveDirectoryIterator class.
 *
 * @copyright  Copyright © 2007-2015 Hoa community
 * @license    New BSD License
 */
class Directory extends \RecursiveDirectoryIterator
{
    /**
     * SplFileInfo classname.
     *
     * @var string
     */
    protected $_splFileInfoClass = null;

    /**
     * Relative path.
     *
     * @var string
     */
    protected $_relativePath     = 0;

    /**
     * Workaround for the bug #65136.
     *
     * @var string
     */
    private static $_handlePath  = null;

    /**
     * Constructor.
     * Please, see \RecursiveDirectoryIterator::__construct() method.
     * We add the $splFileInfoClass parameter.
     *
     * @param   string  $path                Path.
     * @param   int     $flags               Flags.
     * @param   string  $splFileInfoClass    SplFileInfo classname.
     */
    public function __construct($path, $flags = null, $splFileInfoClass = null)
    {
        if (null === $flags) {
            parent::__construct($path);
        } else {
            parent::__construct($path, $flags);
        }

        if (null !== self::$_handlePath) {
            $this->_relativePath = self::$_handlePath;
            self::$_handlePath   = null;
        } else {
            $this->_relativePath = $path;
        }

        $this->setSplFileInfoClass($splFileInfoClass);

        return;
    }

    /**
     * Current.
     * Please, see \RecursiveDirectoryIterator::current() method.
     *
     * @return  mixed
     */
    public function current()
    {
        $out = parent::current();

        if (null !== $this->_splFileInfoClass &&
            $out instanceof \SplFileInfo) {
            $out->setInfoClass($this->_splFileInfoClass);
            $out = $out->getFileInfo();

            if ($out instanceof \Hoa\Iterator\SplFileInfo) {
                $out->setRelativePath($this->getRelativePath());
            }
        }

        return $out;
    }

    /**
     * Get children.
     * Please, see \RecursiveDirectoryIterator::getChildren() method.
     *
     * @return  mixed
     */
    public function getChildren()
    {
        self::$_handlePath = $this->getRelativePath();
        $out               = parent::getChildren();

        if ($out instanceof \RecursiveDirectoryIterator) {
            $out->setSplFileInfoClass($this->_splFileInfoClass);
        }

        return $out;
    }

    /**
     * Set SplFileInfo classname.
     *
     * @param   string  $splFileInfoClass    SplFileInfo classname.
     * @return  void
     */
    public function setSplFileInfoClass($splFileInfoClass)
    {
        $this->_splFileInfoClass = $splFileInfoClass;

        return;
    }

    /**
     * Get relative path (if given).
     *
     * @return  string
     */
    public function getRelativePath()
    {
        return $this->_relativePath;
    }
}


text:
var _ = require('lodash'),
    moment = require('moment-timezone'),
    satellite = require('satellite.js').satellite,
    request = require('request'),
    earliestSeenData = undefined;

function julianYearAndDayToTimestamp(year, days) {
    var thisCentury = Math.round(moment().get('year') / 100) * 100;
    var time = moment({year: thisCentury + year});
    time.add(days, 'days');
    return time.unix();
}

function processTle(name, line1, line2, temporalDataCallback) {
    var now = new Date();
    var record = satellite.twoline2satrec(line1, line2);
    var positionAndVelocity = satellite.propagate(
        record,
        now.getUTCFullYear(),
        now.getUTCMonth() + 1,
        now.getUTCDate(),
        now.getUTCHours(),
        now.getUTCMinutes(),
        now.getUTCSeconds()
    );
    var position = positionAndVelocity.position;
    var velocity = positionAndVelocity.velocity;
    var timestamp = julianYearAndDayToTimestamp(record.epochyr, record.epochdays);
    var fieldValues;

    if (positionAndVelocity.length) {
        // bad data point.
        return;
    }

    // If any values are NaN, ingore the whole point.
    if (isNaN(position.x) || isNaN(position.y) || isNaN(position.z) ||
        isNaN(velocity.x) || isNaN(velocity.y) || isNaN(velocity.z)) {
        return;
    }

    fieldValues = [
        position.x,
        position.y,
        position.z,
        velocity.x,
        velocity.y,
        velocity.z
    ];

    temporalDataCallback(name, timestamp, fieldValues);
}

function processTleBody(body, temporalDataCallback) {
    var lines = body.split('\n'),
        name, line1, line2;

    _.each(lines, function(line) {
        if (! name) {
            name = line.substr(2);
        } else if (! line1) {
            line1 = line;
        } else {
            line2 = line;
            processTle(name, line1, line2, temporalDataCallback);
            name = undefined;
            line1 = undefined;
            line2 = undefined;
        }
    });
}

function processJspoc(body, metaDataCallback) {
    var lines = body.split('\n');
    _.each(_.filter(lines, function(line) {
        return line.length && ! _.startsWith(line, '#');
    }), function(line) {
        var catid = line.substr(0, 5).trim();
        var name = line.substr(7, 20).toUpperCase().trim();
        var rms = line.substr(27, 6).trim();
        metaDataCallback(name, {
            catid: catid,
            rms: rms
        });
        // Sometimes there is a 2nd record for the same catid.
        if (line.length > 35) {
            name = line.substr(31, 20).toUpperCase().trim();
            rms = line.substr(51, 6).trim();
        }
        metaDataCallback(name, {
            catid: catid,
            rms: rms
        });
    });
}

function initialize(options, callback) {
    earliestSeenData = options.lastUpdated;
    callback();
}

function preload(since, until, config, temporalDataCallback) {
    var current = since;
    var urlPattern = config.historicUrlPattern;
    var yesterday = moment().subtract(1, 'day');
    if (! until) {
        until = yesterday;
    }
    while (current < until) {
        //var day = current.day();
        var replacement = current.format('YYYYMMDD');
        var url = urlPattern.replace('YYYYMMDD', replacement);
        if (current >= yesterday) {
            break;
        }
        request.get(url, function(error, response, body) {
            if (error) {
                //console.info(error);
                return;
            }
            if (response.statusCode != 200) {
                //console.info('%s returned status code %s', url, response.statusCode);
                return;
            }
            parse(body, {
                url: url,
                config: config
            }, temporalDataCallback)
        });
        current = current.add(1, 'day');
    }
}

function parse(body, options, temporalDataCallback, metaDataCallback) {
    var url = options.source,
        timezone = options.config.timezone;

    moment.tz.setDefault(timezone);
    if (_.contains(url, 'jspoc_matches')) {
        processJspoc(body, metaDataCallback);
        // Let's preload data for the past 6 months if it doesn't already exist.
        if (! earliestSeenData || earliestSeenData.add(1, 'month') > moment()) {
            preload(
                moment().subtract(18, 'months'),
                earliestSeenData,
                options.config,
                temporalDataCallback
            );
        }
    } else {
        processTleBody(body, temporalDataCallback);
    }
}

module.exports = {
    initialize: initialize,
    parse: parse
};


text:
namespace ash {

namespace {

// ShelfModelObserver implementation that tracks what message are invoked.
class TestShelfModelObserver : public ShelfModelObserver {
 public:
  TestShelfModelObserver()
      : added_count_(0),
        removed_count_(0),
        changed_count_(0),
        moved_count_(0) {
  }

  // Returns a string description of the changes that have occurred since this
  // was last invoked. Resets state to initial state.
  std::string StateStringAndClear() {
    std::string result;
    AddToResult("added=%d", added_count_, &result);
    AddToResult("removed=%d", removed_count_, &result);
    AddToResult("changed=%d", changed_count_, &result);
    AddToResult("moved=%d", moved_count_, &result);
    added_count_ = removed_count_ = changed_count_ = moved_count_ = 0;
    return result;
  }

  // ShelfModelObserver overrides:
  void ShelfItemAdded(int index) override { added_count_++; }
  void ShelfItemRemoved(int index, ShelfID id) override { removed_count_++; }
  void ShelfItemChanged(int index, const ShelfItem& old_item) override {
    changed_count_++;
  }
  void ShelfItemMoved(int start_index, int target_index) override {
    moved_count_++;
  }

 private:
  void AddToResult(const std::string& format, int count, std::string* result) {
    if (!count)
      return;
    if (!result->empty())
      *result += " ";
    *result += base::StringPrintf(format.c_str(), count);
  }

  int added_count_;
  int removed_count_;
  int changed_count_;
  int moved_count_;

  DISALLOW_COPY_AND_ASSIGN(TestShelfModelObserver);
};

}  // namespace

class ShelfModelTest : public testing::Test {
 public:
  ShelfModelTest() {}
  ~ShelfModelTest() override {}

  void SetUp() override {
    model_.reset(new ShelfModel);
    observer_.reset(new TestShelfModelObserver);
    EXPECT_EQ(0, model_->item_count());

    ShelfItem item;
    item.type = TYPE_APP_LIST;
    model_->Add(item);
    EXPECT_EQ(1, model_->item_count());

    model_->AddObserver(observer_.get());
  }

  void TearDown() override {
    observer_.reset();
    model_.reset();
  }

  std::unique_ptr<ShelfModel> model_;
  std::unique_ptr<TestShelfModelObserver> observer_;

 private:
  DISALLOW_COPY_AND_ASSIGN(ShelfModelTest);
};

TEST_F(ShelfModelTest, BasicAssertions) {
  // Add an item.
  ShelfItem item;
  item.type = TYPE_APP_SHORTCUT;
  int index = model_->Add(item);
  EXPECT_EQ(2, model_->item_count());
  EXPECT_EQ("added=1", observer_->StateStringAndClear());

  // Change to a platform app item.
  ShelfID original_id = model_->items()[index].id;
  item.type = TYPE_PLATFORM_APP;
  model_->Set(index, item);
  EXPECT_EQ(original_id, model_->items()[index].id);
  EXPECT_EQ("changed=1", observer_->StateStringAndClear());
  EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[index].type);

  // Remove the item.
  model_->RemoveItemAt(index);
  EXPECT_EQ(1, model_->item_count());
  EXPECT_EQ("removed=1", observer_->StateStringAndClear());

  // Add an app item.
  item.type = TYPE_APP_SHORTCUT;
  index = model_->Add(item);
  observer_->StateStringAndClear();

  // Change everything.
  model_->Set(index, item);
  EXPECT_EQ("changed=1", observer_->StateStringAndClear());
  EXPECT_EQ(TYPE_APP_SHORTCUT, model_->items()[index].type);

  // Add another item.
  item.type = TYPE_APP_SHORTCUT;
  model_->Add(item);
  observer_->StateStringAndClear();

  // Move the second to the first.
  model_->Move(1, 0);
  EXPECT_EQ("moved=1", observer_->StateStringAndClear());

  // And back.
  model_->Move(0, 1);
  EXPECT_EQ("moved=1", observer_->StateStringAndClear());

  // Verifies all the items get unique ids.
  std::set<ShelfID> ids;
  for (int i = 0; i < model_->item_count(); ++i)
    ids.insert(model_->items()[i].id);
  EXPECT_EQ(model_->item_count(), static_cast<int>(ids.size()));
}

// Assertions around where items are added.
TEST_F(ShelfModelTest, AddIndices) {
  // Insert browser short cut at index 1.
  ShelfItem browser_shortcut;
  browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
  int browser_shortcut_index = model_->Add(browser_shortcut);
  EXPECT_EQ(1, browser_shortcut_index);

  // platform app items should be after browser shortcut.
  ShelfItem item;
  item.type = TYPE_PLATFORM_APP;
  int platform_app_index1 = model_->Add(item);
  EXPECT_EQ(2, platform_app_index1);

  // Add another platform app item, it should follow first.
  int platform_app_index2 = model_->Add(item);
  EXPECT_EQ(3, platform_app_index2);

  // APP_SHORTCUT priority is higher than PLATFORM_APP but same as
  // BROWSER_SHORTCUT. So APP_SHORTCUT is located after BROWSER_SHORCUT.
  item.type = TYPE_APP_SHORTCUT;
  int app_shortcut_index1 = model_->Add(item);
  EXPECT_EQ(2, app_shortcut_index1);

  item.type = TYPE_APP_SHORTCUT;
  int app_shortcut_index2 = model_->Add(item);
  EXPECT_EQ(3, app_shortcut_index2);

  // Check that AddAt() figures out the correct indexes for app shortcuts.
  // APP_SHORTCUT and BROWSER_SHORTCUT has the same weight.
  // So APP_SHORTCUT is located at index 0. And, BROWSER_SHORTCUT is located at
  // index 1.
  item.type = TYPE_APP_SHORTCUT;
  int app_shortcut_index3 = model_->AddAt(1, item);
  EXPECT_EQ(1, app_shortcut_index3);

  item.type = TYPE_APP_SHORTCUT;
  int app_shortcut_index4 = model_->AddAt(6, item);
  EXPECT_EQ(5, app_shortcut_index4);

  item.type = TYPE_APP_SHORTCUT;
  int app_shortcut_index5 = model_->AddAt(3, item);
  EXPECT_EQ(3, app_shortcut_index5);

  // Before there are any panels, no icons should be right aligned.
  EXPECT_EQ(model_->item_count(), model_->FirstPanelIndex());

  // Check that AddAt() figures out the correct indexes for platform apps and
  // panels.
  item.type = TYPE_PLATFORM_APP;
  int platform_app_index3 = model_->AddAt(3, item);
  EXPECT_EQ(7, platform_app_index3);

  item.type = TYPE_APP_PANEL;
  int app_panel_index1 = model_->AddAt(2, item);
  EXPECT_EQ(10, app_panel_index1);

  item.type = TYPE_PLATFORM_APP;
  int platform_app_index4 = model_->AddAt(11, item);
  EXPECT_EQ(10, platform_app_index4);

  item.type = TYPE_APP_PANEL;
  int app_panel_index2 = model_->AddAt(12, item);
  EXPECT_EQ(12, app_panel_index2);

  item.type = TYPE_PLATFORM_APP;
  int platform_app_index5 = model_->AddAt(7, item);
  EXPECT_EQ(7, platform_app_index5);

  item.type = TYPE_APP_PANEL;
  int app_panel_index3 = model_->AddAt(13, item);
  EXPECT_EQ(13, app_panel_index3);

  // Right aligned index should be the first app panel index.
  EXPECT_EQ(12, model_->FirstPanelIndex());

  EXPECT_EQ(TYPE_BROWSER_SHORTCUT, model_->items()[2].type);
  EXPECT_EQ(TYPE_APP_LIST, model_->items()[0].type);
}

// Test that the indexes for the running applications are properly determined
// when the first running application is a windowed application.
TEST_F(ShelfModelTest, FirstRunningAppIndexUsingWindowedAppFirst) {
  // Insert the browser shortcut at index 1 and check that the running
  // application index would be behind it.
  ShelfItem item;
  item.type = TYPE_BROWSER_SHORTCUT;
  EXPECT_EQ(1, model_->Add(item));
  EXPECT_EQ(2, model_->FirstRunningAppIndex());

  // Insert a panel application at the end and check that the running
  // application index would be at / before the application panel.
  item.type = TYPE_APP_PANEL;
  EXPECT_EQ(2, model_->Add(item));
  EXPECT_EQ(2, model_->FirstRunningAppIndex());

  // Insert an application shortcut and make sure that the running application
  // index would be behind it.
  item.type = TYPE_APP_SHORTCUT;
  EXPECT_EQ(2, model_->Add(item));
  EXPECT_EQ(3, model_->FirstRunningAppIndex());

  // Insert different running application shortcuts - but first a windowed
  // application - and make sure that the same index gets returned.
  item.type = TYPE_WINDOWED_APP;
  int running_app_index = model_->Add(item);
  EXPECT_EQ(3, running_app_index);
  EXPECT_EQ(running_app_index, model_->FirstRunningAppIndex());
  item.type = TYPE_PLATFORM_APP;
  EXPECT_EQ(running_app_index + 1, model_->Add(item));
  EXPECT_EQ(running_app_index, model_->FirstRunningAppIndex());
}

// Test that the indexes for the running applications are properly determined
// when the first running application is a platform application.
TEST_F(ShelfModelTest, FirstRunningAppIndexUsingPlatformAppFirst) {
  // Insert the browser shortcut at index 1 and check that the running
  // application index would be behind it.
  ShelfItem item;
  item.type = TYPE_BROWSER_SHORTCUT;
  EXPECT_EQ(1, model_->Add(item));
  EXPECT_EQ(2, model_->FirstRunningAppIndex());

  // Insert a panel application at the end and check that the running
  // application index would be at / before the application panel.
  item.type = TYPE_APP_PANEL;
  EXPECT_EQ(2, model_->Add(item));
  EXPECT_EQ(2, model_->FirstRunningAppIndex());

  // Insert an application shortcut and make sure that the running application
  // index would be behind it.
  item.type = TYPE_APP_SHORTCUT;
  EXPECT_EQ(2, model_->Add(item));
  EXPECT_EQ(3, model_->FirstRunningAppIndex());

  // Insert different running application shortcuts - but first a platfom
  // application - and make sure that the same index gets returned.
  item.type = TYPE_PLATFORM_APP;
  int running_app_index = model_->Add(item);
  EXPECT_EQ(3, running_app_index);
  EXPECT_EQ(running_app_index, model_->FirstRunningAppIndex());
  item.type = TYPE_WINDOWED_APP;
  EXPECT_EQ(running_app_index + 1, model_->Add(item));
  EXPECT_EQ(running_app_index, model_->FirstRunningAppIndex());
}

// Assertions around id generation and usage.
TEST_F(ShelfModelTest, ShelfIDTests) {
  // Get the next to use ID counter.
  ShelfID id = model_->next_id();

  // Calling this function multiple times does not change the returned ID.
  EXPECT_EQ(model_->next_id(), id);

  // Check that when we reserve a value it will be the previously retrieved ID,
  // but it will not change the item count and retrieving the next ID should
  // produce something new.
  EXPECT_EQ(model_->reserve_external_id(), id);
  EXPECT_EQ(1, model_->item_count());
  ShelfID id2 = model_->next_id();
  EXPECT_NE(id2, id);

  // Adding another item to the list should also produce a new ID.
  ShelfItem item;
  item.type = TYPE_PLATFORM_APP;
  model_->Add(item);
  EXPECT_NE(model_->next_id(), id2);
}

// This verifies that converting an existing item into a lower weight category
// (e.g. shortcut to running but not pinned app) will move it to the proper
// location. See crbug.com/248769.
TEST_F(ShelfModelTest, CorrectMoveItemsWhenStateChange) {
  // The first item is the app list and last item is the browser.
  ShelfItem browser_shortcut;
  browser_shortcut.type = TYPE_BROWSER_SHORTCUT;
  int browser_shortcut_index = model_->Add(browser_shortcut);
  EXPECT_EQ(TYPE_APP_LIST, model_->items()[0].type);
  EXPECT_EQ(1, browser_shortcut_index);

  // Add three shortcuts. They should all be moved between the two.
  ShelfItem item;
  item.type = TYPE_APP_SHORTCUT;
  int app1_index = model_->Add(item);
  EXPECT_EQ(2, app1_index);
  int app2_index = model_->Add(item);
  EXPECT_EQ(3, app2_index);
  int app3_index = model_->Add(item);
  EXPECT_EQ(4, app3_index);

  // Now change the type of the second item and make sure that it is moving
  // behind the shortcuts.
  item.type = TYPE_PLATFORM_APP;
  model_->Set(app2_index, item);

  // The item should have moved in front of the app launcher.
  EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[4].type);
}

}  // namespace ash


text:
from feedplatform import test as feedev
from feedplatform.lib import feed_image_restrict_mediatypes
from _image_test_utils import image_hook_counter, FeedWithImage

def test_restrict_mediatype():
    """Test mime type validation.
    """
    counter = image_hook_counter()
    ADDINS = [feed_image_restrict_mediatypes(('image/png', 'image/gif')), counter]

    class TestFeedImage(feedev.File):
        content = ""
        def headers(p):
            if p == 1:   return {'Content-Type': 'text/plain'}
            elif p == 2: return {'Content-Type': 'image/jpeg'}
            elif p == 3: return {'Content-Type': 'image/png; charset=ISO-8859-1'}  # charsets are correctly parsed out
            elif p == 4: return {'Content-Type': 'image/png'}

    class TestFeed(feedev.Feed):
        content = FeedWithImage % (TestFeedImage.url)

        def pass1(feed):
            assert counter.success == 0
        def pass2(feed):
            assert counter.success == 0
        def pass3(feed):
            assert counter.success == 1
        def pass4(feed):
            assert counter.success == 2

    feedev.testcaller()

def test_failure_reset():
    """Image fails if no valid extension (=no image).
    """

    counter = image_hook_counter()
    ADDINS = [feed_image_restrict_mediatypes(('image/png', 'image/gif')), counter]

    class TestFeedImage(feedev.File):
        content = ""
        def headers(p):
            if p == 1:   return {'Content-Type': 'image/png'}
            elif p == 2: return {'Content-Type': 'image/jpeg'}

    class TestFeed(feedev.Feed):
        content = FeedWithImage % TestFeedImage.url

        def pass1(feed):
            assert counter.failure == 0

        def pass2(feed):
            # invalid media types cause the image to fail completely
            assert counter.failure == 1

    feedev.testcaller()


text:
// THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
// WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
// TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
// DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS
// ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS
// OF THE CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.

package com.westhealth.aperture.STMlibs;

import android.nfc.Tag;
import android.nfc.tech.NfcV;
//import android.util.Log;

public class NFCCommand {

	 //***********************************************************************/
	 //* the function send an Inventory command (0x26 0x01 0x00)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //***********************************************************************/
	 public static byte[] SendInventoryCommand (Tag myTag)
	 {
		 byte[] UIDFrame = new byte[] { (byte) 0x26, (byte) 0x01, (byte) 0x00 };
		 byte[] response = new byte[] { (byte) 0x01 };

		 int errorOccured = 1;
		 while(errorOccured != 0)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(UIDFrame);
				 nfcvTag.close();
				 if (response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC )
				 {
					//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteToString((byte) 0x26) + " " + Helper.ConvertHexByteToString((byte) 0x01) + " " + Helper.ConvertHexByteToString((byte) 0x00) );
					 errorOccured = 0;
				 }
			 }
			 catch (Exception e)
			 {
				 errorOccured ++;
				//Used for DEBUG : Log.i("Polling**ERROR***", "SendInventoryCommand" + Integer.toString(errorOccured));
				 if(errorOccured >= 2)
				 {
					//Used for DEBUG : Log.i("Exception","Inventory Exception " + e.getMessage());
					 return response;
				 }
			}
		 }
		//Used for DEBUG : Log.i("NFCCOmmand", "Response " + Helper.ConvertHexByteToString((byte)response[0]));
		 return response;
	 }

	 //***********************************************************************/
	 //* the function send an Get System Info command (0x02 0x2B)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //***********************************************************************/
	 //public static byte[] SendGetSystemInfoCommandCustom_Inventory (Tag myTag, DataDevice ma)
	 public static byte[] SendGetSystemInfoCommandCustom (Tag myTag, DataDevice ma)
	 {
		 boolean boolDeviceDetected = false;

		 // --- 1st Step : Inventory to detect 1 or 2 bytes address ---
		 byte[] UIDFrame = new byte[] { (byte) 0x26, (byte) 0x01, (byte) 0x00 };
		 byte[] response = new byte[] { (byte) 0xAA };

		 int errorOccured = 1;
		 while(errorOccured != 0)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(UIDFrame);
				 nfcvTag.close();
				 if (response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC )
				 {
					//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteToString((byte) 0x26) + " " + Helper.ConvertHexByteToString((byte) 0x01) + " " + Helper.ConvertHexByteToString((byte) 0x00) );
					 errorOccured = 0;
				 }
			 }
			 catch (Exception e)
			 {
				 errorOccured ++;
				//Used for DEBUG : Log.i("Polling**ERROR***", "SendInventoryCommand" + Integer.toString(errorOccured));
				 if(errorOccured >= 5)
				 {
					//Used for DEBUG : Log.i("Exception","Inventory Exception " + e.getMessage());
					 return response;
				 }
			}
		 }

		 // Inventory UID analysis
		 if (response[9] == (byte) 0xE0)
		 {
			 if (response[8] == (byte) 0x02) //ST product
			 {
				 //**** PRODUCT NAME *****
				 if(response[7] >= (byte) 0x04 && response[7] <= (byte) 0x07)
				 {
				 	 //ma.setProductName("LRI512");
				 	 ma.setBasedOnTwoBytesAddress(false);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x14 && response[7] <= (byte) 0x17)
				 {
				 	 //ma.setProductName("LRI64");
					 ma.setBasedOnTwoBytesAddress(true);
					 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x20 && response[7] <= (byte) 0x23)
				 {
				 	 //ma.setProductName("LRI2K");
					 ma.setBasedOnTwoBytesAddress(false);
					 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x28 && response[7] <= (byte) 0x2B)
				 {
				 	 //ma.setProductName("LRIS2K");
				 	 ma.setBasedOnTwoBytesAddress(false);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x2C && response[7] <= (byte) 0x2F)
				 {
				 	 //ma.setProductName("M24LR64");
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x40 && response[7] <= (byte) 0x43)
				 {
				 	 //ma.setProductName("LRI1K");
				 	 ma.setBasedOnTwoBytesAddress(false);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x44 && response[7] <= (byte) 0x47)
				 {
				 	 //ma.setProductName("LRIS64K");
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x48 && response[7] <= (byte) 0x4B)
				 {
				 	 //ma.setProductName("M24LR01E");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(false);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x4C && response[7] <= (byte) 0x4F)
				 {
				 	 //ma.setProductName("M24LR16E");
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x50 && response[7] <= (byte) 0x53)
				 {
				 	 //ma.setProductName("M24LR02E");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(false);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x54 && response[7] <= (byte) 0x57)
				 {
				 	 //ma.setProductName("M24LR32E");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x58 && response[7] <= (byte) 0x5B)
				 {
					 //ma.setProductName("M24LR04E");
					 ma.setBasedOnTwoBytesAddress(false);
					 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x5C && response[7] <= (byte) 0x5F)
				 {
				 	 //ma.setProductName("M24LR64E");
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x60 && response[7] <= (byte) 0x63)
				 {
				 	 //ma.setProductName("M24LR08E");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(false);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x64 && response[7] <= (byte) 0x67)
				 {
				 	 //ma.setProductName("M24LR128E");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0x6C && response[7] <= (byte) 0x6F)
				 {
				 	 //ma.setProductName("M24LR256E");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else if(response[7] >= (byte) 0xF8 && response[7] <= (byte) 0xFB)
				 {
				 	 //ma.setProductName("detected product");	This product oen't exists
				 	 ma.setBasedOnTwoBytesAddress(true);
				 	 boolDeviceDetected=true;
				 }
				 else
				 {
				 	 //ma.setProductName("Unknown product");
					 ma.setBasedOnTwoBytesAddress(true);
					 boolDeviceDetected=false;
				 }

			 }
			 else // Non ST product
			 {
				 ma.setBasedOnTwoBytesAddress(false);
				 boolDeviceDetected=true;
			 }

		 }
		 else
			 boolDeviceDetected=false;

		 int cpt2 = 0;
		 int cpt_2bytes = 0;
		 int cpt1=0;
		 int cpt_1bytes=0;

		 response = new byte[] { (byte) 0xAA };
		 byte[] GetSystemInfoFrame2bytesAddress = new byte[2];
		 GetSystemInfoFrame2bytesAddress = new byte[] { (byte) 0x0A, (byte) 0x2B };
		 byte[] GetSystemInfoFrame1bytesAddress = new byte[2];
		 GetSystemInfoFrame1bytesAddress = new byte[] { (byte) 0x02, (byte) 0x2B };

		 // INVENTORY HAS DETECTED DEVICE ... READING GET SYSTEM INFO
		 if (boolDeviceDetected == true)
		 {
				 //while ((response == null || response[0] == 1 || response[0] == (byte)0xAA) && cpt <= 1 && cpt_2bytes <= 2)
				 while ((response == null || response[0] == (byte)0xAA) && cpt2 <= 1 && cpt_2bytes <= 5)
				 {
					 try
					 {
						 cpt_2bytes++;
						 NfcV nfcvTag = NfcV.get(myTag);
						 nfcvTag.close();
						 nfcvTag.connect();
						 if (ma.isBasedOnTwoBytesAddress() == true)
							 response = nfcvTag.transceive(GetSystemInfoFrame2bytesAddress);
						 else
							 response = nfcvTag.transceive(GetSystemInfoFrame1bytesAddress);
						 //nfcvTag.close(); //-> deleted 20130717 too long time consuming
						 if (response[0] == (byte) 0x00)
						 {
						 	return response;
						 }
					 }
					 catch (Exception e)
					 {
						//Used for DEBUG : Log.i("Exception","Get System Info Exception " + e.getMessage());
						 ma.setBasedOnTwoBytesAddress(false);
						 cpt2++;
					}
				 }
		 }
		 // INVENTORY HAS NOT DETECTED DEVICE ... TRYING WITH GET SYSTEM INFO ROUTINE
		 else
		 {
			 int cpt = 0;
			 response = new byte[] { (byte) 0xAA };
			 byte[] GetSystemInfoFrame = new byte[2];

			 // to know if tag's addresses are coded on 1 or 2 byte we consider 2
			 // then we wait the response if it's not good we trying with 1
			 ma.setBasedOnTwoBytesAddress(true);

			 //1st flag=1 for 2 bytes address products
			 GetSystemInfoFrame = new byte[] { (byte) 0x0A, (byte) 0x2B };
			 while ((response == null || response[0] == (byte)0xAA) && cpt <= 1)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(GetSystemInfoFrame);
					 nfcvTag.close();
					 if (response[0] == (byte) 0x00)
					 {
						ma.setBasedOnTwoBytesAddress(true);	//1st (flag=1) = 2 add bytes (M24LR64 FREEDOM2)
					 	return response;
					 }
				 }
				 catch (Exception e)
				 {
					//Used for DEBUG : Log.i("Exception","Get System Info Exception " + e.getMessage());
					 cpt++;
				}
			 }

			 //2nd flag=0 for 1 byte address products
			 cpt=0;
			 GetSystemInfoFrame = new byte[] { (byte) 0x02, (byte) 0x2B };
			 while ((response == null || response[0] == (byte)0xAA) && cpt <= 1)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(GetSystemInfoFrame);
					 nfcvTag.close();
					 if (response[0] == (byte) 0x00)
					 {
						ma.setBasedOnTwoBytesAddress(false);	//1st (flag=1) = 2 add bytes (M24LR64 FREEDOM2)
					 	return response;
					 }
				 }
				 catch (Exception e)
				 {
					//Used for DEBUG : Log.i("Exception","Get System Info Exception " + e.getMessage());
					 cpt++;
				}
			 }

			//Used for DEBUG : Log.i("NFCCOmmand", "Response Get System Info " + Helper.ConvertHexByteArrayToString(response));
			return response;
		 }

		 //Used for DEBUG : Log.i("NFCCOmmand", "Response Get System Info " + Helper.ConvertHexByteArrayToString(response));
		return response;
	 }

	 //***********************************************************************/
	 //* the function send an Get System Info command (0x02 0x2B)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //***********************************************************************/
	 public static byte[] SendGetSystemInfoCommandCustom_v3 (Tag myTag, DataDevice ma)
	 {
		 int cpt = 0;
		 byte[] response = new byte[] { (byte) 0xAA };
		 byte[] GetSystemInfoFrame = new byte[2];

		 // to know if tag's addresses are coded on 1 or 2 byte we consider 2
		 // then we wait the response if it's not good we trying with 1
		 ma.setBasedOnTwoBytesAddress(true);

		 //1st flag=1 for 2 bytes address products
		 GetSystemInfoFrame = new byte[] { (byte) 0x0A, (byte) 0x2B };
		 while ((response == null || response[0] == 1 || response[0] == (byte)0xAA) && cpt <= 1)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(GetSystemInfoFrame);
				 nfcvTag.close();
				 if (response[0] == (byte) 0x00)
				 {
					ma.setBasedOnTwoBytesAddress(true);	//1st (flag=1) = 2 add bytes (M24LR64 FREEDOM2)
				 	return response;
				 }
			 }
			 catch (Exception e)
			 {
				//Used for DEBUG : Log.i("Exception","Get System Info Exception " + e.getMessage());
				 cpt++;
			}
		 }

		 //2nd flag=0 for 1 byte address products
		 cpt=0;
		 GetSystemInfoFrame = new byte[] { (byte) 0x02, (byte) 0x2B };
		 while ((response == null || response[0] == 1 || response[0] == (byte)0xAA) && cpt <= 1)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(GetSystemInfoFrame);
				 nfcvTag.close();
				 if (response[0] == (byte) 0x00)
				 {
					ma.setBasedOnTwoBytesAddress(false);	//1st (flag=1) = 2 add bytes (M24LR64 FREEDOM2)
				 	return response;
				 }
			 }
			 catch (Exception e)
			 {
				//Used for DEBUG : Log.i("Exception","Get System Info Exception " + e.getMessage());
				 cpt++;
			}
		 }

		//Used for DEBUG : Log.i("NFCCOmmand", "Response Get System Info " + Helper.ConvertHexByteArrayToString(response));
		return response;
	 }

		//***********************************************************************/
	 //* the function send an Get System Info command (0x02 0x2B)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //***********************************************************************/
	 public static byte[] SendGetSystemInfoCommandCustom_OLD (Tag myTag, DataDevice ma)
	 {

		 byte[] response = new byte[] { (byte) 0xAA };
		 byte[] GetSystemInfoFrame = new byte[2];

		 // to know if tag's addresses are coded on 1 or 2 byte we consider 2
		 // then we wait the response if it's not good we trying with 1
		 ma.setBasedOnTwoBytesAddress(true);

		 GetSystemInfoFrame = new byte[] { (byte) 0x0A, (byte) 0x2B };	//1st flag=1

		 for(int h=0; h<=1;h++)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(GetSystemInfoFrame);
				 nfcvTag.close();
				 if (response[0] == (byte) 0x00)
				 {
					//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(GetSystemInfoFrame));
					 if (h == 0)
						 ma.setBasedOnTwoBytesAddress(true);	//1st (flag=1) = 2 add bytes (M24LR64 FREEDOM2)
					 else
						 ma.setBasedOnTwoBytesAddress(false);	//2nd (flag=0) = 1 add bytes (LRI M24LR04 FREEDOM1 !)
					 h = 2;// to get out of the loop
				 }
			 }
			 catch (Exception e)
			 {
				//Used for DEBUG : Log.i("Exception","Get System Info Exception " + e.getMessage());
				//Used for DEBUG : Log.i("NFCCOmmand", "Response Get System Info " + Helper.ConvertHexByteArrayToString(response));
				ma.setBasedOnTwoBytesAddress(false);
			}

			//Used for DEBUG : Log.i("NFCCOmmand", "Response Get System Info " + Helper.ConvertHexByteArrayToString(response));
			 GetSystemInfoFrame = new byte[] { (byte) 0x02, (byte) 0x2B }; //2nd flag=0
		 }
		 return response;
	 }

	//***********************************************************************/
	 //* the function send an ReadSingle command (0x0A 0x20) || (0x02 0x20)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
	 //* the function will return 04 blocks read from address 0002
	 //* According to the ISO-15693 maximum block read is 32 for the same sector
	 //***********************************************************************/
	 public static byte[] SendReadSingleBlockCommand (Tag myTag, byte[] StartAddress,  DataDevice ma)
	 {
		 byte[] response = new byte[] {(byte) 0x0A};
		 byte[] ReadSingleBlockFrame;

		 if(ma.isBasedOnTwoBytesAddress())
			 ReadSingleBlockFrame = new byte[]{(byte) 0x0A, (byte) 0x20, StartAddress[1], StartAddress[0]};
		 else
			 ReadSingleBlockFrame = new byte[]{(byte) 0x02, (byte) 0x20, StartAddress[1]};

		 int errorOccured = 1;
		 while(errorOccured != 0)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(ReadSingleBlockFrame);
				 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01)//response 01 = error sent back by tag (new Android 4.2.2) or BC
				 {
					 errorOccured = 0;
					//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadSingleBlockFrame));
				 }
			 }
			 catch(Exception e)
			 {
				 errorOccured++;
				//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Single Block" + Helper.ConvertHexByteArrayToString(response));
				 if(errorOccured == 2)
				 {
					//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
					 return response;
				 }
			 }
		 }
		//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Sigle Block" + Helper.ConvertHexByteArrayToString(response));
		 return response;
	 }

	 //***********************************************************************/
	 //* the function send an ReadSingle Custom command (0x0A 0x20) || (0x02 0x20)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
	 //* the function will return 04 blocks read from address 0002
	 //* According to the ISO-15693 maximum block read is 32 for the same sector
	 //***********************************************************************/
	 public static byte[] SendReadMultipleBlockCommandCustom (Tag myTag, byte[] StartAddress, byte NbOfBlockToRead,   DataDevice ma)
	 {
		long cpt =0;
		boolean checkCorrectAnswer = true;

		//int NbBytesToRead = (NbOfBlockToRead*4)+1;
		int NbBytesToRead = NbOfBlockToRead*4;
		byte[] FinalResponse = new byte[NbBytesToRead+1];

		for(int i =0;i<=(NbOfBlockToRead*4)-4; i = i+4)
		{
			byte[] temp = new byte[5];
			int incrementAddressStart0 = (StartAddress[0]+i/256)  ;								//Most Important Byte
			int incrementAddressStart1 = (StartAddress[1]+i/4) - (incrementAddressStart0*255);	//Less Important Byte

			temp = null;
			while (temp == null || temp[0] == 1 && cpt <= 2)
			{
				temp = SendReadSingleBlockCommand (myTag, new byte[]{(byte)incrementAddressStart0,(byte)incrementAddressStart1},ma);
				cpt ++;
			}
			cpt =0;

			//Check  if Read problem
			if (temp[0] != 0x00)
				checkCorrectAnswer = false;

			if(i==0)
			{
				for(int j=0;j<=4;j++)
				{
					if (temp[0] == 0x00)
						FinalResponse[j] = temp[j];
					else
						FinalResponse[j] = (byte) 0xFF;
				}
			}
			else
			{
				for(int j=1;j<=4;j++)
				{
					if (temp[0] == 0x00)
						FinalResponse[i+j] = temp[j];
					else
						FinalResponse[j] = (byte) 0xFF;
				}
			}
		}

		if (checkCorrectAnswer == false)
			FinalResponse[0] = (byte)0xAE;

		return FinalResponse;
	 }

	 public static byte[] SendReadMultipleBlockCommandCustom_JPG (Tag myTag, byte[] StartAddress, byte NbOfBlockToRead,   DataDevice ma)
	 {
		long cpt =0;
		boolean EndOfJpgFile = false;
		boolean checkCorrectAnswer = true;

		//int NbBytesToRead = (NbOfBlockToRead*4)+1;
		int NbBytesToRead = NbOfBlockToRead*4;
		byte[] FinalResponse = new byte[NbBytesToRead+1];

		for(int i =0;i<=(NbOfBlockToRead*4)-4; i = i+4)
		{
			byte[] temp = new byte[5];
			int incrementAddressStart0 = (StartAddress[0]+i/256)  ;								//Most Important Byte
			int incrementAddressStart1 = (StartAddress[1]+i/4) - (incrementAddressStart0*255);	//Less Important Byte

			temp = null;
			while (temp == null || temp[0] == 1 && cpt <= 2)
			{
				temp = SendReadSingleBlockCommand (myTag, new byte[]{(byte)incrementAddressStart0,(byte)incrementAddressStart1},ma);
				cpt ++;
			}
			cpt =0;

			if (temp[0] != 0x00)
				checkCorrectAnswer = false;

			if(i==0)
			{
				for(int j=0;j<=4;j++)
				{
					if (temp[0] == 0x00)
						FinalResponse[j] = temp[j];
					else
						FinalResponse[j] = (byte) 0xFF;
				}
			}
			else
			{
				for(int j=1;j<=4;j++)
				{
					if (temp[0] == 0x00)
						FinalResponse[i+j] = temp[j];
					else
						FinalResponse[i+j] = (byte) 0xFF;
				}
			}

			//check JPG Start of Frame
			for (int j=1;j<=4;j++)
				if (FinalResponse[i+j]==(byte)0xD9 && FinalResponse[i+j-1]==(byte)0xFF)
					{
						i = (NbOfBlockToRead*4)+50;
						EndOfJpgFile = true;
						j=15;
					}

		}
		if (EndOfJpgFile == false)
			FinalResponse[0] = (byte)0xAE;
		if (checkCorrectAnswer == false)
			FinalResponse[0] = (byte)0xAF;

		return FinalResponse;
	 }

	 public static byte[] Send_several_ReadSingleBlockCommands (Tag myTag, byte[] StartAddress, byte[] bytNbBytesToRead,   DataDevice ma)
	 {
		long cpt =0;
		boolean checkCorrectAnswer = true;

		int NbBytesToRead = Helper.Convert2bytesHexaFormatToInt(bytNbBytesToRead);
		int iNbOfBlockToRead = (NbBytesToRead / 4);
		byte[] FinalResponse = new byte[iNbOfBlockToRead*4 + 1];

        byte[] bytAddress = new byte[2];

		//int intAddress = 0;
		int intAddress = Helper.Convert2bytesHexaFormatToInt(StartAddress);

		int index = 0;

		byte[] temp = new byte[5];

		//boucle for(int i=0;i<iNbOfBlockToRead; i++)
		do
		 {
			bytAddress = Helper.ConvertIntTo2bytesHexaFormat(intAddress);

			temp = null;
			while (temp == null || temp[0] == 1 && cpt <= 5)
			{
				temp = SendReadSingleBlockCommand (myTag, new byte[]{(byte)bytAddress[0],(byte)bytAddress[1]},ma);
				cpt ++;
			}
			cpt =0;

			if (temp[0] != 0x00)
				checkCorrectAnswer = false;

			if (temp[0] == 0)
			{
				if(index==0)
				{
					for(int j=0;j<=4;j++)
						FinalResponse[j] = temp[j];
				}
				else
				{
					for(int j=1;j<=4;j++)
						FinalResponse[(index*4)+j] = temp[j];
				}
		 	}
			else
			{
				if(index==0)
				{
					for(int j=0;j<=4;j++)
						FinalResponse[j] = (byte)0xFF;
				}
				else
				{
					for(int j=1;j<=4;j++)
						FinalResponse[(index*4)+j] = (byte)0xFF;
				}
		 	}

			intAddress++;
			index++;

		} while(index < iNbOfBlockToRead);

		if (checkCorrectAnswer == false)
			FinalResponse[0] = (byte)0xAF;

		return FinalResponse;
	 }

	 public static byte[] Send_several_ReadSingleBlockCommands_NbBlocks (Tag myTag, byte[] StartAddress, byte[] bNbOfBlockToRead,   DataDevice ma)
	 {
		long cpt =0;
		boolean checkCorrectAnswer = true;

		int iNbOfBlockToRead = Helper.Convert2bytesHexaFormatToInt(bNbOfBlockToRead);
		byte[] FinalResponse = new byte[iNbOfBlockToRead*4 + 1];

        byte[] bytAddress = new byte[2];

		//int intAddress = 0;
		int intAddress = Helper.Convert2bytesHexaFormatToInt(StartAddress);

		int index = 0;

		byte[] temp = new byte[5];

		//boucle for(int i=0;i<iNbOfBlockToRead; i++)
		do
		 {
			bytAddress = Helper.ConvertIntTo2bytesHexaFormat(intAddress);

			temp = null;
			while (temp == null || temp[0] == 1 && cpt <= 5)
			{
				temp = SendReadSingleBlockCommand (myTag, new byte[]{(byte)bytAddress[0],(byte)bytAddress[1]},ma);
				cpt ++;
			}
			cpt =0;

			if (temp[0] != 0x00)
				checkCorrectAnswer = false;

			if (temp[0] == 0)
			{
				if(index==0)
				{
					for(int j=0;j<=4;j++)
						FinalResponse[j] = temp[j];
				}
				else
				{
					for(int j=1;j<=4;j++)
						FinalResponse[(index*4)+j] = temp[j];
				}
		 	}
			else
			{
				if(index==0)
				{
					for(int j=0;j<=4;j++)
						FinalResponse[j] = (byte)0xFF;
				}
				else
				{
					for(int j=1;j<=4;j++)
						FinalResponse[(index*4)+j] = (byte)0xFF;
				}
		 	}

			intAddress++;
			index++;

		} while(index < iNbOfBlockToRead);

		if (checkCorrectAnswer == false)
			FinalResponse[0] = (byte)0xAF;

		return FinalResponse;
	 }

	 public static byte[] Send_several_ReadSingleBlockCommands_NbBlocks_JPG (Tag myTag, byte[] StartAddress, byte[] bNbOfBlockToRead,   DataDevice ma)
	 {
		long cpt =0;
		boolean EndOfJpgFile = false;
		boolean checkCorrectAnswer = true;

		int iNbOfBlockToRead = Helper.Convert2bytesHexaFormatToInt(bNbOfBlockToRead);
		byte[] FinalResponse = new byte[iNbOfBlockToRead*4 + 1];

        byte[] bytAddress = new byte[2];

		//int intAddress = 0;
		int intAddress = Helper.Convert2bytesHexaFormatToInt(StartAddress);

		int index = 0;

		byte[] temp = new byte[5];

		//boucle for(int i=0;i<iNbOfBlockToRead; i++)
		do
		 {
			bytAddress = Helper.ConvertIntTo2bytesHexaFormat(intAddress);

			temp = null;
			while (temp == null || temp[0] == 1 && cpt <= 5)
			{
				temp = SendReadSingleBlockCommand (myTag, new byte[]{(byte)bytAddress[0],(byte)bytAddress[1]},ma);
				cpt ++;
			}
			cpt =0;

			if (temp[0] != 0x00)
				checkCorrectAnswer = false;

			if (temp[0] == 0)
			{
				if(index==0)
				{
					for(int j=0;j<=4;j++)
						FinalResponse[j] = temp[j];
				}
				else
				{
					for(int j=1;j<=4;j++)
						FinalResponse[(index*4)+j] = temp[j];
				}
		 	}
			else
			{
				if(index==0)
				{
					for(int j=0;j<=4;j++)
						FinalResponse[j] = (byte)0xFF;
				}
				else
				{
					for(int j=1;j<=4;j++)
						FinalResponse[(index*4)+j] = (byte)0xFF;
				}
		 	}

			//check JPG Start of Frame
			for (int j=1;j<=4;j++)
				if (FinalResponse[(index*4)+j]==(byte)0xD9 && FinalResponse[(index*4)+j-1]==(byte)0xFF)
					{
						index = iNbOfBlockToRead+50;
						EndOfJpgFile = true;
						j=15;
					}

			intAddress++;
			index++;

		} while(index < iNbOfBlockToRead);

		if (EndOfJpgFile == false)
			 FinalResponse[0] = (byte)0xAE;
		if (checkCorrectAnswer == false)
			FinalResponse[0] = (byte)0xAF;

		return FinalResponse;
	 }

	//***********************************************************************/
	 //* the function send an ReadSingle Custom command (0x0A 0x20) || (0x02 0x20)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
	 //* the function will return 04 blocks read from address 0002
	 //* According to the ISO-15693 maximum block read is 32 for the same sector
	 //***********************************************************************/

	 public static byte[] SendReadMultipleBlockCommandCustom2 (Tag myTag, byte[] StartAddress, byte[] bNbOfBlockToRead, DataDevice ma)
	 {

		 boolean checkCorrectAnswer = true;

		 int iNbOfBlockToRead = Helper.Convert2bytesHexaFormatToInt(bNbOfBlockToRead);
		 int iNumberOfSectorToRead;
		 int iStartAddress = Helper.Convert2bytesHexaFormatToInt(StartAddress);
		 int iAddressStartRead = (iStartAddress/32)*32;
		 if(iNbOfBlockToRead%32 == 0)
		 {
			 iNumberOfSectorToRead = (iNbOfBlockToRead/32);
		 }
		 else
		 {
			 iNumberOfSectorToRead = (iNbOfBlockToRead/32)+1;
		 }
		 byte[] bAddressStartRead = Helper.ConvertIntTo2bytesHexaFormat(iAddressStartRead);

		 byte[] AllReadDatas = new byte[((iNumberOfSectorToRead*128)+1)];
		 byte[] FinalResponse = new byte[(iNbOfBlockToRead*4)+1] ;

		 String sMemorySize = ma.getMemorySize();
		 sMemorySize = Helper.StringForceDigit(sMemorySize,4);
		 byte[] bLastMemoryAddress = Helper.ConvertStringToHexBytes(sMemorySize);

		 //Loop needed for number of sector o read
		 for(int i=0; i<iNumberOfSectorToRead;i++)
		 {
			 byte[] temp = new byte[33];

			 int incrementAddressStart0 = (bAddressStartRead[0]+i/8)  ;									//Most Important Byte
			 int incrementAddressStart1 = (bAddressStartRead[1]+i*32) - (incrementAddressStart0*256);	//Less Important Byte

			 if(bAddressStartRead[0]<0)
			 	 incrementAddressStart0 = ((bAddressStartRead[0]+256)+i/8);

			 if(bAddressStartRead[1]<0)
				 incrementAddressStart1 = ((bAddressStartRead[1]+256)+i*32) - (incrementAddressStart0*256);

			 if(incrementAddressStart1 > bLastMemoryAddress[1] && incrementAddressStart0 > bLastMemoryAddress[0])
			 {

			 }
			 else
			 {
				temp = null;
				temp = SendReadMultipleBlockCommand (myTag, new byte[]{(byte)incrementAddressStart0,(byte)incrementAddressStart1},(byte)0x1F,ma);

				if (temp[0] != 0x00)
					checkCorrectAnswer = false;

				// if any error occurs during
				if(temp[0] == (byte)0x01)
				{
					return temp;
				}
				else
				{
					// to construct a response with first byte = 0x00
					if(i==0)
					{
						for(int j=0;j<=128;j++)
						{
							AllReadDatas[j] = temp[j];
						}
					}
					else
					{
						for(int j=1;j<=128;j++)
						{
							AllReadDatas[(i*128)+j] = temp[j];
						}
					}
				}
			 }
		 }

		 int iNbBlockToCopyInFinalReponse = Helper.Convert2bytesHexaFormatToInt(bNbOfBlockToRead);
		 int iNumberOfBlockToIgnoreInAllReadData = 4*(Helper.Convert2bytesHexaFormatToInt(StartAddress)%32);

		 for(int h=1; h <= iNbBlockToCopyInFinalReponse*4 ; h++)
		 {
			 FinalResponse[h] = AllReadDatas[h + iNumberOfBlockToIgnoreInAllReadData];
		 }

		 if (checkCorrectAnswer == true)
			 FinalResponse[0] = AllReadDatas[0];
		 else
			 FinalResponse[0] = (byte)0xAF;

		 return FinalResponse;
	 }

	 public static byte[] SendReadMultipleBlockCommandCustom2_JPG (Tag myTag, byte[] StartAddress, byte[] bNbOfBlockToRead, DataDevice ma)
	 {
		 boolean checkCorrectAnswer = true;
		 boolean EndOfJpgFile = false;

		 int iNbOfBlockToRead = Helper.Convert2bytesHexaFormatToInt(bNbOfBlockToRead);
		 int iNumberOfSectorToRead = 0;
		 int iNumberOfSectorToRead_New = 0;
		 int iStartAddress = Helper.Convert2bytesHexaFormatToInt(StartAddress);
		 int iAddressStartRead = (iStartAddress/32)*32;

		 if(iNbOfBlockToRead%32 == 0)
		 {
			 iNumberOfSectorToRead = (iNbOfBlockToRead/32);
		 }
		 else
		 {
			 iNumberOfSectorToRead = (iNbOfBlockToRead/32)+1;
		 }
		 byte[] bAddressStartRead = Helper.ConvertIntTo2bytesHexaFormat(iAddressStartRead);

		 byte[] AllReadDatas = new byte[((iNumberOfSectorToRead*128)+1)];
		 byte[] FinalResponse = new byte[(iNbOfBlockToRead*4)+1] ;

		 String sMemorySize = ma.getMemorySize();
		 sMemorySize = Helper.StringForceDigit(sMemorySize,4);
		 byte[] bLastMemoryAddress = Helper.ConvertStringToHexBytes(sMemorySize);

		 //Loop needed for number of sector o read
		 for(int i=0; i<iNumberOfSectorToRead;i++)
		 {
			 byte[] temp = new byte[33];

			 int incrementAddressStart0 = (bAddressStartRead[0]+i/8)  ;									//Most Important Byte
			 int incrementAddressStart1 = (bAddressStartRead[1]+i*32) - (incrementAddressStart0*256);	//Less Important Byte

			 if(bAddressStartRead[0]<0)
			 	 incrementAddressStart0 = ((bAddressStartRead[0]+256)+i/8);

			 if(bAddressStartRead[1]<0)
				 incrementAddressStart1 = ((bAddressStartRead[1]+256)+i*32) - (incrementAddressStart0*256);

			 if(incrementAddressStart1 > bLastMemoryAddress[1] && incrementAddressStart0 > bLastMemoryAddress[0])
			 {

			 }
			 else
			 {
				temp = null;
				temp = SendReadMultipleBlockCommand (myTag, new byte[]{(byte)incrementAddressStart0,(byte)incrementAddressStart1},(byte)0x1F,ma);

				if (temp[0] != 0x00)
					checkCorrectAnswer = false;

				// if any error occurs during
				if(temp[0] == (byte)0x01)
				{
					return temp;
				}
				else
				{
					// to construct a response with first byte = 0x00
					if(i==0)
					{
						for(int j=0;j<=128;j++)
						{
							AllReadDatas[j] = temp[j];
						}
					}
					else
					{
						for(int j=1;j<=128;j++)
						{
							AllReadDatas[(i*128)+j] = temp[j];
						}
					}

					//check JPG Start of Frame
					for (int j=1;j<=128;j++)
						if (AllReadDatas[(i*128)+j]==(byte)0xD9 && AllReadDatas[(i*128)+j-1]==(byte)0xFF)
						{
							iNumberOfSectorToRead_New = i+1;
							i = iNumberOfSectorToRead+10;
							EndOfJpgFile = true;
							j=200;
						}
				}
			 }
		 }

		 int iNbBlockToCopyInFinalReponse = iNumberOfSectorToRead_New * 32;
		 int iNumberOfBlockToIgnoreInAllReadData = 4*(Helper.Convert2bytesHexaFormatToInt(StartAddress)%32);

		 for(int h=1; h <= iNbBlockToCopyInFinalReponse*4 ; h++)
		 {
			 FinalResponse[h] = AllReadDatas[h + iNumberOfBlockToIgnoreInAllReadData];
		 }

		 if (EndOfJpgFile = false)
			 FinalResponse[0] = (byte)0xAE;
		 else
		 {
			 if (checkCorrectAnswer == true)
				 FinalResponse[0] = AllReadDatas[0];
			 else
				 FinalResponse[0] = (byte)0xAF;
		 }

		 return FinalResponse;
	 }

	 //32 blocks max
	 //Begining from Address 0x0000
	 public static byte[] Send_several_ReadMultipleBlockCommands (Tag myTag, byte[] bytNbBytesToRead,   DataDevice ma)
	 {
		 long cpt =0;
		 boolean checkCorrectAnswer = true;

		 int NbBytesToRead = Helper.Convert2bytesHexaFormatToInt(bytNbBytesToRead);
		 int iNumberOfSectorToRead;
		 int iResteOfBytes;
		 int iResteOfRows;

		 if(NbBytesToRead%128 == 0)
			 iNumberOfSectorToRead = (NbBytesToRead/128);
		 else
			 iNumberOfSectorToRead = (NbBytesToRead/128)+1;
		 iResteOfBytes = NbBytesToRead%128;
		 iResteOfRows = iResteOfBytes / 4;
 	 	 if (iResteOfBytes % 4 > 0)
 	 		iResteOfRows += 1;

		 //String sMemorySize = ma.getMemorySize();
		 //sMemorySize = Helper.StringForceDigit(sMemorySize,4);
		 //byte[] bLastMemoryAddress = Helper.ConvertStringToHexBytes(sMemorySize);

		 byte[] bytAddress = new byte[2];
		 int intAddress = 0;
		 int index = 0;

		 byte[] FinalResponse = new byte[(iNumberOfSectorToRead*128)+1] ;
		 byte[] temp = new byte[128+1];

		 //Loop needed for number of sector o read
		 do
		 {
			bytAddress = Helper.ConvertIntTo2bytesHexaFormat(intAddress);

			temp = null;
			byte byteNbRowsToRead;
			if(index == iNumberOfSectorToRead-1 && iResteOfRows>0)
				byteNbRowsToRead = (byte)iResteOfRows;
			else
				byteNbRowsToRead = (byte)0x20;

			temp = null;
			while (temp == null || temp[0] == 1 && cpt <= 5)
			{
				temp = SendReadMultipleBlockCommand (myTag, bytAddress, (byte)(byteNbRowsToRead-1),ma);
				cpt ++;
			}
			cpt =0;

			intAddress += 0x20;

			if (temp[0] != 0x00)
				checkCorrectAnswer = false;

			// to construct a response with first byte = 0x00
			if (temp[0] == 0)
			{
				if(index==0)
				{
					for(int j=0;j<=byteNbRowsToRead*4;j++)
						FinalResponse[j] = temp[j];
				}
				else
				{
					for(int j=1;j<=byteNbRowsToRead*4;j++)
						FinalResponse[(index*128)+j] = temp[j];
				}
			}
			else
			{
				if(index==0)
				{
					for(int j=0;j<=byteNbRowsToRead*4;j++)
						FinalResponse[j] = (byte)0xFF;
				}
				else
				{
					for(int j=1;j<=byteNbRowsToRead*4;j++)
						FinalResponse[(index*128)+j] = (byte)0xFF;
				}
			}

			index++;

		 } while(index < iNumberOfSectorToRead);

		 if (checkCorrectAnswer == false)
			 FinalResponse[0] = (byte)0xAF;

		 return FinalResponse;
	 }

	//***********************************************************************/
	 //* the function send an ReadMultiple command (0x0A 0x23) || (0x02 0x23)
	 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
	 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
	 //* the function will return 04 blocks read from address 0002
	 //* According to the ISO-15693 maximum block read is 32 for the same sector
	 //***********************************************************************/
	 public static byte[] SendReadMultipleBlockCommand (Tag myTag, byte[] StartAddress, byte NbOfBlockToRead,  DataDevice ma)
	 {
		 byte[] response = new byte[] {(byte) 0x01};
		 byte[] ReadMultipleBlockFrame;

		 if(ma.isBasedOnTwoBytesAddress())
			 ReadMultipleBlockFrame = new byte[]{(byte) 0x0A, (byte) 0x23, StartAddress[1], StartAddress[0], NbOfBlockToRead};
		 else
			 ReadMultipleBlockFrame = new byte[]{(byte) 0x02, (byte) 0x23, StartAddress[1], NbOfBlockToRead};

		//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadMultipleBlockFrame));

		 int errorOccured = 1;
		 while(errorOccured != 0)
		 {
			 try
			 {
				 NfcV nfcvTag = NfcV.get(myTag);
				 nfcvTag.close();
				 nfcvTag.connect();
				 response = nfcvTag.transceive(ReadMultipleBlockFrame);
				 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01)//response 01 = error sent back by tag (new Android 4.2.2) or BC
				 {
					 errorOccured = 0;
					//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadMultipleBlockFrame));

				 }
			 }
			 catch(Exception e)
			 {
				 errorOccured++;
				//Used for DEBUG : Log.i("NFCCOmmand", "SendReadMultipleBlockCommand errorOccured " + errorOccured);
				 if(errorOccured == 3)
				 {
					//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
					//Used for DEBUG : Log.i("NFCCOmmand", "Error when try to read from address  " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 return response;
				 }
			 }
		 }
		//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Multiple Block" + Helper.ConvertHexByteArrayToString(response));
		 return response;
	 }

		//***********************************************************************/
		 //* the function send an WriteSingle command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendWriteSingleBlockCommand (Tag myTag, byte[] StartAddress, byte[] DataToWrite, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0xFF};
			 byte[] WriteSingleBlockFrame;

			 if(ma.isBasedOnTwoBytesAddress())
				 WriteSingleBlockFrame = new byte[]{(byte) 0x0A, (byte) 0x21, StartAddress[1], StartAddress[0], DataToWrite[0], DataToWrite[1], DataToWrite[2], DataToWrite[3]};
			 else
				 WriteSingleBlockFrame = new byte[]{(byte) 0x02, (byte) 0x21, StartAddress[1], DataToWrite[0], DataToWrite[1], DataToWrite[2], DataToWrite[3]};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(WriteSingleBlockFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("*******", "**SUCCESS** Write Data " + DataToWrite[0] +" "+ DataToWrite[1] +" "+ DataToWrite[2] +" "+ DataToWrite[3] + " at address " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Write Single block command  " + errorOccured);
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						//Used for DEBUG : Log.i("WRITE", "**ERROR WRITE SINGLE** at address " +  Helper.ConvertHexByteArrayToString(StartAddress));
						 return response;
					 }
				 }
			 }
			 return response;
		 }

		//***********************************************************************/
		//* the function send an Write command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendWriteMultipleBlockCommand (Tag myTag, byte[] StartAddress, byte[] DataToWrite, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0x01};
			 long cpt = 0;

			 int NBByteToWrite = DataToWrite.length;
			 while (NBByteToWrite % 4 !=0)
				 NBByteToWrite ++;

			 byte[] fullByteArrayToWrite = new byte[NBByteToWrite];
			 for(int j=0;j<NBByteToWrite;j++)
			 {
				 if(j<DataToWrite.length)
				 {
					 fullByteArrayToWrite[j]=DataToWrite[j];
				 }
				 else
				 {
					 fullByteArrayToWrite[j] = (byte)0xFF;
				 }
			 }

			int intAddress2Write = Helper.Convert2bytesHexaFormatToInt(StartAddress);
			byte[] bytAddress = Helper.ConvertIntTo2bytesHexaFormat(intAddress2Write);

			for(int i =0;i<NBByteToWrite; i = i+4)
			{

				//int incrementAddressStart0 = (StartAddress[0]+i/256)  ;								//Most Important Byte
				//int incrementAddressStart1 = (StartAddress[1]+i/4) - (incrementAddressStart0*255);	//Less Important Byte

				int incrementAddressStart0 = bytAddress[0];
				int incrementAddressStart1 = bytAddress[1];
				intAddress2Write++;
				bytAddress = Helper.ConvertIntTo2bytesHexaFormat(intAddress2Write);

				response[0] = (byte)0x01;

				while((response[0] == (byte)0x01) && cpt <= 2)
				{
					response = SendWriteSingleBlockCommand(myTag,new byte[]{(byte)incrementAddressStart0,(byte)incrementAddressStart1},new byte[]{(byte)fullByteArrayToWrite[i],(byte)fullByteArrayToWrite[i+1],(byte)fullByteArrayToWrite[i+2],(byte)fullByteArrayToWrite[i+3]},ma);
					cpt ++;
				}
				if (response[0] == (byte)0x01)
					return response;
				cpt = 0;
			}
			 return response;
		 }

			//***********************************************************************/
		 //* the function send an WriteSingle command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendPresentPasswordCommand (Tag myTag, byte PasswordNumber, byte[] PasswordData, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0xFF};
			 byte[] PresentPasswordFrame;

			PresentPasswordFrame = new byte[]{(byte) 0x02, (byte) 0xB3, (byte) 0x02, PasswordNumber, PasswordData[0], PasswordData[1], PasswordData[2], PasswordData[3]};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(PresentPasswordFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("*******", "**SUCCESS** Write Data " + DataToWrite[0] +" "+ DataToWrite[1] +" "+ DataToWrite[2] +" "+ DataToWrite[3] + " at address " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Write Single block command  " + errorOccured);
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						//Used for DEBUG : Log.i("WRITE", "**ERROR WRITE SINGLE** at address " +  Helper.ConvertHexByteArrayToString(StartAddress));
						 return response;
					 }
				 }
			 }
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an WriteSingle command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendWritePasswordCommand (Tag myTag, byte PasswordNumber, byte[] PasswordData, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0xFF};
			 byte[] PresentPasswordFrame;

			PresentPasswordFrame = new byte[]{(byte) 0x02, (byte) 0xB1, (byte) 0x02, PasswordNumber, PasswordData[0], PasswordData[1], PasswordData[2], PasswordData[3]};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(PresentPasswordFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("*******", "**SUCCESS** Write Data " + DataToWrite[0] +" "+ DataToWrite[1] +" "+ DataToWrite[2] +" "+ DataToWrite[3] + " at address " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Write Single block command  " + errorOccured);
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						//Used for DEBUG : Log.i("WRITE", "**ERROR WRITE SINGLE** at address " +  Helper.ConvertHexByteArrayToString(StartAddress));
						 return response;
					 }
				 }
			 }
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an WriteSingle command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendLockSectorCommand (Tag myTag, byte[] SectorNumberAddress, byte LockSectorByte, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0xFF};
			 byte[] LockSectorFrame;

			 if(ma.isBasedOnTwoBytesAddress())
				 LockSectorFrame = new byte[]{(byte) 0x0A, (byte) 0xB2, (byte) 0x02, SectorNumberAddress[1], SectorNumberAddress[0], LockSectorByte};
			 else
				 LockSectorFrame = new byte[]{(byte) 0x02, (byte) 0xB2, (byte) 0x02, SectorNumberAddress[1], LockSectorByte};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(LockSectorFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("*******", "**SUCCESS** Write Data " + DataToWrite[0] +" "+ DataToWrite[1] +" "+ DataToWrite[2] +" "+ DataToWrite[3] + " at address " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Write Single block command  " + errorOccured);
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						//Used for DEBUG : Log.i("WRITE", "**ERROR WRITE SINGLE** at address " +  Helper.ConvertHexByteArrayToString(StartAddress));
						 return response;
					 }
				 }
			 }
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an ReadSingle command (0x0A 0x20) || (0x02 0x20)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
		 //* the function will return 04 blocks read from address 0002
		 //* According to the ISO-15693 maximum block read is 32 for the same sector
		 //***********************************************************************/
		 public static byte[] SendReadEHconfigCommand (Tag myTag, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0x0A};
			 byte[] ReadEHconfigFrame;

			ReadEHconfigFrame = new byte[]{(byte) 0x02, (byte) 0xA0, (byte) 0x02};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(ReadEHconfigFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadSingleBlockFrame));
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Single Block" + Helper.ConvertHexByteArrayToString(response));
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						 return response;
					 }
				 }
			 }
			//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Sigle Block" + Helper.ConvertHexByteArrayToString(response));
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an WriteSingle command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendWriteEHconfigCommand (Tag myTag, byte EHconfigByte, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0xFF};
			 byte[] WriteEHconfigFrame;

			 WriteEHconfigFrame = new byte[]{(byte) 0x02, (byte) 0xA1, (byte) 0x02, EHconfigByte};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(WriteEHconfigFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("*******", "**SUCCESS** Write Data " + DataToWrite[0] +" "+ DataToWrite[1] +" "+ DataToWrite[2] +" "+ DataToWrite[3] + " at address " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Write Single block command  " + errorOccured);
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						//Used for DEBUG : Log.i("WRITE", "**ERROR WRITE SINGLE** at address " +  Helper.ConvertHexByteArrayToString(StartAddress));
						 return response;
					 }
				 }
			 }
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an WriteSingle command (0x0A 0x21) || (0x02 0x21)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  DataToWrite : {0x04 0x14 0xFF 0xB2}
		 //* the function will write {0x04 0x14 0xFF 0xB2} at the address 0002
		 //***********************************************************************/
		 public static byte[] SendWriteD0configCommand (Tag myTag, byte D0configByte, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0xFF};
			 byte[] WriteD0configFrame;

			 WriteD0configFrame = new byte[]{(byte) 0x02, (byte) 0xA4, (byte) 0x02, D0configByte};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(WriteD0configFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("*******", "**SUCCESS** Write Data " + DataToWrite[0] +" "+ DataToWrite[1] +" "+ DataToWrite[2] +" "+ DataToWrite[3] + " at address " +  (byte)StartAddress[0] +" "+ (byte)StartAddress[1]);
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Write Single block command  " + errorOccured);
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						//Used for DEBUG : Log.i("WRITE", "**ERROR WRITE SINGLE** at address " +  Helper.ConvertHexByteArrayToString(StartAddress));
						 return response;
					 }
				 }
			 }
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an ReadSingle command (0x0A 0x20) || (0x02 0x20)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
		 //* the function will return 04 blocks read from address 0002
		 //* According to the ISO-15693 maximum block read is 32 for the same sector
		 //***********************************************************************/
		 public static byte[] SendCheckEHenableCommand (Tag myTag, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0x0A};
			 byte[] ReadEHconfigFrame;

			ReadEHconfigFrame = new byte[]{(byte) 0x02, (byte) 0xA3, (byte) 0x02};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(ReadEHconfigFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadSingleBlockFrame));
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Single Block" + Helper.ConvertHexByteArrayToString(response));
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						 return response;
					 }
				 }
			 }
			//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Sigle Block" + Helper.ConvertHexByteArrayToString(response));
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an ReadSingle command (0x0A 0x20) || (0x02 0x20)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
		 //* the function will return 04 blocks read from address 0002
		 //* According to the ISO-15693 maximum block read is 32 for the same sector
		 //***********************************************************************/
		 public static byte[] SendResetEHenableCommand (Tag myTag, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0x0A};
			 byte[] ResetEHenableFrame;

			 ResetEHenableFrame = new byte[]{(byte) 0x02, (byte) 0xA2, (byte) 0x02, (byte) 0x00};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(ResetEHenableFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadSingleBlockFrame));
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Single Block" + Helper.ConvertHexByteArrayToString(response));
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						 return response;
					 }
				 }
			 }
			//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Sigle Block" + Helper.ConvertHexByteArrayToString(response));
			 return response;
		 }

		 //***********************************************************************/
		 //* the function send an ReadSingle command (0x0A 0x20) || (0x02 0x20)
		 //* the argument myTag is the intent triggered with the TAG_DISCOVERED
		 //* example : StartAddress {0x00, 0x02}  NbOfBlockToRead : {0x04}
		 //* the function will return 04 blocks read from address 0002
		 //* According to the ISO-15693 maximum block read is 32 for the same sector
		 //***********************************************************************/
		 public static byte[] SendSetEHenableCommand (Tag myTag, DataDevice ma)
		 {
			 byte[] response = new byte[] {(byte) 0x0A};
			 byte[] SetEHenableFrame;

			SetEHenableFrame = new byte[]{(byte) 0x02, (byte) 0xA2, (byte) 0x02, (byte) 0x01};

			 int errorOccured = 1;
			 while(errorOccured != 0)
			 {
				 try
				 {
					 NfcV nfcvTag = NfcV.get(myTag);
					 nfcvTag.close();
					 nfcvTag.connect();
					 response = nfcvTag.transceive(SetEHenableFrame);
					 if(response[0] == (byte) 0x00 || response[0] == (byte) 0x01) //response 01 = error sent back by tag (new Android 4.2.2) or BC
					 {
						 errorOccured = 0;
						//Used for DEBUG : Log.i("NFCCOmmand", "SENDED Frame : " + Helper.ConvertHexByteArrayToString(ReadSingleBlockFrame));
					 }
				 }
				 catch(Exception e)
				 {
					 errorOccured++;
					//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Single Block" + Helper.ConvertHexByteArrayToString(response));
					 if(errorOccured == 2)
					 {
						//Used for DEBUG : Log.i("Exception","Exception " + e.getMessage());
						 return response;
					 }
				 }
			 }
			//Used for DEBUG : Log.i("NFCCOmmand", "Response Read Sigle Block" + Helper.ConvertHexByteArrayToString(response));
			 return response;
		 }

}


text: require_relative 'error_loader_1'


text:
using System;
using System.Collections;
using System.Collections.Generic;
using MemBus;

namespace PersistentPlanet.Graphics
{
    public interface IMaterial : IDisposable
    {
    }

    public interface IMaterial<in TRenderContext> : IMaterial, IResource<TRenderContext>
        where TRenderContext : IRenderContext
    {
    }

    public interface IResourceFactory<in TRenderContext>
        where TRenderContext : IRenderContext
    {
        IMaterial<TRenderContext> CreateMaterial(IBus objectBus);
        IMesh<TRenderContext> CreateMesh(Vertex[] vertices, uint[] indices);
    }

    public interface IResourceCollection
    {
        IMaterial CreateMaterial(IBus objectBus);
        IMesh CreateMesh(Vertex[] vertices, uint[] indices);
    }

    public class ResourceCollection<TRenderContext> : IEnumerable<IResource<TRenderContext>>, IResourceCollection
        where TRenderContext : IRenderContext
    {
        private readonly IResourceFactory<TRenderContext> _resourceFactory;
        private readonly List<IResource<TRenderContext>> _items;

        public ResourceCollection(IResourceFactory<TRenderContext> resourceFactory)
        {
            _resourceFactory = resourceFactory;
            _items = new List<IResource<TRenderContext>>();
        }

        public IMaterial CreateMaterial(IBus objectBus)
        {
            var vertexShader = _resourceFactory.CreateMaterial(objectBus);
            _items.Add(vertexShader);
            return vertexShader;
        }

        public IMesh CreateMesh(Vertex[] vertices, uint[] indices)
        {
            var mesh = _resourceFactory.CreateMesh(vertices, indices);
            _items.Add(mesh);
            return mesh;
        }

        public IEnumerator<IResource<TRenderContext>> GetEnumerator()
        {
            return _items.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}


text:
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Rebus.Config;
using System;

namespace eFormCore.Installers
{
    public class RebusInstaller : IWindsorInstaller
    {
        private readonly string connectionString;
        private readonly int maxParallelism;
        private readonly int numberOfWorkers;

        public RebusInstaller(string connectionString, int maxParallelism, int numberOfWorkers)
        {
            if (string.IsNullOrEmpty(connectionString)) throw new ArgumentNullException(nameof(connectionString));
            this.connectionString = connectionString;
            this.maxParallelism = maxParallelism;
            this.numberOfWorkers = numberOfWorkers;
        }

        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            if (connectionString.ToLower().Contains("convert zero datetime"))
            {
                Configure.With(new CastleWindsorContainerAdapter(container))
                    .Logging(l => l.ColoredConsole())
                    .Transport(t => t.UseMySql(connectionStringOrConnectionOrConnectionStringName: connectionString, tableName: "Rebus", inputQueueName: "eformsdk-input"))
                    .Options(o =>
                    {
                        o.SetMaxParallelism(maxParallelism);
                        o.SetNumberOfWorkers(numberOfWorkers);
                    })
                    .Start();
            }
            else
            {
                Configure.With(new CastleWindsorContainerAdapter(container))
                    .Logging(l => l.ColoredConsole())
                    .Transport(t => t.UseSqlServer(connectionString: connectionString, inputQueueName: "eformsdk-input"))
                    //.Transport(t => t.UseSqlServer(connectionStringOrConnectionStringName: connectionString, tableName: "Rebus", inputQueueName: "eformsdk-input"))
                    .Options(o =>
                    {
                        o.SetMaxParallelism(maxParallelism);
                        o.SetNumberOfWorkers(numberOfWorkers);
                    })
                    .Start();
            }

        }
    }
}


text:
package de.schillermann.spigotsurvivalkit.listeners;

import org.bukkit.configuration.file.FileConfiguration;

/**
 *
 * @author Mario Schillermann
 */
final public class LockMessage {

    final private String chestOwner;

    final private String chestLocked;

    final private String chestUnlocked;

    final private String doorOwner;

    final private String doorLocked;

    final private String doorUnlocked;

    public LockMessage(FileConfiguration config) {

        this.chestOwner = config.getString("lock.chest.owner");
        this.chestLocked = config.getString("lock.chest.locked");
        this.chestUnlocked = config.getString("lock.chest.unlocked");
        this.doorOwner = config.getString("lock.door.owner");
        this.doorLocked = config.getString("lock.door.locked");
        this.doorUnlocked = config.getString("lock.door.unlocked");
    }

    public String getChestOwner(String name) {
        return String.format(this.chestOwner, name);
    }

    public String getChestLocked() {
        return this.chestLocked;
    }

    public String getChestUnlocked() {
        return this.chestUnlocked;
    }

    public String getDoorOwner(String name) {
        return String.format(this.doorOwner, name);
    }

    public String getDoorLocked() {
        return this.doorLocked;
    }

    public String getDoorUnlocked() {
        return this.doorUnlocked;
    }
}


text:
package org.activiti.api.process.runtime.connector;

import org.activiti.api.process.model.IntegrationContext;

import java.util.function.Function;

public interface Connector extends Function<IntegrationContext, IntegrationContext> {

}


text:
package com.tiny.demo.firstlinecode.uicomponents.constraintlayout;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.tiny.demo.firstlinecode.R;

public class ConstraintLayout2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_constraint_layou2t);
    }
}


text:
package org.apache.wicket;

import java.util.Locale;

import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.request.resource.ResourceReference.Key;
import org.apache.wicket.request.resource.ResourceReferenceRegistry;

/**
 * Class which holds shared resources. Resources can be shared by name. An optional scope can be
 * given to prevent naming conflicts and a locale and/or style can be given as well.
 *
 * <p>
 * Unlike component hosted resources, shared resources have stable URLs, which makes them suitable
 * for indexing by web crawlers and caching by web browsers. As they are also not synchronised on
 * the {@link Session}, they can be loaded asynchronously, which is important with images and
 * resources such as JavaScript and CSS.
 */
public class SharedResources
{
	private final ResourceReferenceRegistry registry;

	/**
	 * Construct.
	 *
	 * @param registry
	 */
	public SharedResources(ResourceReferenceRegistry registry)
	{
		this.registry = registry;
	}

	/**
	 * A {@link ResourceReference} that is used to register a reference to a known {@link IResource}
	 */
	private static final class AutoResourceReference extends ResourceReference
	{
		private static final long serialVersionUID = 1L;

		private final IResource resource;

		private AutoResourceReference(Class<?> scope, String name, Locale locale, String style,
			String variation, IResource resource)
		{
			super(scope, name, locale, style, variation);
			this.resource = resource;
		}

		@Override
		public IResource getResource()
		{
			return resource;
		}
	}

	/**
	 * Adds a resource.
	 *
	 * @param scope
	 *            Scope of resource
	 * @param name
	 *            Logical name of resource
	 * @param locale
	 *            The locale of the resource
	 * @param style
	 *            The resource style (see {@link org.apache.wicket.Session})
	 * @param variation
	 *            The component specific variation of the style
	 * @param resource
	 *            Resource to store
	 */
	public final void add(final Class<?> scope, final String name, final Locale locale,
		final String style, final String variation, final IResource resource)
	{
		ResourceReference ref = new AutoResourceReference(scope, name, locale, style, variation,
			resource);
		registry.registerResourceReference(ref);
	}

	/**
	 * Adds a resource.
	 *
	 * @param name
	 *            Logical name of resource
	 * @param locale
	 *            The locale of the resource
	 * @param resource
	 *            Resource to store
	 */
	public final void add(final String name, final Locale locale, final IResource resource)
	{
		add(Application.class, name, locale, null, null, resource);
	}

	/**
	 * Adds a resource.
	 *
	 * @param name
	 *            Logical name of resource
	 * @param resource
	 *            Resource to store
	 */
	public final void add(final String name, final IResource resource)
	{
		add(Application.class, name, null, null, null, resource);
	}

	/**
	 * Resolves a {@link ResourceReference} for a shared resource.
	 *
	 * @param scope
	 *            Scope of resource
	 * @param name
	 *            Logical name of resource
	 * @param locale
	 *            The locale of the resource
	 * @param style
	 *            The resource style (see {@link org.apache.wicket.Session})
	 * @param variation
	 *            The component specific variation of the style
	 * @param strict
	 *            If true, "weaker" combination of scope, name, locale etc. are not tested
	 * @return Either the resource reference found in the registry or, if requested, a resource
	 *         reference automatically created based on the parameters provided. The automatically
	 *         created resource reference will automatically be added to the registry.
	 */
	public ResourceReference get(Class<?> scope, String name, Locale locale, String style,
		String variation, boolean strict)
	{
		return registry.getResourceReference(scope, name, locale, style, variation, strict, true);
	}

	/**
	 * Removes a resource.
	 *
	 * @param key
	 *            the resource reference's identifier
	 * @return the removed {@link ResourceReference}. {@code null} if there was no registration for
	 *         this {@link Key}
	 */
	public final ResourceReference remove(final Key key)
	{
		return registry.unregisterResourceReference(key);
	}
}


text:
package org.ldp4j.rdf.util;

import org.ldp4j.rdf.Triple;

public interface ITripleTransformation {

	Triple transform(Triple t);

}


text:
extern crate bytes;
#[macro_use]
extern crate cfg_if;
#[macro_use]
extern crate nix;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate rand;
extern crate tempfile;

macro_rules! skip_if_not_root {
    ($name:expr) => {
        use nix::unistd::Uid;
        use std;
        use std::io::Write;

        if !Uid::current().is_root() {
            let stderr = std::io::stderr();
            let mut handle = stderr.lock();
            writeln!(handle, "{} requires root privileges. Skipping test.", $name).unwrap();
            return;
        }
    };
}

mod sys;
mod test_dir;
mod test_fcntl;
#[cfg(any(target_os = "android",
          target_os = "linux"))]
mod test_kmod;
#[cfg(any(target_os = "dragonfly",
          target_os = "freebsd",
          target_os = "fushsia",
          target_os = "linux",
          target_os = "netbsd"))]
mod test_mq;
mod test_net;
mod test_nix_path;
mod test_poll;
mod test_pty;
#[cfg(any(target_os = "android",
          target_os = "freebsd",
          target_os = "ios",
          target_os = "linux",
          target_os = "macos"))]
mod test_sendfile;
mod test_stat;
mod test_unistd;

use std::os::unix::io::RawFd;
use std::sync::Mutex;
use nix::unistd::read;

/// Helper function analogous to `std::io::Read::read_exact`, but for `RawFD`s
fn read_exact(f: RawFd, buf: &mut  [u8]) {
    let mut len = 0;
    while len < buf.len() {
        // get_mut would be better than split_at_mut, but it requires nightly
        let (_, remaining) = buf.split_at_mut(len);
        len += read(f, remaining).unwrap();
    }
}

lazy_static! {
    /// Any test that changes the process's current working directory must grab
    /// this mutex
    pub static ref CWD_MTX: Mutex<()> = Mutex::new(());
    /// Any test that changes the process's supplementary groups must grab this
    /// mutex
    pub static ref GROUPS_MTX: Mutex<()> = Mutex::new(());
    /// Any test that creates child processes must grab this mutex, regardless
    /// of what it does with those children.
    pub static ref FORK_MTX: Mutex<()> = Mutex::new(());
    /// Any test that calls ptsname(3) must grab this mutex.
    pub static ref PTSNAME_MTX: Mutex<()> = Mutex::new(());
    /// Any test that alters signal handling must grab this mutex.
    pub static ref SIGNAL_MTX: Mutex<()> = Mutex::new(());
}