<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Snackycracky Techblog&#187; Snackycracky Blog</title>
	<atom:link href="http://blog.srvme.de/category/algorithms/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.srvme.de</link>
	<description></description>
	<lastBuildDate>Mon, 14 Jun 2010 21:33:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>reading a reflexive association in a recursive way for grails and groovy</title>
		<link>http://blog.srvme.de/2009/11/29/reading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy/</link>
		<comments>http://blog.srvme.de/2009/11/29/reading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 16:22:51 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[multiple menu items]]></category>
		<category><![CDATA[recursive menu items]]></category>
		<category><![CDATA[reflexive menuitems]]></category>
		<category><![CDATA[roles for menu]]></category>

		<guid isPermaLink="false">http://blog.srvme.de/?p=580</guid>
		<description><![CDATA[Imagine you have a Menu with multiple items, those items have multiple items and so on. The Menu Items also depend on a Role a User has in the Application Context like &#8216;ROLE_ADMIN&#8217;, &#8216;ROLE_COOK&#8217;, &#8216;ROLE_SOME&#8217; &#8230; I think the best practice is to save the menu items as a reflexive association in a database table [...]]]></description>
			<content:encoded><![CDATA[<p>Imagine you have a Menu with multiple items, those items have multiple items and so on. The Menu Items also depend on a Role a User has in the Application Context like &#8216;ROLE_ADMIN&#8217;, &#8216;ROLE_COOK&#8217;, &#8216;ROLE_SOME&#8217; &#8230;<br />
I think the best practice is to save the menu items as a reflexive association in a database table like this:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #aaaadd; font-weight: bold;">Long</span> id<span style="color: #66cc66;">;</span>
    <span style="color: #aaaadd; font-weight: bold;">String</span> label<span style="color: #66cc66;">;</span>
    <span style="color: #aaaadd; font-weight: bold;">Boolean</span> topLevel<span style="color: #66cc66;">;</span>
    <span style="color: #aaaadd; font-weight: bold;">Integer</span> position<span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> hasMany <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>roles:Role, childs:<span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">static</span> belongsTo <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>parent:<span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> mapping <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
        topLevel type:<span style="color: #ff0000;">'true_false'</span>
        childs <span style="color: #663399;">sort</span>:<span style="color: #ff0000;">'position'</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #aaaadd; font-weight: bold;">String</span> toString<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #ff0000;">&quot;[MenuItem id: ${id}, label: ${label}, pos: ${position}]&quot;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>so lets initialize some dummy menu Items:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> file <span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'file'</span>, position:<span style="color: #cc66cc;">1</span>,topLevel:<span style="color: #000000; font-weight: bold;">true</span>,parent:<span style="color: #000000; font-weight: bold;">null</span>, roles:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>somerole,cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">def</span> view <span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'view'</span>, position:<span style="color: #cc66cc;">2</span>,topLevel:<span style="color: #000000; font-weight: bold;">true</span>,parent:<span style="color: #000000; font-weight: bold;">null</span>, roles:<span style="color: #66cc66;">&#91;</span>cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">def</span> help <span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'help'</span>, position:<span style="color: #cc66cc;">2</span>,topLevel:<span style="color: #000000; font-weight: bold;">true</span>,parent:<span style="color: #000000; font-weight: bold;">null</span>, roles:<span style="color: #66cc66;">&#91;</span>someroleadminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">def</span> logout <span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'logout'</span>, position:<span style="color: #cc66cc;">2</span>,topLevel:<span style="color: #000000; font-weight: bold;">true</span>,parent:<span style="color: #000000; font-weight: bold;">null</span>, roles:<span style="color: #66cc66;">&#91;</span>somerole,cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>those 4 toplevel MenuItems have different roles assiciated with them, for example the view menu can only be accessed by a user wich has the cookrole or the adminrole. the roles have also the property of a level as a number which is zero for an admin user and one for a role which has less rights than the admin. the algorithm then extracts the hightest role from a user instance.<br />
so lets insert some submenus to the database table:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'save File'</span>, position:<span style="color: #cc66cc;">1</span>,topLevel:<span style="color: #000000; font-weight: bold;">false</span>,parent:file, roles:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>somerole,cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'save All Files'</span>, position:<span style="color: #cc66cc;">2</span>,topLevel:<span style="color: #000000; font-weight: bold;">false</span>,parent:file, roles:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>somerole,cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">def</span> serivces <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'services'</span>, position:<span style="color: #cc66cc;">3</span>,topLevel:<span style="color: #000000; font-weight: bold;">false</span>,parent:file, roles:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>somerole,cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'capture Image'</span>, position:<span style="color: #cc66cc;">1</span>,topLevel:<span style="color: #000000; font-weight: bold;">false</span>,parent:serivces, roles:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>somerole,cookrole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span><span style="color: #66cc66;">&#40;</span>label:<span style="color: #ff0000;">'send As Email'</span>, position:<span style="color: #cc66cc;">2</span>,topLevel:<span style="color: #000000; font-weight: bold;">false</span>,parent:serivces, roles:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>somerole,adminrole<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

<p>notice that the last menu item (send As Email) is not accessible for the cookrole<br />
We now have a three dimensional menu like this:</p>
<ul>
<li>file
<ul>
<li>save File</li>
<li>save All Files</li>
<li>services
<ul>
<li>capture Image</li>
<li>send As Email</li>
</ul>
</li>
</ul>
</li>
<li>view</li>
<li>help</li>
<li>logout</li>
</ul>
<p>here is the code to render this menu structure in a controller and send it to the view:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MainController <span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> authenticateService
    <span style="color: #000000; font-weight: bold;">def</span> testUser <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">null</span>
    <span style="color: #000000; font-weight: bold;">def</span> menuItems <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #66cc66;">&#93;</span>
&nbsp;
    <span style="color: #993333;">void</span> populateMenuItems<span style="color: #66cc66;">&#40;</span>map,hightestRole<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #808080; font-style: italic;">//fill the first time with topLevel Items</span>
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>menuItems.<span style="color: #006600;">isEmpty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
            map.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
                    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">roles</span>.<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span>hightestRole<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                        menuItems<span style="color: #66cc66;">&#91;</span>it<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #66cc66;">&#93;</span>
            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        menuItems.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span> mi <span style="color: #66cc66;">-&gt;</span>
&nbsp;
                <span style="color: #aaaadd; font-weight: bold;">MenuItem</span>.<span style="color: #006600;">findAllByParent</span><span style="color: #66cc66;">&#40;</span>mi.<span style="color: #006600;">key</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span> subMi <span style="color: #66cc66;">-&gt;</span>
&nbsp;
                        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>subMi.<span style="color: #006600;">roles</span>.<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span>hightestRole<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                            mi.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#91;</span>subMi<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #66cc66;">&#93;</span>
&nbsp;
                            findMore<span style="color: #66cc66;">&#40;</span> mi.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#91;</span>subMi<span style="color: #66cc66;">&#93;</span>,subMi<span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#125;</span>
                <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #993333;">void</span> findMore<span style="color: #66cc66;">&#40;</span>mapEntry,mi<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">def</span> moreItems <span style="color: #66cc66;">=</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span>.<span style="color: #006600;">findAllByParent</span><span style="color: #66cc66;">&#40;</span>mi<span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>moreItems.<span style="color: #006600;">isEmpty</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
            moreItems.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
                    mapEntry<span style="color: #66cc66;">&#91;</span>it<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #66cc66;">&#93;</span>
                    findMore<span style="color: #66cc66;">&#40;</span>mapEntry<span style="color: #66cc66;">&#91;</span>it<span style="color: #66cc66;">&#93;</span>,it<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">//recursive call</span>
            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">def</span> index <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">def</span> hightestRole <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">null</span>
        <span style="color: #000000; font-weight: bold;">def</span> principal <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span>testUser <span style="color: #66cc66;">!=</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">?</span> testUser : authenticateService.<span style="color: #006600;">principal</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #000000; font-weight: bold;">def</span> itRole
&nbsp;
        principal.<span style="color: #006600;">getAuthorities</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
                itRole <span style="color: #66cc66;">=</span> Role.<span style="color: #006600;">findByAuthority</span><span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">authority</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>hightestRole <span style="color: #66cc66;">==</span> <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">&#40;</span> hightestRole <span style="color: #66cc66;">!=</span> <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&amp;&amp;</span> itRole.<span style="color: #006600;">level</span> <span style="color: #66cc66;">&lt;</span> hightestRole.<span style="color: #006600;">level</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                    hightestRole <span style="color: #66cc66;">=</span> itRole
&nbsp;
        <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        populateMenuItems<span style="color: #66cc66;">&#40;</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span>.<span style="color: #006600;">findAllByTopLevel</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #663399;">sort</span>: <span style="color: #ff0000;">'position'</span>, order: <span style="color: #ff0000;">'asc'</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>, hightestRole <span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#91;</span>
                    highestRole:hightestRole,
                    menuItems:menuItems,
                    user: principal
                <span style="color: #66cc66;">&#93;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>the function populateMenuItems calls the function findMore which calls itself recursively as long as a submenu for some item exists.</p>
<p>here are some integation tests for this:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">def</span> miSaveFile <span style="color: #66cc66;">=</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span>.<span style="color: #006600;">findByLabel</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'save File'</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #000000; font-weight: bold;">def</span> miSendAsEmail <span style="color: #66cc66;">=</span> <span style="color: #aaaadd; font-weight: bold;">MenuItem</span>.<span style="color: #006600;">findByLabel</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'send As Email'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">def</span> user <span style="color: #66cc66;">=</span> User.<span style="color: #663399;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>
assertEquals <span style="color: #ff0000;">&quot;bestcook&quot;</span>, user.<span style="color: #006600;">username</span>
&nbsp;
controller.<span style="color: #006600;">testUser</span> <span style="color: #66cc66;">=</span> user<span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">def</span> model <span style="color: #66cc66;">=</span>  controller.<span style="color: #006600;">index</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
assertEquals <span style="color: #ff0000;">&quot;bestcook&quot;</span>, model<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;bestcook&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">?</span>.<span style="color: #006600;">username</span>
assertEquals Role.<span style="color: #006600;">findByAuthority</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ROLE_COOK&quot;</span><span style="color: #66cc66;">&#41;</span>,model<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;highestRole&quot;</span><span style="color: #66cc66;">&#93;</span>
assertFalse SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>model, miSendAsEmail<span style="color: #66cc66;">&#41;</span>
assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>model, miSaveFile<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>the SearchNestedHash class is explained in my previous article.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d580').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d580" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;submitHeadline=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;title=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;title=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;title=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;bm_description=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;T=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;title=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;title=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy+@+http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F29%2Freading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy%2F&amp;t=reading+a+reflexive+association+in+a+recursive+way+for+grails+and+groovy" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d580').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d580').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2009/11/29/reading-a-reflexive-association-in-a-recursive-way-for-grails-and-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>recursive search on a nested (multidimensional) collection for groovy</title>
		<link>http://blog.srvme.de/2009/11/28/recursive-search-on-a-nested-multidimensional-collection-for-groovy/</link>
		<comments>http://blog.srvme.de/2009/11/28/recursive-search-on-a-nested-multidimensional-collection-for-groovy/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 01:35:21 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[crawl]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[hashmap]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[multidimensional]]></category>
		<category><![CDATA[multidimensional map]]></category>
		<category><![CDATA[nested list]]></category>
		<category><![CDATA[nested map]]></category>
		<category><![CDATA[nested set]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://blog.srvme.de/?p=573</guid>
		<description><![CDATA[you can search for any object in a nested list containing hash&#8217;s and lists recursively, check out the tests for examples: here are the tests: class SearchNestedHashTests extends GrailsUnitTestCase &#123; protected void setUp&#40;&#41; &#123; super.setUp&#40;&#41; &#125; protected void tearDown&#40;&#41; &#123; super.tearDown&#40;&#41; &#125; void testHashMap&#40;&#41;&#123; &#160; def map = &#91; 'x' , 'y', 's' &#93; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>you can search for any object in a nested list containing hash&#8217;s and lists recursively, check out the tests for examples:<br />
<strong> </strong></p>
<p><strong>here are the tests:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> SearchNestedHashTests <span style="color: #000000; font-weight: bold;">extends</span> GrailsUnitTestCase <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> setUp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">setUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> tearDown<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">tearDown</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #993333;">void</span> testHashMap<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">def</span> map <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                            <span style="color: #ff0000;">'x'</span> , <span style="color: #ff0000;">'y'</span>, <span style="color: #ff0000;">'s'</span>
                         <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">def</span> a <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'a'</span>
            <span style="color: #000000; font-weight: bold;">def</span> b <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">false</span>
            <span style="color: #000000; font-weight: bold;">def</span> c <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>a,b<span style="color: #66cc66;">&#93;</span> : c<span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                   <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,a<span style="color: #66cc66;">&#41;</span>
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,b<span style="color: #66cc66;">&#41;</span>
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,c<span style="color: #66cc66;">&#41;</span>
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                           <span style="color: #ff0000;">'y'</span> : <span style="color: #ff0000;">'null'</span>
                       <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertFalse SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                           <span style="color: #ff0000;">'x'</span>:<span style="color: #ff0000;">'null'</span>
                       <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'n'</span> : <span style="color: #ff0000;">'y'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'x'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertFalse SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'t'</span><span style="color: #66cc66;">&#41;</span>
            assertFalse SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'n'</span> : <span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'x'</span> : <span style="color: #ff0000;">'n'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'x'</span>:<span style="color: #ff0000;">'z'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'n'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'c'</span>:<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'n'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #000000; font-weight: bold;">null</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">def</span> x <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'a'</span>:<span style="color: #ff0000;">'b'</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'y'</span>: x <span style="color: #66cc66;">&#93;</span> : <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,x<span style="color: #66cc66;">&#41;</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'y'</span>: <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'a'</span>:<span style="color: #ff0000;">'b'</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span> : <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,x<span style="color: #66cc66;">&#41;</span>
&nbsp;
            map<span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'s'</span>:<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertTrue SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>map,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">def</span> crazyMap <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span>
                        <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'c'</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'c'</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'c'</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'xxsxx'</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'c'</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'c'</span>:<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>          <span style="color: #ff0000;">'X'</span>            :<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'y'</span>
                    <span style="color: #66cc66;">&#93;</span>
&nbsp;
            assertFalse SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>crazyMap,<span style="color: #ff0000;">'q'</span><span style="color: #66cc66;">&#41;</span>
            assertFalse SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>crazyMap,<span style="color: #ff0000;">'x'</span><span style="color: #66cc66;">&#41;</span><span style="color: #808080; font-style: italic;">//only the capital X is inside</span>
            assertTrue  SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>crazyMap,<span style="color: #ff0000;">'X'</span><span style="color: #66cc66;">&#41;</span><span style="color: #808080; font-style: italic;">//only the capital X is inside</span>
            assertTrue  SearchNestedHash.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span>crazyMap,<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'xxsxx'</span>:<span style="color: #ff0000;">'v'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
     <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>here is the Class:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> SearchNestedHash <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">def</span> found <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">synchronized</span> search<span style="color: #66cc66;">&#40;</span>collection,targetObj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        found <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> searchRec<span style="color: #66cc66;">&#40;</span>collection,targetObj<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">synchronized</span> searchRec<span style="color: #66cc66;">&#40;</span>collection, targetObj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>collection <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">List</span> <span style="color: #66cc66;">&amp;&amp;</span> collection.<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span>targetObj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>
&nbsp;
        collection.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>
                    <span style="color: #66cc66;">&#40;</span>
                        collection <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">Map</span>
                        <span style="color: #66cc66;">&amp;&amp;</span>
                        <span style="color: #66cc66;">&#40;</span>
                            it.<span style="color: #006600;">key</span> <span style="color: #66cc66;">==</span> targetObj <span style="color: #66cc66;">||</span>
                            it.<span style="color: #006600;">value</span> <span style="color: #66cc66;">==</span> targetObj <span style="color: #66cc66;">||</span>
                            it.<span style="color: #006600;">key</span>    <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">List</span> <span style="color: #66cc66;">&amp;&amp;</span> it.<span style="color: #006600;">key</span>    .<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span>targetObj<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span>
                            it.<span style="color: #006600;">value</span> <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">List</span> <span style="color: #66cc66;">&amp;&amp;</span> it.<span style="color: #006600;">value</span> .<span style="color: #CC0099;">contains</span><span style="color: #66cc66;">&#40;</span>targetObj<span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">&#41;</span>
                    <span style="color: #66cc66;">&#41;</span>
                        <span style="color: #66cc66;">||</span>
                    <span style="color: #66cc66;">&#40;</span>
                        it <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">List</span> <span style="color: #66cc66;">&amp;&amp;</span> it <span style="color: #66cc66;">==</span> targetObj
                    <span style="color: #66cc66;">&#41;</span>
&nbsp;
                <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>found <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">;</span>return<span style="color: #66cc66;">&#125;</span>
            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>found<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
            collection.<span style="color: #663399;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
                    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">key</span> <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">Map</span><span style="color: #66cc66;">&#41;</span>
                    searchRec<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">key</span>,targetObj<span style="color: #66cc66;">&#41;</span>
&nbsp;
                    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">value</span> <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">Map</span><span style="color: #66cc66;">&#41;</span>
                    searchRec<span style="color: #66cc66;">&#40;</span>it.<span style="color: #006600;">value</span>,targetObj<span style="color: #66cc66;">&#41;</span>
&nbsp;
                    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>it <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #aaaadd; font-weight: bold;">List</span><span style="color: #66cc66;">&#41;</span>
                    searchRec<span style="color: #66cc66;">&#40;</span>it,targetObj<span style="color: #66cc66;">&#41;</span>
&nbsp;
                <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> found
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d573').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d573" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;submitHeadline=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;title=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;title=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;title=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;bm_description=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;T=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;title=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;title=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy+@+http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2009%2F11%2F28%2Frecursive-search-on-a-nested-multidimensional-collection-for-groovy%2F&amp;t=recursive+search+on+a+nested+%28multidimensional%29+collection+for+groovy" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d573').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d573').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2009/11/28/recursive-search-on-a-nested-multidimensional-collection-for-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>working with time periods</title>
		<link>http://blog.srvme.de/2008/09/09/working-with-dates/</link>
		<comments>http://blog.srvme.de/2008/09/09/working-with-dates/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 13:49:39 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[dates]]></category>
		<category><![CDATA[every Day between]]></category>
		<category><![CDATA[overlay]]></category>

		<guid isPermaLink="false">http://snackycracky.wordpress.com/?p=127</guid>
		<description><![CDATA[this here is my Dates class with some usefull methods for working with time periods. For example getEveryDayBetween countDays convert from String to GregorianCalendar and vice versa getOverlay isBetweenOrExactlyEqual here is the source Bookmark It Hide Sites $$('div.d127').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) });]]></description>
			<content:encoded><![CDATA[<p>this here is my Dates class with some usefull methods for working with time periods.<br />
For example</p>
<ul>
<li>getEveryDayBetween</li>
<li>countDays</li>
<li>convert from String to GregorianCalendar and vice versa</li>
<li>getOverlay</li>
<li>isBetweenOrExactlyEqual</li>
</ul>
<p><a href="http://srvme.de/trac/snackycracky_techblog/browser/snackycrack_techblog/dates/Dates.java" target="_blank">here</a> is the source</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d127').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d127" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;submitHeadline=working+with+time+periods&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;title=working+with+time+periods" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;title=working+with+time+periods" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;title=working+with+time+periods" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;bm_description=working+with+time+periods" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;T=working+with+time+periods" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;title=working+with+time+periods" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;title=working+with+time+periods" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+working+with+time+periods+@+http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2008%2F09%2F09%2Fworking-with-dates%2F&amp;t=working+with+time+periods" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d127').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d127').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2008/09/09/working-with-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>best way through a truth table</title>
		<link>http://blog.srvme.de/2008/08/19/best-way-through-a-truth-table/</link>
		<comments>http://blog.srvme.de/2008/08/19/best-way-through-a-truth-table/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 15:56:31 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[best way]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[truth table]]></category>

		<guid isPermaLink="false">http://snackycracky.wordpress.com/?p=85</guid>
		<description><![CDATA[suppose you have a &#8220;truth table&#8221; which looks like this for example: with this algorithm you can get from the left to the right side of the table by switching the true Boolean values next to each other. It calculates the number of row switches down to the minimum possible !!! the Alg. is recursive [...]]]></description>
			<content:encoded><![CDATA[<p>suppose you have a &#8220;truth table&#8221; which looks like this for example:<br />
<a href="http://snackycracky.files.wordpress.com/2008/08/picture-11-copy1.png"><img class="alignnone size-full wp-image-87" src="http://snackycracky.files.wordpress.com/2008/08/picture-11-copy1.png" alt="" width="487" height="125" /></a></p>
<p>with this algorithm you can get from the left to the right side of the table<br />
by switching the true Boolean values next to each other. It calculates the number<br />
of row switches down to the minimum possible !!!<br />
the Alg. is recursive but it&#8217;s not deterministic when in a column is no true Boolean value at all.<br />
In the above picture the alg switches only one time to get from the left to the right side.</p>
<p>It works like this (really abstract):</p>
<ol>
<li>it builds this table by making maps and lists</li>
<li>the loop starts at the most left side of every row in the table and checks for the column value</li>
<li>count the occurrences of unbreaked true values from step 2</li>
<li>if a false value is detected the counting of the true values before is saved in x and the counter is resetted.</li>
<li>get the maximum x in the whole table. this one result y is then one of the best ways.</li>
<li>delete the columns included in y from the table.</li>
<li>if the table has more columns go back to point 2.</li>
</ol>
<p>in my alg i work with calendar dates as columns and row numbers.<br />
most of the comments are in German, ask me if you like a translation.</p>
<p><a href="http://srvme.de/trac/snackycracky_techblog/browser/snackycrack_techblog/searchTheWayTroughATruthTable/tableWayAlg.java" target="_blank">here</a></p>
<p>this is just a innerclass not the actual one, please implement this in your own class&#8230;</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d85').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d85" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;submitHeadline=best+way+through+a+truth+table&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;title=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;title=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;title=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;bm_description=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;T=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;title=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;title=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+best+way+through+a+truth+table+@+http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F19%2Fbest-way-through-a-truth-table%2F&amp;t=best+way+through+a+truth+table" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d85').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d85').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2008/08/19/best-way-through-a-truth-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xml for mysql for radius for coovachilli because hibernates 2nd datasource was weak :(</title>
		<link>http://blog.srvme.de/2008/08/18/xml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak/</link>
		<comments>http://blog.srvme.de/2008/08/18/xml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 18:33:58 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[coova chilli]]></category>
		<category><![CDATA[datasource]]></category>
		<category><![CDATA[decode url]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[radcheck]]></category>
		<category><![CDATA[radius]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[stored procedure]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml service mysql]]></category>

		<guid isPermaLink="false">http://snackycracky.wordpress.com/?p=64</guid>
		<description><![CDATA[when i tried to add another datasource to the hibernate environment i ran into problems (connection timed out)&#8230; i now use the xml way which i talk about earlier &#8230; well i didn&#8217;t want to install mysql 6 because its just in the alpha release. so i wrote this little cgi script. later when mysql [...]]]></description>
			<content:encoded><![CDATA[<p>when i tried to add another datasource to the hibernate environment i ran into problems (connection timed out)&#8230; i now use the xml way which i talk about earlier &#8230; well i didn&#8217;t want to install mysql 6 because its just in the alpha release. so i wrote this little cgi script. later when mysql 6 is stable I will use the LOAD XML function. This has the big benefit that i don&#8217;t have to open the 3306 &#8230; which was dirty but fast anyway.</p>
<p>the privileges: &#8220;insert, update, select, <tt>ALTER ROUTINE,</tt> <tt>CREATE ROUTINE, </tt> <tt>EXECUTE, File</tt>&#8221; are needed.</p>
<p>This script <a href="http://srvme.de/trac/snackycracky_techblog/browser/snackycrack_techblog/xmlServiceForMySql/update.cgi" target="_blank">here </a>can insert and update data in the tables via xml:</p>
<p>here is the format of the xml files for input:</p>
<p>&lt;updates&gt;<br />
&lt;update&gt;<br />
&lt;field name=&#8221;UserName&#8221;&gt;some new name&lt;/field&gt;<br />
&lt;condition name=&#8221;id&#8221;&gt;7&lt;/condition&gt;<br />
&lt;/update&gt;<br />
&#8230;.<br />
&lt;/updates&gt;</p>
<p>&lt;inserts&gt;<br />
&lt;insert&gt;<br />
&lt;field name=&#8221;UserName&#8221;&gt;tttttttttttt&lt;/field&gt;<br />
&lt;field name=&#8221;Value&#8221;&gt;tttttt&lt;/field&gt;<br />
&#8230;<br />
&lt;/insert&gt;<br />
&#8230;<br />
&lt;/inserts&gt;</p>
<p>for getting data this here is possible:</p>
<p>for getting the rows when somebody was online, put the parameters &#8216;actTime&#8217; with the condition Value yyyy-mm-dd hh:mm and for the &#8216;type&#8217; put the Value &#8216;getActionsInTime&#8217;, than you get something like this:</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;resultset&gt;
&lt;row&gt;
&lt;field&gt;
&lt;WlanUserActions&gt;
&lt;Action&gt;
&lt;AcctStartTime&gt;2008-09-01 19:34:01&lt;/AcctStartTime&gt;
&lt;UserName&gt;username&lt;/UserName&gt;
&lt;FramedIPAddress&gt;10.1.0.114&lt;/FramedIPAddress&gt;
&lt;AcctTerminateCause&gt;User-Request&lt;/AcctTerminateCause&gt;
&lt;AcctSessionTime&gt;16731&lt;/AcctSessionTime&gt;
&lt;AcctStopTime&gt;2008-09-02 00:12:52&lt;/AcctStopTime&gt;
&lt;/Action&gt;
....
&lt;/WlanUserActions &gt;
&lt;/field&gt;
&lt;/row&gt;
&lt;/resultset&gt;</pre>
<p>i haven&#8217;t figured out how to get rid of the row and field tags&#8230;from a mysql command.<br />
To get Rows from the radacct table for a specific user put &#8216;getActions&#8217; as type and set the Value<br />
for the parameter &#8216;UserName&#8217;.</p>
<p><span style="color:#ff0000;">BE WARNED THERE SOME HIGH SECURITY RISKS BY IMPLEMENTING THIS SCRIPT, I CAN NOT BE MADE RESPONSIBLE FOR ANYTHING HAPPENING BECAUSE OF THIS SCRIPT.<br />
</span><br />
<a href="http://srvme.de/trac/snackycracky_techblog/browser/snackycrack_techblog/xmlServiceForMySql/update.cgi" target="_blank">here</a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d64').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d64" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;submitHeadline=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;title=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;title=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;title=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;bm_description=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;T=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;title=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;title=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28+@+http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2008%2F08%2F18%2Fxml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak%2F&amp;t=xml+for+mysql+for+radius+for+coovachilli+because+hibernates+2nd+datasource+was+weak+%3A%28" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d64').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d64').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2008/08/18/xml-for-mysql-for-radius-for-coovachilli-because-hibernates-2nd-datasource-was-weak/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>höchste Zahl im Array, biggest Value Array</title>
		<link>http://blog.srvme.de/2007/12/18/hochste-zahl-im-array-biggest-value-array/</link>
		<comments>http://blog.srvme.de/2007/12/18/hochste-zahl-im-array-biggest-value-array/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 06:38:23 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[biggest]]></category>
		<category><![CDATA[largest]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://snackycracky.wordpress.com/2007/12/18/hochste-zahl-im-array-biggest-value-array/</guid>
		<description><![CDATA[int biggestNumber=0,temp=0; for (i = 0; i &#60; someArray.length &#8211; 1; i++) { temp = someArray[i]; if (biggestNumber &#60;= temp) biggestNumber = temp; } Bookmark It Hide Sites $$('div.d16').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) });]]></description>
			<content:encoded><![CDATA[<p>int biggestNumber=0,temp=0;</p>
<p>for (i = 0; i &lt; someArray.length &#8211; 1; i++) {<br />
temp = someArray[i];<br />
if (biggestNumber &lt;= temp)<br />
biggestNumber = temp;<br />
}</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d16').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d16" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;submitHeadline=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;title=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;title=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;title=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;bm_description=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;T=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;title=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;title=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array+@+http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2007%2F12%2F18%2Fhochste-zahl-im-array-biggest-value-array%2F&amp;t=h%C3%B6chste+Zahl+im+Array%2C+biggest+Value+Array" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d16').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d16').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2007/12/18/hochste-zahl-im-array-biggest-value-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ListenVorgänger vergleichen</title>
		<link>http://blog.srvme.de/2007/10/08/vorganger/</link>
		<comments>http://blog.srvme.de/2007/10/08/vorganger/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 15:40:35 +0000</pubDate>
		<dc:creator>nils</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[list test equals elements element change changes]]></category>

		<guid isPermaLink="false">http://snackycracky.wordpress.com/2007/10/08/vorganger/</guid>
		<description><![CDATA[Wenn ListenElemente unterschiedlich sind soll eine andere Aktion im gegensatz zur normalen ausgeführt werden. Liste = 1,2,3,4,4,4,4,6,5,5,3,2,5,7,8,8,9,9, (zufällig, objekte möglich, quasi alles was verglichen werden kann) y=null //leeres Element foreach(Obj x : Liste) if(y==null) y=x; if(x.equals(y)){ normalAction(); } else{ WennElementNichtGleichDemVorgängerIstAktion(); y=x; } Bookmark It Hide Sites $$('div.d6').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) });]]></description>
			<content:encoded><![CDATA[<p>Wenn ListenElemente unterschiedlich sind soll eine andere Aktion im gegensatz zur normalen ausgeführt werden.</p>
<p>Liste = 1,2,3,4,4,4,4,6,5,5,3,2,5,7,8,8,9,9, (zufällig, objekte möglich, quasi alles was verglichen werden kann)</p>
<p>y=null //leeres Element</p>
<p>foreach(Obj x : Liste)</p>
<blockquote><p>if(y==null) y=x;</p>
<p>if(x.equals(y)){</p>
<blockquote><p>normalAction();</p></blockquote>
<p>} else{</p>
<blockquote><p>WennElementNichtGleichDemVorgängerIstAktion();<br />
y=x;</p></blockquote>
<p>}</p></blockquote>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d6').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d6" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;submitHeadline=ListenVorg%C3%A4nger+vergleichen&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;title=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;title=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;title=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;bm_description=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;T=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;title=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;title=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+ListenVorg%C3%A4nger+vergleichen+@+http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fblog.srvme.de%2F2007%2F10%2F08%2Fvorganger%2F&amp;t=ListenVorg%C3%A4nger+vergleichen" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://blog.srvme.de/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d6').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d6').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://blog.srvme.de/2007/10/08/vorganger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
