text:
@implementation OrgApacheLuceneUtilPackedDirect32

- (instancetype)initPackagePrivateWithInt:(jint)valueCount {
  OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_(self, valueCount);
  return self;
}

- (instancetype)initPackagePrivateWithInt:(jint)packedIntsVersion
        withOrgApacheLuceneStoreDataInput:(OrgApacheLuceneStoreDataInput *)inArg
                                  withInt:(jint)valueCount {
  OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_withOrgApacheLuceneStoreDataInput_withInt_(self, packedIntsVersion, inArg, valueCount);
  return self;
}

- (jlong)getWithInt:(jint)index {
  return IOSIntArray_Get(nil_chk(values_), index) & (jlong) 0xFFFFFFFFLL;
}

- (void)setWithInt:(jint)index
          withLong:(jlong)value {
  *IOSIntArray_GetRef(nil_chk(values_), index) = (jint) (value);
}

- (jlong)ramBytesUsed {
  return OrgApacheLuceneUtilRamUsageEstimator_alignObjectSizeWithLong_(JreLoadStatic(OrgApacheLuceneUtilRamUsageEstimator, NUM_BYTES_OBJECT_HEADER) + 2 * OrgApacheLuceneUtilRamUsageEstimator_NUM_BYTES_INT + JreLoadStatic(OrgApacheLuceneUtilRamUsageEstimator, NUM_BYTES_OBJECT_REF)) + OrgApacheLuceneUtilRamUsageEstimator_sizeOfWithIntArray_(values_);
}

- (void)clear {
  JavaUtilArrays_fillWithIntArray_withInt_(values_, (jint) 0LL);
}

- (jint)getWithInt:(jint)index
     withLongArray:(IOSLongArray *)arr
           withInt:(jint)off
           withInt:(jint)len {
  JreAssert(len > 0, JreStrcat("$IC", @"len must be > 0 (got ", len, ')'));
  JreAssert(index >= 0 && index < valueCount_, @"org/apache/lucene/util/packed/Direct32.java:79 condition failed: assert index >= 0 && index < valueCount;");
  JreAssert(off + len <= ((IOSLongArray *) nil_chk(arr))->size_, @"org/apache/lucene/util/packed/Direct32.java:80 condition failed: assert off + len <= arr.length;");
  jint gets = JavaLangMath_minWithInt_withInt_(valueCount_ - index, len);
  for (jint i = index, o = off, end = index + gets; i < end; ++i, ++o) {
    *IOSLongArray_GetRef(arr, o) = IOSIntArray_Get(nil_chk(values_), i) & (jlong) 0xFFFFFFFFLL;
  }
  return gets;
}

- (jint)setWithInt:(jint)index
     withLongArray:(IOSLongArray *)arr
           withInt:(jint)off
           withInt:(jint)len {
  JreAssert(len > 0, JreStrcat("$IC", @"len must be > 0 (got ", len, ')'));
  JreAssert(index >= 0 && index < valueCount_, @"org/apache/lucene/util/packed/Direct32.java:92 condition failed: assert index >= 0 && index < valueCount;");
  JreAssert(off + len <= ((IOSLongArray *) nil_chk(arr))->size_, @"org/apache/lucene/util/packed/Direct32.java:93 condition failed: assert off + len <= arr.length;");
  jint sets = JavaLangMath_minWithInt_withInt_(valueCount_ - index, len);
  for (jint i = index, o = off, end = index + sets; i < end; ++i, ++o) {
    *IOSIntArray_GetRef(nil_chk(values_), i) = (jint) IOSLongArray_Get(arr, o);
  }
  return sets;
}

- (void)fillWithInt:(jint)fromIndex
            withInt:(jint)toIndex
           withLong:(jlong)val {
  JreAssert(val == (val & (jlong) 0xFFFFFFFFLL), @"org/apache/lucene/util/packed/Direct32.java:104 condition failed: assert val == (val & 0xFFFFFFFFL);");
  JavaUtilArrays_fillWithIntArray_withInt_withInt_withInt_(values_, fromIndex, toIndex, (jint) val);
}

- (void)dealloc {
  RELEASE_(values_);
  [super dealloc];
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x0, -1, 0, -1, -1, -1, -1 },
    { NULL, NULL, 0x0, -1, 1, 2, -1, -1, -1 },
    { NULL, "J", 0x1, 3, 0, -1, -1, -1, -1 },
    { NULL, "V", 0x1, 4, 5, -1, -1, -1, -1 },
    { NULL, "J", 0x1, -1, -1, -1, -1, -1, -1 },
    { NULL, "V", 0x1, -1, -1, -1, -1, -1, -1 },
    { NULL, "I", 0x1, 3, 6, -1, -1, -1, -1 },
    { NULL, "I", 0x1, 4, 6, -1, -1, -1, -1 },
    { NULL, "V", 0x1, 7, 8, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(initPackagePrivateWithInt:);
  methods[1].selector = @selector(initPackagePrivateWithInt:withOrgApacheLuceneStoreDataInput:withInt:);
  methods[2].selector = @selector(getWithInt:);
  methods[3].selector = @selector(setWithInt:withLong:);
  methods[4].selector = @selector(ramBytesUsed);
  methods[5].selector = @selector(clear);
  methods[6].selector = @selector(getWithInt:withLongArray:withInt:withInt:);
  methods[7].selector = @selector(setWithInt:withLongArray:withInt:withInt:);
  methods[8].selector = @selector(fillWithInt:withInt:withLong:);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "values_", "[I", .constantValue.asLong = 0, 0x10, -1, -1, -1, -1 },
  };
  static const void *ptrTable[] = { "I", "ILOrgApacheLuceneStoreDataInput;I", "LJavaIoIOException;", "get", "set", "IJ", "I[JII", "fill", "IIJ" };
  static const J2ObjcClassInfo _OrgApacheLuceneUtilPackedDirect32 = { "Direct32", "org.apache.lucene.util.packed", ptrTable, methods, fields, 7, 0x10, 9, 1, -1, -1, -1, -1, -1 };
  return &_OrgApacheLuceneUtilPackedDirect32;
}

@end

void OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_(OrgApacheLuceneUtilPackedDirect32 *self, jint valueCount) {
  OrgApacheLuceneUtilPackedPackedInts_MutableImpl_initWithInt_withInt_(self, valueCount, 32);
  JreStrongAssignAndConsume(&self->values_, [IOSIntArray newArrayWithLength:valueCount]);
}

OrgApacheLuceneUtilPackedDirect32 *new_OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_(jint valueCount) {
  J2OBJC_NEW_IMPL(OrgApacheLuceneUtilPackedDirect32, initPackagePrivateWithInt_, valueCount)
}

OrgApacheLuceneUtilPackedDirect32 *create_OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_(jint valueCount) {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneUtilPackedDirect32, initPackagePrivateWithInt_, valueCount)
}

void OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_withOrgApacheLuceneStoreDataInput_withInt_(OrgApacheLuceneUtilPackedDirect32 *self, jint packedIntsVersion, OrgApacheLuceneStoreDataInput *inArg, jint valueCount) {
  OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_(self, valueCount);
  for (jint i = 0; i < valueCount; ++i) {
    *IOSIntArray_GetRef(nil_chk(self->values_), i) = [((OrgApacheLuceneStoreDataInput *) nil_chk(inArg)) readInt];
  }
  jint remaining = (jint) ([((OrgApacheLuceneUtilPackedPackedInts_Format *) nil_chk(JreLoadEnum(OrgApacheLuceneUtilPackedPackedInts_Format, PACKED))) byteCountWithInt:packedIntsVersion withInt:valueCount withInt:32] - 4LL * valueCount);
  for (jint i = 0; i < remaining; ++i) {
    [((OrgApacheLuceneStoreDataInput *) nil_chk(inArg)) readByte];
  }
}

OrgApacheLuceneUtilPackedDirect32 *new_OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_withOrgApacheLuceneStoreDataInput_withInt_(jint packedIntsVersion, OrgApacheLuceneStoreDataInput *inArg, jint valueCount) {
  J2OBJC_NEW_IMPL(OrgApacheLuceneUtilPackedDirect32, initPackagePrivateWithInt_withOrgApacheLuceneStoreDataInput_withInt_, packedIntsVersion, inArg, valueCount)
}

OrgApacheLuceneUtilPackedDirect32 *create_OrgApacheLuceneUtilPackedDirect32_initPackagePrivateWithInt_withOrgApacheLuceneStoreDataInput_withInt_(jint packedIntsVersion, OrgApacheLuceneStoreDataInput *inArg, jint valueCount) {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneUtilPackedDirect32, initPackagePrivateWithInt_withOrgApacheLuceneStoreDataInput_withInt_, packedIntsVersion, inArg, valueCount)
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneUtilPackedDirect32)


text:
$(function () {

    $('.ui.dropdown:not(.native):not(.special)[multiple]').dropdown({
        fullTextSearch: true,
        duration: 100
    });

    $('.ui.dropdown:not(.native):not(.special):not([multiple]):not(.clearable)').dropdown({
        fullTextSearch: true,
        duration: 100
    });

    $('.ui.dropdown:not(.native):not(.special):not([multiple]).clearable').dropdown({
        clearable: true,
        fullTextSearch: true,
        duration: 100
    });

    $('body').on('click', '.message .close', function() {

        $(this)
          .closest('.message')
          .transition('fade')
        ;
    });

    $('.ui.accordion')
      .accordion()
    ;

    $('.popover').popup({ 'on': Modernizr.touch ? 'click' : 'hover' });

    // Initialize main menu features.

    $('.main_navigation_wrapper').visibility({
        type: 'fixed'
    });

    $('.main_navigation_wrapper:not(:first-of-type) [id]').removeAttr('id');

    $('.main_navigation_wrapper:first-of-type').headroom({
        offset : 50,
        tolerance : 5
    });

    function show_mobile_menu() {

        //
        $('html, body').animate({
            scrollTop: 0
        }, 100);
        //

        var menu = $('#main_navigation .ui.vertical.menu');

        $('#main_navigation .extra').hide();

        menu.transition({
            animation: 'slide down',
            onComplete : function() {

                menu.css('display', 'block');
                $('#main_navigation .menu.toggle i').addClass('close').removeClass('content');
            }
        });
    }

    function hide_mobile_menu() {

        //
        $('html, body').animate({
            scrollTop: 0
        }, 100);
        //

        var menu = $('#main_navigation .ui.vertical.menu');

        menu.transition({
            animation: 'slide down',
            onComplete : function() {

                menu.css('display', 'none');
                $('#main_navigation .menu.toggle i').addClass('content').removeClass('close');
            }
        });
    }

    function toggle_mobile_menu() {

        var menu = $('#main_navigation .ui.vertical.menu');

        if (menu.hasClass('hidden')) {
            show_mobile_menu();
        } else {
            hide_mobile_menu();
        }
    }

    $('#main_navigation .menu.toggle').on('click', function(e) {

        e.preventDefault();
        toggle_mobile_menu();
    });

});

/*
 * See http://appglobe.com/scroll-to-top-animation/
 */

(function($) {

    addScrollTopAnimation();

    function addScrollTopAnimation() {

        var $scrolltop_link = $('.ui.button.scroll.top');

        $scrolltop_link.on( 'click' ,  function ( ev ) {

            ev.preventDefault();

            $( 'html, body' ).animate( {

                scrollTop: 0

            }, 700 );

        })

        // Hides the link initially
        .data('hidden', 1).hide();

        var scroll_event_fired = false;

        $(window).on('scroll', function() {

            scroll_event_fired = true;

        });

        /*
        Checks every 300 ms if a scroll event has been fired.
        */
        setInterval( function() {

            if( scroll_event_fired ) {

                // Main menu shadow.
                if ($(this).scrollTop() > 2) {
                    $('#main_navigation .main_navigation_wrapper').addClass('with-shadow');
                } else {
                    $('#main_navigation .main_navigation_wrapper').removeClass('with-shadow');
                }

                /*
                Stop code below from being executed until the next scroll event.
                */
                scroll_event_fired = false;

                var is_hidden =  $scrolltop_link.data('hidden');

                /*
                Display the scroll top link when the page is scrolled
                down the height of half a viewport from top,  Hide it otherwise.
                */
                if ( $( this ).scrollTop()  >  $( this ).height() / 2 ) {

                    if( is_hidden ) {

                        $scrolltop_link.fadeIn(600).data('hidden', 0);

                    }
                }

                else {

                    if( !is_hidden ) {

                        $scrolltop_link.fadeOut(600).data('hidden', 1);

                    }
                }

            }

        }, 300);

    }

})(jQuery);

redpajama_set_name: RedPajamaGithub


text:
package com.speajus.llama.service;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.expression.BeanFactoryResolver;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.web.client.RestTemplate;

import com.speajus.llama.core.LlamaQualifier;
import com.speajus.llama.http.HttpPublisher;
@Configuration
public class HttpContext {

	@Autowired(required = false)
	CloseableHttpClient httpClient;

	@Bean
	ExpressionParser parser() {
		return new SpelExpressionParser();
	}

	@Bean
	@Autowired
	BeanFactoryResolver beanFactoryResolver(ApplicationContext ctx) {
		return new BeanFactoryResolver(ctx);
	}

	@Bean
	RestTemplate restTemplate() {
		return new RestTemplate();
	}

	@LlamaQualifier
	@Bean
	CloseableHttpClient httpClient() {
		if (httpClient != null) {
			return httpClient;
		}
		return (httpClient = HttpClients.createDefault());
	};

	@Bean
	HttpPublisher httpPublisher() {
		return new HttpPublisher();
	}
}


text:
package org.olat.core.gui.util.bandwidth;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Description:<br>
 * inspired from http://jakarta.apache.org/jmeter for the licence see: http://www.apache.org/licenses/LICENSE-2.0
 */

public class SlowOutputStream extends FilterOutputStream {

	private CPSPauser pauser;

	/**
	 * Create wrapped Output Stream toe emulate the requested CPS.
	 *
	 * @param out OutputStream
	 */
	public SlowOutputStream(OutputStream out, CPSPauser pauser) {
		super(out);
		this.pauser = pauser;
	}

	// Also handles write(byte[])
	@Override
	public void write(byte[] b, int off, int len) throws IOException {
		// pauser.pause(len);
		// out.write(b, off, len);

		if (pauser.isOff()) {
			// unlimited, do not flush inbetween
			out.write(b, off, len);
		} else {
			// distribute answer more steadily
			int blocksize = 2048;
			// b[off] is the first byte written and b[off+len-1] is the last byte written by this operation
			for (int i = off; i < len + off; i++) {
				out.write(b[i]);
				if ((i % blocksize) == 0) {
					pauser.pause(blocksize);
					out.flush();
					// System.out.println("flushing "+blocksize+ " bytes");
				}
			}
			System.out.println("sent " + len + " bytes");
		}

	}

	@Override
	public void write(int b) throws IOException {
		pauser.pause(1);
		out.write(b);
	}
}


text:
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using Intacct.SDK.Exceptions;
using Intacct.SDK.Functions.Common.NewQuery.QueryFilter;
using Intacct.SDK.Xml;
using Xunit;

namespace Intacct.SDK.Tests.Functions.Common.NewQuery.QueryFilter
{
    public class OrOperatorTest
    {
        [Fact]
        public void DefaultParamsTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>" +
"<or>" +
    "<lessthanorequalto>" +
        "<field>RECORDNO</field>" +
        "<value>1</value>" +
    "</lessthanorequalto>" +
    "<equalto>" +
        "<field>RECORDNO</field>" +
        "<value>100</value>" +
    "</equalto>" +
    "<equalto>" +
        "<field>RECORDNO</field>" +
        "<value>1000</value>" +
    "</equalto>" +
    "<equalto>" +
        "<field>RECORDNO</field>" +
        "<value>10000</value>" +
    "</equalto>" +
"</or>";

            Stream stream = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            List<IFilter> filters = new List<IFilter>();
            filters.Add((new Filter("RECORDNO")).SetLessThanOrEqualTo("1"));
            filters.Add((new Filter("RECORDNO")).SetEqualTo("100"));
            filters.Add((new Filter("RECORDNO")).SetEqualTo("1000"));
            filters.Add((new Filter("RECORDNO")).SetEqualTo("10000"));
            IFilter orFilter = new OrOperator(filters);
            orFilter.WriteXml(ref xml);

            xml.Flush();

            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Assert.Equal(expected, reader.ReadToEnd());
        }

        [Fact]
        public void SingleFilterTest()
        {
            Stream stream = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            List<IFilter> filters = new List<IFilter>();
            filters.Add((new Filter("RECORDNO")).SetGreaterThanOrEqualTo("1"));
            IFilter orFilter = new OrOperator(filters);

            var ex = Record.Exception(() => orFilter.WriteXml(ref xml));
            Assert.IsType<IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for or", ex.Message);
        }

        [Fact]
        public void EmptyFilterTest()
        {
            Stream stream = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            List<IFilter> filters = new List<IFilter>();

            IFilter orFilter = new OrOperator(filters);

            var ex = Record.Exception(() => orFilter.WriteXml(ref xml));
            Assert.IsType<IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for or", ex.Message);
        }

        [Fact]
        public void NullFilterTest()
        {
            Stream stream = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            IFilter orFilter = new OrOperator(null);

            var ex = Record.Exception(() => orFilter.WriteXml(ref xml));
            Assert.IsType<IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for or", ex.Message);
        }

        [Fact]
        public void AddFilterTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>" +
"<or>" +
    "<lessthanorequalto>" +
        "<field>RECORDNO</field>" +
        "<value>1</value>" +
    "</lessthanorequalto>" +
    "<equalto>" +
        "<field>RECORDNO</field>" +
        "<value>100</value>" +
    "</equalto>" +
    "<equalto>" +
        "<field>RECORDNO</field>" +
        "<value>1000</value>" +
    "</equalto>" +
    "<equalto>" +
        "<field>RECORDNO</field>" +
        "<value>10000</value>" +
    "</equalto>" +
"</or>";

            Stream stream = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            OrOperator orFilter = new OrOperator(null);
            orFilter.AddFilter((new Filter("RECORDNO")).SetLessThanOrEqualTo("1"));
            orFilter.AddFilter((new Filter("RECORDNO")).SetEqualTo("100"));
            orFilter.AddFilter((new Filter("RECORDNO")).SetEqualTo("1000"));
            orFilter.AddFilter((new Filter("RECORDNO")).SetEqualTo("10000"));
            orFilter.WriteXml(ref xml);

            xml.Flush();

            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            Assert.Equal(expected, reader.ReadToEnd());
        }

        [Fact]
        public void AddNullFilterTest()
        {
            Stream stream = new MemoryStream();
            XmlWriterSettings xmlSettings = new XmlWriterSettings
            {
                Encoding = Encoding.GetEncoding("UTF-8")
            };

            IaXmlWriter xml = new IaXmlWriter(stream, xmlSettings);

            OrOperator orFilter = new OrOperator(null);
            orFilter.AddFilter(null);

            var ex = Record.Exception(() => orFilter.WriteXml(ref xml));
            Assert.IsType<IntacctException>(ex);
            Assert.Equal("Two or more IFilter objects required for or", ex.Message);
        }
    }
}


text:
import { JMap } from "./JMap";
import { MapEntry } from "./MapEntry";
/**
 * A Map that further provides a total ordering on its keys. The map is ordered according to a Comparator provided at sorted map creation time.
 * This order is reflected when iterating over the navigable map's collection views (returned by the entrySet and keySet).
 * Several additional operations are provided to take advantage of the ordering. (This interface is the map analogue of NavigableSet.)
 *
 * Note that the ordering maintained by a navigable map must be consistent with equals if the navigable map is to correctly implement the Map interface.
 * (See the Comparator interface for a precise definition of consistent with equals.)
 * This is so because the Map interface is defined in terms of the equals operation,
 * but a navigable map performs all key comparisons using its Comparator so two keys that are deemed equal by this method are,
 * from the standpoint of the navigable map, equal.
 * The behavior of an implementing map is well-defined even if its ordering is inconsistent with equals;
 * it just fails to obey the general contract of the Map interface.
 *
 * Methods lowerEntry, floorEntry, ceilingEntry, and higherEntry return MapEntry objects associated with keys respectively less than,
 * less than or equal, greater than or equal, and greater than a given key, returning null if there is no such key.

 * Similarly, methods lowerKey, floorKey, ceilingKey, and higherKey return only the associated keys.
 * All of these methods are designed for locating, not traversing entries.

 * This interface additionally defines methods firstEntry, pollFirstEntry, lastEntry, and pollLastEntry
 * that return and/or remove the least and greatest mappings, if any exist, else returning null.
 *
 * This interface corresponds to java.util.NavigableMap
 */
export interface NavigableMap<K, V> extends JMap<K, V> {
    /**
    * Returns the first (lowest) key currently in this map.
    * @return {K} the first (lowest) key currently in this map, returns null if the Map is empty
    */
    firstKey(): K;
    /**
     * Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
     * @return {MapEntry} an entry with the least key, or null if this map is empty
     */
    firstEntry(): MapEntry<K, V>;
    /**
     * Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
     * @param {K} key the key
     * @return {MapEntry} an entry with the least key greater than or equal to key, or null if there is no such key
     */
    ceilingEntry(key: K): MapEntry<K, V>;
    /**
    * Returns the least key greater than or equal to the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {K} the least key greater than or equal to key, or null if there is no such key
    */
    ceilingKey(key: K): K;
    /**
    * Returns the least key greater than the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {K} the least key greater than key, or null if there is no such key
    */
    higherKey(key: K): K;
    /**
    * Returns a key-value mapping associated with the least key greater than the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {MapEntry} an entry with the least key greater than key, or null if there is no such key
    */
    higherEntry(key: K): MapEntry<K, V>;
    /**
    * Returns the highest key lower than the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {K} the highest key lower than key, or null if there is no such key
    */
    lowerKey(key: K): K;
    /**
    * Returns a key-value mapping associated with the highest key lower than the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {MapEntry} an entry with the highest key lower than key, or null if there is no such key
    */
    lowerEntry(key: K): MapEntry<K, V>;
    /**
    * Returns the greatest key less than or equal to the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {K} the greatest key less than or equal to key, or null if there is no such key
    */
    floorKey(key: K): K;
    /**
    * Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
    * @param {K} key the key
    * @return {MapEntry} an entry with the greatest key less than or equal to key, or null if there is no such key
    */
    floorEntry(key: K): MapEntry<K, V>;
    /**
     * Returns the last (highest) key currently in this map.
     * @return {K} the last (highest) key currently in this map, returns null if the Map is empty
     */
    lastKey(): K;
    /**
     * Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
     * @return {MapEntry} an entry with the greatest key, or null if this map is empty
     */
    lastEntry(): MapEntry<K, V>;
}


text:
class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      t.string :username
      t.string :password_hash
      t.text :bio

      t.timestamps
    end
  end
end


text:
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <stdio.h>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <cstdint>
#include <sstream>

#include "fastrtps/log/Log.h"
#include "fastrtps/rtps/RTPSDomain.h"

#include "TestWriterSocket.h"
#include "TestReaderSocket.h"

using namespace eprosima;
using namespace fastrtps;
using namespace rtps;
using namespace std;

int main(int argc, char** argv){

    std::cout << "Starting" << std::endl;
    int type;
    if(argc > 1)
    {
        if(strcmp(argv[1],"writer")==0)
            type = 1;
        else if(strcmp(argv[1],"reader")==0)
            type = 2;
        else
        {
            std::cout << "NEEDS writer OR reader as first argument"<<std::endl;
            return 0;
        }
    }
    else
    {
        std::cout << "NEEDS writer OR reader ARGUMENT"<<std::endl;
        std::cout << "RTPSTest writer"<<std::endl;
        std::cout << "RTPSTest reader" <<std::endl;
        return 0;
    }
    switch (type)
    {
        case 1:
            {
                TestWriterSocket TW;
                if(TW.init("239.255.1.4",22222))
                    TW.run(10);
                break;
            }
        case 2:
            {
                TestReaderSocket TR;
                if(TR.init("239.255.1.4",22222))
                    TR.run();
                break;
            }
    }

    RTPSDomain::stopAll();
    std::cout << "EVERYTHING STOPPED FINE"<<std::endl;

    return 0;
}


text:
var $ = jQuery = require('jquery');
var moment       = require('moment');
var fullcalendar = require('fullcalendar');

angular.module('appTaskCalendar',[	])
.controller('taskCalendarController',['$scope','uiCalendarConfig',function($scope,uiCalendarConfig){
	console.info('taskCalendarController');
 	var date = new Date();
	var d = date.getDate();
	var m = date.getMonth();
	var y = date.getFullYear();

	$scope.uiConfig = {
	  calendar:{
		height: 450,
		editable: true,
		header:{
		  left: 'month basicWeek basicDay agendaWeek agendaDay',
		  center: 'title',
		  right: ' prev,next today'
		},
		eventClick: $scope.alertEventOnClick,
		eventDrop: $scope.alertOnDrop,
		eventResize: $scope.alertOnResize
	  }
	};

	$scope.events = [
	  {title: 'All Day Event'		,start: new Date(y, m, 1)	},
	  {title: 'Long Event'			,start: new Date(y, m, d - 5)				,end: new Date(y, m, d - 2)},
	  {title: 'Repeating Event'	,start: new Date(y, m, d - 3, 16, 0),allDay: false},
	  {title: 'Repeating Event'	,start: new Date(y, m, d + 4, 16, 0),allDay: false},
	  {title: 'Birthday Party'	,start: new Date(y, m, d + 1, 19, 0),end: new Date(y, m, d + 1, 22, 30),allDay: false},
	  {title: 'Click for Google',start: new Date(y, m, 28)					,end: new Date(y, m, 29),	url: 'http://google.com/'}
	];

	$scope.eventSource = {
			url: "http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic",
			className: 'gcal-event',           // an option!
			currentTimezone: 'America/Chicago' // an option!
	};

 	$scope.eventsF = function (start, end, timezone, callback) {
	  var s = new Date(start).getTime() / 1000;
	  var e = new Date(end).getTime() / 1000;
	  var m = new Date(start).getMonth();
	  var events = [{title: 'Feed Me ' + m,start: s + (50000),end: s + (100000),allDay: false, className: ['customFeed']}];
	  callback(events);
	};

	$scope.eventSources = [$scope.events];

	$scope.changeView = function(view,calendar) {
		uiCalendarConfig.calendars[calendar].fullCalendar('changeView',view);
	};

}])


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_enabled="false" android:color="@color/grey"></item>
    <item android:color="@color/white"></item>

</selector>


text:
package org.springframework.web.scala

import javax.servlet.http.{HttpServletRequest, HttpServletResponse}

import org.springframework.web.servlet.resource.ResourceHttpRequestHandler
import org.springframework.web.servlet.{HandlerAdapter, ModelAndView}

/**
  * Created by sam on 09/03/17.
  */
class FunctorHandlerActionAdapter  extends HandlerAdapter{

  val functor:FunctorHandler = new FunctorHandler()

  override def handle(httpServletRequest: HttpServletRequest, httpServletResponse: HttpServletResponse, o: scala.Any): ModelAndView = {

    o match {

      case action:Action[_,_] => {
        val input = action.req.defaultConverter()(httpServletRequest)

        val eval = functor.map(input,action.fn)

        val outModel = new ModelAndView("jsonTemplate")

        outModel.addObject("content",eval.read())

        //TODO manage response

        return outModel
      }
      case _ =>  {
        println("got a " + o.getClass.getCanonicalName)
        new ModelAndView("broken")
      }

    }

  //  val action:Action[AnyRef,AnyRef] = o.asInstanceOf[Action[AnyRef,AnyRef]]

  }

  override def getLastModified(httpServletRequest: HttpServletRequest, o: scala.Any): Long = -1L

  override def supports(o: scala.Any): Boolean =  true //o.isInstanceOf[FunctoidHandler[_,_]]
}


text:
 #include "debug/debug.h"
 #include "debug/recorder.h"
#endif

#define SHIZ_MIN_OPENGL_VERSION_MAJOR 3
#define SHIZ_MIN_OPENGL_VERSION_MINOR 3

extern SHIZGraphicsContext _graphics_context;

const SHIZWindowSettings SHIZWindowSettingsDefault = {
    .title = "SHIZEN",
    .description = NULL,
    .fullscreen = false,
    .vsync = true,
    .size = {
        .width = 320,
        .height = 240
    },
    .pixel_size = 1
};

static
void
z_engine__error_callback(int error, char const * description);

static
void
z_engine__window_close_callback(GLFWwindow *);

static
void
z_engine__window_focus_callback(GLFWwindow *, int focused);

static
void
z_engine__key_callback(GLFWwindow * const window,
                       int key, int scancode, int action, int mods);

static
void
z_engine__framebuffer_size_callback(GLFWwindow *,
                                    int width, int height);

static
bool
z_engine__create_window(bool fullscreen,
                        char const * title);

static
void
z_engine__toggle_windowed(GLFWwindow *);

static
bool
z_engine__is_fullscreen(void);

static
float
z_engine__get_pixel_scale(void);

static
SHIZSize
z_engine__get_window_size(void);

static
SHIZSize
z_engine__get_framebuffer_size(void);

static
SHIZViewport
z_engine__build_viewport(void);

static
bool
z_engine__can_run(void);

static
void
z_engine__intro(char const * description);

static
void
z_engine__intro_gl(void);

static
uint8_t
z_engine__get_refresh_rate(void);

static SHIZVector2 _preferred_window_position;

bool
z_startup(SHIZWindowSettings const settings)
{
    if (_graphics_context.is_initialized) {
        return false;
    }

    z_engine__intro(settings.description);

    _graphics_context.native_size = settings.size;
    _graphics_context.pixel_size = 1;
    _graphics_context.swap_interval = settings.vsync ? 1 : 0;

    if (settings.pixel_size > 0) {
        _graphics_context.pixel_size = settings.pixel_size;
    } else {
        z_io__warning("SHIZEN does not support a pixel-size of 0; defaulting to 1");
    }

    _graphics_context.display_size =
        SHIZSizeMake(_graphics_context.native_size.width * _graphics_context.pixel_size,
                     _graphics_context.native_size.height * _graphics_context.pixel_size);

    glfwSetErrorCallback(z_engine__error_callback);

    if (!glfwInit()) {
        z_io__error_context("GLFW", "(%s) failed to initialize",
                            glfwGetVersionString());

        return false;
    } else {
        printf(" Using GLFW %s\n\n", glfwGetVersionString());
    }

    if (!z_engine__create_window(settings.fullscreen, settings.title)) {
        z_io__error_context("GLFW", "(%s) failed to create window",
                            glfwGetVersionString());

        return false;
    }

    if (gl3wInit()) {
        z_io__error_context("gl3w", "failed to initialize");

        return false;
    }

    z_engine__intro_gl();

    if (!z_engine__can_run()) {
        z_io__error("SHIZEN is not supported on this system");

        return false;
    }

    if (!z_gfx__init(z_engine__build_viewport())) {
        return false;
    }

    if (!z_mixer__init()) {
        return false;
    }

    _graphics_context.is_initialized = true;

    z_time_reset();

#ifdef SHIZ_DEBUG
    if (!z_debug__init()) {
        z_io__error("SHIZEN could not initialize a debugging state");

        return false;
    }

    if (z_recorder__init()) {
        z_recorder__setup(_graphics_context.display_size,
                          z_engine__get_refresh_rate());
    } else {
        z_io__error("SHIZEN could not initialize recorder");

        return false;
    }
#endif

    z_rand_seed_now();

    return true;
}

bool
z_shutdown()
{
    if (!_graphics_context.is_initialized) {
        return false;
    }

    z_res__unload_all();

    if (!z_mixer__kill()) {
        return false;
    }

    if (!z_gfx__kill()) {
        return false;
    }

#ifdef SHIZ_DEBUG
    if (!z_recorder__kill()) {
        return false;
    }

    if (!z_debug__kill()) {
        return false;
    }
#endif

    GLFWwindow * const window = _graphics_context.window;

    glfwSetWindowCloseCallback(window, NULL);
    glfwSetWindowFocusCallback(window, NULL);
    glfwSetFramebufferSizeCallback(window, NULL);
    glfwSetKeyCallback(window, NULL);
    glfwSetErrorCallback(NULL);

    glfwTerminate();

    _graphics_context.is_initialized = false;

    return true;
}

void
z_engine__present_frame()
{
    glfwSwapBuffers(_graphics_context.window);

#ifdef SHIZ_DEBUG
    if (z_recorder_is_recording()) {
        z_recorder__capture();
    }
#endif

    glfwPollEvents();
}

void
z_request_finish()
{
    _graphics_context.should_finish = true;
}

bool
z_should_finish()
{
    return _graphics_context.should_finish;
}

SHIZSize
z_get_display_size()
{
    return _graphics_context.native_size;
}

SHIZVector2
z_get_display_point(SHIZVector2 const anchor)
{
    SHIZSize const display = z_get_display_size();

    SHIZSize const pixels = SHIZSizeMake(display.width,
                                         display.height);

    SHIZSize const pixels_half = SHIZSizeMake(pixels.width / 2,
                                              pixels.height / 2);

    SHIZVector2 const delta = SHIZVector2Make(pixels_half.width * anchor.x,
                                              pixels_half.height * anchor.y);

    SHIZVector2 const point = SHIZVector2Make(pixels_half.width + delta.x,
                                              pixels_half.height + delta.y);

    return SHIZVector2Make(PIXEL(point.x),
                           PIXEL(point.y));
}

static
SHIZViewport
z_engine__build_viewport()
{
    SHIZViewport viewport = SHIZViewportDefault;

    viewport.resolution = _graphics_context.native_size;
    viewport.framebuffer = z_engine__get_framebuffer_size();
    viewport.scale = z_engine__get_pixel_scale();

    return viewport;
}

static
void
z_engine__intro(char const * const description)
{
    char const * mode = "";

#ifdef SHIZ_DEBUG
    mode = "DEBUG";
#else
    mode = "RELEASE";
#endif

    printf("\n");
    printf("  __|  |  | _ _| __  /  __|   \\ |\n");
    printf("\\__ \\  __ |   |     /   _|   .  |\n");
    printf("____/ _| _| ___| ____| ___| _|\\_|\n\n");
    printf(" SHIZEN %d.%d.%d / %s %s (built %s, %s)\n",
           SHIZEN_VERSION_MAJOR, SHIZEN_VERSION_MINOR, SHIZEN_VERSION_PATCH,
           SHIZEN_VERSION_NAME, mode, __DATE__, __TIME__);
    printf(" Copyright (c) 2017 Jacob Hauberg Hansen\n\n");

    if (description != NULL) {
        printf("%s\n", description);
    }

    printf(" ----------------\n");
}

static
void
z_engine__intro_gl()
{
    printf(" OPENGL VERSION:  %s (GLSL %s)\n",
           glGetString(GL_VERSION), glGetString(GL_SHADING_LANGUAGE_VERSION));
    printf(" OPENGL RENDERER: %s\n",
           glGetString(GL_RENDERER));
    printf(" OPENGL VENDOR:   %s\n\n",
           glGetString(GL_VENDOR));
}

static
bool
z_engine__can_run()
{
    int major;
    int minor;

    glGetIntegerv(GL_MAJOR_VERSION, &major);
    glGetIntegerv(GL_MINOR_VERSION, &minor);

    if (major < SHIZ_MIN_OPENGL_VERSION_MAJOR ||
        (major == SHIZ_MIN_OPENGL_VERSION_MAJOR &&
         minor < SHIZ_MIN_OPENGL_VERSION_MINOR)) {
        return false;
    }

    return true;
}

static
bool
z_engine__create_window(bool const fullscreen,
                        char const * const title)
{
    glfwWindowHint(GLFW_SAMPLES, 0);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, SHIZ_MIN_OPENGL_VERSION_MAJOR);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, SHIZ_MIN_OPENGL_VERSION_MINOR);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
    glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);

    SHIZSize const visible_size = _graphics_context.display_size;

    if (fullscreen) {
        GLFWmonitor * const monitor = glfwGetPrimaryMonitor();

        if (monitor) {
            GLFWvidmode const * const mode = glfwGetVideoMode(monitor);

            int const display_width = mode->width;
            int const display_height = mode->height;

            _graphics_context.window = glfwCreateWindow(display_width, display_height,
                                                        title, glfwGetPrimaryMonitor(), NULL);

            // prefer centered window if initially fullscreen;
            // otherwise let the OS determine window placement
            _preferred_window_position.x = (display_width / 2) - (visible_size.width / 2);
            _preferred_window_position.y = (display_height / 2) - (visible_size.height / 2);
        }
    } else {
        _graphics_context.window = glfwCreateWindow((int)visible_size.width,
                                                    (int)visible_size.height,
                                                    title, NULL, NULL);
    }

    if (!_graphics_context.window) {
        return false;
    }

    GLFWwindow * const window = _graphics_context.window;

    _graphics_context.is_fullscreen = z_engine__is_fullscreen();

    glfwSetWindowCloseCallback(window, z_engine__window_close_callback);
    glfwSetWindowFocusCallback(window, z_engine__window_focus_callback);

    glfwSetFramebufferSizeCallback(window, z_engine__framebuffer_size_callback);

    glfwSetKeyCallback(window, z_engine__key_callback);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(_graphics_context.swap_interval);

    return true;
}

static
SHIZSize
z_engine__get_window_size()
{
    int window_width;
    int window_height;

    glfwGetWindowSize(_graphics_context.window,
                      &window_width, &window_height);

    return SHIZSizeMake(window_width, window_height);
}

static
SHIZSize
z_engine__get_framebuffer_size()
{
    int framebuffer_width;
    int framebuffer_height;

    // determine pixel size of the framebuffer for the window
    // this size is not necesarilly equal to the size of the window, as some
    // platforms may increase the pixel count (e.g. doubling on retina screens)
    glfwGetFramebufferSize(_graphics_context.window,
                           &framebuffer_width, &framebuffer_height);

    return SHIZSizeMake(framebuffer_width, framebuffer_height);
}

static
float
z_engine__get_pixel_scale()
{
    SHIZSize const framebuffer = z_engine__get_framebuffer_size();
    SHIZSize const window = z_engine__get_window_size();

    return (framebuffer.width + framebuffer.height) /
        (window.width + window.height);
}

static
uint8_t
z_engine__get_refresh_rate()
{
    GLFWmonitor * const monitor = glfwGetPrimaryMonitor();

    if (monitor != NULL) {
        GLFWvidmode const * const mode = glfwGetVideoMode(monitor);

        if (mode != NULL) {
            return (uint8_t)mode->refreshRate;
        }
    }

    return 0;
}

static
bool
z_engine__is_fullscreen()
{
    if (_graphics_context.window != NULL) {
        return glfwGetWindowMonitor(_graphics_context.window) != NULL;
    }

    return false;
}

static
void
z_engine__toggle_windowed(GLFWwindow * const window)
{
    bool const is_currently_fullscreen = z_engine__is_fullscreen();

    int window_position_x = (int)_preferred_window_position.x;
    int window_position_y = (int)_preferred_window_position.y;

    if (is_currently_fullscreen) {
        // go windowed
        glfwSetWindowMonitor(window, NULL,
                             window_position_x, window_position_y,
                             (int)_graphics_context.display_size.width,
                             (int)_graphics_context.display_size.height,
                             0);
    } else {
        // go fullscreen
        GLFWmonitor * const monitor = glfwGetPrimaryMonitor();

        if (monitor) {
            GLFWvidmode const * const mode = glfwGetVideoMode(monitor);

            glfwGetWindowPos(window,
                             &window_position_x,
                             &window_position_y);

            _preferred_window_position.x = window_position_x;
            _preferred_window_position.y = window_position_y;

            glfwSetWindowMonitor(window, monitor, 0, 0,
                                 mode->width, mode->height,
                                 mode->refreshRate);
        }
    }

    _graphics_context.is_fullscreen = z_engine__is_fullscreen();
}

static
void
z_engine__key_callback(GLFWwindow * const window,
                       int const key,
                       int const scancode,
                       int const action,
                       int const mods)
{
    (void)scancode;
    // todo: we should use input to handle this stuff; i.e. create specialized input key that trigger this stuff
    if ((mods == GLFW_MOD_ALT && key == GLFW_KEY_ENTER) && action == GLFW_RELEASE) {
        z_engine__toggle_windowed(window);
    }
#ifdef SHIZ_DEBUG
    else if (key == GLFW_KEY_F2 && action == GLFW_RELEASE) {
        if (!z_recorder_is_recording()) {
            z_recorder__start();
        } else {
            z_recorder__stop();
        }
    } else if ((key == GLFW_KEY_GRAVE_ACCENT) && action == GLFW_PRESS) {
        z_debug__toggle_enabled();
    }

    if (z_debug__is_enabled()) {
        z_debug__toggle_expanded(mods == GLFW_MOD_SHIFT);
        z_debug__set_is_printing_sprite_order((mods == GLFW_MOD_SHIFT &&
                                               key == GLFW_KEY_Z) &&
                                              action == GLFW_PRESS);

        if ((mods == GLFW_MOD_SHIFT && key == GLFW_KEY_1) && action == GLFW_RELEASE) {
            z_debug__toggle_draw_shapes();
        } else if ((mods == GLFW_MOD_SHIFT && key == GLFW_KEY_2) && action == GLFW_RELEASE) {
            z_debug__toggle_draw_events();
        } else if ((mods == GLFW_MOD_SHIFT && key == GLFW_KEY_3) && action == GLFW_RELEASE) {
            z_debug__toggle_draw_axes();
        } else if ((mods == GLFW_MOD_SHIFT && key == GLFW_KEY_MINUS) && (action == GLFW_PRESS ||
                                                                         action == GLFW_REPEAT)) {
            z_time_set_scale(z_time_get_scale() - 0.1);
        } else if ((mods == GLFW_MOD_SHIFT && key == GLFW_KEY_EQUAL) && (action == GLFW_PRESS ||
                                                                         action == GLFW_REPEAT)) {
            z_time_set_scale(z_time_get_scale() + 0.1);
        }
    }
#endif
}

static
void
z_engine__error_callback(int const error,
                         char const * const description)
{
    z_io__error_context("GLFW", "%d %s", error, description);
}

static
void
z_engine__window_close_callback(GLFWwindow * const window)
{
    (void)window;

    _graphics_context.should_finish = true;
}

static
void
z_engine__window_focus_callback(GLFWwindow * const window,
                                int const focused)
{
    (void)window;

    _graphics_context.is_focused = focused;
}

static
void
z_engine__framebuffer_size_callback(GLFWwindow * const window,
                                    int const width,
                                    int const height)
{
    (void)window;
    (void)width;
    (void)height;

    _graphics_context.is_fullscreen = z_engine__is_fullscreen();

    SHIZViewport const viewport = z_engine__build_viewport();

    z_viewport__set(viewport);

#ifdef SHIZ_DEBUG
    if (z_recorder_is_recording()) {
        z_io__warning_context("RECORDER",
                              "Switching window mode is not supported while recording; stopping recording");
        z_recorder__stop();
    }

    z_recorder__setup(_graphics_context.display_size,
                      z_engine__get_refresh_rate());
#endif
}


text:
package com.samsung.sec.dexter.core.metrics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.google.common.base.Strings;
import com.samsung.sec.dexter.core.TargetFile;

public class FunctionMetrics extends TargetFile {
	private long createdDateTime = System.currentTimeMillis();
	private Map<String, Object> metrics = new HashMap<String, Object>(10);
	private List<Map<String, Object>> functionMetrics = new ArrayList<Map<String, Object>>();
	final static Logger logger = Logger.getLogger(FunctionMetrics.class);

	public long getCreatedDateTime(){
		return createdDateTime;
	}

	public Map<String, Object> getMetrics(){
		return metrics;

	}

	public List<Map<String, Object>> getFunctionMetrics(){
		return functionMetrics;
	}

	/**
	 * @param createdDateTime the createdDateTime to set
	 */
	public void setCreatedDateTime(final long createdDateTime) {
		this.createdDateTime = createdDateTime;
	}

	/**
	 * @param metrics the metrics to set
	 */
	public void setMetrics(final Map<String, Object> metrics) {
		this.metrics = metrics;
	}

	public void setFunctionMetrics(final List<Map<String, Object>> functionMetrics){
		this.functionMetrics = functionMetrics;
	}

	public void addMetric(final String key, final String value){
		if(Strings.isNullOrEmpty(key) || Strings.isNullOrEmpty(value)){
			logger.error("Invalid Parameter : key or value is null or empty");
			return;
		}

		if(!this.metrics.containsKey(key)){
			this.metrics.put(key, value);
		}
	}

	public void addMetric(final String key, final int value){
		if(Strings.isNullOrEmpty(key)){
			logger.error("Invalid Parameter : key is null or empty");
			return;
		}

		if(!this.metrics.containsKey(key)){
			this.metrics.put(key, value);
		}
	}

	public void addMetric(final String key, final float value){
		if(Strings.isNullOrEmpty(key)){
			logger.error("Invalid Parameter : key is null or empty");
			return;
		}

		if(!this.metrics.containsKey(key)){
			this.metrics.put(key, value);
		}
	}

	public void setMetric(final String key, final String value){
		if(Strings.isNullOrEmpty(key) || Strings.isNullOrEmpty(value)){
			logger.error("Invalid Parameter : key or value is null or empty");
			return;
		}

		this.metrics.put(key, value);
	}

	public void setMetric(final String key, final int value){
		if(Strings.isNullOrEmpty(key)){
			logger.error("Invalid Parameter : key is null or empty");
			return;
		}

		this.metrics.put(key, value);
	}

	public Object getMetric(final String key){
		if(Strings.isNullOrEmpty(key)){
			logger.error("Invalid Parameter : key is null or empty");
			return "";
		}

		return this.metrics.get(key);
	}

	public String getMetricString(final String key){
		if(Strings.isNullOrEmpty(key)){
			logger.error("Invalid Parameter : key is null or empty");
			return "";
		}

		return (String) this.metrics.get(key);
	}
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <deployment-targets>
        <target device="mobileweb">false</target>
        <target device="iphone">false</target>
        <target device="ipad">false</target>
        <target device="android">true</target>
        <target device="blackberry">false</target>
    </deployment-targets>
    <sdk-version>2.1.2.GA</sdk-version>
    <id>com.appcelerator.tibh</id>
    <name>TiBountyHunter</name>
    <version>1.0</version>
    <publisher>brychapman</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>2012 by brychapman</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>a43e475a-54ef-49ee-bbae-7f9d1fd4379a</guid>
    <property name="ti.ui.defaultunit">system</property>
    <property name="ti.android.google.map.api.key.development">0dSJ66vHhLJTTXzy2XRc9E4VG3BKlMuwt2Bj3YQ</property>
	<property name="ti.android.google.map.api.key.production">0dSJ66vHhLJTTXzy2XRc9E4VG3BKlMuwt2Bj3YQ</property>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android"/>
    <mobileweb>
        <precache/>
        <splash>
            <enabled>true</enabled>
            <inline-css-images>true</inline-css-images>
        </splash>
        <theme>default</theme>
    </mobileweb>
    <modules/>
</ti:app>


text:
/**
 * \file ImagerMod.cpp
 * \brief Definition of CImagerMod class.
 *
 * CImagerMod Class is derived from base class PBModule. Handles META TAG processing request from Core, META TAG should be in EMML 1.1 format.
 *
 */
#include "ImagerMod.h"
#include "..\..\Engine\Common\pbengine_defs.h"

//to store wav file to be played during capture
TCHAR			m_tcImagerSound[MAX_PATH];
//Username for FTP server
//TCHAR			m_tcImagerUsername[MAX_PATH];
//password for FTP server
//TCHAR			m_tcImagerPassword[MAX_PATH];
///Flag indicating http transfer is requested
BOOL			m_bHttpTransfer=FALSE;
//Navigation url
extern TCHAR m_ImagerURL[2050];
//Enum var to hold active image capture device
extern EnumImageCapDevType g_ActiveImageCapDevice;
//global list of available image capture device
extern PListDevName g_ListDevName;
//Vars for color camera , VF dimensions and position
extern DWORD g_dwTop,g_dwLeft,g_dwWidth,g_dwHeight;
extern BOOL g_bTop,g_bLeft,g_bWidth, g_bHeight;
//Events for synchronization
extern HANDLE g_hBuildGraph,g_hTaskPending;
//For Navigation
//extern TCHAR m_IMGNav[2050];
//AT any time only one instance of imager is possible
DWORD g_InstanceCount=0;
////////////////////////////////////////////////////////////////////////
// Function:	CImagerMod
// Description:	Constructor.
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
CImagerMod::CImagerMod(void)
{
	m_bImgOn=FALSE;
	m_pImagerInst = NULL;

}
////////////////////////////////////////////////////////////////////////
// Function:	~CImagerMod
// Description:	Destructor.
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
CImagerMod::~CImagerMod(void)
{
	return;
}
////////////////////////////////////////////////////////////////////////
// Function:	onInit
// Description:	Public function called when first instance of Imager is loaded.
// initializes member m_szModName with Imager.
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::onInit(PPBSTRUCT pPBStructure)
{
UNREFERENCED_PARAMETER(pPBStructure);
	//Copy The module name
	wcscpy(m_szModName, L"Imager");
	RegisterForEvent(RHO_APPFOCUS_EVENT);
	m_bAppHasFocus = (pPBStructure->bLaunchingAppHasFocus==TRUE);
	if(RegisterForEvent(PB_BROWSER_BEFORE_NAV_EVENT)){
		m_FileTransferIMO = CreateIMO(L"filetransfer");
		if(m_FileTransferIMO){
			if(SetIMOCallBack (m_FileTransferIMO,IMOCBFunc,(LPARAM)this)){
				return TRUE;
			}
		}
	}
	return FALSE;
}
////////////////////////////////////////////////////////////////////////
// Function:	onDeInit
// Description:	This Fucntion is called when dispose on final instance is called
//
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
void CImagerMod::onDeInit(PBStruct *pPBStructure)
{
UNREFERENCED_PARAMETER(pPBStructure);
	DeleteIMO(m_FileTransferIMO);
	UnRegisterForEvent(PB_BROWSER_BEFORE_NAV_EVENT);
	UnRegisterForEvent(RHO_APPFOCUS_EVENT);
}
////////////////////////////////////////////////////////////////////////
// Function:	onAttachInstance
// Description:	Public function called every time new instance is created.
// does initializations for Imager instance upon creation.
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::onAttachInstance(PPBSTRUCT pPBStructure, PPBINSTSTRUCT pInstStruct)
{
	//Log
	BOOL bRet=FALSE;
	LPCTSTR pVal;

	CImager *pImager=NULL;
	if(g_InstanceCount == 0)
	{

		pInstStruct->pWrappedObj = pImager =
			(CImager*)new CImager(pPBStructure->hInstance,
				pPBStructure->hWnd,
				pPBStructure->iTabID,
				this);
		if(pInstStruct->pWrappedObj){

			pImager->m_pPBStructure.hWnd = pPBStructure->hWnd;
			pImager->m_pPBStructure.hInstance = pPBStructure->hInstance;
			pImager->m_pPBStructure.bInvoked = pPBStructure->bInvoked;
			pImager->m_pPBStructure.iTabID = pPBStructure->iTabID;

			//Initialize the wav for imager from config file
			pVal = GetAppSettingPtr(pImager->m_pPBStructure.iTabID,L"Sound\\ImagerCaptureWav",L"Value");

			if(pVal)
			{
				int iStart = 0;
				if (wcslen(pVal) > wcslen(L"file://") &&
					wcsnicmp(pVal, L"file://", 7) == 0)
					iStart = 7;
				wcscpy(m_tcImagerSound, pVal + iStart);
			}

			bRet = TRUE;
			g_InstanceCount++;
		}

	}

	return bRet;
}
////////////////////////////////////////////////////////////////////////
// Function:	onReleaseInstance
// Description:	Called during scanner instance deletion also does cleanup activity
//              before instance deletion.
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::onReleaseInstance(PPBSTRUCT pPBStructure, PPBINSTSTRUCT pInstStruct)
{
UNREFERENCED_PARAMETER(pPBStructure);
	//Log
//	DWORD dwRetValue;
	if(1 == g_InstanceCount)
	{
//		CImager *pImager = (CImager *)pInstStruct->pWrappedObj;
		delete (CImager *)pInstStruct->pWrappedObj;
		pInstStruct->pWrappedObj = NULL;
		g_InstanceCount--;
	}

	return TRUE;
}

////////////////////////////////////////////////////////////////////////
// Function:	MetaProc
// Description:	public function invked whenever META tag needs processing
//
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::MetaProc(PBMetaStruct *pbMetaStructure, PPBSTRUCT pPBStructure, VOID* pParam)
{
	Log(PB_LOG_WARNING, L"The Imager API has been deprecated in 4.0, please transition your applications to use the Camera API for future releases", _T(__FUNCTION__), __LINE__);
	BOOL bRet=TRUE;

	CImager *pImager = (CImager *)pParam;
//	LPCTSTR pParameters = pbMetaStructure->lpParameter;
//	LPCTSTR pValue = pbMetaStructure->lpValue;

	//Check if Imager parameter is valid
	if(!pImager)
	{
		return FALSE;
	}

	//Initialize the PPBStruct
	if(pPBStructure!=NULL)
	{
		pImager->m_pPBStructure.hWnd = pPBStructure->hWnd;
		pImager->m_pPBStructure.hInstance = pPBStructure->hInstance;
		pImager->m_pPBStructure.bInvoked = pPBStructure->bInvoked;
		pImager->m_pPBStructure.iTabID = pPBStructure->iTabID;
	}

	if(cmp(pbMetaStructure->lpParameter,L"Enabled") ||
		cmp(pbMetaStructure->lpParameter,L"Enable"))
	{
		if (m_bAppHasFocus) {
			if (!m_bImgOn) {
				//m_bImgOn flag is going to be set within EnableImager
				EnableImager(pImager,pbMetaStructure->lpValue);
				Log(PB_LOG_DEBUG, L"Imager enabled", L"Imager",__LINE__);
			}
		}
		else {
			wcscpy(m_szBgImager, pbMetaStructure->lpValue);
		}
	}
	else if(cmp(pbMetaStructure->lpParameter,L"disabled") || cmp(pbMetaStructure->lpParameter,L"disable")){
		if (m_bAppHasFocus) {
			if (m_bImgOn) {
				// Imager is disabled so stop it
				m_bImgOn=FALSE;
				pImager->DeInit();
				Log(PB_LOG_DEBUG, L"Imager disabled", L"Imager",__LINE__);
			}
		}
		else {
			m_szBgImager[0] = L'\0';
		}
	}
	else if(cmp(pbMetaStructure->lpParameter, L"capture"))
	{
		if (m_bImgOn)
		{
			bRet = FALSE;

			if (pImager->m_hImager != INVALID_HANDLE_VALUE)
				pImager->Image_StopViewfinder(pImager->m_hImager);

			if (m_tcImagerSound[0] && (wcslen(m_tcImagerSound) >0) &&
				(!pImager->DirectShowShutterClick()))
				PlaySound(m_tcImagerSound,NULL,SND_FILENAME|SND_ASYNC);

			if(pImager->SaveImage()==SUCCESS)
			{
				bRet = TRUE;
				////////////////////////Send Image if configured//////////////////////////////////
				if(m_FileTransferIMO)
				{
					//make sure the inter module object to communicate with file transfer exists
					//ensure that a destination etc has been set otherwise IMO is not needed
					if(pImager->m_bTransfer)
					{
						bRet = FALSE;
						// By default set the Overwrite parameter to TRUE
						SetIMOProperty(m_FileTransferIMO, L"overwrite", L"true");
						if(SetIMOProperty(m_FileTransferIMO, L"Source",pImager->m_lpSzFilename))
						{
							if (SetIMOProperty(m_FileTransferIMO, L"SetFileDestination", L"FALSE"))
							{
								bRet = CallIMOMethod(m_FileTransferIMO ,L"Transfer");
							}
						}
					}
				}
			}

			if (pImager->m_hImager != INVALID_HANDLE_VALUE)
				pImager->Image_StartViewfinder(pImager->m_hImager);

					////////////////////////Stop IMO///////////////////////////////////
					//pImager->SendImage();
		}
	}
	else if(cmp(pbMetaStructure->lpParameter, L"ImagerEvent")){
		if(pbMetaStructure->lpValue != NULL)
			bRet = SetIMOProperty(m_FileTransferIMO, L"TransferEvent",pbMetaStructure->lpValue);
			//wcscpy(m_IMGNav,pbMetaStructure->lpValue);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"ImagerEnumEvent")){
		if(pbMetaStructure->lpValue != NULL)
			wcscpy(pImager->m_EnumIMGNav,pbMetaStructure->lpValue);
	}
	else if (cmp(pbMetaStructure->lpParameter, L"ImagerCaptureEvent"))
	{
		if (pbMetaStructure->lpValue)
			return pImager->SetImagerCaptureEvent(pbMetaStructure->lpValue);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Left")){
		if(NULL != pbMetaStructure->lpValue && isFloat(pbMetaStructure->lpValue) && _wtoi(pbMetaStructure->lpValue) >= 0)
			pImager->SetViewerPosition(_wtoi(pbMetaStructure->lpValue), -9999, -9999, -9999);
		else
			bRet = FALSE;
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Top")){
		if(NULL != pbMetaStructure->lpValue && isFloat(pbMetaStructure->lpValue) && _wtoi(pbMetaStructure->lpValue) >= 0)
			pImager->SetViewerPosition(-9999, -9999, _wtoi(pbMetaStructure->lpValue), -9999);
		else
			bRet = FALSE;
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Width")){
		if(NULL != pbMetaStructure->lpValue && isFloat(pbMetaStructure->lpValue) && _wtoi(pbMetaStructure->lpValue) >= 0)
			pImager->SetViewerPosition(-9999, _wtoi(pbMetaStructure->lpValue), -9999, -9999);
		else
			bRet = FALSE;
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Height")){
		if(NULL != pbMetaStructure->lpValue && isFloat(pbMetaStructure->lpValue) && _wtoi(pbMetaStructure->lpValue) >= 0)
			pImager->SetViewerPosition(-9999, -9999, -9999, _wtoi(pbMetaStructure->lpValue));
		else
			bRet = FALSE;
	}
	else if(cmp(pbMetaStructure->lpParameter, L"number"))
	{
		if(NULL != pbMetaStructure->lpValue)
			pImager->m_ImgNo = _wtoi(pbMetaStructure->lpValue);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Name"))
	{
		if (pbMetaStructure->lpValue)
			return pImager->SetName(pbMetaStructure->lpValue);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"lamp"))
	{
			if(cmp(pbMetaStructure->lpValue, L"on")) pImager->SetOptions(1, 9999);
			else if (cmp(pbMetaStructure->lpValue, L"off")) pImager->SetOptions(0, 9999);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"aim"))
	{
		BOOL bFlag;
			if(CheckImagerOrCamera(pImager->m_szDevName,&bFlag))
			{
				if(!bFlag)
				{
					PBModule::Log(PB_LOG_INFO,L"Aim feature not available in Camera",L"Imager",__LINE__);
					bRet = FALSE;
				}
				else
				{
					if(cmp(pbMetaStructure->lpValue, L"on"))
						pImager->SetOptions(9999, 1);
					else
						if (cmp(pbMetaStructure->lpValue, L"off"))
								pImager->SetOptions(9999, 0);
				}
			}
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Destination"))
	{
		if(pbMetaStructure->lpValue){
			if(SetIMOProperty(m_FileTransferIMO, L"Destination", pbMetaStructure->lpValue)){
				return pImager->m_bTransfer = TRUE;

			}
			bRet = FALSE;
		}
	}
	else if(cmp(pbMetaStructure->lpParameter, L"username"))
	{
		if(NULL != pbMetaStructure->lpValue)
			return SetIMOProperty(m_FileTransferIMO, L"Username", pbMetaStructure->lpValue);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"password"))
	{
		if(NULL != pbMetaStructure->lpValue)
			return SetIMOProperty(m_FileTransferIMO, L"Password", pbMetaStructure->lpValue);
	}
	else if(cmp(pbMetaStructure->lpParameter, L"protocol"))
	{
		if(NULL != pbMetaStructure->lpValue)
		{
			return SetIMOProperty(m_FileTransferIMO, L"Protocol", pbMetaStructure->lpValue);
		}
	}
	else if(cmp(pbMetaStructure->lpParameter, L"sound"))
	{
		if(NULL != pbMetaStructure->lpValue)
		{
			int iStart = 0;
			if (wcslen(pbMetaStructure->lpValue) > wcslen(L"file://") &&
				wcsnicmp(pbMetaStructure->lpValue, L"file://", 7) == 0)
				iStart = 7;
			wcscpy(m_tcImagerSound, pbMetaStructure->lpValue + iStart);

			if ((pImager) && (pImager->DirectShowShutterClick()))
			{
				pImager->SetDirectShowShutterSound(m_tcImagerSound);
			}
		}
	}
	else if(cmp(pbMetaStructure->lpParameter, L"Enumerate"))
	{
		EnumImager(pImager);
	}
	else if (cmp(pbMetaStructure->lpParameter, L"desiredWidth"))
	{
		if (pbMetaStructure->lpValue)
			pImager->SetDesiredWidth(_wtoi(pbMetaStructure->lpValue));
	}
	else if (cmp(pbMetaStructure->lpParameter, L"desiredHeight"))
	{
		if (pbMetaStructure->lpValue)
			pImager->SetDesiredHeight(_wtoi(pbMetaStructure->lpValue));
	}

	return bRet;
}

////////////////////////////////////////////////////////////////////////
// Function:	CheckImagerOrCamera
// Description:	Checks if devName is valid imager or Color Camera devicename
//              if yes return TRUE and bFlag will be TRUE if it imager else it will be FALSE
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::CheckImagerOrCamera(LPCTSTR devName, BOOL *bFlag)
{
	//Check if device is available in List of imager and DShow camera
	BOOL bDevPresent=FALSE;
	PListDevName pRoot = g_ListDevName;

	if(pRoot)
	{
		do
		{
			if(cmp(devName, pRoot->DeviceName))
			{
				bDevPresent = TRUE;
				if(pRoot->bDeviceType)//Imager
				{
					(*bFlag) = TRUE;
				}
				else
					(*bFlag) = FALSE;
			}
			pRoot = pRoot->pNext;
		}while(pRoot != NULL);
	}

	return bDevPresent;
}
////////////////////////////////////////////////////////////////////////
// Function:	EnableImager
// Description:	Enables Imager device
//
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::EnableImager(CImager *pImager, LPCTSTR szDevicename)
{
	BOOL bFlag=FALSE;

	if(pImager == NULL)
	{
		Log(PB_LOG_ERROR,L"imager object does not exist",L"Imager",__LINE__);
		return FALSE;
	}
	//Check if it is empty then open default Imager IMG1:
	if(szDevicename!=NULL)
	{
		if(cmp(szDevicename,L""))
		{
			// use the default imager device if there is one
			if(CheckImagerOrCamera(L"IMG1:",&bFlag))
			{
				wcscpy(pImager->m_szDevName,L"IMG1:");//default device
			} // otherwise use the existing default (first device or last used device)
		}
		else
		{
			wcscpy(pImager->m_szDevName,szDevicename);//default device
			if (wcsncmp(pImager->m_szDevName,L"IMG",3) == 0)
			{
				pImager->m_szDevName[4]=L':';//Append ':' to device name
				pImager->m_szDevName[5]=L'\0';//Append null character to device name
			}
			else
			{
				wcscat(pImager->m_szDevName, L":\0");
			}
		}
	}
	else if (CheckImagerOrCamera(L"IMG1:",&bFlag)) 		// use the default imager device if there is one
		wcscpy(pImager->m_szDevName,L"IMG1:");//default device

	//Check if device is present on the terminal
	if(CheckImagerOrCamera(pImager->m_szDevName,&bFlag))//return TRue if device is present
	{	                                        //bFlag will be True if Camera else it will be false
	}
	else
	{//SR 17045
		//already an Imager is active cannot have two image capture device simultaneously
		//Log error here
		Log(PB_LOG_INFO,L"Unknown Imager Device",L"Imager",__LINE__);

		return FALSE;

	}

	//Default Initialize Imager
	if(pImager->m_hImager == INVALID_HANDLE_VALUE)//m_hImager = INVALID_HANDLE_VALUE;
	{
		if (pImager->InitImager()!= E_IMG_SUCCESS)
		{ Log(PB_LOG_ERROR,L"InitImager failed",L"Imager",__LINE__);
		};
	}

	// Imager is enabled so try to start it
	if (pImager->StartViewer() != E_IMG_SUCCESS)
	{
		PBModule::Log(PB_LOG_ERROR,L"StartViewer failed, retrying",L"Imager",__LINE__);
		// if we're switching between apps with the camera active this can happen
		// so retry a few times
		int i=0;
		do
		{
			if (++i >= 5)
			{
				PBModule::Log(PB_LOG_ERROR,L"StartViewer failed 5 times",L"Imager",__LINE__);
				return FALSE;
			}
			Sleep(100);
		} while (pImager->StartViewer() != E_IMG_SUCCESS);
	}

	m_bImgOn= TRUE;
	return TRUE;
}

////////////////////////////////////////////////////////////////////////
// Function:	EnableImager
// Description:	Enables Imager device
//
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::EnumImager(CImager *pImager)
{

	if(pImager->m_EnumIMGNav[0])//if navigation string is valid
	{
		//  Variable to hold the read attribute
		//TCHAR szImagers[MAXURL + 1];
		//  Aiming for :
		//		new Array(
		//		new Array(0, 1, 2),
		//		new Array(1, 2, 3)
		//		);
		memset(&pImager->tc_szImagers, 0, sizeof(pImager->tc_szImagers));
		wcscpy(pImager->tc_szImagers,L"new Array( ");

		PListDevName pRoot = g_ListDevName;

		while(pRoot != NULL)
		{
			//  Remove Comma from end of Device Name
			TCHAR tcModifiedDeviceName[50];
			wcscpy(tcModifiedDeviceName, pRoot->DeviceName);

			if (wcslen(tcModifiedDeviceName) > 0 &&
				tcModifiedDeviceName[wcslen(tcModifiedDeviceName) - 1] == L':')
				tcModifiedDeviceName[wcslen(tcModifiedDeviceName) - 1] = L'\0';

			wcscat(pImager->tc_szImagers, L"new Array('");
			wcscat(pImager->tc_szImagers, tcModifiedDeviceName);
			wcscat(pImager->tc_szImagers, L"','");
			wcscat(pImager->tc_szImagers, pRoot->DeviceFriendlyName);
			wcscat(pImager->tc_szImagers, L" ')");

			pRoot = pRoot->pNext;

			if(pRoot!=NULL)//if one more device is there then
				wcscat(pImager->tc_szImagers, L",");
		}
		wcscat(pImager->tc_szImagers, L")");

		//  Send the built array to the caller
		m_pImagerInst = pImager;
		CloseHandle(CreateThread (NULL, 0, SendNavigateURI, this, 0, NULL));

	}

	return 0;
}
/**
* \author	Ramanagouda
* \date		January 2010 (Initial Creation)
*/
DWORD CImagerMod::SendNavigateURI (LPVOID pparam)
{
	//  Parameter is a pointer to the notification object
	CImagerMod *pImagerMod = (CImagerMod *) pparam;

	if(pImagerMod->m_pImagerInst !=NULL)
		pImagerMod->SendPBNavigate(tcImagerEnumEventNames, pImagerMod->m_pImagerInst->m_iInstanceID,
			pImagerMod->m_pImagerInst->m_EnumIMGNav,
			pImagerMod->m_pImagerInst->tc_szImagers,
			NULL);

	//pImagerMod->m_pImagerInst = NULL;
	return 0;
}

////////////////////////////////////////////////////////////////////////
// Function:	onBeforeNavigate
// Description:	This Fucntion is a callback function invoked before navigating to new page
//
//
// Author:	    Ramanagouda S Patil(RSP)
// Date:	    JULY 2009
////////////////////////////////////////////////////////////////////////
BOOL CImagerMod::onBeforeNavigate(int iInstID)
{
	CImager *pImager;

	PBModule::Log(PB_LOG_DEBUG, L"Change of page for Imager", L"onNaviagtionEvent", __LINE__);

	// Look for app instance pointer of the currently focused app.
	pImager = (CImager *) GetObjFromID(iInstID);

	//MessageBox(NULL,L"onBeforeNavigate",L"Scanner",MB_OK);

	if (pImager != NULL)
	{
		//Reset Navigate String
		memset(pImager->m_EnumIMGNav, 0, wcslen(pImager->m_EnumIMGNav));

		//memset(m_IMGNav, 0, wcslen(m_IMGNav));

		if (m_bImgOn)
		{
			// Imager is disabled so stop it
			//  Request from SAP to make disabling during navigate configurable
			if (pImager->m_bDisableDuringNavigate)
				pImager->DeInit();
		}
	}
	if (pImager->m_bDisableDuringNavigate)
		m_bImgOn = FALSE;
	return TRUE;
}

//called from another thread
int CALLBACK CImagerMod::IMOCBFunc(PVARSTRUCT pVars,int iTABID,LPARAM lParam)
{
UNREFERENCED_PARAMETER(pVars);
UNREFERENCED_PARAMETER(iTABID);
UNREFERENCED_PARAMETER(lParam);
//	CImagerMod *pImgMod = (CImagerMod *)lParam;
	//do something with the Module object
	return IMO_PASS_ON;//allow the navigation to go through to Browser

}

BOOL CImagerMod::onRhoAppFocus(bool bActivate, int iInstID)
{
	CImager *pImager = (CImager *)GetObjFromID(iInstID);
	if (!pImager)
	{
		m_bAppHasFocus = bActivate;
		return FALSE;
	}

	if (!bActivate && m_bAppHasFocus)
	{
		// we're losing focus
		m_bAppHasFocus = false;
		if (m_bImgOn)
		{
			// Imager is disabled so stop it
			wcscpy(m_szBgImager, pImager->m_szDevName);
			m_bImgOn=FALSE;
			pImager->DeInit();
			Log(PB_LOG_DEBUG, L"Imager disabled", L"Imager",__LINE__);
		}
		else
		{
			m_szBgImager[0] = L'\0';
		}
		return TRUE;
	}
	else if (bActivate && !m_bAppHasFocus)
	{
		// we've regained focus
		m_bAppHasFocus = true;

		if (m_szBgImager[0] != L'\0')
		{
			// we need to re-enable the imager, but we can't do it from this thread - we
			// need to send an ONMETA message back to the core to enable the correct imager
			// from our MetaProc on the main thread
			if (m_szBgImager[wcslen(m_szBgImager)-1] == L':')
				m_szBgImager[wcslen(m_szBgImager)-1] = L'\0';
			EngineMETATag tag;
			tag.tcHTTPEquiv = L"Imager";
			WCHAR contents[50];
			wsprintf(contents, L"Enabled:%s", m_szBgImager);
			tag.tcContents = contents;
			SendMessage(m_pCoreStructure->hParentWnd,PB_ONMETA,(WPARAM)iInstID,(LPARAM)&tag);
		}
		return TRUE;
	}
	return FALSE;
};


text:
package org.apache.fontbox.cff;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;

import org.junit.jupiter.api.Test;

class DataInputTest
{
    @Test
    void testReadBytes() throws IOException
    {
        byte[] data = new byte[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 };
        DataInput dataInput = new DataInputByteArray(data);
        assertThrows(IOException.class, () -> dataInput.readBytes(20));
        assertArrayEquals(new byte[] { 0 }, dataInput.readBytes(1));
        assertArrayEquals(new byte[] { -1, 2, -3 }, dataInput.readBytes(3));
        dataInput.setPosition(6);
        assertArrayEquals(new byte[] { 6, -7, 8 }, dataInput.readBytes(3));
        assertThrows(IOException.class, () -> dataInput.readBytes(-1));
        assertThrows(IOException.class, () -> dataInput.readBytes(5));
    }

    @Test
    void testReadByte() throws IOException
    {
        byte[] data = new byte[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals(0, dataInput.readByte());
        assertEquals(-1, dataInput.readByte());
        dataInput.setPosition(6);
        assertEquals(6, dataInput.readByte());
        assertEquals(-7, dataInput.readByte());
        dataInput.setPosition(dataInput.length() - 1);
        assertEquals(-9, dataInput.readByte());
        assertThrows(IOException.class, () -> dataInput.readByte());
    }

    @Test
    void testReadUnsignedByte() throws IOException
    {
        byte[] data = new byte[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals(0, dataInput.readUnsignedByte());
        assertEquals(255, dataInput.readUnsignedByte());
        dataInput.setPosition(6);
        assertEquals(6, dataInput.readUnsignedByte());
        assertEquals(249, dataInput.readUnsignedByte());
        dataInput.setPosition(dataInput.length() - 1);
        assertEquals(247, dataInput.readUnsignedByte());
        assertThrows(IOException.class, () -> dataInput.readUnsignedByte());
    }

    @Test
    void testBasics() throws IOException
    {
        byte[] data = new byte[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals(10, dataInput.length());
        assertTrue(dataInput.hasRemaining());
        assertThrows(IOException.class, () -> dataInput.setPosition(-1));
        int length = dataInput.length();
        assertThrows(IOException.class, () -> dataInput.setPosition(length));
    }

    @Test
    void testPeek() throws IOException
    {
        byte[] data = new byte[] { 0, -1, 2, -3, 4, -5, 6, -7, 8, -9 };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals(0, dataInput.peekUnsignedByte(0));
        assertEquals(251, dataInput.peekUnsignedByte(5));
        assertThrows(IOException.class, () -> dataInput.peekUnsignedByte(-1));
        int length = dataInput.length();
        assertThrows(IOException.class, () -> dataInput.peekUnsignedByte(length));
    }

    @Test
    void testReadShort() throws IOException
    {
        byte[] data = new byte[] { 0x00, 0x0F, (byte) 0xAA, 0, (byte) 0xFE, (byte) 0xFF };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals((short) 0x000F, dataInput.readShort());
        assertEquals((short) 0xAA00, dataInput.readShort());
        assertEquals((short) 0xFEFF, dataInput.readShort());
        assertThrows(IOException.class, () -> dataInput.readShort());
    }

    @Test
    void testReadUnsignedShort() throws IOException
    {
        byte[] data = new byte[] { 0x00, 0x0F, (byte) 0xAA, 0, (byte) 0xFE, (byte) 0xFF };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals(0x000F, dataInput.readUnsignedShort());
        assertEquals(0xAA00, dataInput.readUnsignedShort());
        assertEquals(0xFEFF, dataInput.readUnsignedShort());
        assertThrows(IOException.class, () -> dataInput.readUnsignedShort());

        byte[] data2 = new byte[] { 0x00 };
        DataInput dataInput2 = new DataInputByteArray(data2);
        assertThrows(IOException.class, () -> dataInput2.readUnsignedShort());
    }

    @Test
    void testReadInt() throws IOException
    {
        byte[] data = new byte[] { 0x00, 0x0F, (byte) 0xAA, 0, (byte) 0xFE, (byte) 0xFF, 0x30,
                0x50 };
        DataInput dataInput = new DataInputByteArray(data);
        assertEquals(0x000FAA00, dataInput.readInt());
        assertEquals(0xFEFF3050, dataInput.readInt());
        assertThrows(IOException.class, () -> dataInput.readInt());

        byte[] data2 = new byte[] { 0x00, 0x0F, (byte) 0xAA };
        DataInput dataInput2 = new DataInputByteArray(data2);
        assertThrows(IOException.class, () -> dataInput2.readInt());

    }
}