text:
//Copyright © 2014 Sony Computer Entertainment America LLC. See License.txt.

using System.Collections;
using System.Collections.Generic;
using System.Drawing;

namespace Sce.Atf.Controls.Adaptable.Graphs
{
    ///
    /// Class for missing circuit element type
    public class MissingElementType : ICircuitElementType
    {
        ///
        /// Constructor with name
        /// <param name="name">Name</param>
        public MissingElementType(  string name)
        {
            Name = name;
        }

        ///
        /// Get missing element name
        public string Name { get; private set; }

        ///
        /// Get missing element interior size
        public Size InteriorSize
        {
            get { return (Image != null) ? new Size(Image.Width + 18, Image.Height +18) : new Size(); }
        }

        ///
        /// Get missing element image
        public Image Image { get;  set; }

        ///
        /// Get missing element input pins
        public IList<ICircuitPin> Inputs
        {
            get { return m_inputs; }
        }

        ///
        /// Get missing element output pins
        public IList<ICircuitPin> Outputs
        {
            get
            {
                return m_outputs;
            }
        }

        private MissingPinList m_inputs = new MissingPinList("In");
        private MissingPinList m_outputs = new MissingPinList("Out");

        private class MissingPinList : IList<ICircuitPin>
        {
            public MissingPinList(string name)
            {
                m_missingPin = new MissingPin(name, "MissingPin", 0);
            }

            public IEnumerator<ICircuitPin> GetEnumerator()
            {
                for (int i=0;  i< Count; ++i)
                    yield return m_missingPin;
            }

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

            public void Add(ICircuitPin item)
            {
                //throw new System.NotImplementedException();
            }

            public void Clear()
            {
                //throw new System.NotImplementedException();
            }

            public bool Contains(ICircuitPin item)
            {
                //throw new System.NotImplementedException();
                return false;
            }

            public void CopyTo(ICircuitPin[] array, int arrayIndex)
            {
                //throw new System.NotImplementedException();
            }

            public bool Remove(ICircuitPin item)
            {
                //throw new System.NotImplementedException();
                return false;
            }

            public int Count
            {
                get { return m_count; }
            }
            public bool IsReadOnly { get; private set; }
            public int IndexOf(ICircuitPin item)
            {
                throw new System.NotImplementedException();
            }

            public void Insert(int index, ICircuitPin item)
            {
                //throw new System.NotImplementedException();
            }

            public void RemoveAt(int index)
            {
                //throw new System.NotImplementedException();
            }

            public ICircuitPin this[int index]
            {
                get
                {
					// dynamically update count
                    if (index + 1 > m_count)
                        m_count = index + 1;
                    return m_missingPin;
                }
                set { throw new System.NotImplementedException(); }
            }

            private MissingPin m_missingPin;
            private int m_count;
        }

        ///
        /// Pin for an ElementType
        public class MissingPin : ICircuitPin
        {
            ///
            /// Constructor specifying Pin type's attributes
            /// <param name="name">Pin's name</param>
            /// <param name="typeName">Pin's type's name</param>
            /// <param name="index">Index of pin on module</param>
            public MissingPin(string name, string typeName, int index)
            {
                m_name = name;
                m_typeName = typeName;
                m_index = index;
            }

            ///
            /// Gets pin's name
            public string Name
            {
                get { return m_name; }
            }

            ///
            /// Gets pin's type's name
            public string TypeName
            {
                get { return m_typeName; }
            }

            ///
            /// Gets index of pin on module
            public int Index
            {
                get { return m_index; }
            }

            ///
            /// Gets whether connection fan in to pin is allowed
            public bool AllowFanIn
            {
                get { return true; }
            }

            ///
            /// Gets whether connection fan out from pin is allowed
            public bool AllowFanOut
            {
                get { return true; }
            }

            private string m_name;
            private string m_typeName;
            private int m_index;
        }
    }
}


text:
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ValveResourceFormat.Blocks
{
    /// <summary>
    /// "NTRO" block. CResourceIntrospectionManifest.
    /// </summary>
    public class ResourceIntrospectionManifest : Block
    {
        public override BlockType Type => BlockType.NTRO;

        public class ResourceDiskStruct
        {
            public class Field
            {
                public string FieldName { get; set; }
                public short Count { get; set; }
                public short OnDiskOffset { get; set; }
                public List<byte> Indirections { get; private set; }
                public uint TypeData { get; set; }
                public DataType Type { get; set; } // TODO: make this an enum?

                public Field()
                {
                    Indirections = new List<byte>();
                }

                public void WriteText(IndentedTextWriter writer)
                {
                    writer.WriteLine("CResourceDiskStructField");
                    writer.WriteLine("{");
                    writer.Indent++;
                    writer.WriteLine("CResourceString m_pFieldName = \"{0}\"", FieldName);
                    writer.WriteLine("int16 m_nCount = {0}", Count);
                    writer.WriteLine("int16 m_nOnDiskOffset = {0}", OnDiskOffset);

                    writer.WriteLine("uint8[{0}] m_Indirection =", Indirections.Count);
                    writer.WriteLine("[");
                    writer.Indent++;

                    foreach (var dep in Indirections)
                    {
                        writer.WriteLine("{0:D2}", dep);
                    }

                    writer.Indent--;
                    writer.WriteLine("]");

                    writer.WriteLine("uint32 m_nTypeData = 0x{0:X8}", TypeData);
                    writer.WriteLine("int16 m_nType = {0}", (int)Type);
                    writer.Indent--;
                    writer.WriteLine("}");
                }
            }

            public uint IntrospectionVersion { get; set; }
            public uint Id { get; set; }
            public string Name { get; set; }
            public uint DiskCrc { get; set; }
            public int UserVersion { get; set; }
            public ushort DiskSize { get; set; }
            public ushort Alignment { get; set; }
            public uint BaseStructId { get; set; }
            public byte StructFlags { get; set; }
            public List<Field> FieldIntrospection { get; private set; }

            public ResourceDiskStruct()
            {
                FieldIntrospection = new List<Field>();
            }

            public void WriteText(IndentedTextWriter writer)
            {
                writer.WriteLine("CResourceDiskStruct");
                writer.WriteLine("{");
                writer.Indent++;
                writer.WriteLine("uint32 m_nIntrospectionVersion = 0x{0:X8}", IntrospectionVersion);
                writer.WriteLine("uint32 m_nId = 0x{0:X8}", Id);
                writer.WriteLine("CResourceString m_pName = \"{0}\"", Name);
                writer.WriteLine("uint32 m_nDiskCrc = 0x{0:X8}", DiskCrc);
                writer.WriteLine("int32 m_nUserVersion = {0}", UserVersion);
                writer.WriteLine("uint16 m_nDiskSize = 0x{0:X4}", DiskSize);
                writer.WriteLine("uint16 m_nAlignment = 0x{0:X4}", Alignment);
                writer.WriteLine("uint32 m_nBaseStructId = 0x{0:X8}", BaseStructId);

                writer.WriteLine("Struct m_FieldIntrospection[{0}] =", FieldIntrospection.Count);
                writer.WriteLine("[");
                writer.Indent++;

                foreach (var field in FieldIntrospection)
                {
                    field.WriteText(writer);
                }

                writer.Indent--;
                writer.WriteLine("]");
                writer.WriteLine("uint8 m_nStructFlags = 0x{0:X2}", StructFlags);
                writer.Indent--;
                writer.WriteLine("}");
            }
        }

        public class ResourceDiskEnum
        {
            public class Value
            {
                public string EnumValueName { get; set; }
                public int EnumValue { get; set; }

                public void WriteText(IndentedTextWriter writer)
                {
                    writer.WriteLine("CResourceDiskEnumValue");
                    writer.WriteLine("{");
                    writer.Indent++;
                    writer.WriteLine("CResourceString m_pEnumValueName = \"{0}\"", EnumValueName);
                    writer.WriteLine("int32 m_nEnumValue = {0}", EnumValue);
                    writer.Indent--;
                    writer.WriteLine("}");
                }
            }

            public uint IntrospectionVersion { get; set; }
            public uint Id { get; set; }
            public string Name { get; set; }
            public uint DiskCrc { get; set; }
            public int UserVersion { get; set; }
            public List<Value> EnumValueIntrospection { get; private set; }

            public ResourceDiskEnum()
            {
                EnumValueIntrospection = new List<Value>();
            }

            public void WriteText(IndentedTextWriter writer)
            {
                writer.WriteLine("CResourceDiskEnum");
                writer.WriteLine("{");
                writer.Indent++;
                writer.WriteLine("uint32 m_nIntrospectionVersion = 0x{0:X8}", IntrospectionVersion);
                writer.WriteLine("uint32 m_nId = 0x{0:X8}", Id);
                writer.WriteLine("CResourceString m_pName = \"{0}\"", Name);
                writer.WriteLine("uint32 m_nDiskCrc = 0x{0:X8}", DiskCrc);
                writer.WriteLine("int32 m_nUserVersion = {0}", UserVersion);

                writer.WriteLine("Struct m_EnumValueIntrospection[{0}] =", EnumValueIntrospection.Count);
                writer.WriteLine("[");
                writer.Indent++;

                foreach (var value in EnumValueIntrospection)
                {
                    value.WriteText(writer);
                }

                writer.Indent--;
                writer.WriteLine("]");
                writer.Indent--;
                writer.WriteLine("}");
            }
        }

        public uint IntrospectionVersion { get; private set; }

        public List<ResourceDiskStruct> ReferencedStructs { get; }
        public List<ResourceDiskEnum> ReferencedEnums { get; }

        public ResourceIntrospectionManifest()
        {
            ReferencedStructs = new List<ResourceDiskStruct>();
            ReferencedEnums = new List<ResourceDiskEnum>();
        }

        public override void Read(BinaryReader reader, Resource resource)
        {
            reader.BaseStream.Position = Offset;

            IntrospectionVersion = reader.ReadUInt32();

            ReadStructs(reader);

            reader.BaseStream.Position = Offset + 12; // skip 3 ints

            ReadEnums(reader);
        }

        private void ReadStructs(BinaryReader reader)
        {
            var entriesOffset = reader.ReadUInt32();
            var entriesCount = reader.ReadUInt32();

            if (entriesCount == 0)
            {
                return;
            }

            reader.BaseStream.Position += entriesOffset - 8; // offset minus 2 ints we just read

            for (var i = 0; i < entriesCount; i++)
            {
                var diskStruct = new ResourceDiskStruct
                {
                    IntrospectionVersion = reader.ReadUInt32(),
                    Id = reader.ReadUInt32(),
                    Name = reader.ReadOffsetString(Encoding.UTF8),
                    DiskCrc = reader.ReadUInt32(),
                    UserVersion = reader.ReadInt32(),
                    DiskSize = reader.ReadUInt16(),
                    Alignment = reader.ReadUInt16(),
                    BaseStructId = reader.ReadUInt32()
                };

                var fieldsOffset = reader.ReadUInt32();
                var fieldsSize = reader.ReadUInt32();

                // jump to fields
                if (fieldsSize > 0)
                {
                    var prev = reader.BaseStream.Position;
                    reader.BaseStream.Position += fieldsOffset - 8; // offset minus 2 ints we just read

                    for (var y = 0; y < fieldsSize; y++)
                    {
                        var field = new ResourceDiskStruct.Field
                        {
                            FieldName = reader.ReadOffsetString(Encoding.UTF8),
                            Count = reader.ReadInt16(),
                            OnDiskOffset = reader.ReadInt16()
                        };

                        var indirectionOffset = reader.ReadUInt32();
                        var indirectionSize = reader.ReadUInt32();

                        if (indirectionSize > 0)
                        {
                            // jump to indirections
                            var prev2 = reader.BaseStream.Position;
                            reader.BaseStream.Position += indirectionOffset - 8; // offset minus 2 ints we just read

                            for (var x = 0; x < indirectionSize; x++)
                            {
                                field.Indirections.Add(reader.ReadByte());
                            }

                            reader.BaseStream.Position = prev2;
                        }

                        field.TypeData = reader.ReadUInt32();
                        field.Type = (DataType)reader.ReadInt16();

                        reader.ReadBytes(2); // TODO: ????

                        diskStruct.FieldIntrospection.Add(field);
                    }

                    reader.BaseStream.Position = prev;
                }

                diskStruct.StructFlags = reader.ReadByte();

                reader.ReadBytes(3); // TODO: ????

                ReferencedStructs.Add(diskStruct);
            }
        }

        private void ReadEnums(BinaryReader reader)
        {
            var entriesOffset = reader.ReadUInt32();
            var entriesCount = reader.ReadUInt32();

            if (entriesCount == 0)
            {
                return;
            }

            reader.BaseStream.Position += entriesOffset - 8; // offset minus 2 ints we just read

            for (var i = 0; i < entriesCount; i++)
            {
                var diskEnum = new ResourceDiskEnum
                {
                    IntrospectionVersion = reader.ReadUInt32(),
                    Id = reader.ReadUInt32(),
                    Name = reader.ReadOffsetString(Encoding.UTF8),
                    DiskCrc = reader.ReadUInt32(),
                    UserVersion = reader.ReadInt32()
                };

                var fieldsOffset = reader.ReadUInt32();
                var fieldsSize = reader.ReadUInt32();

                // jump to fields
                if (fieldsSize > 0)
                {
                    var prev = reader.BaseStream.Position;
                    reader.BaseStream.Position += fieldsOffset - 8; // offset minus 2 ints we just read

                    for (var y = 0; y < fieldsSize; y++)
                    {
                        var field = new ResourceDiskEnum.Value
                        {
                            EnumValueName = reader.ReadOffsetString(Encoding.UTF8),
                            EnumValue = reader.ReadInt32()
                        };

                        diskEnum.EnumValueIntrospection.Add(field);
                    }

                    reader.BaseStream.Position = prev;
                }

                ReferencedEnums.Add(diskEnum);
            }
        }

        public override void WriteText(IndentedTextWriter writer)
        {
            writer.WriteLine("CResourceIntrospectionManifest");
            writer.WriteLine("{");
            writer.Indent++;

            writer.WriteLine("uint32 m_nIntrospectionVersion = 0x{0:x8}", IntrospectionVersion);
            writer.WriteLine("Struct m_ReferencedStructs[{0}] =", ReferencedStructs.Count);
            writer.WriteLine("[");
            writer.Indent++;

            foreach (var refStruct in ReferencedStructs)
            {
                refStruct.WriteText(writer);
            }

            writer.Indent--;
            writer.WriteLine("]");

            writer.WriteLine("Struct m_ReferencedEnums[{0}] =", ReferencedEnums.Count);
            writer.WriteLine("[");
            writer.Indent++;

            foreach (var refEnum in ReferencedEnums)
            {
                refEnum.WriteText(writer);
            }

            writer.Indent--;
            writer.WriteLine("]");

            writer.Indent--;
            writer.WriteLine("}");
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package org.openntf.domino.design.impl;

import org.openntf.domino.Document;

/**
 * @author Roland Praml
 *
 */
public class SharedField extends AbstractDesignBaseNamed implements org.openntf.domino.design.SharedField {
	private static final long serialVersionUID = 1L;

	/**
	 * @param document
	 */
	protected SharedField(final Document document) {
		super(document);
	}

	@Override
	protected boolean enforceRawFormat() {
		return false;
	}

}


text:
.navbar-default .navbar-nav li a:hover{
    background-color: #777;
}

.meu-input-group{
    margin-bottom: 10px;
}

.meu-grupo-addon{
    border-radius: 3px !important;
    border: 1px solid #CCC !important;
}

.espaco-radio{
    margin: 3px 0;
}


text:
<!DOCTYPE html>

		<title>Documentation of {{className}}</title>
		<link rel="stylesheet" href="../../../../../../../styles/dbm/documentation/main.css" />
		<link rel="stylesheet" href="../../../../../../../styles/dbm/documentation/class.css" />

Dbm documentation

						Index

						<form action="https://www.google.co.uk/cse/publicurl" method="GET">
							<input type="hidden" name="cx" value="006746230495882673940:ilr36kbyhjo" />
							<input type="text" name="q" value="" />
						</form>

TimelineEncoder

dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder

EncodingBaseObject > BaseObject

Subclasses

Class has no subclasses.

Dependencies

ErrorManager, ReportLevelTypes, ReportTypes

Import code

var TimelineEncoder = dbm.importClass("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder");

Full code

dbm.registerClass("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder", "dbm.core.globalobjects.xmlobjectencoder.encoders.EncodingBaseObject", function(objectFunctions, staticFunctions, ClassReference) {
	//console.log("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder");

	//Self reference
	var TimelineEncoder = dbm.importClass("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder");

	//Error report
	var ErrorManager = dbm.importClass("dbm.core.globalobjects.errormanager.ErrorManager");
	var ReportTypes = dbm.importClass("dbm.constants.ReportTypes");
	var ReportLevelTypes = dbm.importClass("dbm.constants.ReportLevelTypes");

	//Dependencies

	//Utils

	//Constants

	/**
	 * Constructor
	 */
	objectFunctions._init = function() {
		//console.log("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder::_init");

		this.superCall();

		return this;
	};

	objectFunctions._encodeValue = function(aValue, aNode) {
		//console.log("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder::_encodeValue");

		this.superCall(aValue, aNode);

		var partsNode = dbm.singletons.dbmXmlObjectEncoder.encodeValue(aValue._parts, aNode); //METODO: fix so that it doesn't have to access private variable
		partsNode.name = "parts";
		partsNode.parentApplyType = "timeline/applyParts";
	};

	staticFunctions.create = function() {
		var newTimelineEncoder = ClassReference._createAndInitClass(ClassReference);

		newTimelineEncoder.addVariableToEncode("startTime");
		newTimelineEncoder.addVariableToEncode("endTime");
		newTimelineEncoder.addVariableToEncode("startApplyTime");
		newTimelineEncoder.addVariableToEncode("endApplyTime");
		newTimelineEncoder.addPropertyToEncode("startValue");

		return newTimelineEncoder;
	};
})

Local variables

Local functions

					_init():self

Constructor

Arguments

Function has no arguments

Return value

Self. Function is linkable.

Full code

objectFunctions._init = function() {
		//console.log("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder::_init");

		this.superCall();

		return this;
	}

					_encodeValue(aValue, aNode):void

Arguments

aValue

aNode

Return value

Function has no return value.

Full code

objectFunctions._encodeValue = function(aValue, aNode) {
		//console.log("dbm.core.globalobjects.xmlobjectencoder.encoders.timeline.TimelineEncoder::_encodeValue");

		this.superCall(aValue, aNode);

		var partsNode = dbm.singletons.dbmXmlObjectEncoder.encodeValue(aValue._parts, aNode); //METODO: fix so that it doesn't have to access private variable
		partsNode.name = "parts";
		partsNode.parentApplyType = "timeline/applyParts";
	}

Static variables

Static functions

					create():Unknown

Arguments

Function has no arguments

Return value

Unknown

Full code

staticFunctions.create = function() {
		var newTimelineEncoder = ClassReference._createAndInitClass(ClassReference);

		newTimelineEncoder.addVariableToEncode("startTime");
		newTimelineEncoder.addVariableToEncode("endTime");
		newTimelineEncoder.addVariableToEncode("startApplyTime");
		newTimelineEncoder.addVariableToEncode("endApplyTime");
		newTimelineEncoder.addPropertyToEncode("startValue");

		return newTimelineEncoder;
	}

				Documentation exported with dbm.


text:
View the slides at [http://asheshwor.github.io/innolab](http://asheshwor.github.io/innolab/#/)

Recommended browsers: Chrome, Safari, Firefox, Opera and IE10

### License for Reveal.js framework

This repository contains the code of [Reveal.js](https://github.com/hakimel/reveal.js) licensed under the [MIT license](https://github.com/asheshwor/ca2014/blob/master/LICENSE).


text:
package org.keycloak.exportimport.util;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.jboss.logging.Logger;
import org.keycloak.Config;
import org.keycloak.exportimport.ExportImportConfig;
import org.keycloak.exportimport.Strategy;
import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RealmProvider;
import org.keycloak.models.utils.RealmImporter;
import org.keycloak.models.utils.RepresentationToModel;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserRepresentation;

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

/**
 * @author Marek Posolda
 */
public class ImportUtils {

    private static final Logger logger = Logger.getLogger(ImportUtils.class);

    public static void importRealms(KeycloakSession session, Collection<RealmRepresentation> realms, Strategy strategy) {
        // Import admin realm first
        for (RealmRepresentation realm : realms) {
            if (Config.getAdminRealm().equals(realm.getRealm())) {
                importRealm(session, realm, strategy);
            }
        }

        for (RealmRepresentation realm : realms) {
            if (!Config.getAdminRealm().equals(realm.getRealm())) {
                importRealm(session, realm, strategy);
            }
        }
    }

    /**
     * Fully import realm from representation, save it to model and return model of newly created realm
     *
     * @param session
     * @param rep
     * @param strategy specifies whether to overwrite or ignore existing realm or user entries
     * @return newly imported realm (or existing realm if ignoreExisting is true and realm of this name already exists)
     */
    public static void importRealm(KeycloakSession session, RealmRepresentation rep, Strategy strategy) {
        String realmName = rep.getRealm();
        RealmProvider model = session.realms();
        RealmModel realm = model.getRealmByName(realmName);

        if (realm != null) {
            if (strategy == Strategy.IGNORE_EXISTING) {
                logger.infof("Realm '%s' already exists. Import skipped", realmName);
                return;
            } else {
                logger.infof("Realm '%s' already exists. Removing it before import", realmName);
                if (Config.getAdminRealm().equals(realm.getId())) {
                    // Delete all masterAdmin apps due to foreign key constraints
                    for (RealmModel currRealm : model.getRealms()) {
                        currRealm.setMasterAdminClient(null);
                    }
                }
                // TODO: For migration between versions, it should be possible to delete just realm but keep it's users
                model.removeRealm(realm.getId());
            }
        }

        RealmImporter realmManager = session.getContext().getRealmManager();
        realm = realmManager.importRealm(rep);

        if (System.getProperty(ExportImportConfig.ACTION) != null) {
            logger.infof("Realm '%s' imported", realmName);
        }

        return;
    }

    /**
     * Fully import realm (or more realms from particular stream)
     *
     * @param session
     * @param mapper
     * @param is
     * @param strategy
     * @throws IOException
     */
    public static void importFromStream(KeycloakSession session, ObjectMapper mapper, InputStream is, Strategy strategy) throws IOException {
        Map<String, RealmRepresentation> realmReps = getRealmsFromStream(mapper, is);
        importRealms(session, realmReps.values(), strategy);
    }

    public static Map<String, RealmRepresentation> getRealmsFromStream(ObjectMapper mapper, InputStream is) throws IOException {
        Map<String, RealmRepresentation> result = new HashMap<String, RealmRepresentation>();

        JsonFactory factory = mapper.getFactory();
        JsonParser parser = factory.createParser(is);
        try {
            parser.nextToken();

            if (parser.getCurrentToken() == JsonToken.START_ARRAY) {
                // Case with more realms in stream
                parser.nextToken();

                List<RealmRepresentation> realmReps = new ArrayList<RealmRepresentation>();
                while (parser.getCurrentToken() == JsonToken.START_OBJECT) {
                    RealmRepresentation realmRep = parser.readValueAs(RealmRepresentation.class);
                    parser.nextToken();

                    // Ensure that master realm is imported first
                    if (Config.getAdminRealm().equals(realmRep.getRealm())) {
                        realmReps.add(0, realmRep);
                    } else {
                        realmReps.add(realmRep);
                    }
                }

                for (RealmRepresentation realmRep : realmReps) {
                    result.put(realmRep.getRealm(), realmRep);
                }
            } else if (parser.getCurrentToken() == JsonToken.START_OBJECT) {
                // Case with single realm in stream
                RealmRepresentation realmRep = parser.readValueAs(RealmRepresentation.class);
                result.put(realmRep.getRealm(), realmRep);
            }
        } finally {
            parser.close();
        }

        return result;
    }

    // Assuming that it's invoked inside transaction
    public static void importUsersFromStream(KeycloakSession session, String realmName, ObjectMapper mapper, InputStream is) throws IOException {
        RealmProvider model = session.realms();
        JsonFactory factory = mapper.getJsonFactory();
        JsonParser parser = factory.createJsonParser(is);
        try {
            parser.nextToken();

            while (parser.nextToken() == JsonToken.FIELD_NAME) {
                if ("realm".equals(parser.getText())) {
                    parser.nextToken();
                    String currRealmName = parser.getText();
                    if (!currRealmName.equals(realmName)) {
                        throw new IllegalStateException("Trying to import users into invalid realm. Realm name: " + realmName + ", Expected realm name: " + currRealmName);
                    }
                } else if ("users".equals(parser.getText())) {
                    parser.nextToken();

                    if (parser.getCurrentToken() == JsonToken.START_ARRAY) {
                        parser.nextToken();
                    }

                    // TODO: support for more transactions per single users file (if needed)
                    List<UserRepresentation> userReps = new ArrayList<UserRepresentation>();
                    while (parser.getCurrentToken() == JsonToken.START_OBJECT) {
                        UserRepresentation user = parser.readValueAs(UserRepresentation.class);
                        userReps.add(user);
                        parser.nextToken();
                    }

                    importUsers(session, model, realmName, userReps);

                    if (parser.getCurrentToken() == JsonToken.END_ARRAY) {
                        parser.nextToken();
                    }
                }
            }
        } finally {
            parser.close();
        }
    }

    private static void importUsers(KeycloakSession session, RealmProvider model, String realmName, List<UserRepresentation> userReps) {
        RealmModel realm = model.getRealmByName(realmName);
        Map<String, ClientModel> apps = realm.getClientNameMap();
        for (UserRepresentation user : userReps) {
            RepresentationToModel.createUser(session, realm, user, apps);
        }
    }

}


text:
package org.spongepowered.common.data.manipulator.mutable.block;

import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.immutable.block.ImmutableSeamlessData;
import org.spongepowered.api.data.manipulator.mutable.block.SeamlessData;
import org.spongepowered.api.data.value.mutable.Value;
import org.spongepowered.common.data.manipulator.immutable.block.ImmutableSpongeSeamlessData;
import org.spongepowered.common.data.manipulator.mutable.common.AbstractBooleanData;
import org.spongepowered.common.data.value.mutable.SpongeValue;

public class SpongeSeamlessData extends AbstractBooleanData<SeamlessData, ImmutableSeamlessData> implements SeamlessData {

    public SpongeSeamlessData(boolean value) {
        super(SeamlessData.class, value, Keys.SEAMLESS, ImmutableSpongeSeamlessData.class);
    }

    @Override
    public Value<Boolean> seamless() {
        return new SpongeValue<>(Keys.SEAMLESS, this.getValue());
    }

    @Override
    protected Value<?> getValueGetter() {
        return seamless();
    }
}


text:
DELIMITER ;;

CREATE TRIGGER on_delete_experiment BEFORE DELETE ON experiment
for each row begin
  DELETE FROM experiment_rollup WHERE experiment_id=OLD.id;
  DELETE FROM event_impression WHERE experiment_id=OLD.id;
  DELETE FROM event_action WHERE experiment_id=OLD.id;
  DELETE FROM bucket WHERE experiment_id=OLD.id;
end ;;

DELIMITER ;


text:
using Microsoft.CodeAnalysis.Editor.Shared.Tagging;

namespace Microsoft.CodeAnalysis.Editor.Implementation.ReferenceHighlighting
{
    internal class WrittenReferenceHighlightTag : AbstractNavigatableReferenceHighlightingTag
    {
        internal const string TagId = "MarkerFormatDefinition/HighlightedWrittenReference";

        public static readonly WrittenReferenceHighlightTag Instance = new WrittenReferenceHighlightTag();

        private WrittenReferenceHighlightTag()
            : base(TagId)
        {
        }
    }
}


text: from .models import IEntropySearchModel  # noqa: F401


text:
FROM nginx

#Install Curl
RUN apt-get update -qq && apt-get -y install curl

#Download and Install Consul Template
ENV CT_URL https://github.com/hashicorp/consul-template/releases/download/v0.10.0/consul-template_0.10.0_linux_amd64.tar.gz
RUN curl -L $CT_URL | tar -C /usr/local/bin --strip-components 1 -zxf -

#Setup Consul Template Files
RUN mkdir /etc/consul-templates
ENV CT_FILE /etc/consul-templates/nginx.conf

#Setup Nginx File
ENV NX_FILE /etc/nginx/conf.d/app.conf

#Default Variables
ENV CONSUL consul:8500
ENV SERVICE consul-8500
ENV REVERSE ""
ENV METHOD "least_conn;"
ENV PROTOCOL "http"
# Command will
# 1. Write Consul Template File
# 2. Start Nginx
# 3. Start Consul Template

CMD echo "" > /etc/nginx/conf.d/app.conf;

CMD echo "upstream app {                 \n\
  $METHOD                                \n\
  {{range service \"$SERVICE\"}}         \n\
  server  {{.Address}}:{{.Port}};        \n\
  {{else}}server 127.0.0.1:65535;{{end}} \n\
}                                        \n\
server {                                 \n\
  location /$REVERSE {                   \n\
    proxy_pass $PROTOCOL://app;          \n\
    rewrite  ^/$REVERSE(.*)  /\$1 break; \n\
    proxy_set_header   Host \$host;      \n\
  }                                      \n\
}" > $CT_FILE; \
/usr/sbin/nginx -c /etc/nginx/nginx.conf \
& CONSUL_TEMPLATE_LOG=debug consul-template \
  -consul=$CONSUL \
  -template "$CT_FILE:$NX_FILE:/usr/sbin/nginx -s reload";


text:
package proxy

import (
	"context"
	"errors"

	logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
	loggables "gx/ipfs/QmTMy4hVSY28DdwJ9kBz6y7q6MuioFzPcpM3Ma3aPjo1i3/go-libp2p-loggables"
	kbucket "gx/ipfs/QmUKePKcUEXwdvJENZJ6z8mJjPaxLsDZ3V9CZjPPtyawPm/go-libp2p-kbucket"
	pstore "gx/ipfs/QmXXCcQ7CLg5a81Ui9TTR35QcR4y7ZyihxwfjqaHfUVcVo/go-libp2p-peerstore"
	ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io"
	dhtpb "gx/ipfs/QmaWzyiqs7sUayh2G1EaovupWrA1qdKXqRMYA97ruU1xS5/go-libp2p-kad-dht/pb"
	host "gx/ipfs/QmdML3R42PRSwnt46jSuEts9bHSqLctVYEjJqMR3UYV8ki/go-libp2p-host"
	inet "gx/ipfs/QmdXimY9QHaasZmw6hWojWnCJvfgxETjZQfg9g6ZrA9wMX/go-libp2p-net"
	peer "gx/ipfs/QmfMmLGoKzCHDN7cGgk64PJr4iipzidDRME8HABSJqvmhC/go-libp2p-peer"
)

const ProtocolSNR = "/ipfs/supernoderouting"

var log = logging.Logger("supernode/proxy")

type Proxy interface {
	Bootstrap(context.Context) error
	HandleStream(inet.Stream)
	SendMessage(ctx context.Context, m *dhtpb.Message) error
	SendRequest(ctx context.Context, m *dhtpb.Message) (*dhtpb.Message, error)
}

type standard struct {
	Host host.Host

	remoteInfos []pstore.PeerInfo // addr required for bootstrapping
	remoteIDs   []peer.ID         // []ID is required for each req. here, cached for performance.
}

func Standard(h host.Host, remotes []pstore.PeerInfo) Proxy {
	var ids []peer.ID
	for _, remote := range remotes {
		ids = append(ids, remote.ID)
	}
	return &standard{h, remotes, ids}
}

func (px *standard) Bootstrap(ctx context.Context) error {
	var cxns []pstore.PeerInfo
	for _, info := range px.remoteInfos {
		if err := px.Host.Connect(ctx, info); err != nil {
			continue
		}
		cxns = append(cxns, info)
	}
	if len(cxns) == 0 {
		log.Error("unable to bootstrap to any supernode routers")
	} else {
		log.Infof("bootstrapped to %d supernode routers: %s", len(cxns), cxns)
	}
	return nil
}

func (p *standard) HandleStream(s inet.Stream) {
	// TODO(brian): Should clients be able to satisfy requests?
	log.Error("supernode client received (dropped) a routing message from", s.Conn().RemotePeer())
	s.Close()
}

const replicationFactor = 2

// SendMessage sends message to each remote sequentially (randomized order),
// stopping after the first successful response. If all fail, returns the last
// error.
func (px *standard) SendMessage(ctx context.Context, m *dhtpb.Message) error {
	var err error
	var numSuccesses int
	for _, remote := range sortedByKey(px.remoteIDs, m.GetKey()) {
		if err = px.sendMessage(ctx, m, remote); err != nil { // careful don't re-declare err!
			continue
		}
		numSuccesses++
		switch m.GetType() {
		case dhtpb.Message_ADD_PROVIDER, dhtpb.Message_PUT_VALUE:
			if numSuccesses < replicationFactor {
				continue
			}
		}
		return nil // success
	}
	return err // NB: returns the last error
}

func (px *standard) sendMessage(ctx context.Context, m *dhtpb.Message, remote peer.ID) (err error) {
	e := log.EventBegin(ctx, "sendRoutingMessage", px.Host.ID(), remote, m)
	defer func() {
		if err != nil {
			e.SetError(err)
		}
		e.Done()
	}()
	if err = px.Host.Connect(ctx, pstore.PeerInfo{ID: remote}); err != nil {
		return err
	}
	s, err := px.Host.NewStream(ctx, remote, ProtocolSNR)
	if err != nil {
		return err
	}
	defer s.Close()
	pbw := ggio.NewDelimitedWriter(s)
	if err := pbw.WriteMsg(m); err != nil {
		return err
	}
	return nil
}

// SendRequest sends the request to each remote sequentially (randomized order),
// stopping after the first successful response. If all fail, returns the last
// error.
func (px *standard) SendRequest(ctx context.Context, m *dhtpb.Message) (*dhtpb.Message, error) {
	var err error
	for _, remote := range sortedByKey(px.remoteIDs, m.GetKey()) {
		var reply *dhtpb.Message
		reply, err = px.sendRequest(ctx, m, remote) // careful don't redeclare err!
		if err != nil {
			continue
		}
		return reply, nil // success
	}
	return nil, err // NB: returns the last error
}

func (px *standard) sendRequest(ctx context.Context, m *dhtpb.Message, remote peer.ID) (*dhtpb.Message, error) {
	e := log.EventBegin(ctx, "sendRoutingRequest", px.Host.ID(), remote, logging.Pair("request", m))
	defer e.Done()
	if err := px.Host.Connect(ctx, pstore.PeerInfo{ID: remote}); err != nil {
		e.SetError(err)
		return nil, err
	}
	s, err := px.Host.NewStream(ctx, remote, ProtocolSNR)
	if err != nil {
		e.SetError(err)
		return nil, err
	}
	defer s.Close()
	r := ggio.NewDelimitedReader(s, inet.MessageSizeMax)
	w := ggio.NewDelimitedWriter(s)
	if err = w.WriteMsg(m); err != nil {
		e.SetError(err)
		return nil, err
	}

	response := &dhtpb.Message{}
	if err = r.ReadMsg(response); err != nil {
		e.SetError(err)
		return nil, err
	}
	// need ctx expiration?
	if response == nil {
		err := errors.New("no response to request")
		e.SetError(err)
		return nil, err
	}
	e.Append(logging.Pair("response", response))
	e.Append(logging.Pair("uuid", loggables.Uuid("foo")))
	return response, nil
}

func sortedByKey(peers []peer.ID, skey string) []peer.ID {
	target := kbucket.ConvertKey(skey)
	return kbucket.SortClosestPeers(peers, target)
}


text:
package com.github.rjeschke.weel;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;

/**
 * Weel map implementation.
 *
 * @author René Jeschke <rene_jeschke@yahoo.de>
 */
public final class ValueMap
{
    /** Integer keys. */
    private HashMap<Integer, Integer> intKeys = new HashMap<Integer, Integer>();
    /** String keys. */
    private HashMap<String, Integer> strKeys = new HashMap<String, Integer>();
    /** The size. */
    int size;
    /** Is this map ordered? */
    boolean ordered = true;
    /** The data. */
    ArrayList<Value> data;
    /** The keys. */
    ArrayList<Value> keys;
    /** The highest integer key value for unordered maps. */
    int highestIntKey;

    /**
     * Creates a new ValueMap.
     */
    public ValueMap()
    {
        this.data = new ArrayList<Value>();
        this.keys = new ArrayList<Value>();
    }

    /**
     * Gets the size of this map.
     *
     * @return The size.
     */
    public int size()
    {
        return this.size;
    }

    /**
     * Get the value at the given index.
     *
     * @param index
     *            The index.
     * @return The value or a Value of type NULL.
     * @throws WeelException
     *             If the index is invalid.
     */
    public Value get(final Value index)
    {
        final Value out = new Value();
        this.get(index, out);
        return out;
    }

    /**
     * Get the value at the given index.
     *
     * @param index
     *            The index.
     * @return The value or a Value of type NULL.
     * @throws WeelException
     *             If the index is invalid.
     */
    public Value get(final int index)
    {
        if (this.ordered)
        {
            return index >= 0 && index < this.size ? this.data.get(index)
                    .clone() : new Value();
        }
        return this.get(new Value(index));
    }

    /**
     * Get the value at the given index.
     *
     * @param index
     *            The index.
     * @param out
     *            The output Value.
     * @throws WeelException
     *             If the index is invalid.
     * @return out.
     */
    public Value get(final int index, final Value out)
    {
        if (this.ordered)
        {
            if (index >= 0 && index < this.size)
                this.data.get(index).copyTo(out);
            else
                out.setNull();
        }
        else
        {
            final Integer idx2 = this.intKeys.get(index);
            if (idx2 != null)
                this.data.get(idx2).copyTo(out);
            else
                out.setNull();
        }
        return out;
    }

    /**
     * Get the value at the given index.
     *
     * @param index
     *            The index.
     * @return The value or a Value of type NULL.
     * @throws WeelException
     *             If the index is invalid.
     */
    public Value get(final String index)
    {
        return this.get(index, new Value());
    }

    /**
     * Get the value at the given index.
     *
     * @param index
     *            The index.
     * @param out
     *            The output Value.
     * @return out.
     * @throws WeelException
     *             If the index is invalid.
     */
    public Value get(final String index, final Value out)
    {
        if (this.ordered)
        {
            out.setNull();
        }
        else
        {
            final Integer idx2 = this.strKeys.get(index);
            if (idx2 != null)
                this.data.get(idx2).copyTo(out);
            else
                out.setNull();
        }
        return out;
    }

    /**
     * Gets the value at the given index.
     *
     * @param index
     *            The index.
     * @param out
     *            The output Value.
     * @throws WeelException
     *             If the index is invalid.
     */
    public void get(final Value index, final Value out)
    {
        if (index.type == ValueType.NUMBER)
        {
            final int idx = (int) index.number;
            if (this.ordered)
            {
                if (idx < 0 || idx >= this.size)
                    out.setNull();
                else
                    this.data.get(idx).copyTo(out);

            }
            else
            {
                final Integer idx2 = this.intKeys.get(idx);
                if (idx2 != null)
                    this.data.get(idx2).copyTo(out);
                else
                    out.setNull();
            }
        }
        else if (index.type == ValueType.STRING)
        {
            final Integer idx = this.strKeys.get(index.object);
            if (idx != null)
                this.data.get(idx).copyTo(out);
            else
                out.setNull();
        }
        else
        {
            throw new WeelException("Illegal map index type: " + index.type);
        }
    }

    /**
     * Check if this map contains the given key.
     *
     * @param key
     *            The key
     * @return true if it contains the given key.
     */
    public boolean hasKey(final String key)
    {
        return this.hasKey(new Value(key));
    }

    /**
     * Check if this map contains the given key.
     *
     * @param key
     *            The key
     * @return true if it contains the given key.
     */
    public boolean hasKey(final int key)
    {
        return this.hasKey(new Value(key));
    }

    /**
     * Check if this map contains the given key.
     *
     * @param key
     *            The key
     * @return true if it contains the given key.
     */
    public boolean hasKey(final Value key)
    {
        if (key.type == ValueType.NUMBER)
        {
            final int idx = (int) key.number;
            if (this.ordered)
            {
                return idx >= 0 && idx < this.size;
            }
            return this.intKeys.containsKey(idx);
        }
        if (key.type == ValueType.STRING)
        {
            if (this.ordered)
                return false;
            return this.strKeys.containsKey(key.object);
        }
        throw new WeelException("Illegal map index type: " + key.type);
    }

    /**
     * Creates integer key mappings for ordered to unordered transition.
     */
    private void unorder()
    {
        this.ordered = false;
        // There can only be integer keys inside the map right now
        for (int i = 0; i < this.size; i++)
        {
            this.keys.add(new Value(i));
            this.intKeys.put(i, i);
        }
        this.highestIntKey = this.size - 1;
    }

    /**
     * Sets the value at the given index. Maps grow automatically.
     *
     * @param index
     *            The index.
     * @param value
     *            The value.
     * @throws WeelException
     *             If the index is invalid.
     */
    public void set(final String index, final Value value)
    {
        if (this.ordered)
        {
            this.unorder();
        }
        final Integer idx = this.strKeys.get(index);
        if (idx != null)
        {
            value.copyTo(this.data.get(idx));
        }
        else
        {
            this.strKeys.put(index, this.size);
            this.keys.add(new Value(index));
            this.data.add(value.clone());
            this.size++;
        }
    }

    /**
     * Sets the value at the given index. Maps grow automatically.
     *
     * @param index
     *            The index.
     * @param value
     *            The value.
     * @throws WeelException
     *             If the index is invalid.
     */
    public void set(final int index, final Value value)
    {
        if (this.ordered && index >= 0 && index <= this.size)
        {
            if (index == this.size)
            {
                this.data.add(value.clone());
                this.size++;
            }
            else
            {
                value.copyTo(this.data.get(index));
            }
        }
        else
        {
            if (this.ordered)
            {
                this.unorder();
            }
            final Integer index2 = this.intKeys.get(index);
            if (index2 != null)
            {
                value.copyTo(this.data.get(index2));
            }
            else
            {
                this.intKeys.put(index, this.size);
                this.keys.add(new Value(index));
                this.data.add(value.clone());
                this.highestIntKey = index;
                this.size++;
            }
        }
    }

    /**
     * Sets the value at the given index. Maps grow automatically.
     *
     * @param index
     *            The index.
     * @param value
     *            The value.
     * @throws WeelException
     *             If the index is invalid.
     */
    public void set(final Value index, final Value value)
    {
        if (index.type == ValueType.NUMBER)
        {
            final int idx = (int) index.number;
            if (this.ordered && idx >= 0 && idx <= this.size)
            {
                if (idx == this.size)
                {
                    this.data.add(value.clone());
                    this.size++;
                }
                else
                {
                    value.copyTo(this.data.get(idx));
                }
            }
            else
            {
                if (this.ordered)
                {
                    this.unorder();
                }
                final Integer idx2 = this.intKeys.get(idx);
                if (idx2 != null)
                {
                    value.copyTo(this.data.get(idx2));
                }
                else
                {
                    this.intKeys.put(idx, this.size);
                    this.keys.add(new Value(idx));
                    this.data.add(value.clone());
                    this.highestIntKey = idx;
                    this.size++;
                }
            }
        }
        else if (index.type == ValueType.STRING)
        {
            if (this.ordered)
            {
                this.unorder();
            }
            final Integer idx = this.strKeys.get(index.object);
            if (idx != null)
            {
                value.copyTo(this.data.get(idx));
            }
            else
            {
                this.strKeys.put((String)index.object, this.size);
                this.keys.add(index.clone());
                this.data.add(value.clone());
                this.size++;
            }
        }
        else
        {
            throw new WeelException("Illegal map index type: " + index.type);
        }
    }

    /**
     * Appends the given value to this map using an auto generated integer key.
     *
     * @param value
     *            The value to append.
     */
    public void append(final Value value)
    {
        if (this.ordered)
        {
            this.data.add(value.clone());
        }
        else
        {
            this.keys.add(new Value(++this.highestIntKey));
            this.intKeys.put(this.highestIntKey, this.size);
            this.data.add(value.clone());
        }
        this.size++;
    }

    /** @see java.lang.Object#clone() */
    @Override
    public ValueMap clone()
    {
        final ValueMap ret = new ValueMap();
        final Value k = new Value();
        final Value v = new Value();
        for (final ValueMapIterator i = new ValueMapIterator(this); i
                .next(k, v);)
        {
            ret.set(k, v.isMap() ? new Value(v.getMap().clone()) : v);
        }
        return ret;
    }

    private void remap(final int r)
    {
        for(final Entry<Integer, Integer> e : this.intKeys.entrySet())
        {
            final int i = e.getValue();
            if(i > r)
            {
                this.intKeys.put(e.getKey(), i - 1);
            }
        }
        for(final Entry<String, Integer> e : this.strKeys.entrySet())
        {
            final int i = e.getValue();
            if(i > r)
            {
                this.strKeys.put(e.getKey(), i - 1);
            }
        }
    }

    /**
     * Removes the last entry in this map.
     */
    public Value removeLast()
    {
        if(this.size < 1)
            return new Value();

        this.size--;
        final Value rem = this.data.remove(this.size);
        if(!this.ordered)
        {
            final Value k = this.keys.remove(this.size);
            this.data.remove(this.size);
            if(k.type == ValueType.NUMBER)
            {
                this.intKeys.remove((int)k.number);
            }
            else
            {
                this.strKeys.remove(k.object);
            }
        }
        return rem;
    }

    public void remove(final Value index)
    {
        if(index.type == ValueType.NUMBER)
        {
            final int idx = (int) index.number;
            if(this.ordered)
            {
                if(idx < 0 || idx >= this.size)
                    return;
                if(idx + 1 == this.size)
                {
                    this.size--;
                    this.data.remove(this.size);
                    return;
                }
                this.unorder();
            }
            final Integer idx2 = this.intKeys.get(idx);
            if(idx2 != null)
            {
                final int r = idx2;
                this.data.remove(r);
                this.keys.remove(r);
                this.intKeys.remove(idx);
                this.remap(r);
            }
        }
        else if(index.type == ValueType.STRING)
        {
            if(this.ordered)
                return;

            final Integer idx2 = this.strKeys.get(index.object);
            if(idx2 != null)
            {
                final int r = idx2;
                this.data.remove(r);
                this.keys.remove(r);
                this.strKeys.remove(index.object);
                this.remap(r);
            }
        }
        else
        {
            throw new WeelException("Illegal map index type: " + index.type);
        }
    }

    /**
     * Reverses this map.
     *
     * @return This map.
     */
    public ValueMap reverse()
    {
        // FIXME ... hä?
        Collections.reverse(this.data);
        Collections.reverse(this.keys);

        return this;
    }

    /**
     * Creates an iterator.
     *
     * @return The iterator.
     */
    public ValueMapIterator createIterator()
    {
        return new ValueMapIterator(this);
    }

    /**
     * Iterator implementation.
     *
     * @author René Jeschke <rene_jeschke@yahoo.de>
     */

    public final static class ValueMapIterator
    {
        /** The ValueMap. */
        private final ValueMap map;
        /** Current cursor. */
        private int cursor = 0;

        /**
         * Constructor.
         *
         * @param map
         *            The ValueMap to iterate over.
         */
        ValueMapIterator(final ValueMap map)
        {
            this.map = map;
        }

        /**
         * Gets the next key-value pair.
         *
         * @param key
         *            The key.
         * @param value
         *            The value.
         * @return false if there are no more elements.
         */
        public boolean next(final Value key, final Value value)
        {
            if (this.cursor < this.map.size)
            {
                if (this.map.ordered)
                {
                    key.type = ValueType.NUMBER;
                    key.number = this.cursor;
                }
                else
                {
                    this.map.keys.get(this.cursor).copyTo(key);
                }
                this.map.data.get(this.cursor++).copyTo(value);
                return true;
            }
            return false;
        }
    }

    /** @see java.lang.Object#toString() */
    @Override
    public String toString()
    {
        if(this.size == 0)
            return "{}";
        final StringBuilder sb = new StringBuilder();
        sb.append('{');
        if(this.ordered)
        {
            sb.append(this.data.get(0).toIntString());
            for(int i = 1; i < this.size; i++)
            {
                sb.append(',');
                sb.append(this.data.get(i).toIntString());
            }
        }
        else
        {
            final Value k = new Value(), v = new Value();
            final ValueMapIterator it = new ValueMapIterator(this);
            while(it.next(k, v))
            {
                if(sb.length() > 1)
                    sb.append(',');
                sb.append('[');
                sb.append(k.toIntString());
                sb.append("]=");
                sb.append(v.toIntString());
            }
        }
        sb.append('}');
        return sb.toString();
    }
}


text:
<?php
namespace Customer\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Customer\Model\Customer;
use Customer\Form\CustomerForm;

class CustomerController extends AbstractActionController
{
    protected $CustomerTable;
    public function init(){
        $this->layout('adminLayout');
    }
    public function indexAction()
    {
        /*
        $this->layout('adminLayout');
        return new ViewModel(array(
            'customer_list' => $this->getCustomerTable()->fetchAll(),
        ));*/

        $paginator = $this->getCustomerTable()->fetchAll(true);
        // set the current page to what has been passed in query string, or to 1 if none set
        $paginator->setCurrentPageNumber((int)$this->params()->fromQuery('page', 1));
        // set the number of items per page to 10
        $paginator->setItemCountPerPage(10);
        $this->layout('adminLayout');
        return new ViewModel(array(
            'customer_list' => $paginator
        ));
    }

    public function addAction()
    {
        $this->layout('adminLayout');
        $form = new CustomerForm();
        $form->get('submit')->setValue('Add');
        $request = $this->getRequest();
        if ($request->isPost()) {
            $cus = new Customer();
            $form->setInputFilter($cus->getInputFilter());
            $form->setData($request->getPost());

            if ($form->isValid()) {

                $cus->exchangeArray($form->getData());

                $this->getCustomerTable()->saveCustomer($cus);

                // Redirect to list of albums
                return $this->redirect()->toRoute('customer');
            }
        }
        return array('form' => $form);
    }

    public function editAction()
    {
        $this->layout('adminLayout');
        $id = (int) $this->params()->fromRoute('id', 0);
        if (!$id) {
            return $this->redirect()->toRoute('customer', array(
                'action' => 'add'
            ));
        }

        // Get the Album with the specified id.  An exception is thrown
        // if it cannot be found, in which case go to the index page.
        try {
            $cus = $this->getCustomerTable()->getCustomer($id);
        }
        catch (\Exception $ex) {
            return $this->redirect()->toRoute('customer', array(
                'action' => 'index'
            ));
        }

        $form  = new CustomerForm();
        $form->bind($cus);
        $form->get('submit')->setAttribute('value', 'Edit');

        $request = $this->getRequest();
        if ($request->isPost()) {
            $form->setInputFilter($cus->getInputFilter());
            $form->setData($request->getPost());

            if ($form->isValid()) {
                $this->getCustomerTable()->saveCustomer($cus);

                // Redirect to list of albums
                return $this->redirect()->toRoute('customer');
            }
        }

        return array(
            'id' => $id,
            'form' => $form,
        );

    }

    public function deleteAction()
    {
        $id = (int) $this->params()->fromRoute('id', 0);
        if (!$id) {
            return $this->redirect()->toRoute('customer');
        }

        $request = $this->getRequest();
        if ($request->isPost()) {
            $del = $request->getPost('del', 'No');

            if ($del == 'Yes') {
                $id = (int) $request->getPost('id');
                $this->getCustomerTable()->deleteCustomer($id);
            }

            // Redirect to list of albums
            return $this->redirect()->toRoute('customer');
        }

        return array(
            'id'    => $id,
            'customer' => $this->getCustomerTable()->getcustomer($id)
        );

    }

    public function getCustomerTable()
    {
        if (!$this->CustomerTable) {
            $sm = $this->getServiceLocator();
            $this->CustomerTable = $sm->get('Customer\Model\CustomerTable');
        }
        return $this->CustomerTable;
    }
}