text:
package org.apache.harmony.test.func.api.java.beans.boundproperties;

import org.apache.harmony.test.func.api.java.beans.boundproperties.auxiliary.BoundException;
import org.apache.harmony.test.func.api.java.beans.boundproperties.auxiliary.Variables;
import org.apache.harmony.share.Result;

/**
 * Under test: PropertyChangeSupport, PropertyChangeEvent.
 *

 * Purpose: verify that firePropertyChange(selectedProperyName, oldValue,
 * newValue) method of PropertyChangeSupport reports an update for selected
 * property to any registered listeners. Complex tests were developed in this
 * class.
 *
 * @see java.beans.PropertyChangeSupport
 * @see java.beans.PropertyChangeEvent
 */

public class ComplexTests extends Variables {
    /**
     * Add many listeners for selected property and for all properties. Verify
     * that all registered listeners are notified, when selected property is
     * changed.
     *

     * Step-by-step decoding:
     *

     *
Add 4 times listener#1 for all properties.

     *
Add listener#1 for N different selected properties.

     *
Add listener#2 for N different selected properties.

     *
Add 5 times listener#3 for selected property.

     *
Add 10 times listener#1 for selected property.

     *
After each addition firePropertyChange method is invoked and test
     * verifies that all registered listeners were notified.

     *

     */
    public Result testAddListenersForSelectedPropertyAndForAllProperties() {
        try {
            // Set instance PropertyChangeSupport, AllProperties and
            // CertainProperty classes for SimpleTests the same as for this
            // class.
            SimpleTests simple = new SimpleTests(this);
            // Methods written in SimpleTests class are reused.
            checkResult(simple.testAdd4Listeners1ToAllProperties());
            checkResult(simple.testAddListener1ToAllSelectedProperties());
            checkResult(simple.testAddListener2ToAllSelectedProperties());
            checkResult(simple.testAdd5Listeners0ToProperty1());
            checkResult(simple.testAddListenersForSelectedProperty());
            checkResult(simple.testAddListenersForSelectedProperty());
            return passed();
        } catch (BoundException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     * Add and remove many listeners for selected property, for all properties
     * and for N selected properties. Verify that all registered listeners are
     * notified, when selected property is changed.
     *

     * Step-by-step decoding:
     *

     *
Add 4 times listener#1 for all properties.

     *
Add listener#1 for N different selected properties.

     *
Add listener#2 for N different selected properties

     *
Add 5 times listener#0 for selected property.

     *
Add 10 times listener#1 for selected property.

     *
remove 4 times listener#1 for all properties.

     *
remove listener#0 for N different selected properties.

     *
remove 4 times listener#1 for all properties.

     *
remove 5 times listener#0 for selected property.

     *
remove 5 times listener#1 for selected property.

     *
remove listener#0 for N different selected properties.

     *
remove listener#1 for N different selected properties.

     *
After each adding or removing listener firePropertyChange method is
     * invoked and test verifies that all registered listeners was notified.
     *

     *

     */
    /**
     * Disregard this test case.
     */
    public Result testForSelectedPropertyAndForAllProperties() {
        try {
            checkResult(testAddListenersForSelectedPropertyAndForAllProperties());
            SimpleTests simple = new SimpleTests(this);
            checkResult(simple.testRemoveListenersForAllProperties());
            checkResult(simple.testRemoveListener0FromAllSelectedProperties());
            checkResult(simple.testRemoveListenersForAllProperties());
            checkResult(simple.testRemove5Listeners0fromProperty1());
            checkResult(simple.testRemoveListenersForSelectedProperty());
            checkResult(simple.testRemoveListener0FromAllSelectedProperties());
            checkResult(simple.testRemoveListener1FromAllSelectedProperties());
            return passed();
        } catch (BoundException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     * Test for two selected properties without testing remove methods.
     *

     *

     *
Add 5 times listeners#0 for selected property#1.

     *
Add 12 times listeners#0 for selected property#0.

     *
Add 5 times listener#1 for selected property#1.

     *
Add 6 times listener#0 for selected property#0.

     *
After each adding or removing listener firePropertyChange method is
     * invoked and test verifies that all registered listeners was notified.
     *

     */
    /**
     * Disregard this test case.
     */
    public Result test02() {
        try {
            SimpleTests simple = new SimpleTests(this);
            checkResult(simple.testAdd5Listeners0ToProperty1());
            checkResult(simple.testAdd6Listeners0ToProperty0());
            checkResult(simple.testAdd6Listeners0ToProperty0());
            checkResult(simple.testAddListenersForSelectedProperty());
            checkResult(simple.testAdd6Listeners0ToProperty0());
            return passed();
        } catch (BoundException e) {

            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     * Add and remove many listeners for two different selected properties. Call
     * firePropertyChange method for one of selected property. Verify that all
     * listeners registered for this selected property are notified. Do the same
     * verification for other property.
     *

     * Step-by-step decoding:
     *

     *
Add 5 times listeners#0 for selected property#1.

     *
Add 12 times listeners#0 for selected property#0.

     *
Add 5 times listener#1 for selected property#1.

     *
Add 6 times listener#0 for selected property#0.

     *
Remove 5 times listeners#0 for selected property#1.

     *
Remove 5 times listener#1 for selected property#1.

     *
Remove 12 times listeners#0 for selected property#0.

     *

     */
    public Result testForTwoDifferentProperties() {
        try {
            checkResult(test02());
            SimpleTests simple = new SimpleTests(this);
            checkResult(simple.testRemove5Listeners0fromProperty1());
            checkResult(simple.testRemoveListenersForSelectedProperty());
            checkResult(simple.testRemove6Listeners0fromProperty0());
            checkResult(simple.testRemove6Listeners0fromProperty0());
            return passed();
        } catch (BoundException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     *
Add 4 times listener#1 for all properties.

     *
Add listener#1 for N different selected properties.

     *
Add listener#2 for N different selected properties

     *
Add 5 times listener#3 for selected property.

     *
Add 10 times listener#1 for selected property.

     *
Add 4 times listener#1 for all properties.

     *
Add listener#1 for N different selected properties.

     *
Add listener#2 for N different selected properties

     *
Add 5 times listener#3 for selected property.

     *
Add 10 times listener#1 for selected property.

     */
    /**
     * Disregard this test case.
     */
    public Result test03() {
        try {
            checkResult(testAddListenersForSelectedPropertyAndForAllProperties());
            certainProperties[0].fireAndVerify("older value", "newer value");
            checkResult(testAddListenersForSelectedPropertyAndForAllProperties());
            return passed();
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     * Use different combination of adding and removing different listeners for
     * different selected properties and for all properties. Verify that all
     * listeners registered for selected property and for all property are
     * notified when call firePropertyChange method for selected property.
     *

     * Step-by-step decoding:
     *

     *
Do the same actions as in
     * testForSelectedPropertyAndForAllProperties()

     *
Do the same actions as in testForTwoDifferentProperties()

     *
Add 4 times listener#1 for all properties.

     *
Add listener#1 for N different selected properties.

     *
Add listener#2 for N different selected properties

     *
Add 5 times listener#3 for selected property.

     *
Add 10 times listener#1 for selected property.

     *
Do the same actions as in
     * testForSelectedPropertyAndForAllProperties()

     *
After each adding or removing firePropertyChange method is invoked
     * and test verifies that all registered listeners were notified.

     *

     */
    public Result testAddRemoveStress() {
        try {
            checkResult(testAddListenersForSelectedPropertyAndForAllProperties());
            checkResult(testForTwoDifferentProperties());
            checkResult(testAddListenersForSelectedPropertyAndForAllProperties());
            checkResult(testForSelectedPropertyAndForAllProperties());
            return passed();
        } catch (BoundException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     * Register 200 listeners for selected property. Verify that all registered
     * listeners are notified, when selected property is changed.
     *

     * Step-by-step decoding:
     *

     *
Add 5 times listener for selected property.
     *
Add 5 times other listener for selected property.
     *
Repeat 20 times step 1 and 2.
     *
After each adding firePropertyChange method is invoked and test
     * verifies that all registered listeners were notified.
     */
    /**
     * Disregard this test case.
     */
    public Result testStress() {
        try {
            SimpleTests simple = new SimpleTests(this);
            for (int i = 0; i < 20; i++) {
                checkResult(simple.testAdd5Listeners0ToProperty1());
                checkResult(simple.testAddListenersForSelectedProperty());
            }
            return passed();
        } catch (BoundException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    /**
     * This test runs test01 from this class. Then this test runs
     * testRemove5Listeners0fromProp1() and testRemove5Listeners1fromProp1() 10
     * times.
     */
    /**
     * Disregard this test case.
     */
    public Result test06() {
        try {
            checkResult(testAddListenersForSelectedPropertyAndForAllProperties());
            SimpleTests simple = new SimpleTests(this);
            for (int i = 0; i < 10; i++) {
                checkResult(simple.testRemove5Listeners0fromProperty1());
                checkResult(simple.testRemoveListenersForSelectedProperty());
            }
            return passed();
        } catch (BoundException e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }

    public ComplexTests() {
        startup(null);
    }

    private void checkResult(Result result) throws BoundException {
        if (result.getResult() != Result.PASS) {
            throw new BoundException(result.getMessage());
        }
    }

    public static void main(String[] args) {
        System.exit(new ComplexTests().test(args));
    }
}


text:
package com.intellij.mock;

import javax.annotation.Nonnull;

import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.util.IncorrectOperationException;
import com.intellij.lang.Language;
import consulo.disposer.Disposable;
import org.jetbrains.annotations.NonNls;

import javax.annotation.Nullable;

/**
 * @author peter
 */
public class MockPsiDirectory extends MockPsiElement implements PsiDirectory {
  private final PsiJavaPackage myPackage;

  public MockPsiDirectory(final PsiJavaPackage aPackage, @Nonnull Disposable parentDisposable) {
    super(parentDisposable);
    myPackage = aPackage;
  }

  @Override
  public boolean isDirectory() {
    return true;
  }

  @Nonnull
  @Override
  public Language getLanguage() {
    return Language.ANY;
  }

  @Override
  public void checkCreateFile(@Nonnull final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method checkCreateFile is not yet implemented in " + getClass().getName());
  }

  @Override
  public void checkCreateSubdirectory(@Nonnull final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method checkCreateSubdirectory is not yet implemented in " + getClass().getName());
  }

  @Override
  public PsiDirectory getParent() {
    return getParentDirectory();
  }

  @Override
  @Nonnull
  public PsiFile createFile(@Nonnull final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method createFile is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nonnull
  public PsiFile copyFileFrom(@Nonnull final String newName, @Nonnull final PsiFile originalFile) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method copyFileFrom is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nonnull
  public PsiDirectory createSubdirectory(@Nonnull final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method createSubdirectory is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nullable
  public PsiFile findFile(@Nonnull @NonNls final String name) {
    throw new UnsupportedOperationException("Method findFile is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nullable
  public PsiDirectory findSubdirectory(@Nonnull final String name) {
    throw new UnsupportedOperationException("Method findSubdirectory is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nonnull
  public PsiFile[] getFiles() {
    throw new UnsupportedOperationException("Method getFiles is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nonnull
  public String getName() {
    throw new UnsupportedOperationException("Method getName is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nullable
  public PsiDirectory getParentDirectory() {
    final PsiJavaPackage psiPackage = myPackage.getParentPackage();
    return psiPackage == null ? null : new MockPsiDirectory(psiPackage, getProject());
  }

  @Override
  @Nonnull
  public PsiDirectory[] getSubdirectories() {
    throw new UnsupportedOperationException("Method getSubdirectories is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nonnull
  public VirtualFile getVirtualFile() {
    throw new UnsupportedOperationException("Method getVirtualFile is not yet implemented in " + getClass().getName());
  }

  @Override
  public boolean processChildren(final PsiElementProcessor<PsiFileSystemItem> processor) {
    throw new UnsupportedOperationException("Method processChildren is not yet implemented in " + getClass().getName());
  }

  @Override
  @Nonnull
  public PsiElement setName(@Nonnull final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method setName is not yet implemented in " + getClass().getName());
  }

  @Override
  public void checkSetName(final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Method checkSetName is not yet implemented in " + getClass().getName());
  }

  @Override
  @javax.annotation.Nullable
  public ItemPresentation getPresentation() {
    throw new UnsupportedOperationException("Method getPresentation is not yet implemented in " + getClass().getName());
  }
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.camel.spring.pollingconsumer;
import org.apache.camel.Exchange;
import org.apache.camel.spring.SpringTestSupport;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class FileConsumerSpringSchedulerTest extends SpringTestSupport {

    @Override
    protected AbstractXmlApplicationContext createApplicationContext() {
        return new ClassPathXmlApplicationContext("org/apache/camel/spring/pollingconsumer/FileConsumerSpringSchedulerTest.xml");
    }

    @Override
    @Before
    public void setUp() throws Exception {
        deleteDirectory("target/file/spring");
        super.setUp();
    }

    @Test
    public void testSpringScheduler() throws Exception {
        getMockEndpoint("mock:result").expectedMessageCount(1);

        template.sendBodyAndHeader("file:target/file/spring", "Hello World", Exchange.FILE_NAME, "hello.txt");

        context.getRouteController().startRoute("foo");

        assertMockEndpointsSatisfied();
    }

}


text:
#include "Constraint.h"
#include "RigidBody.h"
#include "PMath.h"

using namespace Physics;
using PMath::Vec3f;

DistanceConstraint :: DistanceConstraint(uint32 a, RigidBody* pBodyA, uint32 b, RigidBody* pBodyB, Real distance, Real tolerance)
	: m_BodyA(a), mp_BodyA(pBodyA), m_BodyB(b), mp_BodyB(pBodyB),
	m_Distance(distance), m_PrevLength(distance), m_Tolerance(tolerance)
{
}

bool DistanceConstraint :: Apply() {
	bool retval = m_Active;
	if (retval) {
		Vec3f* pPosA = &mp_BodyA->m_StateT1.m_Position;
		Vec3f* pPosB = &mp_BodyB->m_StateT1.m_Position;

		Vec3f direction;
		PMath::Vec3fSubtract(direction, *pPosA, *pPosB);
		Real length = PMath::Vec3fLength(direction);

		Real x = length - m_Distance;

		if (1) {
			Real force = 1000.0f /*pSpring->m_Stiffness*/ * x;

			// damping -b * difference in length between this frame and previous
			Real v = (m_PrevLength - x);
			force += v * 0.95f; //pSpring->m_Damping;

			m_PrevLength = length;

			PMath::Vec3fMultiplyAccumulate(mp_BodyA->m_Acc.m_Force, -force, direction);
			PMath::Vec3fMultiplyAccumulate(mp_BodyB->m_Acc.m_Force,  force, direction);
		}
	}

	return retval;
}

/*
bool DistanceConstraint :: Apply() {
	bool retval = m_Active;
	if (m_Active) {
		Vec3f distance;
		Vec3f* pPosA = &mp_BodyA->m_StateT1.m_Position;
		Vec3f* pPosB = &mp_BodyB->m_StateT1.m_Position;
		PMath::Vec3fSubtract(distance, *pPosA, *pPosB);
		Real distSquared = PMath::Vec3fDot(distance, distance);
		Real desiredDistSquared = m_Distance * m_Distance;
		Real tolSquared = m_Tolerance * m_Tolerance;

		// if length is within tolerance, done
		if (PMath::Abs(desiredDistSquared - distSquared) < tolSquared) {
			retval = true;
		}
		else {
			// else move the bodies towards their correct mutual distance, proportionately to their masses
			Real dist = PMath::Sqrt(distSquared) + 1.0e-4f;	// add a teeny bit to avoid divide by zero problems
			Real delta = (dist - m_Distance) / (dist * (mp_BodyA->GetOOMass() + mp_BodyB->GetOOMass()));

			PMath::Vec3fMultiplyAccumulate(*pPosA, -mp_BodyA->GetOOMass() * delta, distance);
			PMath::Vec3fMultiplyAccumulate(*pPosB,  mp_BodyB->GetOOMass() * delta, distance);

			retval = PMath::Abs((dist - m_Distance) / m_Distance) < m_Tolerance;
		}
	}

	return retval;
}
*/

/*
	bool applyConstraint()
	{
	// if the particles are in the same place, dislocate one slightly
	  if (p1->x == p2->x)
	    p2->x.x+=0.001;

	  Vector3 delta(p2->x);
	  // delta is the difference vector between the 2 particles
	  delta -= p1->x;
	  // length of the distance
    float32 deltaLength = delta.length();

    float32 diff = (deltaLength - length) / (deltaLength * (p1->invMass + p2->invMass));
    delta *= diff;
    Vector3 delta2(delta);
    delta *= p1->invMass;
    delta2 *= p2->invMass;
    p1->x += delta;
    p2->x -= delta2;

	  return ((abs(deltaLength - length)/length) <= satisfied);
	}
*/


text:
namespace OpenApoc
{

BitmapFont::~BitmapFont() {}

sp<PaletteImage> BitmapFont::getString(const UString &Text)
{
	int height = this->GetFontHeight();
	int width = this->GetFontWidth(Text);
	auto img = std::make_shared<PaletteImage>(Vec2<int>{width, height});
	int pos = 0;

	for (size_t i = 0; i < Text.length(); i++)
	{
		UniChar c = Text[i];
		auto glyph = this->getGlyph(c);
		PaletteImage::blit(glyph, Vec2<int>{pos, 0}, img);
		pos += glyph->size.x;
	}

	return img;
}

int BitmapFont::GetFontWidth(const UString &Text)
{
	int textlen = 0;
	for (size_t i = 0; i < Text.length(); i++)
	{
		auto glyph = this->getGlyph(Text[i]);
		textlen += glyph->size.x;
	}
	return textlen;
}

}; // namespace OpenApoc


text:
class NMTNI {               // name table with user-defined NIs
public:

    struct SZO {            // string offset: relative to start of buffer
        OFF off;

        SZ sz(const Buffer *pbuf) const {
            assert(isValid(pbuf));
            return getsz(pbuf);
        }
        BOOL Equals(const SZO &szo, const Buffer *pbuf) const {
            return off == szo.off || strcmp(sz(pbuf), szo.sz(pbuf)) == 0;
        }
        BOOL operator ==(const SZO& szo) const {
            return off == szo.off;
        }
        HASH Hash(const Buffer *pbuf) const {
            return hashSz(sz(pbuf));
        }
        BOOL isValid(const Buffer *pbuf) const {
            if (off < 0) {
                // PDB must be corrupted.
                return FALSE;
            }
            return off < pbuf->Size() && fValidateSz(getsz(pbuf), (SZ)pbuf->End());
        }
    private:
        SZ getsz(const Buffer *pbuf) const {
            return (SZ)pbuf->Start() + off;
        }
    };

    typedef HashClassWithContext<SZO,Buffer> HcSzo;

public:
    // create a name table with default name index generation (0, 1, 2, ...)
    NMTNI()
    {
        pfnNi = niNext;
        pfnNiArg = this;
        niMac = niNil + 1;
        mapSzoNi.setContext(&buf);
    }
    // create a name table with client defined name index generation
    NMTNI(BOOL (*pfnNi_)(void*, OUT NI*), void* pfnNiArg_ = 0)
    {
        pfnNi = pfnNi_;
        pfnNiArg = pfnNiArg_;
        niMac = 0; // will not be used
        mapSzoNi.setContext(&buf);
    }
    // append a serialization of this NMTNI to the buffer
    BOOL save(Buffer* pbuf) {
        MTS_PROTECT(m_csReadWrite);

        // optimization: since mapNiSzo is just the reverse map of mapSzoNi,
        // we store only the latter
        if (!buf.save(pbuf))
            return FALSE;
        traceOnly(CB cb0 = pbuf->Size());

        if (!mapSzoNi.save(pbuf))
            return FALSE;
        traceOnly(CB cbMap = pbuf->Size() - cb0);

        if (!pbuf->Append((PB)&niMac, sizeof niMac))
            return FALSE;

        trace((trSave, "NMTNI::save() cbBuf=%d cbMap=%d\n", buf.Size(), cbMap));
        return TRUE;
    }
#if 0
    // reload a serialization of this empty NMTNI from the buffer; leave
    // *ppb pointing just past the NMTNI representation
    BOOL reload(PB* ppb) {
        MTS_PROTECT(m_csReadWrite);

        if (!buf.reload(ppb))
            return FALSE;

        if (!mapSzoNi.reload(ppb))
            return FALSE;

        niMac = *(NI UNALIGNED *)*ppb;
        *ppb += sizeof(niMac);

        // recover mapNiSzo from mapSzoNi
        mapNiSzo.reset();
        EnumMap<SZO,NI,HcSzo,Buffer> enumMap(mapSzoNi);
        while (enumMap.next()) {
            SZO szo;
            NI ni;
            enumMap.get(&szo, &ni);
            if (!mapNiSzo.add(ni, szo))
                return FALSE;
        }

        return TRUE;
    }
#endif
    // reload a serialization of this empty NMTNI from the buffer; leave
    // *ppb pointing just past the NMTNI representation
    BOOL reload(PB* ppb, CB cbReloadBuf) {
        MTS_PROTECT(m_csReadWrite);

        PB  pbEnd = *ppb + cbReloadBuf;

        if (!buf.reload(ppb, cbReloadBuf)) {
            return FALSE;
        }
        cbReloadBuf = static_cast<CB>(pbEnd - *ppb);

        if (!mapSzoNi.reload(ppb, cbReloadBuf)) {
            return FALSE;
        }
        cbReloadBuf = static_cast<CB>(pbEnd - *ppb);

        if (cbReloadBuf < sizeof(niMac)) {
            return FALSE;
        }

        niMac = *(NI UNALIGNED *)*ppb;
        *ppb += sizeof(niMac);

        // recover mapNiSzo from mapSzoNi
        mapNiSzo.reset();
        EnumMap<SZO,NI,HcSzo,Buffer> enumMap(mapSzoNi);
        while (enumMap.next()) {
            SZO szo;
            NI ni;
            enumMap.get(&szo, &ni);

            // make sure that the SZO is valid
            if (!szo.isValid(&buf)) {
                return FALSE;
            }

            if (!mapNiSzo.add(ni, szo)) {
                return FALSE;
            }
        }

        return TRUE;
    }
    // return a name index for this name
    BOOL addNiForSz(SZ_CONST sz, OUT NI *pni) {
        MTS_PROTECT(m_csReadWrite);

        precondition(pni);

        // speculatively add the argument name to the name buffer
        SZO szo;
        if (!addSzo(sz, &szo))
            return FALSE;
        else if (mapSzoNi.map(szo, pni)) {
            // name already in table, remove name we just added to buffer
            verify(retractSzo(szo));
            return TRUE;
        }
        else if (pfnNi(pfnNiArg, pni) &&
                 mapSzoNi.add(szo, *pni) &&
                 mapNiSzo.add(*pni, szo))
        {
            // successfully added the name and its new name index
            return TRUE;
        }
        else {
            // failed hard; we'd better not commit these changes!
            verify(retractSzo(szo));
            return FALSE;
        }
    }

    // return the name corresponding to ni, valid until next NMTNI call

#ifndef PDB_MT
    // MTS note: this cannot be MTS since the result can be invalidate by another thread
    // no one uses it anyway, so just disable it
    BOOL szForNi(NI ni, _Out_opt_ OUT SZ *psz) {
        MTS_PROTECT(m_csReadWrite);

        precondition(ni != niNil);
        precondition(psz);

        SZO szo;
        if (mapNiSzo.map(ni, &szo)) {
            *psz = szo.sz(&buf);
            return TRUE;
        }
        else
            return FALSE;
    }
#endif
    void reset() {
        MTS_PROTECT(m_csReadWrite);

        niMac = niNil + 1;
        mapSzoNi.reset();
        mapNiSzo.reset();
        buf.Clear();
    }

    BOOL deleteNiSzo(NI ni) {
        MTS_PROTECT(m_csReadWrite);

        precondition(ni != 0);

        SZO szo;

        if (!mapNiSzo.map(ni, &szo)) {
            return FALSE;
        }

        if (!mapSzoNi.remove(szo)) {
            return FALSE;
        }

        if (!mapNiSzo.remove(ni)) {
            return FALSE;
        }

        return TRUE;
    }

private:
    Map<SZO,NI,HcSzo,Buffer>   mapSzoNi;   // map from szo to ni
    Map<NI,SZO,HcNi> mapNiSzo;   // map from ni to szo
    Buffer buf;             // store the names
    // REVIEW: this buffer should be a pool!
    BOOL (*pfnNi)(void*, OUT NI*);
    void* pfnNiArg;
    NI niMac;               // last NI allocated by niNext()

#ifdef PDB_MT
    mutable CriticalSection m_csReadWrite;
#endif

    // append the name to the names buffer
    BOOL addSzo(SZ_CONST sz, OUT SZO* pszo) {
        // only used by NMTNI::addNiForSz()
        MTS_ASSERT(m_csReadWrite);
        precondition(sz && strlen(sz) > 0);
        precondition(pszo);

        CB cb = CB(strlen(sz)) + 1;
        PB pb;
        if (buf.Append((PB)sz, cb, &pb)) {
            pszo->off = OFF(pb - buf.Start());  // REVIEW:WIN64 CAST
            return TRUE;
        }
        else
            return FALSE;
    }
    // remove the name recently appended to the names buffer
    BOOL retractSzo(const SZO& szo) {
        // only used by NMTNI::addNiForSz()
        MTS_ASSERT(m_csReadWrite);
        return buf.Truncate(szo.off);
    }
    // default NI generator: returns the sequence (1, 2, ...)
    static BOOL niNext(void* pv, OUT NI* pni) {
        NMTNI* pnmt = (NMTNI*)pv;
        precondition(pnmt);

        MTS_ASSERT(pnmt->m_csReadWrite);
        *pni = pnmt->niMac++;

        return TRUE;
    }

    friend class EnumNMTNI;
};

class EnumNMTNI : public EnumNameMap {
public:
    EnumNMTNI(const NMTNI& nmt)
        : enumMap(nmt.mapSzoNi), pnmt(&nmt)
    {
    }
    void release() {
        delete this;
    }
    void reset() {
        MTS_PROTECT(pnmt->m_csReadWrite);
        enumMap.reset();
    }
    BOOL next() {
        MTS_PROTECT(pnmt->m_csReadWrite);
        return enumMap.next();
    }
    void get(OUT SZ_CONST* psz, OUT NI* pni) {
        MTS_PROTECT(pnmt->m_csReadWrite);

        NMTNI::SZO szo;
        enumMap.get(&szo, pni);
#ifdef PDB_MT
        SZ_CONST sz = szo.sz(&pnmt->buf);
        buf.Reset();
        buf.Append((PB)sz, (CB)strlen(sz) + 1, (PB *)psz);
#else
        *psz = szo.sz(&pnmt->buf);
#endif
    }
private:
    EnumMap<NMTNI::SZO,NI,NMTNI::HcSzo,Buffer> enumMap;
    const NMTNI* pnmt;
#ifdef PDB_MT
    Buffer buf;
#endif
};

#endif // !__NMTNI_INCLUDED__


text:
SELECT * FROM NOTIFICATION_STATUS
 WHERE
TARGET_ID = ?
 AND TYPE = ?
 AND USER_ID = ?
 AND DELETE_FLAG = 0;


text:
from satchmo.configuration import config_value
from satchmo.utils import load_module, load_once
try:
    import decimal
except ImportError:
    from django.utils import _decimal as decimal    # for Python 2.3

TWOPLACES = decimal.Decimal('0.01')

def get_tax_processor(order=None, user=None):
    modulename = config_value('TAX','MODULE')
    mod = load_module(modulename + u'.tax')
    return mod.Processor(order=order,user=user)

def round_cents(x):
    return x.quantize(TWOPLACES, decimal.ROUND_FLOOR)


text:
define([ 'backbone',
         //view
		'view/common/MapView',
		'view/common/BackBtnView',
		'view/common/InfoBtnView',
		'view/tools/DrawElementsBtnView'
       ], function(Backbone, MapView, BackBtnView, InfoBtnView, DrawElementsBtnView) {

	var Controller = function() {
		console.log("This is basic elements drawing controller module!");

		//map
		var map = new MapView();

		//left menu
		var back = new BackBtnView();
		var info = new InfoBtnView();
		var moduleInfo = '
' +
						 '	此模块绘制基础的地图元素,如GeoJSON、' +
						 '	WKT、Node元素、Way元素、Segment元素、Section元素,' +
						 '	其中,Node、Segment和Section可以输入多个id,分隔符为小写的  , 。' +
						 '
';
		info.setInfo(moduleInfo);
		var menu = new DrawElementsBtnView();

		Controller.onRouteChange = function() {
			map.unrender();
			back.unrender();
			info.unrender();
			menu.unrender();
		};
	};

	return Controller;
});


text:
/*

	TableCloth
	by Alen Grakalic, brought to you by cssglobe.com

*/

/* general styles */

#review table, td{
	font-size: 90%;
}
#review table{width:100%; margin:1em 0; border:1px solid #cea;}
#review th {text-align:right;padding:2px 10px;border:1px solid #fff; font-size:105%; font-weight:normal; font-style:italic; }
#review td {text-align:left;padding:2px 10px;border:0px dotted #fff; }

#review td{background:#e5f1f4;}

/* tablecloth styles */

#review tr.even td{background:#e5f1f4;}
#review tr.odd td{background:#f8fbfc;}

#review th.over, tr.even th.over, tr.odd th.over{background:#4a98af;}
#review th.down, tr.even th.down, tr.odd th.down{background:#bce774;}
#review th.selected, tr.even th.selected, tr.odd th.selected{}

#review td.over, tr.even td.over, tr.odd td.over{background:#ecfbd4;}
#review td.down, tr.even td.down, tr.odd td.down{background:#bce774;color:#fff;}
#review td.selected, tr.even td.selected, tr.odd td.selected{background:#bce774;color:#555;}

/* use this if you want to apply different styleing to empty table cells*/
#review td.empty, tr.odd td.empty, tr.even td.empty{background:#fff;}


text:
@implementation DropboxSharedFolderMetadata (DictionaryParser)

- (instancetype)initWithDictionary:(NSDictionary *)dic
{
    self = [self init];
    if (self) {
        DictionaryParseHelper *helper = [[DictionaryParseHelper alloc] initWithDictionary:dic];
        id accessType = [helper dictionaryWithKey:@"access_type"];
        if (accessType)
        {
            self.accessType = [DropboxAccessLevelDictionaryParser accessLevelFromDictionary:accessType];
        }

        self.isTeamFolder = [helper boolWithKey:@"is_team_folder"];

        id policy = [helper dictionaryWithKey:@"policy"];
        if (policy)
        {
            self.policy = [[DropboxFolderPolicy alloc] initWithDictionary:policy];
        }

        self.name = [helper stringWithKey:@"name"];
        self.sharedFolderID = [helper stringWithKey:@"shared_folder_id"];
        self.timeInvited = [helper dateWithKey:@"time_invited"];

        id ownerTeam = [helper dictionaryWithKey:@"owner_team"];
        if (ownerTeam)
        {
            self.ownerTeam = [[DropboxTeam alloc] initWithDictionary:ownerTeam];
        }

        self.parentSharedFolderID = [helper stringWithKey:@"parent_shared_folder_id"];
        self.pathLower = [helper stringWithKey:@"path_lower"];
        self.permissions = [helper arrayWithKey:@"permissions" type:[DropboxFolderPermission class]];
    }
    return self;
}

@end


text:
package okhttp3.internal;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.Socket;
import java.util.Deque;
import java.util.concurrent.LinkedBlockingDeque;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.DelegatingSSLSocket;
import okhttp3.DelegatingSSLSocketFactory;
import okio.Buffer;
import okio.ByteString;

/** Records all bytes written and read from a socket and makes them available for inspection. */
public final class SocketRecorder {
  private final Deque<RecordedSocket> recordedSockets = new LinkedBlockingDeque<>();

  /** Returns an SSLSocketFactory whose sockets will record all transmitted bytes. */
  public SSLSocketFactory sslSocketFactory(SSLSocketFactory delegate) {
    return new DelegatingSSLSocketFactory(delegate) {
      @Override protected SSLSocket configureSocket(SSLSocket sslSocket) throws IOException {
        RecordedSocket recordedSocket = new RecordedSocket();
        recordedSockets.add(recordedSocket);
        return new RecordingSSLSocket(sslSocket, recordedSocket);
      }
    };
  }

  public RecordedSocket takeSocket() {
    return recordedSockets.remove();
  }

  /** A bidirectional transfer of unadulterated bytes over a socket. */
  public static final class RecordedSocket {
    private final Buffer bytesWritten = new Buffer();
    private final Buffer bytesRead = new Buffer();

    synchronized void byteWritten(int b) {
      bytesWritten.writeByte(b);
    }

    synchronized void byteRead(int b) {
      bytesRead.writeByte(b);
    }

    synchronized void bytesWritten(byte[] bytes, int offset, int length) {
      bytesWritten.write(bytes, offset, length);
    }

    synchronized void bytesRead(byte[] bytes, int offset, int length) {
      bytesRead.write(bytes, offset, length);
    }

    /** Returns all bytes that have been written to this socket. */
    public synchronized ByteString bytesWritten() {
      return bytesWritten.readByteString();
    }

    /** Returns all bytes that have been read from this socket. */
    public synchronized ByteString bytesRead() {
      return bytesRead.readByteString();
    }
  }

  static final class RecordingInputStream extends InputStream {
    private final Socket socket;
    private final RecordedSocket recordedSocket;

    RecordingInputStream(Socket socket, RecordedSocket recordedSocket) {
      this.socket = socket;
      this.recordedSocket = recordedSocket;
    }

    @Override public int read() throws IOException {
      int b = socket.getInputStream().read();
      if (b == -1) return -1;
      recordedSocket.byteRead(b);
      return b;
    }

    @Override public int read(byte[] b, int off, int len) throws IOException {
      int read = socket.getInputStream().read(b, off, len);
      if (read == -1) return -1;
      recordedSocket.bytesRead(b, off, read);
      return read;
    }

    @Override public void close() throws IOException {
      socket.getInputStream().close();
    }
  }

  static final class RecordingOutputStream extends OutputStream {
    private final Socket socket;
    private final RecordedSocket recordedSocket;

    RecordingOutputStream(Socket socket, RecordedSocket recordedSocket) {
      this.socket = socket;
      this.recordedSocket = recordedSocket;
    }

    @Override public void write(int b) throws IOException {
      socket.getOutputStream().write(b);
      recordedSocket.byteWritten(b);
    }

    @Override public void write(byte[] b, int off, int len) throws IOException {
      socket.getOutputStream().write(b, off, len);
      recordedSocket.bytesWritten(b, off, len);
    }

    @Override public void close() throws IOException {
      socket.getOutputStream().close();
    }

    @Override public void flush() throws IOException {
      socket.getOutputStream().flush();
    }
  }

  static final class RecordingSSLSocket extends DelegatingSSLSocket {
    private final InputStream inputStream;
    private final OutputStream outputStream;

    RecordingSSLSocket(SSLSocket delegate, RecordedSocket recordedSocket) {
      super(delegate);
      inputStream = new RecordingInputStream(delegate, recordedSocket);
      outputStream = new RecordingOutputStream(delegate, recordedSocket);
    }

    @Override public void startHandshake() throws IOException {
      // Intercept the handshake to properly configure TLS extensions with Jetty ALPN. Jetty ALPN
      // expects the real SSLSocket to be placed in the global map. Because we are wrapping the real
      // SSLSocket, it confuses Jetty ALPN. This patches that up so things work as expected.
      Class<?> alpn = null;
      Class<?> provider = null;
      try {
        alpn = Class.forName("org.eclipse.jetty.alpn.ALPN");
        provider = Class.forName("org.eclipse.jetty.alpn.ALPN$Provider");
      } catch (ClassNotFoundException ignored) {
      }

      if (alpn == null || provider == null) {
        // No Jetty, so nothing to worry about.
        super.startHandshake();
        return;
      }

      Object providerInstance = null;
      Method putMethod = null;
      try {
        Method getMethod = alpn.getMethod("get", SSLSocket.class);
        putMethod = alpn.getMethod("put", SSLSocket.class, provider);
        providerInstance = getMethod.invoke(null, this);
        if (providerInstance == null) {
          // Jetty's on the classpath but TLS extensions weren't used.
          super.startHandshake();
          return;
        }

        // TLS extensions were used; replace with the real SSLSocket to make Jetty ALPN happy.
        putMethod.invoke(null, delegate, providerInstance);
        super.startHandshake();
      } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        throw new AssertionError();
      } finally {
        // If we replaced the SSLSocket in the global map, we must put the original back for
        // everything to work inside OkHttp.
        if (providerInstance != null) {
          try {
            putMethod.invoke(null, this, providerInstance);
          } catch (IllegalAccessException | InvocationTargetException e) {
            throw new AssertionError();
          }
        }
      }
    }

    @Override public InputStream getInputStream() throws IOException {
      return inputStream;
    }

    @Override public OutputStream getOutputStream() throws IOException {
      return outputStream;
    }
  }
}


text:
package de.androidbytes.recipr.app.data.provider;

import android.annotation.TargetApi;
import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.DefaultDatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.util.Log;

import de.androidbytes.recipr.app.BuildConfig;
import de.androidbytes.recipr.app.data.provider.ingredient.IngredientColumns;
import de.androidbytes.recipr.app.data.provider.recipe.RecipeColumns;
import de.androidbytes.recipr.app.data.provider.step.StepColumns;
import de.androidbytes.recipr.app.data.provider.user.UserColumns;

public class ReciprSQLiteOpenHelper extends SQLiteOpenHelper {
    private static final String TAG = ReciprSQLiteOpenHelper.class.getSimpleName();

    public static final String DATABASE_FILE_NAME = "recipr.db";
    private static final int DATABASE_VERSION = 1;
    private static ReciprSQLiteOpenHelper sInstance;
    private final Context mContext;
    private final ReciprSQLiteOpenHelperCallbacks mOpenHelperCallbacks;

    // @formatter:off
    public static final String SQL_CREATE_TABLE_INGREDIENT = "CREATE TABLE IF NOT EXISTS "
            + IngredientColumns.TABLE_NAME + " ( "
            + IngredientColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + IngredientColumns.RECIPE_ID + " INTEGER NOT NULL, "
            + IngredientColumns.NAME + " TEXT, "
            + IngredientColumns.QUANTITY + " INTEGER "
            + ", CONSTRAINT fk_recipe_id FOREIGN KEY (" + IngredientColumns.RECIPE_ID + ") REFERENCES recipe (_id) ON DELETE RESTRICT"
            + " );";

    public static final String SQL_CREATE_TABLE_RECIPE = "CREATE TABLE IF NOT EXISTS "
            + RecipeColumns.TABLE_NAME + " ( "
            + RecipeColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + RecipeColumns.USER_ID + " INTEGER NOT NULL, "
            + RecipeColumns.NAME + " TEXT, "
            + RecipeColumns.RATING + " INTEGER, "
            + RecipeColumns.IMAGE_URL + " TEXT "
            + ", CONSTRAINT fk_user_id FOREIGN KEY (" + RecipeColumns.USER_ID + ") REFERENCES user (_id) ON DELETE RESTRICT"
            + " );";

    public static final String SQL_CREATE_TABLE_STEP = "CREATE TABLE IF NOT EXISTS "
            + StepColumns.TABLE_NAME + " ( "
            + StepColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + StepColumns.RECIPE_ID + " INTEGER NOT NULL, "
            + StepColumns.TITLE + " TEXT, "
            + StepColumns.INSTRUCTION + " TEXT "
            + ", CONSTRAINT fk_recipe_id FOREIGN KEY (" + StepColumns.RECIPE_ID + ") REFERENCES recipe (_id) ON DELETE RESTRICT"
            + " );";

    public static final String SQL_CREATE_TABLE_USER = "CREATE TABLE IF NOT EXISTS "
            + UserColumns.TABLE_NAME + " ( "
            + UserColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + UserColumns.GOOGLE_ID + " INTEGER, "
            + UserColumns.FIRSTNAME + " TEXT, "
            + UserColumns.LASTNAME + " TEXT, "
            + UserColumns.IMAGE_URL + " TEXT "
            + ", CONSTRAINT unique_google_id UNIQUE (google_id) ON CONFLICT REPLACE"
            + " );";

    // @formatter:on

    public static ReciprSQLiteOpenHelper getInstance(Context context) {
        // Use the application context, which will ensure that you
        // don't accidentally leak an Activity's context.
        // See this article for more information: http://bit.ly/6LRzfx
        if (sInstance == null) {
            sInstance = newInstance(context.getApplicationContext());
        }
        return sInstance;
    }

    private static ReciprSQLiteOpenHelper newInstance(Context context) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            return newInstancePreHoneycomb(context);
        }
        return newInstancePostHoneycomb(context);
    }

    /*
     * Pre Honeycomb.
     */
    private static ReciprSQLiteOpenHelper newInstancePreHoneycomb(Context context) {
        return new ReciprSQLiteOpenHelper(context);
    }

    private ReciprSQLiteOpenHelper(Context context) {
        super(context, DATABASE_FILE_NAME, null, DATABASE_VERSION);
        mContext = context;
        mOpenHelperCallbacks = new ReciprSQLiteOpenHelperCallbacks();
    }

    /*
     * Post Honeycomb.
     */
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private static ReciprSQLiteOpenHelper newInstancePostHoneycomb(Context context) {
        return new ReciprSQLiteOpenHelper(context, new DefaultDatabaseErrorHandler());
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private ReciprSQLiteOpenHelper(Context context, DatabaseErrorHandler errorHandler) {
        super(context, DATABASE_FILE_NAME, null, DATABASE_VERSION, errorHandler);
        mContext = context;
        mOpenHelperCallbacks = new ReciprSQLiteOpenHelperCallbacks();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        if (BuildConfig.DEBUG) Log.d(TAG, "onCreate");
        mOpenHelperCallbacks.onPreCreate(mContext, db);
        db.execSQL(SQL_CREATE_TABLE_INGREDIENT);
        db.execSQL(SQL_CREATE_TABLE_RECIPE);
        db.execSQL(SQL_CREATE_TABLE_STEP);
        db.execSQL(SQL_CREATE_TABLE_USER);
        mOpenHelperCallbacks.onPostCreate(mContext, db);
    }

    @Override
    public void onOpen(SQLiteDatabase db) {
        super.onOpen(db);
        if (!db.isReadOnly()) {
            setForeignKeyConstraintsEnabled(db);
        }
        mOpenHelperCallbacks.onOpen(mContext, db);
    }

    private void setForeignKeyConstraintsEnabled(SQLiteDatabase db) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            setForeignKeyConstraintsEnabledPreJellyBean(db);
        } else {
            setForeignKeyConstraintsEnabledPostJellyBean(db);
        }
    }

    private void setForeignKeyConstraintsEnabledPreJellyBean(SQLiteDatabase db) {
        db.execSQL("PRAGMA foreign_keys=ON;");
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    private void setForeignKeyConstraintsEnabledPostJellyBean(SQLiteDatabase db) {
        db.setForeignKeyConstraintsEnabled(true);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        mOpenHelperCallbacks.onUpgrade(mContext, db, oldVersion, newVersion);
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

Provides interfaces for adding menu items and toolbar buttons to the IDE's user interface,
and for working with menus and toolbars.

A detailed overview of the action system can be found in
the Action System (SDK Docs).


text:
.class public Landroid/widget/SimpleAdapter;
.super Landroid/widget/BaseAdapter;
.source "SimpleAdapter.java"

# interfaces
.implements Landroid/widget/Filterable;

# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Landroid/widget/SimpleAdapter$1;,
        Landroid/widget/SimpleAdapter$SimpleFilter;,
        Landroid/widget/SimpleAdapter$ViewBinder;
    }
.end annotation

# instance fields
.field private mData:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<+",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "*>;>;"
        }
    .end annotation
.end field

.field private mDropDownResource:I

.field private mFilter:Landroid/widget/SimpleAdapter$SimpleFilter;

.field private mFrom:[Ljava/lang/String;

.field private mInflater:Landroid/view/LayoutInflater;

.field private mResource:I

.field private mTo:[I

.field private mUnfilteredData:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "*>;>;"
        }
    .end annotation
.end field

.field private mViewBinder:Landroid/widget/SimpleAdapter$ViewBinder;

# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/util/List;I[Ljava/lang/String;[I)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;
    .param p3, "resource"    # I
    .param p4, "from"    # [Ljava/lang/String;
    .param p5, "to"    # [I
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/content/Context;",
            "Ljava/util/List",
            "<+",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "*>;>;I[",
            "Ljava/lang/String;",
            "[I)V"
        }
    .end annotation

    .prologue
    .line 84
    .local p2, "data":Ljava/util/List;, "Ljava/util/List<+Ljava/util/Map<Ljava/lang/String;*>;>;"
    invoke-direct {p0}, Landroid/widget/BaseAdapter;-><init>()V

    .line 85
    iput-object p2, p0, Landroid/widget/SimpleAdapter;->mData:Ljava/util/List;

    .line 86
    iput p3, p0, Landroid/widget/SimpleAdapter;->mDropDownResource:I

    iput p3, p0, Landroid/widget/SimpleAdapter;->mResource:I

    .line 87
    iput-object p4, p0, Landroid/widget/SimpleAdapter;->mFrom:[Ljava/lang/String;

    .line 88
    iput-object p5, p0, Landroid/widget/SimpleAdapter;->mTo:[I

    .line 89
    const-string v0, "layout_inflater"

    invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/view/LayoutInflater;

    iput-object v0, p0, Landroid/widget/SimpleAdapter;->mInflater:Landroid/view/LayoutInflater;

    .line 90
    return-void
.end method

.method static synthetic access$100(Landroid/widget/SimpleAdapter;)Ljava/util/ArrayList;
    .locals 1
    .param p0, "x0"    # Landroid/widget/SimpleAdapter;

    .prologue
    .line 54
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mUnfilteredData:Ljava/util/ArrayList;

    return-object v0
.end method

.method static synthetic access$102(Landroid/widget/SimpleAdapter;Ljava/util/ArrayList;)Ljava/util/ArrayList;
    .locals 0
    .param p0, "x0"    # Landroid/widget/SimpleAdapter;
    .param p1, "x1"    # Ljava/util/ArrayList;

    .prologue
    .line 54
    iput-object p1, p0, Landroid/widget/SimpleAdapter;->mUnfilteredData:Ljava/util/ArrayList;

    return-object p1
.end method

.method static synthetic access$200(Landroid/widget/SimpleAdapter;)Ljava/util/List;
    .locals 1
    .param p0, "x0"    # Landroid/widget/SimpleAdapter;

    .prologue
    .line 54
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mData:Ljava/util/List;

    return-object v0
.end method

.method static synthetic access$202(Landroid/widget/SimpleAdapter;Ljava/util/List;)Ljava/util/List;
    .locals 0
    .param p0, "x0"    # Landroid/widget/SimpleAdapter;
    .param p1, "x1"    # Ljava/util/List;

    .prologue
    .line 54
    iput-object p1, p0, Landroid/widget/SimpleAdapter;->mData:Ljava/util/List;

    return-object p1
.end method

.method static synthetic access$300(Landroid/widget/SimpleAdapter;)[I
    .locals 1
    .param p0, "x0"    # Landroid/widget/SimpleAdapter;

    .prologue
    .line 54
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mTo:[I

    return-object v0
.end method

.method static synthetic access$400(Landroid/widget/SimpleAdapter;)[Ljava/lang/String;
    .locals 1
    .param p0, "x0"    # Landroid/widget/SimpleAdapter;

    .prologue
    .line 54
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mFrom:[Ljava/lang/String;

    return-object v0
.end method

.method private bindView(ILandroid/view/View;)V
    .locals 15
    .param p1, "position"    # I
    .param p2, "view"    # Landroid/view/View;

    .prologue
    .line 151
    iget-object v12, p0, Landroid/widget/SimpleAdapter;->mData:Ljava/util/List;

    move/from16 v0, p1

    invoke-interface {v12, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/util/Map;

    .line 152
    .local v5, "dataSet":Ljava/util/Map;
    if-nez v5, :cond_1

    .line 214
    :cond_0
    return-void

    .line 156
    :cond_1
    iget-object v1, p0, Landroid/widget/SimpleAdapter;->mViewBinder:Landroid/widget/SimpleAdapter$ViewBinder;

    .line 157
    .local v1, "binder":Landroid/widget/SimpleAdapter$ViewBinder;
    iget-object v6, p0, Landroid/widget/SimpleAdapter;->mFrom:[Ljava/lang/String;

    .line 158
    .local v6, "from":[Ljava/lang/String;
    iget-object v10, p0, Landroid/widget/SimpleAdapter;->mTo:[I

    .line 159
    .local v10, "to":[I
    array-length v3, v10

    .line 161
    .local v3, "count":I
    const/4 v7, 0x0

    .local v7, "i":I
    :goto_0
    if-ge v7, v3, :cond_0

    .line 162
    aget v12, v10, v7

    move-object/from16 v0, p2

    invoke-virtual {v0, v12}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v11

    .line 163
    .local v11, "v":Landroid/view/View;
    if-eqz v11, :cond_4

    .line 164
    aget-object v12, v6, v7

    invoke-interface {v5, v12}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v4

    .line 165
    .local v4, "data":Ljava/lang/Object;
    if-nez v4, :cond_5

    const-string v9, ""

    .line 166
    .local v9, "text":Ljava/lang/String;
    :goto_1
    if-nez v9, :cond_2

    .line 167
    const-string v9, ""

    .line 170
    :cond_2
    const/4 v2, 0x0

    .line 171
    .local v2, "bound":Z
    if-eqz v1, :cond_3

    .line 172
    invoke-interface {v1, v11, v4, v9}, Landroid/widget/SimpleAdapter$ViewBinder;->setViewValue(Landroid/view/View;Ljava/lang/Object;Ljava/lang/String;)Z

    move-result v2

    .line 175
    :cond_3
    if-nez v2, :cond_4

    .line 176
    instance-of v12, v11, Landroid/widget/Checkable;

    if-eqz v12, :cond_9

    .line 177
    instance-of v12, v4, Ljava/lang/Boolean;

    if-eqz v12, :cond_6

    .line 178
    check-cast v11, Landroid/widget/Checkable;

    .end local v11    # "v":Landroid/view/View;
    check-cast v4, Ljava/lang/Boolean;

    .end local v4    # "data":Ljava/lang/Object;
    invoke-virtual {v4}, Ljava/lang/Boolean;->booleanValue()Z

    move-result v12

    invoke-interface {v11, v12}, Landroid/widget/Checkable;->setChecked(Z)V

    .line 161
    .end local v2    # "bound":Z
    .end local v9    # "text":Ljava/lang/String;
    :cond_4
    :goto_2
    add-int/lit8 v7, v7, 0x1

    goto :goto_0

    .line 165
    .restart local v4    # "data":Ljava/lang/Object;
    .restart local v11    # "v":Landroid/view/View;
    :cond_5
    invoke-virtual {v4}, Ljava/lang/Object;->toString()Ljava/lang/String;

    move-result-object v9

    goto :goto_1

    .line 179
    .restart local v2    # "bound":Z
    .restart local v9    # "text":Ljava/lang/String;
    :cond_6
    instance-of v12, v11, Landroid/widget/TextView;

    if-eqz v12, :cond_7

    .line 182
    check-cast v11, Landroid/widget/TextView;

    .end local v11    # "v":Landroid/view/View;
    invoke-virtual {p0, v11, v9}, Landroid/widget/SimpleAdapter;->setViewText(Landroid/widget/TextView;Ljava/lang/String;)V

    goto :goto_2

    .line 184
    .restart local v11    # "v":Landroid/view/View;
    :cond_7
    new-instance v13, Ljava/lang/IllegalStateException;

    new-instance v12, Ljava/lang/StringBuilder;

    invoke-direct {v12}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v11}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v14

    invoke-virtual {v14}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v14

    invoke-virtual {v12, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v12

    const-string v14, " should be bound to a Boolean, not a "

    invoke-virtual {v12, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v14

    if-nez v4, :cond_8

    const-string v12, "<unknown type>"

    :goto_3
    invoke-virtual {v14, v12}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v12

    invoke-virtual {v12}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v12

    invoke-direct {v13, v12}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v13

    :cond_8
    invoke-virtual {v4}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v12

    goto :goto_3

    .line 188
    :cond_9
    instance-of v12, v11, Landroid/widget/TextView;

    if-eqz v12, :cond_a

    .line 191
    check-cast v11, Landroid/widget/TextView;

    .end local v11    # "v":Landroid/view/View;
    invoke-virtual {p0, v11, v9}, Landroid/widget/SimpleAdapter;->setViewText(Landroid/widget/TextView;Ljava/lang/String;)V

    goto :goto_2

    .line 192
    .restart local v11    # "v":Landroid/view/View;
    :cond_a
    instance-of v12, v11, Landroid/widget/ImageView;

    if-eqz v12, :cond_d

    .line 193
    instance-of v12, v4, Ljava/lang/Integer;

    if-eqz v12, :cond_b

    .line 194
    check-cast v11, Landroid/widget/ImageView;

    .end local v11    # "v":Landroid/view/View;
    check-cast v4, Ljava/lang/Integer;

    .end local v4    # "data":Ljava/lang/Object;
    invoke-virtual {v4}, Ljava/lang/Integer;->intValue()I

    move-result v12

    invoke-virtual {p0, v11, v12}, Landroid/widget/SimpleAdapter;->setViewImage(Landroid/widget/ImageView;I)V

    goto :goto_2

    .line 197
    .restart local v4    # "data":Ljava/lang/Object;
    .restart local v11    # "v":Landroid/view/View;
    :cond_b
    instance-of v12, v4, Landroid/graphics/drawable/Drawable;

    if-eqz v12, :cond_c

    move-object v8, v11

    .line 199
    check-cast v8, Landroid/widget/ImageView;

    .line 200
    .local v8, "img":Landroid/widget/ImageView;
    check-cast v4, Landroid/graphics/drawable/Drawable;

    .end local v4    # "data":Ljava/lang/Object;
    invoke-virtual {v8, v4}, Landroid/widget/ImageView;->setImageDrawable(Landroid/graphics/drawable/Drawable;)V

    goto :goto_2

    .line 205
    .end local v8    # "img":Landroid/widget/ImageView;
    .restart local v4    # "data":Ljava/lang/Object;
    :cond_c
    check-cast v11, Landroid/widget/ImageView;

    .end local v11    # "v":Landroid/view/View;
    invoke-virtual {p0, v11, v9}, Landroid/widget/SimpleAdapter;->setViewImage(Landroid/widget/ImageView;Ljava/lang/String;)V

    goto :goto_2

    .line 208
    .restart local v11    # "v":Landroid/view/View;
    :cond_d
    new-instance v12, Ljava/lang/IllegalStateException;

    new-instance v13, Ljava/lang/StringBuilder;

    invoke-direct {v13}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v11}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v14

    invoke-virtual {v14}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v14

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    const-string v14, " is not a "

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    const-string v14, " view that can be bounds by this SimpleAdapter"

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v13

    invoke-direct {v12, v13}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v12
.end method

.method private createViewFromResource(ILandroid/view/View;Landroid/view/ViewGroup;I)Landroid/view/View;
    .locals 3
    .param p1, "position"    # I
    .param p2, "convertView"    # Landroid/view/View;
    .param p3, "parent"    # Landroid/view/ViewGroup;
    .param p4, "resource"    # I

    .prologue
    .line 124
    if-nez p2, :cond_0

    .line 125
    iget-object v1, p0, Landroid/widget/SimpleAdapter;->mInflater:Landroid/view/LayoutInflater;

    const/4 v2, 0x0

    invoke-virtual {v1, p4, p3, v2}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

    move-result-object v0

    .line 130
    .local v0, "v":Landroid/view/View;
    :goto_0
    invoke-direct {p0, p1, v0}, Landroid/widget/SimpleAdapter;->bindView(ILandroid/view/View;)V

    .line 132
    return-object v0

    .line 127
    .end local v0    # "v":Landroid/view/View;
    :cond_0
    move-object v0, p2

    .restart local v0    # "v":Landroid/view/View;
    goto :goto_0
.end method

# virtual methods
.method public getCount()I
    .locals 1

    .prologue
    .line 97
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mData:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    return v0
.end method

.method public getDropDownView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 1
    .param p1, "position"    # I
    .param p2, "convertView"    # Landroid/view/View;
    .param p3, "parent"    # Landroid/view/ViewGroup;

    .prologue
    .line 147
    iget v0, p0, Landroid/widget/SimpleAdapter;->mDropDownResource:I

    invoke-direct {p0, p1, p2, p3, v0}, Landroid/widget/SimpleAdapter;->createViewFromResource(ILandroid/view/View;Landroid/view/ViewGroup;I)Landroid/view/View;

    move-result-object v0

    return-object v0
.end method

.method public getFilter()Landroid/widget/Filter;
    .locals 2

    .prologue
    .line 294
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mFilter:Landroid/widget/SimpleAdapter$SimpleFilter;

    if-nez v0, :cond_0

    .line 295
    new-instance v0, Landroid/widget/SimpleAdapter$SimpleFilter;

    const/4 v1, 0x0

    invoke-direct {v0, p0, v1}, Landroid/widget/SimpleAdapter$SimpleFilter;-><init>(Landroid/widget/SimpleAdapter;Landroid/widget/SimpleAdapter$1;)V

    iput-object v0, p0, Landroid/widget/SimpleAdapter;->mFilter:Landroid/widget/SimpleAdapter$SimpleFilter;

    .line 297
    :cond_0
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mFilter:Landroid/widget/SimpleAdapter$SimpleFilter;

    return-object v0
.end method

.method public getItem(I)Ljava/lang/Object;
    .locals 1
    .param p1, "position"    # I

    .prologue
    .line 104
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mData:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->get(I)Ljava/lang/Object;

    move-result-object v0

    return-object v0
.end method

.method public getItemId(I)J
    .locals 2
    .param p1, "position"    # I

    .prologue
    .line 111
    int-to-long v0, p1

    return-wide v0
.end method

.method public getView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 1
    .param p1, "position"    # I
    .param p2, "convertView"    # Landroid/view/View;
    .param p3, "parent"    # Landroid/view/ViewGroup;

    .prologue
    .line 118
    iget v0, p0, Landroid/widget/SimpleAdapter;->mResource:I

    invoke-direct {p0, p1, p2, p3, v0}, Landroid/widget/SimpleAdapter;->createViewFromResource(ILandroid/view/View;Landroid/view/ViewGroup;I)Landroid/view/View;

    move-result-object v0

    return-object v0
.end method

.method public getViewBinder()Landroid/widget/SimpleAdapter$ViewBinder;
    .locals 1

    .prologue
    .line 224
    iget-object v0, p0, Landroid/widget/SimpleAdapter;->mViewBinder:Landroid/widget/SimpleAdapter$ViewBinder;

    return-object v0
.end method

.method public setDropDownViewResource(I)V
    .locals 0
    .param p1, "resource"    # I

    .prologue
    .line 142
    iput p1, p0, Landroid/widget/SimpleAdapter;->mDropDownResource:I

    .line 143
    return-void
.end method

.method public setViewBinder(Landroid/widget/SimpleAdapter$ViewBinder;)V
    .locals 0
    .param p1, "viewBinder"    # Landroid/widget/SimpleAdapter$ViewBinder;

    .prologue
    .line 236
    iput-object p1, p0, Landroid/widget/SimpleAdapter;->mViewBinder:Landroid/widget/SimpleAdapter$ViewBinder;

    .line 237
    return-void
.end method

.method public setViewImage(Landroid/widget/ImageView;I)V
    .locals 0
    .param p1, "v"    # Landroid/widget/ImageView;
    .param p2, "value"    # I

    .prologue
    .line 253
    invoke-virtual {p1, p2}, Landroid/widget/ImageView;->setImageResource(I)V

    .line 254
    return-void
.end method

.method public setViewImage(Landroid/widget/ImageView;Ljava/lang/String;)V
    .locals 2
    .param p1, "v"    # Landroid/widget/ImageView;
    .param p2, "value"    # Ljava/lang/String;

    .prologue
    .line 275
    :try_start_0
    invoke-static {p2}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I

    move-result v1

    invoke-virtual {p1, v1}, Landroid/widget/ImageView;->setImageResource(I)V
    :try_end_0
    .catch Ljava/lang/NumberFormatException; {:try_start_0 .. :try_end_0} :catch_0

    .line 279
    :goto_0
    return-void

    .line 276
    :catch_0
    move-exception v0

    .line 277
    .local v0, "nfe":Ljava/lang/NumberFormatException;
    invoke-static {p2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    invoke-virtual {p1, v1}, Landroid/widget/ImageView;->setImageURI(Landroid/net/Uri;)V

    goto :goto_0
.end method

.method public setViewText(Landroid/widget/TextView;Ljava/lang/String;)V
    .locals 0
    .param p1, "v"    # Landroid/widget/TextView;
    .param p2, "text"    # Ljava/lang/String;

    .prologue
    .line 290
    invoke-virtual {p1, p2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 291
    return-void
.end method


text:
#import "AbstractConfigurationManager.h"
#import "KaaLogging.h"

#define TAG @"AbstractConfigurationManager >>>"

@interface AbstractConfigurationManager ()

@property(nonatomic, strong) KaaClientProperties *properties;
@property(nonatomic, strong) id<KaaClientState> state;
@property(nonatomic, strong) id<ConfigurationStorage> storage;
@property(nonatomic, strong) NSData *configurationData;
@property(nonatomic, strong) id<ExecutorContext> executorContext;

@property(strong) NSMutableSet *delegates;
@property(strong) NSLock *delegatesLock;

- (NSData *)loadConfigurationData;

@end

@implementation AbstractConfigurationManager

- (instancetype)initWithClientProperties:(KaaClientProperties *)properties
                                   state:(id<KaaClientState>)state
                         executorContext:(id<ExecutorContext>)context {
    self = [super init];
    if (self) {
        self.delegates = [NSMutableSet set];
        self.properties = properties;
        self.state = state;
        _deserializer = [[ConfigurationDeserializer alloc] initWithExecutorContext:context];
        self.executorContext = context;
    }
    return self;
}

- (void)initiate {
    [self getConfigurationData];
    DDLogDebug(@"%@ Configuration manager init completed!", TAG);
}

- (void)addDelegate:(id<ConfigurationDelegate>)delegate {
    if (delegate) {
        DDLogVerbose(@"%@ Adding delegate %@", TAG, delegate);
        [self.delegatesLock lock];
        [self.delegates addObject:delegate];
        [self.delegatesLock unlock];
    } else {
        [NSException raise:NSInvalidArgumentException format:@"Can't add nil delegate"];
    }
}

- (void)removeDelegate:(id<ConfigurationDelegate>)delegate {
    if (delegate) {
        DDLogVerbose(@"%@ Removing delegate", TAG);
        [self.delegatesLock lock];
        [self.delegates removeObject:delegate];
        [self.delegatesLock unlock];
    } else {
        [NSException raise:NSInvalidArgumentException format:@"Can't remove nil delegate"];

    }
}

- (void)processConfigurationData:(NSData *)data fullResync:(BOOL)fullResync {
    if (fullResync) {
        self.configurationData = data;
        DDLogVerbose(@"%@ Received configuration data: %@", TAG, self.configurationData);
        if (self.storage) {
            DDLogDebug(@"%@ Persisting configuration data from storage: %@", TAG, self.storage);
            [self.storage saveConfiguration:self.configurationData];
            DDLogDebug(@"%@ Persisted configuration data from storage: %@", TAG, self.storage);
        }
        [self.delegatesLock lock];
        [_deserializer notifyDelegates:self.delegates withData:self.configurationData];
        [self.delegatesLock unlock];
    } else {
        DDLogWarn(@"%@ Only full resync delta is supported!", TAG);
    }
}

- (EndpointObjectHash *)getConfigurationHash {
    return [EndpointObjectHash hashWithSHA1:[self getConfigurationData]];
}

- (void)setConfigurationStorage:(id<ConfigurationStorage>)storage {
    self.storage = storage;
}

- (NSData *)loadConfigurationData {
    if (self.storage) {
        if ([self.state isConfigurationVersionUpdated]) {
            DDLogDebug(@"%@ Clearing old configuration data from storage: %@", TAG, self.storage);
            @try {
                [self.storage clearConfiguration];
            }
            @catch (NSException *exception) {
                DDLogError(@"%@ Failed to clear configuration from storage: %@", TAG, exception);
            }
        } else {
            DDLogDebug(@"%@ Loading configuration data from storage: %@", TAG, self.storage);
            @try {
                self.configurationData = [self.storage loadConfiguration];
            }
            @catch (NSException *exception) {
                DDLogError(@"%@ Failed to load configuration from storage: %@", TAG, exception);
            }
        }
    }
    if (!self.configurationData) {
        DDLogDebug(@"%@ Loading configuration data from defaults: %@", TAG, self.storage);
        self.configurationData = [self getDefaultConfigurationData];
    }
    DDLogVerbose(@"%@ Loaded configuration data: %@", TAG, self.configurationData);
    return self.configurationData;
}

- (NSData *)getConfigurationData {
    if (!self.configurationData) {
        self.configurationData = [self loadConfigurationData];
    }
    return self.configurationData;
}

- (NSData *)getDefaultConfigurationData {
    return [self.properties defaultConfigData];
}

@end


text:
package edu.berkeley.cs.amplab.adam.cli

import edu.berkeley.cs.amplab.adam.util.ParquetLogger
import edu.berkeley.cs.amplab.adam.rdd.AdamContext._
import org.kohsuke.args4j.Argument
import org.apache.hadoop.mapreduce.Job
import edu.berkeley.cs.amplab.adam.avro.ADAMRecord
import edu.berkeley.cs.amplab.adam.projections.{Projection, ADAMRecordField}
import java.util.logging.Level
import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD

object FlagStat extends AdamCommandCompanion {
  val commandName: String = "flagstat"
  val commandDescription: String = "Print statistics on reads in an ADAM file (similar to samtools flagstat)"

  def apply(cmdLine: Array[String]): AdamCommand = {
    new FlagStat(Args4j[FlagStatArgs](cmdLine))
  }
}

class FlagStatArgs extends Args4jBase with SparkArgs with ParquetArgs {
  @Argument(required = true, metaVar = "INPUT", usage = "The ADAM data to return stats for", index = 0)
  val inputPath: String = null
}

class FlagStat(protected val args: FlagStatArgs) extends AdamSparkCommand[FlagStatArgs] {
  val companion: AdamCommandCompanion = FlagStat

  def run(sc: SparkContext, job: Job): Unit = {
    // Quiet parquet logging...
    ParquetLogger.hadoopLoggerLevel(Level.SEVERE)

    val projection = Projection(
      ADAMRecordField.readMapped, ADAMRecordField.mateMapped, ADAMRecordField.readPaired,
      ADAMRecordField.referenceId, ADAMRecordField.mateReferenceId,
      ADAMRecordField.primaryAlignment,
      ADAMRecordField.duplicateRead, ADAMRecordField.readMapped, ADAMRecordField.mateMapped,
      ADAMRecordField.firstOfPair, ADAMRecordField.secondOfPair,
      ADAMRecordField.properPair, ADAMRecordField.mapq,
      ADAMRecordField.failedVendorQualityChecks)

    val adamFile: RDD[ADAMRecord] = sc.adamLoad(args.inputPath, projection = Some(projection))

    val (failedVendorQuality, passedVendorQuality) = adamFile.adamFlagStat()

    def percent(fraction: Long, total: Long) = if (total == 0) 0.0 else 100.00 * fraction.toFloat / total

    println( """
               |%d + %d in total (QC-passed reads + QC-failed reads)
               |%d + %d primary duplicates
               |%d + %d primary duplicates - both read and mate mapped
               |%d + %d primary duplicates - only read mapped
               |%d + %d primary duplicates - cross chromosome
               |%d + %d secondary duplicates
               |%d + %d secondary duplicates - both read and mate mapped
               |%d + %d secondary duplicates - only read mapped
               |%d + %d secondary duplicates - cross chromosome
               |%d + %d mapped (%.2f%%:%.2f%%)
               |%d + %d paired in sequencing
               |%d + %d read1
               |%d + %d read2
               |%d + %d properly paired (%.2f%%:%.2f%%)
               |%d + %d with itself and mate mapped
               |%d + %d singletons (%.2f%%:%.2f%%)
               |%d + %d with mate mapped to a different chr
               |%d + %d with mate mapped to a different chr (mapQ>=5)
             """.stripMargin('|').format(
        passedVendorQuality.total, failedVendorQuality.total,
        passedVendorQuality.duplicatesPrimary.total, failedVendorQuality.duplicatesPrimary.total,
        passedVendorQuality.duplicatesPrimary.bothMapped, failedVendorQuality.duplicatesPrimary.bothMapped,
        passedVendorQuality.duplicatesPrimary.onlyReadMapped, failedVendorQuality.duplicatesPrimary.onlyReadMapped,
        passedVendorQuality.duplicatesPrimary.crossChromosome, failedVendorQuality.duplicatesPrimary.crossChromosome,
        passedVendorQuality.duplicatesSecondary.total, failedVendorQuality.duplicatesSecondary.total,
        passedVendorQuality.duplicatesSecondary.bothMapped, failedVendorQuality.duplicatesSecondary.bothMapped,
        passedVendorQuality.duplicatesSecondary.onlyReadMapped, failedVendorQuality.duplicatesSecondary.onlyReadMapped,
        passedVendorQuality.duplicatesSecondary.crossChromosome, failedVendorQuality.duplicatesSecondary.crossChromosome,
        passedVendorQuality.mapped, failedVendorQuality.mapped,
        percent(passedVendorQuality.mapped, passedVendorQuality.total),
        percent(failedVendorQuality.mapped, failedVendorQuality.total),
        passedVendorQuality.pairedInSequencing, failedVendorQuality.pairedInSequencing,
        passedVendorQuality.read1, failedVendorQuality.read1,
        passedVendorQuality.read2, failedVendorQuality.read2,
        passedVendorQuality.properlyPaired, failedVendorQuality.properlyPaired,
        percent(passedVendorQuality.properlyPaired, passedVendorQuality.total),
        percent(failedVendorQuality.properlyPaired, failedVendorQuality.total),
        passedVendorQuality.withSelfAndMateMapped, failedVendorQuality.withSelfAndMateMapped,
        passedVendorQuality.singleton, failedVendorQuality.singleton,
        percent(passedVendorQuality.singleton, passedVendorQuality.total),
        percent(failedVendorQuality.singleton, failedVendorQuality.total),
        passedVendorQuality.withMateMappedToDiffChromosome, failedVendorQuality.withMateMappedToDiffChromosome,
        passedVendorQuality.withMateMappedToDiffChromosomeMapQ5, failedVendorQuality.withMateMappedToDiffChromosomeMapQ5))
  }

}


text:
#ifndef CAF_REPLIES_TO_HPP
#define CAF_REPLIES_TO_HPP

#include <string>

#include "caf/illegal_message_element.hpp"

#include "caf/detail/type_list.hpp"
#include "caf/detail/type_pair.hpp"
#include "caf/detail/type_traits.hpp"

namespace caf {

/// @cond PRIVATE
std::string replies_to_type_name(size_t input_size,
                                 const std::string* input,
                                 size_t output_opt1_size,
                                 const std::string* output_opt1);
/// @endcond

template <class...>
struct output_stream {};

template <class...>
struct output_tuple {};

template <class Input, class Output>
struct typed_mpi {};

/*
<detail::type_list<Is...>,
                 detail::type_list<Ls...>> {
  static_assert(sizeof...(Is) > 0, "template parameter pack Is empty");
  static_assert(sizeof...(Ls) > 0, "template parameter pack Ls empty");
  using input = detail::type_list<Is...>;
  using output = detail::type_list<Ls...>;
  static_assert(!detail::tl_exists<
                  input_types,
                  is_illegal_message_element
                >::value
                && !detail::tl_exists<
                  output_types,
                  is_illegal_message_element
                >::value,
                "interface definition contains an illegal message type");
};
*/

template <class... Is>
struct replies_to {
  template <class... Os>
  using with = typed_mpi<detail::type_list<Is...>, output_tuple<Os...>>;

  /// @private
  template <class... Os>
  using with_stream = typed_mpi<detail::type_list<Is...>, output_stream<Os...>>;
};

template <class... Is>
using reacts_to = typed_mpi<detail::type_list<Is...>, output_tuple<void>>;

} // namespace caf

#endif // CAF_REPLIES_TO_HPP


text:
package org.owasp.esapi;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Set;

import org.owasp.esapi.errors.EncryptionException;

/**
 * The {@code EncryptedProperties} interface represents a properties file
 * where all the data is encrypted before it is added, and decrypted when it
 * retrieved. This interface can be implemented in a number of ways, the
 * simplest being extending {@link java.util.Properties} and overloading
 * the {@code getProperty} and {@code setProperty} methods. In all cases,
 * the master encryption key, as given by the {@code Encryptor.MasterKey}
 * property in ESAPI.properties file.
 *
 * @author Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security
 * @since June 1, 2007
 */
public interface EncryptedProperties {

	/**
	 * Gets the property value from the encrypted store, decrypts it, and
	 * returns the plaintext value to the caller.
	 *
	 * @param key
	 *      the name of the property to get
	 *
	 * @return
	 * 	The decrypted property value. null if the key is not set.
	 *
	 * @throws EncryptionException
	 *      if the property could not be decrypted
	 */
	String getProperty(String key) throws EncryptionException;

	/**
	 * Encrypts the plaintext property value and stores the ciphertext value
	 * in the encrypted store.
	 *
	 * @param key
	 *      the name of the property to set
	 * @param value
	 * 		the value of the property to set
	 *
	 * @return
	 * 		the previously encrypted property value for the specified key, or
	 *      {@code null} if it did not have one.
	 *
	 * @throws EncryptionException
	 *      if the property could not be encrypted
	 */
	String setProperty(String key, String value) throws EncryptionException;

	/**
	 * Returns a {@code Set} view of properties. The {@code Set} is backed by a
	 * {@code java.util.Hashtable}, so changes to the {@code Hashtable} are
	 * reflected in the {@code Set}, and vice-versa. The {@code Set} supports element
	 * removal (which removes the corresponding entry from the {@code Hashtable),
	 * but not element addition.
	 *
	 * @return
	 * 		a set view of the properties contained in this map.
	 */
	public Set<?> keySet();

	/**
	 * Reads a property list (key and element pairs) from the input stream.
	 *
	 * @param in
	 * 		the input stream that contains the properties file
	 *
	 * @throws IOException
	 *      Signals that an I/O exception has occurred.
	 */
	public void load(InputStream in) throws IOException;

	/**
	 * Writes this property list (key and element pairs) in this Properties table to
	 * the output stream in a format suitable for loading into a Properties table using the load method.
	 *
	 * @param out
	 * 		the output stream that contains the properties file
	 * @param comments
	 *            a description of the property list (ex. "Encrypted Properties File").
	 *
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	public void store(OutputStream out, String comments) throws IOException;

}


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context="com.android2ee.recyclerview.ComplexActivity" >

    <Button android:id="@+id/myButtonComplexAdd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Add" />

	<android.support.v7.widget.RecyclerView
	    android:id="@+id/myListComplex"
	    android:scrollbars="vertical"
	    android:layout_width="match_parent"
	    android:layout_height="match_parent"/>

</LinearLayout>


text:
/*
 ONOS GUI -- Cluster Controller - Unit Tests
 */
describe('Controller: OvClusterCtrl', function () {

    var $scope, $controller, createController;

    beforeEach(module('ovCluster', 'onosRemote', 'onosLayer', 'onosSvg',
        'onosNav', 'ngRoute', 'onosWidget', 'onosMast'));

    beforeEach(inject(function ($rootScope, _$controller_) {
        $scope = $rootScope.$new();
        $controller = _$controller_;

        createController = function () {
            return $controller('OvClusterCtrl', {
                '$scope': $scope,
            });
        };
    }));

    it('should create controller', function () {
        var controller = createController();
    });

});


text:
using System.Linq;
using Cake.EntityFramework.Interfaces;
using Cake.EntityFramework.Migrator;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
using Cake.EntityFramework.Tests.Fixtures;

namespace Cake.EntityFramework.Tests.Migrator.SqlServer
{
    public class LocalMigrationFacts
    {
        private readonly ITestOutputHelper _logHelper;

        // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
        private readonly ILogger _mockLogger;

        private readonly IEfMigrator _migrator;

        public LocalMigrationFacts(ITestOutputHelper logHelper)//, SqlServerFixture sqlServerFixture)
        {
            _logHelper = logHelper;
            _mockLogger = new MockLogger(logHelper);
            _migrator = new EfMigrator(SqlServerFactConstants.DdlPath, SqlServerFactConstants.ConfigName, SqlServerFactConstants.AppConfig,
                SqlServerFactConstants.InstanceConnectionString, SqlServerFactConstants.ConnectionProvider, _mockLogger, false);
        }

        [Fact]
        public void When_migrations_exist_locally_return_list()
        {
            var migrations = _migrator.GetLocalMigrations()
                                      .ToList();

            foreach (var migration in migrations)
            {
                _logHelper.WriteLine(migration);
            }

            migrations.Should().HaveCount(8);
        }

        [Fact]
        public void Local_migrations_should_be_in_ascending_order()
        {
            var migrations = _migrator.GetLocalMigrations()
                                      .ToList();

            foreach (var migration in migrations)
            {
                _logHelper.WriteLine(migration);
            }

            migrations.Should().BeInAscendingOrder();
        }

        [Fact]
        public void Latest_migration_should_be_latest_local()
        {
            var localMigrations = _migrator.GetLocalMigrations().ToList();

            // Act
            var result = _migrator.GetLatestMigration();

            // Assert
            result.Should().Be(localMigrations.Last());
        }

        [Fact]
        public void When_pending_migrations_exist_has_pening_should_be_true()
        {
            // Act
            var result = _migrator.HasPendingMigrations();

            // Assert
            result.Should().BeTrue();
        }
    }
}


text:
package org.jetbrains.plugins.scala.base.libraryLoaders

import java.io.File

import com.intellij.openapi.module.Module
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.{LocalFileSystem, VirtualFile}
import com.intellij.testFramework.PsiTestUtil
import org.jetbrains.plugins.scala.debugger.ScalaVersion

/**
  * @author adkozlov
  */
case class SourcesLoader(rootPath: String) extends LibraryLoader {

  override def init(implicit module: Module, version: ScalaVersion): Unit = {
    FileUtil.createIfDoesntExist(new File(rootPath))
    PsiTestUtil.addSourceRoot(module, rootFile)
  }

  override def clean(implicit module: Module): Unit = {
    PsiTestUtil.removeSourceRoot(module, rootFile)
  }

  private def rootFile: VirtualFile =
    LocalFileSystem.getInstance.refreshAndFindFileByPath(rootPath)
}


text:
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.HashMap;

class Solution
{
	public static void main(String ... ags)throws IOException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		HashMap<String,String> hm = new HashMap<String,String>();
		for(int i=0;i<n;i++)
		{
			String name = in.readLine();
			String num = in.readLine();
			hm.put(name,num);
		}
		String str;
		while((str=in.readLine())!=null)
		{
			if(hm.get(str)==null)
				System.out.println("Not found");
			else
				System.out.println(str+"="+hm.get(str));
		}
	}
}


text:
package apavlov.nonblock;

import org.junit.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

/**
 * The test class NonBlockingCacheTest for class`s NonBlockingCache use junit4.
 *
 * @author Pavlov Artem
 * @since 26.12.2017
 */
public class NonBlockingCacheTest {
    /**
     * The method for check work add new element by key and value to collection.
     *
     * @throws Exception - check any errors;
     */
    @Test
    public void whenAddElementsToCollections() throws Exception {
        NonBlockingCache<Integer, Model> base = new NonBlockingCache<>();

        assertThat(base.add(1, new Model("1")), is(true));
        assertThat(base.add(1, new Model("2")), is(false));
        assertThat(base.add(2, new Model("2")), is(true));

        assertThat(base.size(), is(2));
    }

    /**
     * The method for check work delete element by key to collection.
     *
     * @throws Exception - check any errors;
     */
    @Test
    public void whenDeleteElementsToCollections() throws Exception {
        NonBlockingCache<Integer, Model> base = new NonBlockingCache<>();

        base.add(1, new Model("1"));
        base.add(2, new Model("2"));
        base.add(3, new Model("3"));

        assertThat(base.delete(1), is(true));
        assertThat(base.delete(2), is(true));
        assertThat(base.delete(4), is(false));

        assertThat(base.size(), is(1));
    }

    /**
     * The method for check correct work method`s update.
     *
     * @throws Exception - check any errors;
     */
    @Test
    public void whenCorrectUpdateElementToCollections() throws Exception {
        NonBlockingCache<Integer, Model> base = new NonBlockingCache<>();
        Model first = new Model("first");
        Model middle = new Model("middle");
        Model last = new Model("last");
        base.add(1, first);
        base.add(2, middle);
        base.add(3, last);
        Model[] result = new Model[]{first, middle, last};

        middle.setName("second");
        base.update(2, middle);

        assertThat(base.size(), is(3));
        assertThat(base.toArray(new Model[0]), is(result));
    }

    /**
     * The method for check un correct work method`s update.
     *
     * @throws Exception - check any errors;
     */
    @Test (expected = OptimisticException.class)
    public void whenUnCorrectUpdateElementToCollections() throws Exception {
        NonBlockingCache<Integer, Model> base = new NonBlockingCache<>();
        Model first = new Model("first");
        base.add(1, first);
        base.update(1, new Model("first"));
    }
}


text:
#include <stdlib.h>

/**

From https://ravenspoint.wordpress.com/2010/05/30/world-wide-characters/

Conversion between UTF-8 and UTF-16 strings.

UTF-8 is used by web pages.  It is a variable byte length encoding
of UNICODE characters which is independant of the byte order in a computer word.

UTF-16 is the native Windows UNICODE encoding.

The class stores two copies of the string, one in each encoding,
so should only exist briefly while conversion is done.

This is a wrapper for the WideCharToMultiByte and MultiByteToWideChar
*/
class cUTF
{
	wchar_t * myString16;       ///&lt; string in UTF-16
	char * myString8;           ///&lt; string in UTF-6

public:
	/// Construct from UTF-16
	cUTF(const wchar_t * ws);
	///  Construct from UTF8
	cUTF(const char * s);
	/// get UTF16 version
	const wchar_t * get16() { return myString16; }
	/// get UTF8 version
	const char * get8() { return myString8; }
	/// free buffers
	~cUTF() { free(myString8); free(myString16); }
};


text:
package org.lwjgl.vulkan;

/**
 * Extends the set of sampler address modes to include an additional mode ({@link #VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE}) that effectively uses a texture map
 * twice as large as the original image in which the additional half of the new image is a mirror image of the original image.
 *
 *
This new mode relaxes the need to generate images whose opposite edges match by using the original image to generate a matching "mirror image". This
 * mode allows the texture to be mirrored only once in the negative s, t, and r directions.

 */
public final class KHRSamplerMirrorClampToEdge {

	/** The extension specification version. */
	public static final int VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION = 1;

	/** The extension name. */
	public static final String VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME = "VK_KHR_sampler_mirror_clamp_to_edge";

	/** Indicates that the mirror clamp to edge wrap mode will be used. */
	public static final int VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE = 4;

	private KHRSamplerMirrorClampToEdge() {}

}


text:
This document is for those people who are relatively new to GitHub but know the basic concepts like repositories and commits etc. For experts this document can act as a revision document.

**Happy learning!!**

### Commands
  1. Creating a repository: `git init`

You need to be in the repository that is to be initialised as the git repository

  2. Checking status: `git status`

Command gives the current status of the the repository irrestective of file being commited or not. Status includes whether file is 'tracked' or 'untracked' or 'modified' etc.

  3. Adding file:

		`git add <file_to_add>`	Adds the specified file to staging area

		`git add .`	Adds all untracked files to staging area

		`git add *.<extension>`	Adds all files with the specified extension

**Adding is only done to the staging area and not to the final commit straight away!!**

  4. Making a commit: `git commit`

Command redirects to an editor where you have to specify some description regarding the commit. This commits the files that were present in the staging area only!!

  5. Unstaging a file: `git rm --commit<file_name>`

Removes the file from the staging area  and transfers it back to the modification area.

  6. Changed files:

		`git diff`	Command shows the changes made to the files. Command works only when the file is in the unstaged area.

		For staged files: `git diff --staged`

  7. Pushing to remote repo:

		`git remote add origin <url to the remote repo>`

		`git push -u origin <branch to which pushin is to be done>`

  8. Pulling from your own remote repo to a locally existing repo

		`git pull <url of remote repo> <branch>`

To pull into a local repo the command prompt control needs to be inside the repo


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using BookShopDAL;
using Model;

namespace BookShopBLL
{
    public class UserManagerBLL
    {
        UserManagerDAL dal = new UserManagerDAL();
        /// <summary>
        /// Get User Manager Info By Name
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public UserManager GetUserManagerByUserName(string userName)
        {
            return dal.GetUserManagerByUserName(userName);
        }
    }
}


text:
Settings Page {{tokenid}}

Vehicle

Route

Profile

Logout

<form class='form' ng-submit="saveVehicle()">

Add vehicle

	<input class='form-control' placeholder="Vehicle Name" ng-model="vehicle.name" required>
	<button class="btn btn-large btn-primary" type="submit">Save</button>
</form>

				name
				delete

				{{vehicle.name}}
				<a class='btn btn-primary' ng-click='deleteVehicle(vehicle, $index)' ng-class='{disabled: index < 0}'>Delete


text:
% names & full names
\newcommand{\fsc}{F.\ Scala\xspace}
\newcommand{\fscf}{Fabio Scala\xspace}

\newcommand{\rli}{R.\ Liebi\xspace}
\newcommand{\rlif}{Remo Liebi\xspace}

\newcommand{\chu}{C.\ Hüsler\xspace}
\newcommand{\chuf}{Christoph Hüsler\xspace}

\newcommand{\proff}{Prof.\ Stefan Keller\xspace}
\newcommand{\prof}{Prof.\ S.\ Keller\xspace}

\newcommand{\mstolze}{Prof.\ M.\ Stolze\xspace}

% \mytable{cols}{content}{caption}{lbl}
\newcommand{\mytable}[4]{
	\begin{table}[H]
		\centering
		\begin{tabularx}{\textwidth}{#1}
			\toprule
			#2
			\bottomrule
		\end{tabularx}
		\caption{#3}
\label{tab:#4}
	\end{table}
}

% uses todonotes
\newcommand{\xxx}[1][]{
	\ifthenelse{\equal{#1}{}}{\todo[inline]{TODO}}{\todo[inline]{TODO:\ #1}}
}

% pretty url without http://
\newcommand{\purl}[1]{%
	\href{#1}{\StrBehind{#1}{http://}}%
}
\newcommand{\shellcmd}[1]{\\\indent\indent\texttt{\footnotesize\# #1}\\}

\newcommand*{\zeroOfThree}{\FiveStar\FiveStar\FiveStarOpen}
\newcommand*{\oneOfThree}{\FiveStar\FiveStarOpen\FiveStarOpen}
\newcommand*{\twoOfThree}{\FiveStar\FiveStar\FiveStarOpen}
\newcommand*{\threeOfThree}{\FiveStar\FiveStar\FiveStar}

\newcommand*\cleartoleftpage{%
  \clearpage
  \ifodd\value{page}\hbox{}\newpage\fi
}


text:
dojo.provide("dojo.dnd.Sortable");
dojo.require("dojo.dnd.*");

dojo.dnd.Sortable = function () {}

dojo.lang.extend(dojo.dnd.Sortable, {

	ondragstart: function (e) {
		var dragObject = e.target;
		while (dragObject.parentNode && dragObject.parentNode != this) {
			dragObject = dragObject.parentNode;
		}
		// TODO: should apply HtmlDropTarget interface to self
		// TODO: should apply HtmlDragObject interface?
		return dragObject;
	}

});


text:
package ro.androidiasi.codecamp.data.source.remote;

/**
 * Created by andrei on 21/04/16.
 */

import android.content.Context;
import android.support.annotation.NonNull;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import ro.androidiasi.codecamp.data.source.DataConference;
import ro.androidiasi.codecamp.data.source.ILoadCallback;
import ro.androidiasi.codecamp.data.source.remote.exception.DataUnavailable;

/**
 * Used to have some data available when the app starts
 * The idea is to have the user engaged in the app,
 * not waiting for the data to be fetched,
 * and in background we refresh the data
 */
@EBean
public class FileRemoteDataSource extends BaseRemoteDataSource{

    @RootContext Context mContext;

    @Override public void startCodecampJsonRequest() throws DataUnavailable {
        super.startCodecampJsonRequest();
        try {
            String file = mConference.getDataJsonFile();
            String json = retrieveStringFromFile(file);
            this.onSuccess(json);
        } catch (IOException ex) {
            this.onFailure(ex);
        }
    }

    @Override
    public void startConferencesRequest(ILoadCallback<List<DataConference>> pLoadCallback) throws DataUnavailable {
        try {
            String file = DataConference.CONFERENCES_LIST_LOCAL_FILE;
            String json = retrieveStringFromFile(file);
            pLoadCallback.onSuccess(getDataConferencesFromJson(json));
        } catch (IOException ex) {
            this.onFailure(ex);
        }
    }

    @NonNull private String retrieveStringFromFile(String file) throws IOException {
        String json;
        InputStream is = mContext.getAssets().open(file);
        int size = is.available();
        byte[] buffer = new byte[size];
        is.read(buffer);
        is.close();
        json = new String(buffer, "UTF-8");
        return json;
    }

    public void invalidate() {

    }
}