text:
const expect = require('chai').expect;
// using base generator which extends the private base
const BaseGenerator = require('../generators/generator-base').prototype;

BaseGenerator.log = msg => {
    // eslint-disable-next-line no-console
    console.log(msg);
};

describe('Generator Base Private', () => {
    describe('stripMargin', () => {
        it('should produce correct output without margin', () => {
            const entityFolderName = 'entityFolderName';
            const entityFileName = 'entityFileName';
            const content = `|export * from './${entityFolderName}/${entityFileName}-update.component';
                 |export * from './${entityFolderName}/${entityFileName}-delete-dialog.component';
                 |export * from './${entityFolderName}/${entityFileName}-detail.component';
                 |export * from './${entityFolderName}/${entityFileName}.component';
                 |export * from './${entityFolderName}/${entityFileName}.state';`;
            const out = `export * from './entityFolderName/entityFileName-update.component';
export * from './entityFolderName/entityFileName-delete-dialog.component';
export * from './entityFolderName/entityFileName-detail.component';
export * from './entityFolderName/entityFileName.component';
export * from './entityFolderName/entityFileName.state';`;
            expect(BaseGenerator.stripMargin(content)).to.equal(out);
        });
        it('should produce correct indented output without margin', () => {
            const routerName = 'routerName';
            const enableTranslation = true;
            const glyphiconName = 'glyphiconName';
            const content = `|

                 |
                 |
                 |        <span ${enableTranslation ? `data-translate="global.menu.${routerName}"` : ''}>${routerName}
                 |
                 |
`;
            const out = `

        routerName

`;
            expect(BaseGenerator.stripMargin(content)).to.equal(out);
        });
    });

    describe('getDBTypeFromDBValue', () => {
        describe('when called with sql DB name', () => {
            it('return SQL', () => {
                expect(BaseGenerator.getDBTypeFromDBValue('mysql')).to.equal('sql');
            });
        });
        describe('when called with mongo DB', () => {
            it('return mongodb', () => {
                expect(BaseGenerator.getDBTypeFromDBValue('mongodb')).to.equal('mongodb');
            });
        });
        describe('when called with cassandra', () => {
            it('return cassandra', () => {
                expect(BaseGenerator.getDBTypeFromDBValue('cassandra')).to.equal('cassandra');
            });
        });
    });

    describe('generateEntityClientImports', () => {
        describe('with relationships from or to the User', () => {
            const relationships = [
                {
                    otherEntityAngularName: 'User'
                },
                {
                    otherEntityAngularName: 'AnEntity'
                }
            ];
            describe('when called with dto option', () => {
                it('return an empty Map', () => {
                    const imports = BaseGenerator.generateEntityClientImports(relationships, 'yes');
                    expect(imports.size).to.eql(0);
                });
            });
            describe('when called with 2 distinct relationships without dto option', () => {
                it('return a Map with 2 imports', () => {
                    const imports = BaseGenerator.generateEntityClientImports(relationships, 'no');
                    expect(imports).to.have.all.keys('IUser', 'IAnEntity');
                    expect(imports.size).to.eql(relationships.length);
                });
            });
            describe('when called with 2 identical relationships without dto option', () => {
                const relationships = [
                    {
                        otherEntityAngularName: 'User'
                    },
                    {
                        otherEntityAngularName: 'User'
                    }
                ];
                it('return a Map with 1 import', () => {
                    const imports = BaseGenerator.generateEntityClientImports(relationships, 'no');
                    expect(imports).to.have.key('IUser');
                    expect(imports.size).to.eql(1);
                });
            });
        });
        describe('with no relationship from or to the User', () => {
            describe('when called to have models to be imported in the templates', () => {
                let importsForAngular = null;
                let importsForReact = null;
                const relationships = [
                    {
                        otherEntityAngularName: 'AnEntity',
                        otherEntityFileName: 'AnEntity',
                        otherEntityClientRootFolder: 'anEntity'
                    },
                    {
                        otherEntityAngularName: 'AnotherEntity',
                        otherEntityFileName: 'AnotherEntity',
                        otherEntityClientRootFolder: 'anotherEntity'
                    }
                ];

                before(() => {
                    importsForAngular = BaseGenerator.generateEntityClientImports(relationships, 'no', 'angularX');
                    importsForReact = BaseGenerator.generateEntityClientImports(relationships, 'no', 'react');
                });

                it('adds the same imports regardless of the client framework', () => {
                    expect(importsForAngular).to.eql(importsForReact);
                });
            });
        });
    });

    describe('generateLanguageOptions', () => {
        describe('when called with empty array', () => {
            it('return empty', () => {
                expect(BaseGenerator.generateLanguageOptions([])).to.eql([]);
            });
        });
        describe('when called with languages array', () => {
            it('return languages pipe syntax', () => {
                expect(BaseGenerator.generateLanguageOptions(['en', 'fr'])).to.eql([
                    `'en': { name: 'English' }`, // eslint-disable-line
                    `'fr': { name: 'Français' }` // eslint-disable-line
                ]);
            });
        });
    });

    describe('skipLanguageForLocale', () => {
        describe('when called with english', () => {
            it('return false', () => {
                expect(BaseGenerator.skipLanguageForLocale('en')).to.equal(false);
            });
        });
        describe('when called with languages ar-ly', () => {
            it('return true', () => {
                expect(BaseGenerator.skipLanguageForLocale('ar-ly')).to.equal(true);
            });
        });
    });

    describe('generateTestEntityId', () => {
        describe('when called with int', () => {
            it('return 123', () => {
                expect(BaseGenerator.generateTestEntityId('int')).to.equal(123);
            });
        });
        describe('when called with String', () => {
            it("return '123'", () => {
                expect(BaseGenerator.generateTestEntityId('String')).to.equal("'123'");
            });
        });
        describe('when called with String and cassandra', () => {
            it("return '9fec3727-3421-4967-b213-ba36557ca194'", () => {
                expect(BaseGenerator.generateTestEntityId('String', 'cassandra')).to.equal("'9fec3727-3421-4967-b213-ba36557ca194'");
            });
        });
    });

    describe('formatAsApiDescription', () => {
        describe('when formatting a nil text', () => {
            it('returns it', () => {
                expect(BaseGenerator.formatAsApiDescription()).to.equal(undefined);
            });
        });
        describe('when formatting an empty text', () => {
            it('returns it', () => {
                expect(BaseGenerator.formatAsApiDescription('')).to.equal('');
            });
        });
        describe('when formatting normal texts', () => {
            describe('when having empty lines', () => {
                it('discards them', () => {
                    expect(BaseGenerator.formatAsApiDescription('First line\n \nSecond line\n\nThird line')).to.equal(
                        'First line Second line Third line'
                    );
                });
            });
            describe('when having HTML tags', () => {
                it('keeps them', () => {
                    expect(BaseGenerator.formatAsApiDescription('Not boldy\nboldy')).to.equal('Not boldyboldy');
                });
            });
            describe('when having a plain text', () => {
                it('puts a space before each line', () => {
                    expect(BaseGenerator.formatAsApiDescription('JHipster is\na great generator')).to.equal(
                        'JHipster is a great generator'
                    );
                });
            });
            describe('when having quotes', () => {
                it('formats the text to make the string valid', () => {
                    // eslint-disable-next-line quotes
                    expect(BaseGenerator.formatAsApiDescription('JHipster is "the" best')).to.equal('JHipster is \\"the\\" best');
                });
            });
        });
    });

    describe('formatAsLiquibaseRemarks', () => {
        describe('when formatting a nil text', () => {
            it('returns it', () => {
                expect(BaseGenerator.formatAsLiquibaseRemarks()).to.equal(undefined);
            });
        });
        describe('when formatting an empty text', () => {
            it('returns it', () => {
                expect(BaseGenerator.formatAsLiquibaseRemarks('')).to.equal('');
            });
        });
        describe('when formatting normal texts', () => {
            describe('when having empty lines', () => {
                it('discards them', () => {
                    expect(BaseGenerator.formatAsLiquibaseRemarks('First line\n \nSecond line\n\nThird line')).to.equal(
                        'First line Second line Third line'
                    );
                });
            });
            describe('when having a plain text', () => {
                it('puts a space before each line', () => {
                    expect(BaseGenerator.formatAsLiquibaseRemarks('JHipster is\na great generator')).to.equal(
                        'JHipster is a great generator'
                    );
                });
            });
            describe('when having ampersand', () => {
                it('formats the text to escape it', () => {
                    expect(BaseGenerator.formatAsLiquibaseRemarks('JHipster uses Spring & Hibernate')).to.equal(
                        'JHipster uses Spring & Hibernate'
                    );
                });
            });
            describe('when having quotes', () => {
                it('formats the text to escape it', () => {
                    // eslint-disable-next-line quotes
                    expect(BaseGenerator.formatAsLiquibaseRemarks('JHipster is "the" best')).to.equal('JHipster is "the" best');
                });
            });
            describe('when having apostrophe', () => {
                it('formats the text to escape it', () => {
                    // eslint-disable-next-line quotes
                    expect(BaseGenerator.formatAsLiquibaseRemarks("JHipster is 'the' best")).to.equal('JHipster is 'the' best');
                });
            });
            describe('when having HTML tags < and >', () => {
                it('formats the text to escape it', () => {
                    expect(BaseGenerator.formatAsLiquibaseRemarks('Not boldy\nboldy')).to.equal('Not boldy<b>boldy</b>');
                });
            });
        });
    });
});


text:
package uk.hfox.morphix.exception.transformer;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class MorphixTransformationExceptionTest {

    @Test
    void getQueryBuilder() {
        String msg = "Test Message";
        MorphixTransformationException ex = new MorphixTransformationException(msg);
        assertEquals(msg, ex.getMessage());

        Exception cause = new Exception();
        ex = new MorphixTransformationException(msg, cause);
        assertEquals(msg, ex.getMessage());
        assertEquals(cause, ex.getCause());
    }

}

redpajama_set_name: RedPajamaGithub


text:
Context XML

This example of context xml is compatible in apache-tomcat7 or higher version.
Be sure to add the resources following your system rules if it is not tomcat.

[webApplication]/META-INF/context.xml
------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Context>
<Context>
<!-- Database -->
	<Resource
		name				=	"jdbc/efw"
		auth				=	"Container"
		type				=	"javax.sql.DataSource"
		driverClassName	 =	"org.postgresql.Driver"
		url				 =	"jdbc:postgresql://localhost:5432/efw"
		username			=	"username"
		password			=	"password"
		maxActive		   =	"100"
		maxIdle		 	=	"20"
		maxWait		 	=	"10"
	/>
	<Resource
		name				=	"jdbc/efw2"
		auth				=	"Container"
		type				=	"javax.sql.DataSource"
		driverClassName	 =	"org.postgresql.Driver"
		url				 =	"jdbc:postgresql://localhost:5432/efw2"
		username			=	"username"
		password			=	"password"
		maxActive		   =	"100"
		maxIdle			 =	"20"
		maxWait			 =	"10"
	/>
	.
	.
	.
<!-- Mail -->
	<Resource
        name       	    	 	=    "mail/efw"
        auth       	    	 	=    "Container"
        type       	   	  	=    "javax.mail.Session"
        username   	    	 	=    ""
        password   	    		 =    ""
        mail.debug 	   	      =    "false"
        mail.user  	   	      =    ""
        mail.from  	   	      =    "admin@test.co.jp"
        mail.transport.protocol 	=	"smtp"
        mail.smtp.host    		  =    "127.0.0.1"
        mail.smtp.auth    		  =    "false"
        mail.smtp.port    		  =    "25"
        mail.smtp.starttls.enable   =	"true"
        description        		 =    "E-Mail Resource"
    />
</Context>

Database Resource

The default one must be named "jdbc/efw". It can be called by db.select ,
 db.change and db.master without the jdbcResourceName param.
If you need some addition database, add the database resource with another name. In this way, you must call the db functions with the jdbcResourceName param.

For example,

db.select(groupId, sqlId, params)		//using the default db resource "jdbc/efw"
db.select(groupId, sqlId, params, "jdbc/efw2")	//using the addition db resource "jdbc/efw2"

Mail Resource

name

If mail.send is called in your program, the mail resource must be set up with the name "mail/efw".


text:
function bool = feature_BD_bool_footLeftSideways_robust(mot, varargin)

input_params = { 'threshold_dist1' , 'threshold_dist2' };

if( ~(nargin == 1 || nargin == 3) ) error('Wrong number of arguments.'); end

threshold_dist1 = 0.35;
threshold_dist2 = 0.5;
for i = 1:length(varargin);
    if(~isempty(varargin{i}))
        eval([input_params{i} ' = varargin{i};']) ;
    end
end
bool =  features_combine_robust( feature_BD_bool_footLeftSideways( mot, threshold_dist1 ) , feature_BD_bool_footLeftSideways( mot, threshold_dist2 ) );


text:
/* -- Jto -- 03 Jun 1990
 * Changed the order of defines...
 */

/* parse.c 2.33 1/30/94 (C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen */

#include <string.h>
#include "struct.h"
#include "common.h"

#undef RAWDEBUG

char backupbuf[8192];

#define MSGTAB
#include "msg.h"
#undef MSGTAB
#include "sys.h"
#include "numeric.h"
#include "h.h"
#include "proto.h"

/*
 * NOTE: parse() should not be called recursively by other functions!
 */
static char *para[MAXPARA + 2];

static char sender[HOSTLEN + 1];
static int cancel_clients(aClient *, aClient *, char *);
static void remove_unknown(aClient *, char *);
/*
**  Find a client (server or user) by name.
**
**  *Note*
**	Semantics of this function has been changed from
**	the old. 'name' is now assumed to be a null terminated
**	string and the search is the for server and user.
*/
aClient *find_client(char *name, aClient *cptr)
{
	if (cptr == NULL || IsServer(cptr))
	{
		aClient *acptr;

		if ((acptr = hash_find_id(name, NULL)) != NULL)
			return acptr;
	}

	return hash_find_client(name, NULL);
}

aClient inline *find_nickserv(char *name, aClient *cptr)
{
	if (name)
		cptr = hash_find_nickserver(name, cptr);

	return cptr;
}

/*
**  Find server by name.
**
**	This implementation assumes that server and user names
**	are unique, no user can have a server name and vice versa.
**	One should maintain separate lists for users and servers,
**	if this restriction is removed.
**
**  *Note*
**	Semantics of this function has been changed from
**	the old. 'name' is now assumed to be a null terminated
**	string.
*/
aClient inline *find_server(char *name, aClient *cptr)
{
	if (name)
	{
		aClient *acptr;

		if ((acptr = find_client(name, NULL)) != NULL && IsServer(acptr))
			return acptr;
	}

	return NULL;
}

aClient inline *find_name(char *name, aClient *cptr)
{
	aClient *c2ptr = cptr;

	if (!collapse(name))
		return c2ptr;

	if ((c2ptr = hash_find_server(name, cptr)))
		return (c2ptr);
	if (!index(name, '*'))
		return c2ptr;
	list_for_each_entry(c2ptr, &client_list, client_node)
	{
		if (!IsServer(c2ptr) && !IsMe(c2ptr))
			continue;
		if (match(name, c2ptr->name) == 0)
			break;
		if (index(c2ptr->name, '*'))
			if (match(c2ptr->name, name) == 0)
				break;
	}
	return (c2ptr ? c2ptr : cptr);
}

/*
**  Find person by (nick)name.
*/
aClient *find_person(char *name, aClient *cptr)
{
	aClient *c2ptr;

	c2ptr = find_client(name, cptr);

	if (c2ptr && IsClient(c2ptr) && c2ptr->user)
		return c2ptr;

	return NULL;
}

void ban_flooder(aClient *cptr)
{
	/* place_host_ban also takes care of removing any other clients with same host/ip */
	place_host_ban(cptr, BAN_ACT_ZLINE, "Flood from unknown connection", UNKNOWN_FLOOD_BANTIME);
	return;
}

/*
 * This routine adds fake lag if needed.
 */
inline void parse_addlag(aClient *cptr, int cmdbytes)
{
	if (!IsServer(cptr) && !IsNoFakeLag(cptr) &&
#ifdef FAKELAG_CONFIGURABLE
		!(cptr->local->class && (cptr->local->class->options & CLASS_OPT_NOFAKELAG)) &&
#endif
	!ValidatePermissionsForPath("privacy:fakelag",cptr,NULL,NULL,NULL))
	{
		cptr->local->since += (1 + cmdbytes/90);
	}
}

/*
 * parse a buffer.
 *
 * NOTE: parse() should not be called recusively by any other fucntions!
 */
int  parse(aClient *cptr, char *buffer, char *bufend)
{
	Hook *h;
	int buf_len = 0;
	aClient *from = cptr;
	char *ch, *s;
	int  len, i, numeric = 0, paramcount;
#ifdef DEBUGMODE
	time_t then, ticks;
	int  retval;
#endif
	aCommand *cmptr = NULL;

	for(h = Hooks[HOOKTYPE_PACKET]; h; h = h->next) {
		buf_len = (int)(bufend - buffer);
		(*(h->func.intfunc))(from, &me, &buffer, &buf_len);
		if(!buffer) return 0;
		bufend = buffer + buf_len;
	}

	Debug((DEBUG_ERROR, "Parsing: %s (from %s)", buffer,
	    (*cptr->name ? cptr->name : "*")));
	if (IsDead(cptr))
		return 0;

	if ((cptr->local->receiveK >= UNKNOWN_FLOOD_AMOUNT) && IsUnknown(cptr))
	{
		sendto_snomask(SNO_FLOOD, "Flood from unknown connection %s detected",
			cptr->local->sockhost);
		ban_flooder(cptr);
		return FLUSH_BUFFER;
	}

	/* this call is a bit obsolete? - takes up CPU */
	backupbuf[0] = '\0';
	strlcpy(backupbuf, buffer, sizeof(backupbuf));
#if defined(DEBUGMODE) && defined(RAWCMDLOGGING)
	ircd_log(LOG_ERROR, "<- %s: %s", cptr->name, backupbuf);
#endif
	s = sender;
	*s = '\0';
	for (ch = buffer; *ch == ' '; ch++)
		;
	//para[0] = from->name;
	para[0] = (char *)0xDEADBEEF; /* helps us catch bugs :) -- 1/2 */
	if (*ch == ':' || *ch == '@')
	{
		/*
		   ** Copy the prefix to 'sender' assuming it terminates
		   ** with SPACE (or NULL, which is an error, though).
		 */
		for (++ch, i = 0; *ch && *ch != ' '; ++ch)
			if (s < (sender + sizeof(sender) - 1))
				*s++ = *ch;	/* leave room for NULL */
		*s = '\0';
		/*
		   ** Actually, only messages coming from servers can have
		   ** the prefix--prefix silently ignored, if coming from
		   ** a user client...
		   **
		   ** ...sigh, the current release "v2.2PL1" generates also
		   ** null prefixes, at least to NOTIFY messages (e.g. it
		   ** puts "sptr->nickname" as prefix from server structures
		   ** where it's null--the following will handle this case
		   ** as "no prefix" at all --msa  (": NOTICE nick ...")
		 */
		if (*sender && IsServer(cptr))
		{
			from = find_client(sender, (aClient *)NULL);
			if (!from && index(sender, '@'))
				from = find_nickserv(sender, (aClient *)NULL);
			//para[0] = sender;
			para[0] = (char *)0xDEADBEEF; /* helps us catch bugs :) -- 2/2 */

			/* Hmm! If the client corresponding to the
			 * prefix is not found--what is the correct
			 * action??? Now, I will ignore the message
			 * (old IRC just let it through as if the
			 * prefix just wasn't there...) --msa
			 */

			if (!from)
			{
				Debug((DEBUG_ERROR,
				    "Unknown prefix (%s)(%s) from (%s)",
				    sender, buffer, cptr->name));
				ircstp->is_unpf++;
				remove_unknown(cptr, sender);
				return -1;
			}
			if (from->from != cptr)
			{
				ircstp->is_wrdi++;
				Debug((DEBUG_ERROR,
				    "Message (%s) coming from (%s)",
				    buffer, cptr->name));
				return cancel_clients(cptr, from, ch);
			}
		}
		while (*ch == ' ')
			ch++;
	}

	if (*ch == '\0')
	{
		ircstp->is_empt++;
		Debug((DEBUG_NOTICE, "Empty message from host %s:%s",
		    cptr->name, from->name));
		if (!IsServer(cptr))
			cptr->local->since++; /* 1s fake lag */
		return (-1);
	}

	/*
	   ** Extract the command code from the packet.  Point s to the end
	   ** of the command code and calculate the length using pointer
	   ** arithmetic.  Note: only need length for numerics and *all*
	   ** numerics must have paramters and thus a space after the command
	   ** code. -avalon
	 */
	s = (char *)index(ch, ' ');	/* s -> End of the command code */
	len = (s) ? (s - ch) : 0;
	if (len == 3 &&
	    isdigit(*ch) && isdigit(*(ch + 1)) && isdigit(*(ch + 2)))
	{
		cmptr = NULL;
		numeric = (*ch - '0') * 100 + (*(ch + 1) - '0') * 10
		    + (*(ch + 2) - '0');
		paramcount = MAXPARA;
		ircstp->is_num++;
	}
	else
	{
		int flags = 0;
		int bytes = bufend - ch;
		if (s)
			*s++ = '\0';
		if (!IsRegistered(from))
			flags |= M_UNREGISTERED;
		if (IsPerson(from))
			flags |= M_USER;
		if (IsServer(from))
			flags |= M_SERVER;
		if (IsShunned(from))
			flags |= M_SHUN;
		if (IsVirus(from))
			flags |= M_VIRUS;
		if (IsOper(from))
			flags |= M_OPER;
		cmptr = find_Command(ch, IsServer(cptr) ? 1 : 0, flags);
		if (!cmptr)
		{
			/*
			   ** Note: Give error message *only* to recognized
			   ** persons. It's a nightmare situation to have
			   ** two programs sending "Unknown command"'s or
			   ** equivalent to each other at full blast....
			   ** If it has got to person state, it at least
			   ** seems to be well behaving. Perhaps this message
			   ** should never be generated, though...  --msa
			   ** Hm, when is the buffer empty -- if a command
			   ** code has been found ?? -Armin
			   ** This error should indeed not be sent in case
			   ** of notices -- Syzop.
			 */
			if (!IsRegistered(cptr) && stricmp(ch, "NOTICE")) {
				sendto_one(from, ":%s %d %s :You have not registered",
				    me.name, ERR_NOTREGISTERED, ch);
				parse_addlag(cptr, bytes);
				return -1;
			}
			if (IsShunned(cptr))
				return -1;

			if (buffer[0] != '\0')
			{
				if (IsPerson(from))
					sendto_one(from,
					    ":%s %d %s %s :Unknown command",
					    me.name, ERR_UNKNOWNCOMMAND,
					    from->name, ch);
				Debug((DEBUG_ERROR, "Unknown (%s) from %s",
				    ch, get_client_name(cptr, TRUE)));
				parse_addlag(cptr, bytes);
			}
			ircstp->is_unco++;
			return (-1);
		}
		if (cmptr->flags != 0) { /* temporary until all commands are updated */

		/* Logic in comparisions below is a bit complicated, see notes */

		/* If you're a user, and this command does not permit users or opers, deny */
		if ((flags & M_USER) && !(cmptr->flags & M_USER) && !(cmptr->flags & M_OPER))
		{
			sendto_one(cptr, rpl_str(ERR_NOTFORUSERS), me.name,
					from->name, cmptr->cmd);
			return -1;
		}

		/* If you're a server, but command doesn't want servers, deny */
		if ((flags & M_SERVER) && !(cmptr->flags & M_SERVER))
			return -1;
		}

		/* If you're a user, but not an operator, and this requires operators, deny */
		if ((cmptr->flags & M_OPER) && (flags & M_USER) && !(flags & M_OPER))
		{
			sendto_one(cptr, rpl_str(ERR_NOPRIVILEGES),
					me.name, from->name);
			return -1;
		}
		paramcount = cmptr->parameters;
		cmptr->bytes += bytes;
		if (!(cmptr->flags & M_NOLAG))
			parse_addlag(cptr, bytes);
	}
	/*
	   ** Must the following loop really be so devious? On
	   ** surface it splits the message to parameters from
	   ** blank spaces. But, if paramcount has been reached,
	   ** the rest of the message goes into this last parameter
	   ** (about same effect as ":" has...) --msa
	 */

	/* Note initially true: s==NULL || *(s-1) == '\0' !! */

	i = 0;
	if (s)
	{
		/*
		if (paramcount > MAXPARA)
			paramcount = MAXPARA;
		We now use functions to create commands, so we can just check this
		once when the command is created rather than each time the command
		is used -- codemastr
		*/
		for (;;)
		{
			/*
			   ** Never "FRANCE " again!! ;-) Clean
			   ** out *all* blanks.. --msa
			 */
			while (*s == ' ')
				*s++ = '\0';

			if (*s == '\0')
				break;
			if (*s == ':')
			{
				/*
				   ** The rest is single parameter--can
				   ** include blanks also.
				 */
				para[++i] = s + 1;
				break;
			}
			para[++i] = s;
			if (i >= paramcount)
				break;
			for (; *s != ' ' && *s; s++)
				;
		}
	}
	para[++i] = NULL;
	if (cmptr == NULL)
		return (do_numeric(numeric, cptr, from, i, para));
	cmptr->count++;
	if (IsRegisteredUser(cptr) && (cmptr->flags & M_RESETIDLE))
		cptr->local->last = TStime();

#ifndef DEBUGMODE
	if (cmptr->flags & M_ALIAS)
		return (*cmptr->func) (cptr, from, i, para, cmptr->cmd);
	else
	{
		if (!cmptr->overriders)
			return (*cmptr->func) (cptr, from, i, para);
		return (*cmptr->overridetail->func) (cmptr->overridetail, cptr, from, i, para);
	}
#else
	then = clock();
	if (cmptr->flags & M_ALIAS)
		retval = (*cmptr->func) (cptr, from, i, para, cmptr->cmd);
	else
	{
		if (!cmptr->overriders)
			retval = (*cmptr->func) (cptr, from, i, para);
		else
			retval = (*cmptr->overridetail->func) (cmptr->overridetail, cptr, from, i, para);
	}
	if (retval != FLUSH_BUFFER)
	{
		ticks = (clock() - then);
		if (IsServer(cptr))
			cmptr->rticks += ticks;
		else
			cmptr->lticks += ticks;
		cptr->local->cputime += ticks;
	}

	return retval;
#endif
}

static int cancel_clients(aClient *cptr, aClient *sptr, char *cmd)
{
	if (IsServer(cptr) || IsServer(sptr) || IsMe(sptr)) return 0;
	return exit_client(cptr, cptr, &me, "Fake prefix");
}

static void remove_unknown(aClient *cptr, char *sender)
{
	if (!IsRegistered(cptr) || IsClient(cptr))
		return;
	/*
	 * Not from a server so don't need to worry about it.
	 */
	if (!IsServer(cptr))
		return;

#ifdef DEVELOP
	sendto_ops("Killing %s (%s)", sender, backupbuf);
	return;
#endif
	/*
	 * Do kill if it came from a server because it means there is a ghost
	 * user on the other server which needs to be removed. -avalon
	 */
	if (!index(sender, '.') && !isdigit(*sender))
		sendto_one(cptr, ":%s KILL %s :%s (%s(?) <- %s)",
		    me.name, sender, me.name, sender, cptr->name);
	else
		sendto_one(cptr, ":%s SQUIT %s :(Unknown from %s)",
		    me.name, sender, get_client_name(cptr, FALSE));
}


text:
/*
 * Information local to this implementation of stdio,
 * in particular, macros and private variables.
 */

#include <_ansi.h>
#include <reent.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#ifdef __SCLE
# include <io.h>
#endif

extern u_char *_EXFUN(__sccl, (char *, u_char *fmt));
extern int    _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
extern int    _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
extern int    _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
extern int    _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
extern int    _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
extern int    _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
extern int    _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
extern int    _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
int	      _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *,
				  va_list)
               			_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int	      _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *,
				  va_list)
               			_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int	      _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *,
				  va_list));
int	      _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *,
				  va_list));
extern FILE  *_EXFUN(__sfp,(struct _reent *));
extern int    _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
extern int    _EXFUN(__srefill_r,(struct _reent *,FILE *));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *,
					       int));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *,
						  char *, int));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *,
						const char *, int));
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int));
extern int    _EXFUN(__sclose,(struct _reent *, void *));
extern int    _EXFUN(__stextmode,(int));
extern _VOID   _EXFUN(__sinit,(struct _reent *));
extern _VOID   _EXFUN(_cleanup_r,(struct _reent *));
extern _VOID   _EXFUN(__smakebuf_r,(struct _reent *, FILE *));
extern int    _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *)));
extern int    _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *)));
struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n));
extern int _EXFUN(__submore, (struct _reent *, FILE *));

#ifdef __LARGE64_FILES
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
						  const char *, int));
#endif

/* Called by the main entry point fns to ensure stdio has been initialized.  */

#ifdef _REENT_SMALL
#define CHECK_INIT(ptr, fp) \
  do						\
    {						\
      if ((ptr) && !(ptr)->__sdidinit)		\
	__sinit (ptr);				\
      if ((fp) == (FILE *)&__sf_fake_stdin)	\
	(fp) = _stdin_r(ptr);			\
      else if ((fp) == (FILE *)&__sf_fake_stdout) \
	(fp) = _stdout_r(ptr);			\
      else if ((fp) == (FILE *)&__sf_fake_stderr) \
	(fp) = _stderr_r(ptr);			\
    }						\
  while (0)
#else /* !_REENT_SMALL   */
#define CHECK_INIT(ptr, fp) \
  do						\
    {						\
      if ((ptr) && !(ptr)->__sdidinit)		\
	__sinit (ptr);				\
    }						\
  while (0)
#endif /* !_REENT_SMALL  */

#define CHECK_STD_INIT(ptr) \
  do						\
    {						\
      if ((ptr) && !(ptr)->__sdidinit)		\
	__sinit (ptr);				\
    }						\
  while (0)

/* Return true iff the given FILE cannot be written now.  */

#define	cantwrite(ptr, fp)                                     \
  ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
   __swsetup_r(ptr, fp))

/* Test whether the given stdio file has an active ungetc buffer;
   release such a buffer, without restoring ordinary unread data.  */

#define	HASUB(fp) ((fp)->_ub._base != NULL)
#define	FREEUB(ptr, fp) {                    \
	if ((fp)->_ub._base != (fp)->_ubuf) \
		_free_r(ptr, (char *)(fp)->_ub._base); \
	(fp)->_ub._base = NULL; \
}

/* Test for an fgetline() buffer.  */

#define	HASLB(fp) ((fp)->_lb._base != NULL)
#define	FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \
      (fp)->_lb._base = NULL; }

/*
 * Set the orientation for a stream. If o > 0, the stream has wide-
 * orientation. If o < 0, the stream has byte-orientation.
 */
#define ORIENT(fp,ori)					\
  do								\
    {								\
      if (!((fp)->_flags & __SORD))	\
	{							\
	  (fp)->_flags |= __SORD;				\
	  if (ori > 0)						\
	    (fp)->_flags2 |= __SWID;				\
	  else							\
	    (fp)->_flags2 &= ~__SWID;				\
	}							\
    }								\
  while (0)

/* WARNING: _dcvt is defined in the stdlib directory, not here!  */

char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int));
char *_EXFUN(_sicvt,(char *, short, char));
char *_EXFUN(_icvt,(char *, int, char));
char *_EXFUN(_licvt,(char *, long, char));
#ifdef __GNUC__
char *_EXFUN(_llicvt,(char *, long long, char));
#endif

#define CVT_BUF_SIZE 128

#define	NDYNAMIC 4	/* add four more whenever necessary */

#ifdef __SINGLE_THREAD__
#define __sfp_lock_acquire()
#define __sfp_lock_release()
#define __sinit_lock_acquire()
#define __sinit_lock_release()
#else
_VOID _EXFUN(__sfp_lock_acquire,(_VOID));
_VOID _EXFUN(__sfp_lock_release,(_VOID));
_VOID _EXFUN(__sinit_lock_acquire,(_VOID));
_VOID _EXFUN(__sinit_lock_release,(_VOID));
#endif

/* Types used in positional argument support in vfprinf/vfwprintf.
   The implementation is char/wchar_t dependent but the class and state
   tables are only defined once in vfprintf.c. */
typedef enum {
  ZERO,   /* '0' */
  DIGIT,  /* '1-9' */
  DOLLAR, /* '$' */
  MODFR,  /* spec modifier */
  SPEC,   /* format specifier */
  DOT,    /* '.' */
  STAR,   /* '*' */
  FLAG,   /* format flag */
  OTHER,  /* all other chars */
  MAX_CH_CLASS /* place-holder */
} __CH_CLASS;

typedef enum {
  START,  /* start */
  SFLAG,  /* seen a flag */
  WDIG,   /* seen digits in width area */
  WIDTH,  /* processed width */
  SMOD,   /* seen spec modifier */
  SDOT,   /* seen dot */
  VARW,   /* have variable width specifier */
  VARP,   /* have variable precision specifier */
  PREC,   /* processed precision */
  VWDIG,  /* have digits in variable width specification */
  VPDIG,  /* have digits in variable precision specification */
  DONE,   /* done */
  MAX_STATE, /* place-holder */
} __STATE;

typedef enum {
  NOOP,  /* do nothing */
  NUMBER, /* build a number from digits */
  SKIPNUM, /* skip over digits */
  GETMOD,  /* get and process format modifier */
  GETARG,  /* get and process argument */
  GETPW,   /* get variable precision or width */
  GETPWB,  /* get variable precision or width and pushback fmt char */
  GETPOS,  /* get positional parameter value */
  PWPOS,   /* get positional parameter value for variable width or precision */
} __ACTION;

extern _CONST __CH_CLASS __chclass[256];
extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS];
extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS];


text:
import sys
import boto3
import botocore

"""
A very simple example of using boto3 client APIs for multipart upload.
Some key things to consider when performing the multipart upload.
1. ALways make sure to either complete or abort the upload in case of failure
   The uploaded chunks do not get deleted automatically and they start
   accumulating and costing a lot.
2. Set a lifecycle policy on the bucket to clean out chunks after x no of days
3. The minimum size of a single chunk is 5MB except the last chunk, any licenses
   than that and you will get a boto exception of EntityTooSmall.
"""

def multipart_upload(s3client,
                     bucket_name,
                     filename,
                     key):
    """
    Upload a large file using multipart upload.

    Three distinct steps:
    1. Initiate a multipart upload. Get the upload id which will be used in
       subsequent steps.
    2. Start uploading chunks (pass the upload id to let it know ID
       of the initiated upload), also keep track of the parts . You will use that
       to complete the upload.
    3. Complete the upload. (pass the list of parts (a dict of eTag and part no)
        )
    """
    # Initiate multipart upload.
    try:
        response = s3client.create_multipart_upload(
            Bucket=bucket_name,
            Key=key,
            ACL='private',
            StorageClass='STANDARD')
    except botocore.exceptions.ClientError as err:
        print "Exception occured initiating multipart upload: %s" % err
        sys.exit()

    upload_id = response['UploadId']

    parts = []
    part_no = 1

    # Upload individual Chunks.
    with open(filename, "rb") as fhandle:
        # 5MB is the minimum size of each part you upload.
        chunk_size = 5 * 1024 * 1024
        while True:
            chunk = fhandle.read(chunk_size)
            if len(chunk) == 0:
                print "Done!"
                break

            # upload chunks
            try:
                response = s3client.upload_part(Bucket=bucket_name,
                                                Body=chunk,
                                                Key=key,
                                                PartNumber=part_no,
                                                UploadId=upload_id)
            except botocore.exceptions.ParamValidationError as err:
                print "Upload part failed [%s]" % err
                s3client.abort_multipart_upload(Bucket=bucket_name,
                                                Key="test.iso",
                                                UploadId=upload_id)
                sys.exit()
            except botocore.errorfactory.NoSuchUpload as err:
                print "No such upload"
                s3client.abort_multipart_upload(Bucket=bucket_name,
                                                Key="test.iso",
                                                UploadId=upload_id)
                sys.exit()

            parts.append({'ETag': response['ETag'], 'PartNumber': part_no})
            part_no += 1

    print "Total Chunks uploaded: ", len(parts)
    # Complete the upload.
    response = s3client.complete_multipart_upload(Bucket=bucket_name,
                                                  Key="test.iso",
                                                  MultipartUpload={
                                                      'Parts': parts
                                                  },
                                                  UploadId=upload_id)

def main():
    profile_name = "default"
    try:
        session = boto3.Session(profile_name=profile_name,
                                region_name="eu-central-1")
        s3client = session.client('s3')
    except botocore.exceptions.ProfileNotFound:
        print "Profile %s not found" % profile_name
        sys.exit()

    multipart_upload(s3client, 'simple-testbucket101',
                     'test.iso', 'test.iso')

if __name__ == '__main__':
    main()


text:
package org.apache.harmony.pack200;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.harmony.pack200.AttributeDefinitionBands.AttributeDefinition;
import org.objectweb.asm.Label;

/**
 * Set of bands relating to a non-predefined attribute that has had a layout
 * definition given to pack200 (e.g. via one of the -C, -M, -F or -D command
 * line options)
 */
public class NewAttributeBands extends BandSet {

    protected List attributeLayoutElements;
    private int[] backwardsCallCounts;
    private final CpBands cpBands;
    private final AttributeDefinition def;
    private boolean usedAtLeastOnce;

    // used when parsing
    private Integral lastPIntegral;

    public NewAttributeBands(int effort, CpBands cpBands, SegmentHeader header, AttributeDefinition def) throws IOException {
        super(effort, header);
        this.def = def;
        this.cpBands = cpBands;
        parseLayout();
    }

    public void addAttribute(NewAttribute attribute) {
        usedAtLeastOnce = true;
        InputStream stream = new ByteArrayInputStream(attribute.getBytes());
        for (Iterator iterator = attributeLayoutElements.iterator(); iterator.hasNext();) {
            AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
            layoutElement.addAttributeToBand(attribute, stream);
        }
    }

    public void pack(OutputStream out) throws IOException, Pack200Exception {
        for (Iterator iterator = attributeLayoutElements.iterator(); iterator.hasNext();) {
            AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
            layoutElement.pack(out);
        }
    }

    public String getAttributeName() {
        return def.name.getUnderlyingString();
    }

    public int getFlagIndex() {
        return def.index;
    }

    public int[] numBackwardsCalls() {
        return backwardsCallCounts;
    }

    public boolean isUsedAtLeastOnce() {
        return usedAtLeastOnce;
    }

    private void parseLayout() throws IOException {
        String layout = def.layout.getUnderlyingString();
        if (attributeLayoutElements == null) {
            attributeLayoutElements = new ArrayList();
            StringReader stream = new StringReader(layout);
            AttributeLayoutElement e;
            while ((e = readNextAttributeElement(stream)) != null) {
                attributeLayoutElements.add(e);
            }
            resolveCalls();
        }
    }

    /**
     * Resolve calls in the attribute layout and returns the number of backwards
     * callables
     *
     * @param tokens -
     *            the attribute layout as a List of AttributeElements
     */
    private void resolveCalls() {
        for (int i = 0; i < attributeLayoutElements.size(); i++) {
            AttributeLayoutElement element = (AttributeLayoutElement) attributeLayoutElements
                    .get(i);
            if (element instanceof Callable) {
                Callable callable = (Callable) element;
                List body = callable.body; // Look for calls in the body
                for (int iIndex = 0; iIndex < body.size(); iIndex++) {
                    LayoutElement layoutElement = (LayoutElement) body
                            .get(iIndex);
                    // Set the callable for each call
                    resolveCallsForElement(i, callable, layoutElement);
                }
            }
        }
        int backwardsCallableIndex = 0;
        for (int i = 0; i < attributeLayoutElements.size(); i++) {
            AttributeLayoutElement element = (AttributeLayoutElement) attributeLayoutElements
                    .get(i);
            if (element instanceof Callable) {
                Callable callable = (Callable) element;
                if(callable.isBackwardsCallable) {
                    callable.setBackwardsCallableIndex(backwardsCallableIndex);
                    backwardsCallableIndex++;
                }
            }
        }
        backwardsCallCounts = new int[backwardsCallableIndex];
    }

    private void resolveCallsForElement(int i,
            Callable currentCallable, LayoutElement layoutElement) {
        if (layoutElement instanceof Call) {
            Call call = (Call) layoutElement;
            int index = call.callableIndex;
            if (index == 0) { // Calls the parent callable
                call.setCallable(currentCallable);
            } else if (index > 0) { // Forwards call
                for (int k = i + 1; k < attributeLayoutElements.size(); k++) {
                    AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
                            .get(k);
                    if (el instanceof Callable) {
                        index--;
                        if (index == 0) {
                            call.setCallable((Callable) el);
                            break;
                        }
                    }
                }
            } else { // Backwards call
                for (int k = i - 1; k >= 0; k--) {
                    AttributeLayoutElement el = (AttributeLayoutElement) attributeLayoutElements
                            .get(k);
                    if (el instanceof Callable) {
                        index++;
                        if (index == 0) {
                            call.setCallable((Callable) el);
                            break;
                        }
                    }
                }
            }
        } else if (layoutElement instanceof Replication) {
            List children = ((Replication)layoutElement).layoutElements;
            for (Iterator iterator = children.iterator(); iterator.hasNext();) {
                LayoutElement object = (LayoutElement) iterator.next();
                resolveCallsForElement(i, currentCallable, object);
            }
        }
    }

    private AttributeLayoutElement readNextAttributeElement(StringReader stream)
            throws IOException {
        stream.mark(1);
        int nextChar = stream.read();
        if (nextChar == -1) {
            return null;
        }
        if (nextChar == '[') {
            List body = readBody(getStreamUpToMatchingBracket(stream));
            return new Callable(body);
        } else {
            stream.reset();
            return readNextLayoutElement(stream);
        }
    }

    private LayoutElement readNextLayoutElement(StringReader stream)
            throws IOException {
        int nextChar = stream.read();
        if (nextChar == -1) {
            return null;
        }

        switch (nextChar) {
        // Integrals
        case 'B':
        case 'H':
        case 'I':
        case 'V':
            return new Integral(new String(new char[] { (char)nextChar }));
        case 'S':
        case 'F':
            return new Integral(new String(new char[] { (char)nextChar,
                    (char) stream.read() }));
        case 'P':
            stream.mark(1);
            if (stream.read() != 'O') {
                stream.reset();
                lastPIntegral = new Integral("P" + (char) stream.read());
                return lastPIntegral;
            } else {
                lastPIntegral = new Integral("PO" + (char) stream.read(), lastPIntegral);
                return lastPIntegral;
            }
        case 'O':
            stream.mark(1);
            if (stream.read() != 'S') {
                stream.reset();
                return new Integral("O" + (char) stream.read(), lastPIntegral);
            } else {
                return new Integral("OS" + (char) stream.read(), lastPIntegral);
            }

            // Replication
        case 'N':
            char uint_type = (char) stream.read();
            stream.read(); // '['
            String str = readUpToMatchingBracket(stream);
            return new Replication("" + uint_type, str);

            // Union
        case 'T':
            String int_type = "" + (char) stream.read();
            if (int_type.equals("S")) {
                int_type += (char) stream.read();
            }
            List unionCases = new ArrayList();
            UnionCase c;
            while ((c = readNextUnionCase(stream)) != null) {
                unionCases.add(c);
            }
            stream.read(); // '('
            stream.read(); // ')'
            stream.read(); // '['
            List body = null;
            stream.mark(1);
            char next = (char) stream.read();
            if (next != ']') {
                stream.reset();
                body = readBody(getStreamUpToMatchingBracket(stream));
            }
            return new Union(int_type, unionCases, body);

            // Call
        case '(':
            int number = readNumber(stream).intValue();
            stream.read(); // ')'
            return new Call(number);
            // Reference
        case 'K':
        case 'R':
            String string = "" + (char)nextChar + (char) stream.read();
            char nxt = (char) stream.read();
            string += nxt;
            if (nxt == 'N') {
                string += (char) stream.read();
            }
            return new Reference(string);
        }
        return null;
    }

    /**
     * Read a UnionCase from the stream
     *
     * @param stream
     * @return
     * @throws IOException
     */
    private UnionCase readNextUnionCase(StringReader stream) throws IOException {
        stream.mark(2);
        stream.read(); // '('
        char next = (char) stream.read();
        if (next == ')') {
            stream.reset();
            return null;
        } else {
            stream.reset();
            stream.read(); // '('
        }
        List tags = new ArrayList();
        Integer nextTag;
        do {
            nextTag = readNumber(stream);
            if(nextTag != null) {
                tags.add(nextTag);
                stream.read(); // ',' or ')'
            }
        } while (nextTag != null);
        stream.read(); // '['
        stream.mark(1);
        next = (char) stream.read();
        if (next == ']') {
            return new UnionCase(tags);
        } else {
            stream.reset();
            return new UnionCase(tags,
                    readBody(getStreamUpToMatchingBracket(stream)));
        }
    }

    /**
     * An AttributeLayoutElement is a part of an attribute layout and has one or
     * more bands associated with it, which transmit the AttributeElement data
     * for successive Attributes of this type.
     */
    public interface AttributeLayoutElement {

        public void addAttributeToBand(NewAttribute attribute, InputStream stream);

        public void pack(OutputStream out) throws IOException, Pack200Exception;

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets);

    }

    public abstract class LayoutElement implements AttributeLayoutElement {

        protected int getLength(char uint_type) {
            int length = 0;
            switch (uint_type) {
            case 'B':
                length = 1;
                break;
            case 'H':
                length = 2;
                break;
            case 'I':
                length = 4;
                break;
            case 'V':
                length = 0;
                break;
            }
            return length;
        }
    }

    public class Integral extends LayoutElement {

        private final String tag;

        private final List band = new ArrayList();
        private final BHSDCodec defaultCodec;

        // used for bytecode offsets (OH and POH)
        private Integral previousIntegral;
        private int previousPValue;

        public Integral(String tag) {
            this.tag = tag;
            this.defaultCodec = getCodec(tag);
        }

        public Integral(String tag, Integral previousIntegral) {
            this.tag = tag;
            this.defaultCodec = getCodec(tag);
            this.previousIntegral = previousIntegral;
        }

        public String getTag() {
            return tag;
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            Object val = null;
            int value = 0;
            if (tag.equals("B") || tag.equals("FB")) {
                value = readInteger(1, stream) & 0xFF; // unsigned byte
            } else if (tag.equals("SB")) {
                value = readInteger(1, stream);
            } else if (tag.equals("H") || tag.equals("FH")) {
                value = readInteger(2, stream) & 0xFFFF; // unsigned short
            } else if (tag.equals("SH")) {
                value = readInteger(2, stream);
            } else if (tag.equals("I") || tag.equals("FI")) {
                value = readInteger(4, stream);
            } else if (tag.equals("SI")) {
                value = readInteger(4, stream);
            } else if (tag.equals("V") || tag.equals("FV") || tag.equals("SV")) {
                // Not currently supported
            } else if (tag.startsWith("PO") || tag.startsWith("OS")) {
                char uint_type = tag.substring(2).toCharArray()[0];
                int length = getLength(uint_type);
                value = readInteger(length, stream);
                value += previousIntegral.previousPValue;
                val = attribute.getLabel(value);
                previousPValue = value;
            } else if (tag.startsWith("P")) {
                char uint_type = tag.substring(1).toCharArray()[0];
                int length = getLength(uint_type);
                value = readInteger(length, stream);
                val = attribute.getLabel(value);
                previousPValue = value;
            } else if (tag.startsWith("O")) {
                char uint_type = tag.substring(1).toCharArray()[0];
                int length = getLength(uint_type);
                value = readInteger(length, stream);
                value += previousIntegral.previousPValue;
                val = attribute.getLabel(value);
                previousPValue = value;
            }
            if(val == null) {
                val = new Integer(value);
            }
            band.add(val);
        }

        public void pack(OutputStream out) throws IOException, Pack200Exception {
            PackingUtils.log("Writing new attribute bands...");
            byte[] encodedBand = encodeBandInt(tag, integerListToArray(band),
                    defaultCodec);
            out.write(encodedBand);
            PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
                    + tag + "[" + band.size() + "]");
        }

        public int latestValue() {
            return ((Integer)band.get(band.size() - 1)).intValue();
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            if(tag.startsWith("O") || tag.startsWith("PO")) {
                renumberOffsetBci(previousIntegral.band, bciRenumbering, labelsToOffsets);
            } else if (tag.startsWith("P")) {
                for (int i = band.size() - 1; i >= 0; i--) {
                    Object label = band.get(i);
                    if (label instanceof Integer) {
                        break;
                    } else if (label instanceof Label) {
                        band.remove(i);
                        Integer bytecodeIndex = (Integer) labelsToOffsets
                                .get(label);
                        band.add(i, new Integer(bciRenumbering.get(bytecodeIndex
                                .intValue())));
                    }
                }
            }
        }

        private void renumberOffsetBci(List relative,
                IntList bciRenumbering, Map labelsToOffsets) {
            for (int i = band.size() - 1; i >= 0; i--) {
                Object label = band.get(i);
                if (label instanceof Integer) {
                    break;
                } else if (label instanceof Label) {
                    band.remove(i);
                    Integer bytecodeIndex = (Integer) labelsToOffsets.get(label);
                    Integer renumberedOffset = new Integer(bciRenumbering
                            .get(bytecodeIndex.intValue())
                            - ((Integer) relative.get(i)).intValue());
                    band.add(i, renumberedOffset);
                }
            }
        }

    }

    /**
     * A replication is an array of layout elements, with an associated count
     */
    public class Replication extends LayoutElement {

        private final Integral countElement;

        private final List layoutElements = new ArrayList();

        public Integral getCountElement() {
            return countElement;
        }

        public List getLayoutElements() {
            return layoutElements;
        }

        public Replication(String tag, String contents) throws IOException {
            this.countElement = new Integral(tag);
            StringReader stream = new StringReader(contents);
            LayoutElement e;
            while ((e = readNextLayoutElement(stream)) != null) {
                layoutElements.add(e);
            }
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            countElement.addAttributeToBand(attribute, stream);
            int count = countElement.latestValue();
            for (int i = 0; i < count; i++) {
                for (Iterator iterator = layoutElements.iterator(); iterator.hasNext();) {
                    AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
                    layoutElement.addAttributeToBand(attribute, stream);
                }
            }
        }

        public void pack(OutputStream out) throws IOException, Pack200Exception {
            countElement.pack(out);
            for (Iterator iterator = layoutElements.iterator(); iterator.hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
                layoutElement.pack(out);
            }
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            for (Iterator iterator = layoutElements.iterator(); iterator.hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
                layoutElement.renumberBci(bciRenumbering, labelsToOffsets);
            }
        }
    }

    /**
     * A Union is a type of layout element where the tag value acts as a
     * selector for one of the union cases
     */
    public class Union extends LayoutElement {

        private final Integral unionTag;
        private final List unionCases;
        private final List defaultCaseBody;

        public Union(String tag, List unionCases, List body) {
            this.unionTag = new Integral(tag);
            this.unionCases = unionCases;
            this.defaultCaseBody = body;
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            unionTag.addAttributeToBand(attribute, stream);
            long tag = unionTag.latestValue();
            boolean defaultCase = true;
            for (int i = 0; i < unionCases.size(); i++) {
                UnionCase element = (UnionCase) unionCases.get(i);
                if (element.hasTag(tag)) {
                    defaultCase = false;
                    element.addAttributeToBand(attribute, stream);
                }
            }
            if (defaultCase) {
                for (int i = 0; i < defaultCaseBody.size(); i++) {
                    LayoutElement element = (LayoutElement) defaultCaseBody
                            .get(i);
                    element.addAttributeToBand(attribute, stream);
                }
            }
        }

        public void pack(OutputStream out) throws IOException, Pack200Exception {
            unionTag.pack(out);
            for (Iterator iterator = unionCases.iterator(); iterator.hasNext();) {
                UnionCase unionCase = (UnionCase) iterator.next();
                unionCase.pack(out);
            }
            for (Iterator iterator = defaultCaseBody.iterator(); iterator
                    .hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator
                        .next();
                layoutElement.pack(out);
            }
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            for (Iterator iterator = unionCases.iterator(); iterator.hasNext();) {
                UnionCase unionCase = (UnionCase) iterator.next();
                unionCase.renumberBci(bciRenumbering, labelsToOffsets);
            }
            for (Iterator iterator = defaultCaseBody.iterator(); iterator
                    .hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator
                        .next();
                layoutElement.renumberBci(bciRenumbering, labelsToOffsets);
            }
        }

        public Integral getUnionTag() {
            return unionTag;
        }

        public List getUnionCases() {
            return unionCases;
        }

        public List getDefaultCaseBody() {
            return defaultCaseBody;
        }
    }

    public class Call extends LayoutElement {

        private final int callableIndex;
        private Callable callable;

        public Call(int callableIndex) {
            this.callableIndex = callableIndex;
        }

        public void setCallable(Callable callable) {
            this.callable = callable;
            if (callableIndex < 1) {
                callable.setBackwardsCallable();
            }
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            callable.addAttributeToBand(attribute, stream);
            if(callableIndex < 1) {
                callable.addBackwardsCall();
            }
        }

        public void pack(OutputStream out) {
            // do nothing here as pack will be called on the callable at another time
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            // do nothing here as renumberBci will be called on the callable at another time
        }

        public int getCallableIndex() {
            return callableIndex;
        }

        public Callable getCallable() {
            return callable;
        }
    }

    /**
     * Constant Pool Reference
     */
    public class Reference extends LayoutElement {

        private final String tag;

        private List band;

        private boolean nullsAllowed = false;

        public Reference(String tag) {
            this.tag = tag;
            nullsAllowed = tag.indexOf('N') != -1;
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            int index = readInteger(4, stream);
            if(tag.startsWith("RC")) { // Class
                band.add(cpBands.getCPClass(attribute.readClass(index)));
            } else if (tag.startsWith("RU")) { // UTF8 String
                band.add(cpBands.getCPUtf8(attribute.readUTF8(index)));
            } else if (tag.startsWith("RS")) { // Signature
                band.add(cpBands.getCPSignature(attribute.readUTF8(index)));
            } else { // Constant
                band.add(cpBands.getConstant(attribute.readConst(index)));
            }
            // TODO method and field references
        }

        public String getTag() {
            return tag;
        }

        public void pack(OutputStream out) throws IOException, Pack200Exception {
            int[] ints;
            if(nullsAllowed) {
                ints = cpEntryOrNullListToArray(band);
            } else {
                ints = cpEntryListToArray(band);
            }
            byte[] encodedBand = encodeBandInt(tag, ints, Codec.UNSIGNED5);
            out.write(encodedBand);
            PackingUtils.log("Wrote " + encodedBand.length + " bytes from "
                    + tag + "[" + ints.length + "]");
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            // nothing to do here
        }

    }

    public class Callable implements AttributeLayoutElement {

        private final List body;

        private boolean isBackwardsCallable;

        private int backwardsCallableIndex;

        public Callable(List body) throws IOException {
            this.body = body;
        }

        public void setBackwardsCallableIndex(int backwardsCallableIndex) {
            this.backwardsCallableIndex = backwardsCallableIndex;
        }

        public void addBackwardsCall() {
            backwardsCallCounts[backwardsCallableIndex]++;
        }

        public boolean isBackwardsCallable() {
            return isBackwardsCallable;
        }

        /**
         * Tells this Callable that it is a backwards callable
         */
        public void setBackwardsCallable() {
            this.isBackwardsCallable = true;
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            for (Iterator iterator = body.iterator(); iterator.hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
                layoutElement.addAttributeToBand(attribute, stream);
            }
        }

        public void pack(OutputStream out) throws IOException, Pack200Exception {
            for (Iterator iterator = body.iterator(); iterator.hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
                layoutElement.pack(out);
            }
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            for (Iterator iterator = body.iterator(); iterator.hasNext();) {
                AttributeLayoutElement layoutElement = (AttributeLayoutElement) iterator.next();
                layoutElement.renumberBci(bciRenumbering, labelsToOffsets);
            }
        }

        public List getBody() {
            return body;
        }
    }

    /**
     * A Union case
     */
    public class UnionCase extends LayoutElement {

        private final List body;

        private final List tags;

        public UnionCase(List tags) {
            this.tags = tags;
            this.body = Collections.EMPTY_LIST;
        }

        public boolean hasTag(long l) {
            return tags.contains(new Integer((int) l));
        }

        public UnionCase(List tags, List body) throws IOException {
            this.tags = tags;
            this.body = body;
        }

        public void addAttributeToBand(NewAttribute attribute,
                InputStream stream) {
            for (int i = 0; i < body.size(); i++) {
                LayoutElement element = (LayoutElement) body.get(i);
                element.addAttributeToBand(attribute, stream);
            }
        }

        public void pack(OutputStream out) throws IOException, Pack200Exception {
            for (int i = 0; i < body.size(); i++) {
                LayoutElement element = (LayoutElement) body.get(i);
                element.pack(out);
            }
        }

        public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
            for (int i = 0; i < body.size(); i++) {
                LayoutElement element = (LayoutElement) body.get(i);
                element.renumberBci(bciRenumbering, labelsToOffsets);
            }
        }

        public List getBody() {
            return body;
        }
    }

    /**
     * Utility method to get the contents of the given stream, up to the next
     * ']', (ignoring pairs of brackets '[' and ']')
     *
     * @param stream
     * @return
     * @throws IOException
     */
    private StringReader getStreamUpToMatchingBracket(StringReader stream)
            throws IOException {
        StringBuffer sb = new StringBuffer();
        int foundBracket = -1;
        while (foundBracket != 0) {
            char c = (char) stream.read();
            if (c == ']') {
                foundBracket++;
            }
            if (c == '[') {
                foundBracket--;
            }
            if (!(foundBracket == 0)) {
                sb.append(c);
            }
        }
        return new StringReader(sb.toString());
    }

    private int readInteger(int i, InputStream stream) {
        int result = 0;
        for (int j = 0; j < i; j++) {
            try {
                result = result << 8 | stream.read();
            } catch (IOException e) {
                throw new RuntimeException("Error reading unknown attribute");
            }
        }
        // use casting to preserve sign
        if(i == 1) result = (byte) result;
        if(i == 2) result = (short) result;
        return result;
    }

    /**
     * Returns the {@link BHSDCodec} that should be used for the given layout
     * element
     *
     * @param layoutElement
     */
    private BHSDCodec getCodec(String layoutElement) {
        if (layoutElement.indexOf('O') >= 0) {
            return Codec.BRANCH5;
        } else if (layoutElement.indexOf('P') >= 0) {
            return Codec.BCI5;
        } else if (layoutElement.indexOf('S') >= 0 && layoutElement.indexOf("KS") < 0 //$NON-NLS-1$
                && layoutElement.indexOf("RS") < 0) { //$NON-NLS-1$
            return Codec.SIGNED5;
        } else if (layoutElement.indexOf('B') >= 0) {
            return Codec.BYTE1;
        } else {
            return Codec.UNSIGNED5;
        }
    }

    /**
     * Utility method to get the contents of the given stream, up to the next
     * ']', (ignoring pairs of brackets '[' and ']')
     *
     * @param stream
     * @return
     * @throws IOException
     */
    private String readUpToMatchingBracket(StringReader stream)
            throws IOException {
        StringBuffer sb = new StringBuffer();
        int foundBracket = -1;
        while (foundBracket != 0) {
            char c = (char) stream.read();
            if (c == ']') {
                foundBracket++;
            }
            if (c == '[') {
                foundBracket--;
            }
            if (!(foundBracket == 0)) {
                sb.append(c);
            }
        }
        return sb.toString();
    }

    /**
     * Read a number from the stream and return it
     *
     * @param stream
     * @return
     * @throws IOException
     */
    private Integer readNumber(StringReader stream) throws IOException {
        stream.mark(1);
        char first = (char) stream.read();
        boolean negative = first == '-';
        if (!negative) {
            stream.reset();
        }
        stream.mark(100);
        int i;
        int length = 0;
        while ((i = (stream.read())) != -1 && Character.isDigit((char) i)) {
            length++;
        }
        stream.reset();
        if(length == 0) {
            return null;
        }
        char[] digits = new char[length];
        int read = stream.read(digits);
        if (read != digits.length) {
            throw new IOException("Error reading from the input stream");
        }
        return new Integer(Integer.parseInt((negative ? "-" : "") + new String(digits)));
    }

    /**
     * Read a 'body' section of the layout from the given stream
     *
     * @param stream
     * @return List of LayoutElements
     * @throws IOException
     */
    private List readBody(StringReader stream) throws IOException {
        List layoutElements = new ArrayList();
        LayoutElement e;
        while ((e = readNextLayoutElement(stream)) != null) {
            layoutElements.add(e);
        }
        return layoutElements;
    }

    /**
     * Renumber any bytecode indexes or offsets as described in section 5.5.2 of
     * the pack200 specification
     *
     * @param bciRenumbering
     * @param labelsToOffsets
     */
    public void renumberBci(IntList bciRenumbering, Map labelsToOffsets) {
        for (Iterator iterator = attributeLayoutElements.iterator(); iterator.hasNext();) {
            AttributeLayoutElement element = (AttributeLayoutElement) iterator.next();
            element.renumberBci(bciRenumbering, labelsToOffsets);
        }
    }

}


text:
#region License

#endregion

using Newtonsoft.Json;

namespace ShipStation4Net.Domain.Entities
{
    public class CustomsItem
    {
        [JsonProperty("customsItemId")]
        public string CustomsItemId { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }

        [JsonProperty("quantity")]
        public int? Quantity { get; set; }

        [JsonProperty("value")]
        public double? Value { get; set; }

        [JsonProperty("harmonizedTariffCode")]
        public string HarmonizedTariffCode { get; set; }

        [JsonProperty("countryOfOrigin")]
        public string CountryOfOrigin { get; set; }
    }
}


text:
/*
(c) 2014-2015 Glen Joseph Fernandes
<glenjofe -at- gmail.com>

Distributed under the Boost Software
License, Version 1.0.
http://boost.org/LICENSE_1_0.txt
*/
#ifndef BOOST_ALIGN_HPP
#define BOOST_ALIGN_HPP

#include <boost/align/align.hpp>
#include <boost/align/align_down.hpp>
#include <boost/align/align_up.hpp>
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_allocator.hpp>
#include <boost/align/aligned_allocator_adaptor.hpp>
#include <boost/align/aligned_delete.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/align/assume_aligned.hpp>
#include <boost/align/is_aligned.hpp>

#endif


text:
import Controller from 'home/controllers/home.controller'
import template from 'views/home/home.template.html'

const component = {
    template : template,
    controller: Controller,
    controllerAs: 'vm'
};
export default component;


text:
"""Tests for various static pages (like the About page)."""

from core.tests import test_utils

class NoninteractivePagesTest(test_utils.GenericTestBase):

    def test_about_page(self):
        """Test the About page."""
        response = self.testapp.get('/about')
        self.assertEqual(response.status_int, 200)
        self.assertEqual(response.content_type, 'text/html')
        response.mustcontain(
            'I18N_ABOUT_PAGE_CREDITS_TAB_HEADING',
            'I18N_ABOUT_PAGE_FOUNDATION_TAB_PARAGRAPH_5_LICENSE_HEADING')


text:
package nl.tno.idsa.library.relations.role_requires_action;

import nl.tno.idsa.framework.semantics_impl.relations.ActionEnablesRole;
import nl.tno.idsa.library.actions.StreetTheft;
import nl.tno.idsa.library.roles.VictimOfCrime;

/**
 * Created by jongsd on 7-8-15.
 */
// TODO Add ignore unused. Document the class.
public class StreetTheftCreatesVictimOfCrime extends ActionEnablesRole {
    public StreetTheftCreatesVictimOfCrime() {
        super(StreetTheft.class, VictimOfCrime.class, false);
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx.xsd
       ">

    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

    <context:property-placeholder location="classpath:db.properties"/>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

        <property name="dataSource" ref="dataSource"/>

        <property name="packagesToScan" value="com.mc.spring.samples.services.persistence.model"/>

        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="${db.hibernate.show.sql}"/>
                <property name="generateDdl" value="${db.hibernate.generate}"/>
            </bean>
        </property>

    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

</beans>


text:
t('test count', function() {
  var hydro = Hydro();

  hydro.addSuite('root', function() {
    hydro.addTest('test 1');
    hydro.addTest('test 2');
    hydro.addTest('test 3');
  });

  assert(hydro.tests().length === 3);
});


text:
package de.fu_berlin.imp.apiua.groundedtheory.storage.impl;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

import junit.framework.Assert;

import org.apache.commons.io.FileUtils;

import com.bkahlert.nebula.utils.colors.RGB;

import de.fu_berlin.imp.apiua.core.model.ILocatable;
import de.fu_berlin.imp.apiua.core.model.TimeZoneDate;
import de.fu_berlin.imp.apiua.core.model.URI;
import de.fu_berlin.imp.apiua.groundedtheory.model.Code;
import de.fu_berlin.imp.apiua.groundedtheory.model.ICode;
import de.fu_berlin.imp.apiua.groundedtheory.model.ICodeInstance;
import de.fu_berlin.imp.apiua.groundedtheory.services.CodeServiceTest;
import de.fu_berlin.imp.apiua.groundedtheory.storage.ICodeStore;
import de.fu_berlin.imp.apiua.groundedtheory.storage.exceptions.CodeStoreReadException;
import de.fu_berlin.imp.apiua.groundedtheory.storage.impl.CodeInstance;
import de.fu_berlin.imp.apiua.groundedtheory.storage.impl.CodeStore;

public class CodeStoreHelper {
	private static File getTempFile() throws IOException {
		File dir = com.bkahlert.nebula.utils.FileUtils.getTempDirectory();
		File temp = new File(dir, CodeServiceTest.class.getSimpleName()
				+ ".xml");
		dir.deleteOnExit();
		return temp;
	}

	private File empty;
	private File small;

	protected File getEmptyFile() throws IOException {
		File file = getTempFile();
		FileUtils.copyFile(this.empty, file);
		return file;
	}

	protected File getSmallFile() throws IOException {
		File file = getTempFile();
		FileUtils.copyFile(this.small, file);
		return file;
	}

	protected ICode code1;
	protected ICode code2;
	protected ILocatable locatable1;
	protected ILocatable locatable2;
	protected ILocatable locatable3;
	protected ICodeInstance codeInstance1;
	protected ICodeInstance codeInstance2;
	protected ICodeInstance codeInstance3;

	protected ICode[] codes;
	protected ICodeInstance[] codeInstances;

	public CodeStoreHelper() throws URISyntaxException {
		this.empty = new File(
				CodeServiceTest.class
						.getResource(
								"/de/fu_berlin/imp/apiua/groundedtheory/data/CodeStore.empty.xml")
						.getFile());

		this.small = new File(
				CodeServiceTest.class
						.getResource(
								"/de/fu_berlin/imp/apiua/groundedtheory/data/CodeStore.small.xml")
						.getFile());

		this.code1 = new Code(234233209l, "Code #1", new RGB(1, 0.5, 0),
				new TimeZoneDate());
		this.code2 = new Code(9908372l, "Code #2", new RGB(0, 0.5, 1),
				new TimeZoneDate());

		this.codes = new ICode[] { this.code1, this.code2 };

		this.locatable1 = new ILocatable() {
			private static final long serialVersionUID = 1L;

			@Override
			public URI getUri() {
				return new URI("apiua://codeInstance1");
			}
		};
		this.locatable2 = new ILocatable() {
			private static final long serialVersionUID = 1L;

			@Override
			public URI getUri() {
				return new URI("apiua://codeInstance2");
			}
		};
		this.locatable3 = new ILocatable() {
			private static final long serialVersionUID = 1L;

			@Override
			public URI getUri() {
				return new URI("apiua://codeInstance3");
			}
		};

		this.codeInstance1 = new CodeInstance(1l, this.code2,
				this.locatable1.getUri(), new TimeZoneDate(
						"1984-05-15T14:30:00+02:00"));
		this.codeInstance2 = new CodeInstance(2l, this.code1,
				this.locatable2.getUri(), new TimeZoneDate(
						"2011-11-11T11:11:11+11:00"));
		this.codeInstance3 = new CodeInstance(3l, this.code2,
				this.locatable3.getUri(), new TimeZoneDate(
						"2002-09-23T23:08:01-04:30"));

		this.codeInstances = new ICodeInstance[] { this.codeInstance1,
				this.codeInstance2, this.codeInstance3 };
	}

	/**
	 * Tests whether the {@link ICodeStore} only contains all given
	 * {@link ICode}s.
	 *
	 * @param codeStore
	 * @param codes
	 * @throws IOException
	 */
	protected void testCodes(ICodeStore codeStore, ICode[] codes)
			throws IOException {
		List<ICode> loadedCodes = codeStore.getTopLevelCodes();
		Assert.assertEquals(codes.length, loadedCodes.size());

		HashMap<ICode, Boolean> inCodeStore = new HashMap<ICode, Boolean>();
		for (ICode loadedCode : loadedCodes) {
			inCodeStore.put(loadedCode, false);
		}

		for (ICode loadedCode : loadedCodes) {
			for (ICode code : codes) {
				if (loadedCode.getId() == code.getId()) {
					Assert.assertEquals(code.getCaption(),
							loadedCode.getCaption());
					inCodeStore.put(code, true);
				}
			}
			Assert.assertTrue(ICode.class.getSimpleName() + " " + loadedCode
					+ " is not in the test set", inCodeStore.get(loadedCode));
		}

		for (ICode code : inCodeStore.keySet()) {
			Assert.assertTrue(ICode.class.getSimpleName() + " " + code
					+ " is not in the " + ICodeStore.class.getSimpleName(),
					inCodeStore.get(code));
		}
	}

	protected void testCodeInstances(ICodeStore actualCodeInstances,
			ICodeInstance[] expectedCodeInstances)
			throws CodeStoreReadException {
		this.testCodeInstances(actualCodeInstances.getInstances(),
				expectedCodeInstances);
	}

	protected void testCodeInstances(Set<ICodeInstance> actualCodeInstances,
			ICodeInstance[] expectedCodeInstances)
			throws CodeStoreReadException {
		Assert.assertEquals(expectedCodeInstances.length,
				actualCodeInstances.size());

		HashMap<ICodeInstance, Boolean> inCodeStore = new HashMap<ICodeInstance, Boolean>();
		for (ICodeInstance loadedInstance : actualCodeInstances) {
			inCodeStore.put(loadedInstance, false);
		}

		for (ICodeInstance loadedInstance : actualCodeInstances) {
			for (ICodeInstance instance : expectedCodeInstances) {
				if (loadedInstance.equals(instance)) {
					Assert.assertEquals(instance.getCodeInstanceID(),
							loadedInstance.getCodeInstanceID());
					Assert.assertEquals(instance.getUri(),
							loadedInstance.getUri());
					Assert.assertEquals(instance.getCode(),
							loadedInstance.getCode());
					Assert.assertEquals(instance.getId(),
							loadedInstance.getId());
					Assert.assertEquals(instance.getCreation(),
							loadedInstance.getCreation());
					inCodeStore.put(loadedInstance, true);
				}
			}
			Assert.assertTrue(ICodeInstance.class.getSimpleName() + " "
					+ loadedInstance + " is not in the test set",
					inCodeStore.get(loadedInstance));
		}

		for (ICodeInstance instance : inCodeStore.keySet()) {
			Assert.assertTrue(
					ICodeInstance.class.getSimpleName() + " " + instance
							+ " is not in the "
							+ ICodeStore.class.getSimpleName(),
					inCodeStore.get(instance));
		}
	}

	protected ICodeStore getNonExistingCodeStore() throws IOException {
		return CodeStore.load(new File("/I/do/not/exist"));
	}

	protected ICodeStore getEmptyCodeStore() throws IOException {
		return CodeStore.create(this.getEmptyFile());
	}

	protected ICodeStore getSmallCodeStore() throws IOException {
		return CodeStore.load(this.getSmallFile());
	}

	protected ICodeStore loadFromCodeStore(ICodeStore codeStore)
			throws IOException {
		codeStore.save();
		return CodeStore.load(((CodeStore) codeStore).getCodeStoreFile());
	}
}


text:
Places is an iOS App that helps you manage all your favorite places. It uses Apple Maps and Local Notifications to help you categorize, discover, navigate and organize the world around you.

### Licensing
Places is licensed under [the MIT License](https://github.com/duliodenis/Places/blob/master/LICENSE).

### Support or Contact
Visit [ddApps.co](http://ddapps.co) to see more.