Input:
    AbstractCallPeer<?, ?> createOutgoingCall(
            CallJabberImpl call,
            String calleeAddress,
            Iterable<PacketExtension> sessionInitiateExtensions)
        throws OperationFailedException
    {
        if (logger.isInfoEnabled())
            logger.info("creating outgoing call...");
        if (protocolProvider.getConnection() == null || call == null)
        {
            throw new OperationFailedException(
                    "Failed to create OutgoingJingleSession."
                        + " We don't have a valid XMPPConnection.",
                    OperationFailedException.INTERNAL_ERROR);
        }
        boolean isGoogle = protocolProvider.isGmailOrGoogleAppsAccount();
        boolean isGoogleVoice = false;
        if(isGoogle)
        {
            if(!calleeAddress.contains("@"))
            {
                calleeAddress += "@" + GOOGLE_VOICE_DOMAIN;
                isGoogleVoice = true;
            }
            else if(calleeAddress.endsWith(GOOGLE_VOICE_DOMAIN))
            {
                isGoogleVoice = true;
            }
        }
        if(calleeAddress.indexOf('@') == -1)
        {
            String serviceName = null;
            String phoneSuffix =
                (String)getProtocolProvider().getAccountID().getAccountProperty(
                    "OVERRIDE_PHONE_SUFFIX");
            if(phoneSuffix == null || phoneSuffix.length() == 0)
            {
                serviceName = "@" + StringUtils.parseServer(
                    getProtocolProvider().getAccountID().getUserID());
            }
            else
            {
                serviceName = "@" + phoneSuffix;
            }
            calleeAddress += serviceName;
        }
        AccountID accountID = getProtocolProvider().getAccountID();
        String bypassDomain = accountID.getAccountPropertyString(
            "TELEPHONY_BYPASS_GTALK_CAPS");
        boolean alwaysCallGtalk = ((bypassDomain != null) &&
                bypassDomain.equals(calleeAddress.substring(
                    calleeAddress.indexOf('@') + 1))) || isGoogleVoice;
        String fullCalleeURI = null;
        DiscoverInfo di = null;
        int bestPriority = -1;
        if(!getProtocolProvider().getConnection().getRoster().contains(
            calleeAddress) && !alwaysCallGtalk)
        {
            throw new OperationFailedException(
                calleeAddress + " does not belong to our contact list",
                OperationFailedException.NOT_FOUND);
        }
        Iterator<Presence> it =
            getProtocolProvider().getConnection().getRoster().getPresences(
                calleeAddress);
        String calleeURI = null;
        boolean isGingle = false;
        String gingleURI = null;
        while(it.hasNext())
        {
            Presence presence = it.next();
            int priority = (presence.getPriority() == Integer.MIN_VALUE) ? 0 :
                presence.getPriority();
            calleeURI = presence.getFrom();
            DiscoverInfo discoverInfo = null;
            try
            {
                discoverInfo =
                    protocolProvider.getDiscoveryManager().
                        discoverInfo(calleeURI);
            }
            catch (XMPPException ex)
            {
                logger.warn("could not retrieve info for " + fullCalleeURI, ex);
            }
            boolean hasGtalkCaps =
                getProtocolProvider().isExtFeatureListSupported(
                    calleeURI, ProtocolProviderServiceJabberImpl.
                        CAPS_GTALK_WEB_VOICE);
            if (discoverInfo != null && discoverInfo.containsFeature(
                ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE))
            {
                if(priority > bestPriority)
                {
                    bestPriority = priority;
                    di = discoverInfo;
                    fullCalleeURI = calleeURI;
                    isGingle = false;
                }
            }
            else
            {
                if(!protocolProvider.isGTalkTesting() && !alwaysCallGtalk)
                {
                    continue;
                }
                if(hasGtalkCaps || alwaysCallGtalk)
                {
                    if(priority > bestPriority)
                    {
                        bestPriority = priority;
                        isGingle = true;
                        gingleURI = calleeURI;
                    }
                }
            }
        }
        if(isGingle)
        {
            if(logger.isInfoEnabled())
            {
                logger.info(gingleURI + ": Google Talk dialect supported");
            }
            fullCalleeURI = gingleURI;
        }
        else if(di != null)
        {
            if (logger.isInfoEnabled())
                logger.info(fullCalleeURI + ": jingle supported ");
        }
        else
        {
            if (logger.isInfoEnabled())
                logger.info(calleeURI +
                        ": jingle and Google Talk not supported ?");
            throw new OperationFailedException(
                    "Failed to create OutgoingJingleSession.\n"
                        + calleeURI + " does not support jingle or Google Talk",
                    OperationFailedException.INTERNAL_ERROR);
        }
        if(logger.isInfoEnabled())
        {
            logger.info("Choose one is: " + fullCalleeURI + " " + bestPriority);
        }
        AbstractCallPeer<?, ?> peer = null;
        try
        {
            if(isGingle)
            {
                logger.info("initiate Gingle call");
                CallGTalkImpl callGTalk = new CallGTalkImpl(this);
                MediaUseCase useCase = call.getMediaUseCase();
                boolean isVideo = call.isLocalVideoAllowed(useCase);
                callGTalk.setLocalVideoAllowed(isVideo, useCase);
                peer = callGTalk.initiateGTalkSession(fullCalleeURI,
                       sessionInitiateExtensions);
            }
            else if(di != null)
            {
                peer
                    = call.initiateSession(
                            fullCalleeURI,
                            di,
                            sessionInitiateExtensions);
            }
        }
        catch(Throwable t)
        {
            if (t instanceof ThreadDeath)
                throw (ThreadDeath) t;
            throw new OperationFailedException(
                    "Failed to create a call",
                    OperationFailedException.INTERNAL_ERROR,
                    t);
        }
        return peer;
    }

Output:
    AbstractCallPeer<?, ?> createOutgoingCall(
            CallJabberImpl call,
            String calleeAddress,
            Iterable<PacketExtension> sessionInitiateExtensions)
        throws OperationFailedException
    {
        if (logger.isInfoEnabled())
            logger.info("creating outgoing call...");
        if (protocolProvider.getConnection() == null || call == null)
        {
            throw new OperationFailedException(
                    "Failed to create OutgoingJingleSession."
                        + " We don't have a valid XMPPConnection.",
                    OperationFailedException.INTERNAL_ERROR);
        }
        boolean isGoogle = protocolProvider.isGmailOrGoogleAppsAccount();
        boolean isGoogleVoice = false;
        if(isGoogle)
        {
            if(!calleeAddress.contains("@"))
            {
                calleeAddress += "@" + GOOGLE_VOICE_DOMAIN;
                isGoogleVoice = true;
            }
            else if(calleeAddress.endsWith(GOOGLE_VOICE_DOMAIN))
            {
                isGoogleVoice = true;
            }
        }
        if(calleeAddress.indexOf('@') == -1)
        {
            String serviceName = null;
            String phoneSuffix =
                (String)getProtocolProvider().getAccountID().getAccountProperty(
                    "OVERRIDE_PHONE_SUFFIX");
            if(phoneSuffix == null || phoneSuffix.length() == 0)
            {
                serviceName = "@" + StringUtils.parseServer(
                    getProtocolProvider().getAccountID().getUserID());
            }
            else
            {
                serviceName = "@" + phoneSuffix;
            }
            calleeAddress += serviceName;
        }
        AccountID accountID = getProtocolProvider().getAccountID();
        String bypassDomain = accountID.getAccountPropertyString(
            "TELEPHONY_BYPASS_GTALK_CAPS");
        boolean alwaysCallGtalk = ((bypassDomain != null) &&
                bypassDomain.equals(calleeAddress.substring(
                    calleeAddress.indexOf('@') + 1))) || isGoogleVoice;
        String fullCalleeURI = null;
        DiscoverInfo di = null;
        int bestPriority = -1;
        if(!getProtocolProvider().getConnection().getRoster().contains(
            StringUtils.parseBareAddress(calleeAddress)) && !alwaysCallGtalk)
        {
            throw new OperationFailedException(
                calleeAddress + " does not belong to our contact list",
                OperationFailedException.NOT_FOUND);
        }
        Iterator<Presence> it =
            getProtocolProvider().getConnection().getRoster().getPresences(
                calleeAddress);
        String calleeURI = null;
        boolean isGingle = false;
        String gingleURI = null;
        while(it.hasNext())
        {
            Presence presence = it.next();
            int priority = (presence.getPriority() == Integer.MIN_VALUE) ? 0 :
                presence.getPriority();
            calleeURI = presence.getFrom();
            DiscoverInfo discoverInfo = null;
            try
            {
                discoverInfo =
                    protocolProvider.getDiscoveryManager().
                        discoverInfo(calleeURI);
            }
            catch (XMPPException ex)
            {
                logger.warn("could not retrieve info for " + fullCalleeURI, ex);
            }
            boolean hasGtalkCaps =
                getProtocolProvider().isExtFeatureListSupported(
                    calleeURI, ProtocolProviderServiceJabberImpl.
                        CAPS_GTALK_WEB_VOICE);
            if (discoverInfo != null && discoverInfo.containsFeature(
                ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE))
            {
                if(priority > bestPriority)
                {
                    bestPriority = priority;
                    di = discoverInfo;
                    fullCalleeURI = calleeURI;
                    isGingle = false;
                }
            }
            else
            {
                if(!protocolProvider.isGTalkTesting() && !alwaysCallGtalk)
                {
                    continue;
                }
                if(hasGtalkCaps || alwaysCallGtalk)
                {
                    if(priority > bestPriority)
                    {
                        bestPriority = priority;
                        isGingle = true;
                        gingleURI = calleeURI;
                    }
                }
            }
        }
        if(isGingle)
        {
            if(logger.isInfoEnabled())
            {
                logger.info(gingleURI + ": Google Talk dialect supported");
            }
            fullCalleeURI = gingleURI;
        }
        else if(di != null)
        {
            if (logger.isInfoEnabled())
                logger.info(fullCalleeURI + ": jingle supported ");
        }
        else
        {
            if (logger.isInfoEnabled())
                logger.info(calleeURI +
                        ": jingle and Google Talk not supported ?");
            throw new OperationFailedException(
                    "Failed to create OutgoingJingleSession.\n"
                        + calleeURI + " does not support jingle or Google Talk",
                    OperationFailedException.INTERNAL_ERROR);
        }
        if(logger.isInfoEnabled())
        {
            logger.info("Choose one is: " + fullCalleeURI + " " + bestPriority);
        }
        AbstractCallPeer<?, ?> peer = null;
        try
        {
            if(isGingle)
            {
                logger.info("initiate Gingle call");
                CallGTalkImpl callGTalk = new CallGTalkImpl(this);
                MediaUseCase useCase = call.getMediaUseCase();
                boolean isVideo = call.isLocalVideoAllowed(useCase);
                callGTalk.setLocalVideoAllowed(isVideo, useCase);
                peer = callGTalk.initiateGTalkSession(fullCalleeURI,
                       sessionInitiateExtensions);
            }
            else if(di != null)
            {
                peer
                    = call.initiateSession(
                            fullCalleeURI,
                            di,
                            sessionInitiateExtensions);
            }
        }
        catch(Throwable t)
        {
            if (t instanceof ThreadDeath)
                throw (ThreadDeath) t;
            throw new OperationFailedException(
                    "Failed to create a call",
                    OperationFailedException.INTERNAL_ERROR,
                    t);
        }
        return peer;
    }


Input:
public void defaultConfiguration() {
        assertProcess("Simple text", "Simple text");
        assertProcess("&", "&");
        assertProcess("'", "'");
        assertProcess("<", "<");
        assertProcess(">", ">");
        assertProcess(""", "\"");
        assertProcess("
", "\r\n");
        assertProcess("
", "\n\r");
        assertProcess("
", "\r");
        assertProcess("
", "\n");
        assertProcess("\\", "\\\\");
        assertProcess("[", "\\[");
        assertProcess("]", "\\]");
        assertProcess("test", "[b]test[/b]");
        assertProcess("test", "[u]test[/u]");
        assertProcess("test", "[s]test[/s]");
        assertProcess("test", "[i]test[/i]");
        assertProcess("", "[img]http://kefir-bb.sourceforge.net/ava.jpg[/img]");
        assertProcess("", "[img]/ava.jpg[/img]");
        assertProcess("KefirBB", "[url=http://kefir-bb.sourceforge.net]KefirBB[/url]");
        assertProcess("http://kefir-bb.sourceforge.net", "[url]http://kefir-bb.sourceforge.net[/url]");
        assertProcess("KefirBB", "[url=kefir-bb.sourceforge.net]KefirBB[/url]");
        assertProcess("kefir-bb.sourceforge.net", "[url]kefir-bb.sourceforge.net[/url]");
        assertProcess("Secured", "[url=https://securedsite.org]Secured[/url]");
        assertProcess("https://securedsite.org", "[url]https://securedsite.org[/url]");
        assertProcess("Mail to Kefir", "[url=mailto:kefir@perm.ru]Mail to Kefir[/url]");
        assertProcess("mailto:kefir@perm.ru", "[url]mailto:kefir@perm.ru[/url]");
        assertProcess("Test", "[url=/test.xml]Test[/url]");
        assertProcess("/test.xml", "[url]/test.xml[/url]");
        assertProcess("Test", "[url=./test.xml]Test[/url]");
        assertProcess("./test.xml", "[url]./test.xml[/url]");
        assertProcess("Test", "[url=../test.xml]Test[/url]");
        assertProcess("../test.xml", "[url]../test.xml[/url]");
        assertProcess("javascript:alert('Kefir is stupid!');", "[url]javascript:alert('Kefir is stupid!');[/url]");
        assertProcess("Red text", "[color=red]Red text[/color]");
        assertProcess("Test", "[size=14px]Test[/size]");
        assertProcess("
Quoted text
", "[quote]Quoted text[/quote]");
        assertProcess("«Test»", "[aquote]Test[/aquote]");
        assertProcess("", "[*Comment*]");
        assertProcess("©", "[symbol=copy/]");
    }

Output:
    public void defaultConfiguration() {
        assertProcess("Simple text", "Simple text");
        assertProcess("&amp;", "&");
        assertProcess("&apos;", "'");
        assertProcess("&lt;", "<");
        assertProcess("&gt;", ">");
        assertProcess("&quot;", "\"");
        assertProcess("<br/>", "\r\n");
        assertProcess("<br/>", "\n\r");
        assertProcess("<br/>", "\r");
        assertProcess("<br/>", "\n");
        assertProcess("\\", "\\\\");
        assertProcess("[", "\\[");
        assertProcess("]", "\\]");
        assertProcess("<span style=\"font-weight:bold;\">test</span>", "[B]test[/b]");
        assertProcess("<span style=\"text-decoration:underline;\">test</span>", "[u]test[/u]");
        assertProcess("<span style=\"text-decoration:line-through;\">test</span>", "[s]test[/s]");
        assertProcess("<span style=\"font-style:italic;\">test</span>", "[i]test[/i]");
        assertProcess("<img src=\"http://kefir-bb.sourceforge.net/ava.jpg\"/>", "[img]http://kefir-bb.sourceforge.net/ava.jpg[/img]");
        assertProcess("<img src=\"/ava.jpg\"/>", "[img]/ava.jpg[/img]");
        assertProcess("<a href=\"http://kefir-bb.sourceforge.net\">KefirBB</a>", "[url=http://kefir-bb.sourceforge.net]KefirBB[/url]");
        assertProcess("<a href=\"http://kefir-bb.sourceforge.net\">http://kefir-bb.sourceforge.net</a>", "[url]http://kefir-bb.sourceforge.net[/url]");
        assertProcess("<a href=\"http://kefir-bb.sourceforge.net\">KefirBB</a>", "[url=kefir-bb.sourceforge.net]KefirBB[/url]");
        assertProcess("<a href=\"http://kefir-bb.sourceforge.net\">kefir-bb.sourceforge.net</a>", "[url]kefir-bb.sourceforge.net[/url]");
        assertProcess("<a href=\"https://securedsite.org\">Secured</a>", "[url=https://securedsite.org]Secured[/url]");
        assertProcess("<a href=\"https://securedsite.org\">https://securedsite.org</a>", "[url]https://securedsite.org[/url]");
        assertProcess("<a href=\"mailto:kefir@perm.ru\">Mail to Kefir</a>", "[url=mailto:kefir@perm.ru]Mail to Kefir[/url]");
        assertProcess("<a href=\"mailto:kefir@perm.ru\">mailto:kefir@perm.ru</a>", "[url]mailto:kefir@perm.ru[/url]");
        assertProcess("<a href=\"/test.xml\">Test</a>", "[url=/test.xml]Test[/url]");
        assertProcess("<a href=\"/test.xml\">/test.xml</a>", "[url]/test.xml[/url]");
        assertProcess("<a href=\"./test.xml\">Test</a>", "[url=./test.xml]Test[/url]");
        assertProcess("<a href=\"./test.xml\">./test.xml</a>", "[url]./test.xml[/url]");
        assertProcess("<a href=\"../test.xml\">Test</a>", "[url=../test.xml]Test[/url]");
        assertProcess("<a href=\"../test.xml\">../test.xml</a>", "[url]../test.xml[/url]");
        assertProcess("<a href=\"http://javascript:alert(&apos;Kefir is stupid!&apos;);\">javascript:alert(&apos;Kefir is stupid!&apos;);</a>", "[url]javascript:alert('Kefir is stupid!');[/url]");
        assertProcess("<span style=\"color:red;\">Red text</span>", "[color=red]Red text[/color]");
        assertProcess("<span style=\"font-size:14px;\">Test</span>", "[size=14px]Test[/size]");
        assertProcess("<blockquote>Quoted text</blockquote>", "[quote]Quoted text[/quote]");
        assertProcess("&laquo;Test&raquo;", "[aquote]Test[/aquote]");
        assertProcess("", "[*Comment*]");
        assertProcess("&copy;", "[symbol=copy/]");
    }


Input:
        private void processPartiallyTagged(Context context) throws IOException, InterruptedException {
        	stateIndexes.clear();
        	for (int i = 0; i <  items.length; ++i) {
        		if (ArrayUtils.contains(states, items[i])) {
        			stateIndexes.add(i);
        		}
        	}
    		outKey.initialize();
    		outKey.add(INITIAL_STATE, items[stateIndexes.get(0)], items[stateIndexes.get(0)]);
    		outVal.set(1);
    		context.write(outKey, outVal);
        	int leftBound = 0;
        	int rightBound = 0;
        	int leftWindow = 0;
        	int rightWindow = 0;
        	for (int i = 0; i < stateIndexes.size(); ++i ) {
        		if (i > 0) {
        			leftWindow = stateIndexes.get(i) - stateIndexes.get(i-1) / 2;
        			leftBound =stateIndexes.get(i) - leftWindow;
        		} else {
        			leftBound = -1;
        		}
        		if (i  < stateIndexes.size() -1) {
        			rightWindow = stateIndexes.get(i+1) - stateIndexes.get(i) / 2;
        			rightBound =  stateIndexes.get(i) + rightWindow;
        		} else {
        			rightBound = -1;
        		}
        		if (leftBound == -1 && rightBound != -1) {
        			leftBound =stateIndexes.get(i) - rightWindow;
        			if (leftBound < 0) {
        				leftBound = 0;
        			}
        		} else if    (rightBound == -1 && leftBound != -1) {
        			rightBound =stateIndexes.get(i) + leftWindow;
        			if (rightBound >= items.length) {
        				rightBound =  items.length-1;
        			}
        		}
        		String state = items[stateIndexes.get(i)];
        		for (int j = stateIndexes.get(i)-1, k=0;  j >= leftBound;  --j,++k ) {
        			String obs = items[j];
            		outKey.initialize();
            		outKey.add(STATE_OBS, state, obs);
            		outVal.set(windowFunction[k]);
            		context.write(outKey, outVal);
        		}
        		for (int j = stateIndexes.get(i)+1, k=0;  j <= rightBound;  ++j,++k ) {
        			String obs = items[j];
            		outKey.initialize();
            		outKey.add(STATE_OBS, state, obs);
            		outVal.set(windowFunction[k]);
            		context.write(outKey, outVal);
        		}
        	}
        	for (int i = 0;  i < stateIndexes.size() -1; ++i) {
        		outKey.initialize();
        		outKey.add(STATE_TRANS, items[stateIndexes.get(i)],  items[stateIndexes.get(i+1)]);
        		outVal.set(1);
        		context.write(outKey, outVal);
        	}
        }

Output:
        private void processPartiallyTagged(Context context) throws IOException, InterruptedException {
        	stateIndexes.clear();
        	for (int i = 0; i <  items.length; ++i) {
        		if (ArrayUtils.contains(states, items[i])) {
        			stateIndexes.add(i);
        		}
        	}
    		outKey.initialize();
    		outKey.add(INITIAL_STATE, items[stateIndexes.get(0)], items[stateIndexes.get(0)]);
    		outVal.set(1);
    		context.write(outKey, outVal);
        	int leftBound = 0;
        	int rightBound = 0;
        	int leftWindow = 0;
        	int rightWindow = 0;
        	for (int i = 0; i < stateIndexes.size(); ++i ) {
        		if (i > 0) {
        			leftWindow = stateIndexes.get(i) - stateIndexes.get(i-1) / 2;
        			leftBound =stateIndexes.get(i) - leftWindow;
        		} else {
        			leftBound = -1;
        		}
        		if (i  < stateIndexes.size() -1) {
        			rightWindow = stateIndexes.get(i+1) - stateIndexes.get(i) / 2;
        			rightBound =  stateIndexes.get(i) + rightWindow;
        		} else {
        			rightBound = -1;
        		}
        		if (leftBound == -1 && rightBound != -1) {
        			leftBound =stateIndexes.get(i) - rightWindow;
        			if (leftBound < 0) {
        				leftBound = 0;
        			}
        		} else if    (rightBound == -1 && leftBound != -1) {
        			rightBound =stateIndexes.get(i) + leftWindow;
        			if (rightBound >= items.length) {
        				rightBound =  items.length-1;
        			}
        		} else if (leftBound == -1 && rightBound == -1) {
        			leftBound =stateIndexes.get(i) / 2;
        			rightBound = stateIndexes.get(i) + (items.length - 1 - stateIndexes.get(i)) / 2;
        		}
        		String state = items[stateIndexes.get(i)];
        		for (int j = stateIndexes.get(i)-1, k=0;  j >= leftBound;  --j,++k ) {
        			String obs = items[j];
            		outKey.initialize();
            		outKey.add(STATE_OBS, state, obs);
            		int val = k < windowFunction.length ?  windowFunction[k]  :   windowFunction[ windowFunction.length -1];
            		outVal.set(val);
            		context.write(outKey, outVal);
        		}
        		for (int j = stateIndexes.get(i)+1, k=0;  j <= rightBound;  ++j,++k ) {
        			String obs = items[j];
            		outKey.initialize();
            		outKey.add(STATE_OBS, state, obs);
            		int val = k < windowFunction.length ?  windowFunction[k]  :   windowFunction[ windowFunction.length -1];
            		outVal.set(val);
            		context.write(outKey, outVal);
        		}
        	}
        	for (int i = 0;  i < stateIndexes.size() -1; ++i) {
        		outKey.initialize();
        		outKey.add(STATE_TRANS, items[stateIndexes.get(i)],  items[stateIndexes.get(i+1)]);
        		outVal.set(1);
        		context.write(outKey, outVal);
        	}
        }


Input:
     public void testExchangeCZKUSD() throws Exception {
         Currency usd = new Currency("USD");
         Currency czk = new Currency("CZK");
         Calculator c = createCZKtoUSD();
         CurrencyValue result = c.convert(new CurrencyValue(usd, 5.0), czk);
         assertEquals(result.getValue(), 85.0);
         assertEquals(result.getCurrency(), czk);
         result = c.convert(new CurrencyValue(usd, 8.0), czk);
         assertEquals(result.getValue(), 136);
         assertEquals(result.getCurrency(), czk);
         result = c.convert(new CurrencyValue(czk, 1003.0), usd);
         assertEquals(result.getValue(), 59);
         assertEquals(result.getCurrency(), usd);
     }

Output:
     public void testExchangeCZKUSD() throws Exception {
         Currency usd = new Currency("USD");
         Currency czk = new Currency("CZK");
         Calculator c = createCZKtoUSD();
         CurrencyValue result = c.convert(new CurrencyValue(usd, 5.0), czk);
         assertEquals(result.getValue(), 85.0);
         assertEquals(result.getCurrency(), czk);
         result = c.convert(new CurrencyValue(usd, 8.0), czk);
         assertEquals(result.getValue(), 136.0);
         assertEquals(result.getCurrency(), czk);
         result = c.convert(new CurrencyValue(czk, 1003.0), usd);
         assertEquals(result.getValue(), 59.0);
         assertEquals(result.getCurrency(), usd);
     }


Input:
	private void selectAttribute() {
		if(attribute == null || attribute.length() == 0) return;
		XAttribute a = object.getModelEntity().getAttribute(attribute);
		if(isESB(a)) {
			findESBAttrPosition(a);
		}
		String xml = (a == null) ? null : a.getXMLName();
		if(xml == null || xml.length() == 0) return;
		if(xml.indexOf(".") < 0) {
			String s = text.substring(startPosition, endPosition);
			int i1 = findAttrPosition(s, xml);
			if(selectAttributeName) {
				if(i1 < 0) return;
				startPosition = startPosition + i1;
				endPosition = startPosition + xml.length();
				return;
			}
			int i2 = (i1 < 0) ? -1 : s.indexOf('"', i1 + 1);
			int i3 = (i2 < 0) ? -1 : s.indexOf('"', i2 + 1);
			if(i3 > 0) {
				endPosition = startPosition + i3;
				startPosition = startPosition + i2 + 1;
			}
		} else {
			xml = xml.substring(0, xml.indexOf('.'));
			int e1 = text.indexOf("</" + getTagXMLName(object) + ">", startPosition);
			String s = e1 < 0 ? "" : text.substring(startPosition, e1);
			if(xml.length() == 0) {
				int i1 = s.indexOf(">");
				endPosition = startPosition + i1 + 1;
				startPosition = startPosition + e1;
			} else if(s.length() > 0) {
				int i1a = s.indexOf("<" + xml + ">");
				int i1b = s.indexOf("<" + xml + "/>");
				int i2 = (i1a < 0) ? -1 : s.indexOf("</", i1a);
				if(i1a >= 0 && i2 >= 0) {
					endPosition = startPosition + i2;
					startPosition = startPosition + i1a + 2 + xml.length();
				} else if(i1b >= 0) {
					endPosition = startPosition + i1b + 3 + xml.length();
					startPosition = startPosition + i1b;
				}
			}
		}
	}

Output:
	private void selectAttribute() {
		if(attribute == null || attribute.length() == 0) return;
		XAttribute a = object.getModelEntity().getAttribute(attribute);
		if(isESB(a)) {
			findESBAttrPosition(a);
		}
		String xml = (a == null) ? null : a.getXMLName();
		if(xml == null || xml.length() == 0) return;
		if(xml.indexOf(".") < 0) {
			String s = text.substring(startPosition, endPosition);
			int i1 = findAttrPosition(s, xml);
			if(selectAttributeName) {
				if(i1 < 0) return;
				startPosition = startPosition + i1;
				endPosition = startPosition + xml.length();
				return;
			}
			int i2 = (i1 < 0) ? -1 : s.indexOf('"', i1 + 1);
			int i3 = (i2 < 0) ? -1 : s.indexOf('"', i2 + 1);
			if(i3 > 0) {
				endPosition = startPosition + i3;
				startPosition = startPosition + i2 + 1;
			}
		} else {
			xml = xml.substring(0, xml.lastIndexOf('.'));
			if(xml.indexOf('.') >= 0) {
				xml = xml.substring(xml.lastIndexOf('.') + 1);
			}
			int e1 = text.indexOf("</" + getTagXMLName(object) + ">", startPosition);
			String s = e1 < 0 ? "" : text.substring(startPosition, e1);
			if(xml.length() == 0) {
				int i1 = s.indexOf(">");
				endPosition = startPosition + i1 + 1;
				startPosition = startPosition + e1;
			} else if(s.length() > 0) {
				int i1a = s.indexOf("<" + xml + ">");
				int i1b = s.indexOf("<" + xml + "/>");
				int i2 = (i1a < 0) ? -1 : s.indexOf("</", i1a);
				if(i1a >= 0 && i2 >= 0) {
					endPosition = startPosition + i2;
					startPosition = startPosition + i1a + 2 + xml.length();
				} else if(i1b >= 0) {
					endPosition = startPosition + i1b + 3 + xml.length();
					startPosition = startPosition + i1b;
				}
			}
		}
	}


Input:
    public RuleViolation(Rule rule, RuleContext ctx, SimpleNode node, String specificMsg) {
        this.rule = rule;
        this.filename = ctx.getSourceCodeFilename();
        this.description = specificMsg;
        if (node != null) {
	        if (node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class) == null) {
	            className = "";
	        } else {
	            className = node.getScope().getEnclosingClassScope().getClassName() == null ? "" : node.getScope().getEnclosingClassScope().getClassName();
	        }
	        String qualifiedName = null;
	        List<ASTClassOrInterfaceDeclaration> parents = node.getParentsOfType(ASTClassOrInterfaceDeclaration.class);
	        for ( ASTClassOrInterfaceDeclaration parent : parents )
	        {
	        	if (qualifiedName == null) {
	        		qualifiedName = parent.getScope().getEnclosingClassScope().getClassName();
	            } else {
	            	qualifiedName = qualifiedName + "$" + parent.getScope().getEnclosingClassScope().getClassName();
	            }
	        }
	        if ( ! "net.sourceforge.pmd.symboltable.SourceFileScope".equals(node.getScope().getClass().getName() ) ) {
	        	className = node.getScope().getEnclosingClassScope().getClassName() == null ? "" : qualifiedName;
	        }
	        setVariableNameIfExists(node);
	        methodName = node.getFirstParentOfType(ASTMethodDeclaration.class) == null ? "" : node.getScope().getEnclosingMethodScope().getName();
	        packageName = node.getScope().getEnclosingSourceFileScope().getPackageName() == null ? "" : node.getScope().getEnclosingSourceFileScope().getPackageName();
	        beginLine = node.getBeginLine();
	        endLine = node.getEndLine();
	        beginColumn = node.getBeginColumn();
	        endColumn = node.getEndColumn();
	        List<SimpleNode> parentTypes = new ArrayList<SimpleNode>(node.getParentsOfType(ASTTypeDeclaration.class));
	        if (node instanceof ASTTypeDeclaration) {
	            parentTypes.add(node);
	        }
	        parentTypes.addAll(node.getParentsOfType(ASTClassOrInterfaceBodyDeclaration.class));
	        if (node instanceof ASTClassOrInterfaceBodyDeclaration) {
	            parentTypes.add(node);
	        }
	        parentTypes.addAll(node.getParentsOfType(ASTFormalParameter.class));
	        if (node instanceof ASTFormalParameter) {
	            parentTypes.add(node);
	        }
	        parentTypes.addAll(node.getParentsOfType(ASTLocalVariableDeclaration.class));
	        if (node instanceof ASTLocalVariableDeclaration) {
	            parentTypes.add(node);
	        }
	        for (SimpleNode parentType : parentTypes) {
	            CanSuppressWarnings t = (CanSuppressWarnings) parentType;
	            if (t.hasSuppressWarningsAnnotationFor(getRule())) {
	                isSuppressed = true;
	            }
	        }
        } else {
        	className = "";
        	methodName = "";
        	packageName = "";
        	filename = "";
        }
    }

Output:
    public RuleViolation(Rule rule, RuleContext ctx, SimpleNode node, String specificMsg) {
        this.rule = rule;
        this.filename = ctx.getSourceCodeFilename();
        this.description = specificMsg;
        if (node != null) {
	        if (node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class) == null) {
	            className = "";
	        } else {
	            className = node.getScope().getEnclosingClassScope().getClassName() == null ? "" : node.getScope().getEnclosingClassScope().getClassName();
	        }
	        String qualifiedName = null;
	        List<ASTClassOrInterfaceDeclaration> parents = node.getParentsOfType(ASTClassOrInterfaceDeclaration.class);
	        for ( ASTClassOrInterfaceDeclaration parent : parents )
	        {
	        	if (qualifiedName == null) {
	        		qualifiedName = parent.getScope().getEnclosingClassScope().getClassName();
	            } else {
	            	qualifiedName = parent.getScope().getEnclosingClassScope().getClassName() + "$" + qualifiedName;
	            }
	        }
	        if ( ! "net.sourceforge.pmd.symboltable.SourceFileScope".equals(node.getScope().getClass().getName() ) ) {
	        	className = node.getScope().getEnclosingClassScope().getClassName() == null ? "" : qualifiedName;
	        }
	        setVariableNameIfExists(node);
	        methodName = node.getFirstParentOfType(ASTMethodDeclaration.class) == null ? "" : node.getScope().getEnclosingMethodScope().getName();
	        packageName = node.getScope().getEnclosingSourceFileScope().getPackageName() == null ? "" : node.getScope().getEnclosingSourceFileScope().getPackageName();
	        beginLine = node.getBeginLine();
	        endLine = node.getEndLine();
	        beginColumn = node.getBeginColumn();
	        endColumn = node.getEndColumn();
	        List<SimpleNode> parentTypes = new ArrayList<SimpleNode>(node.getParentsOfType(ASTTypeDeclaration.class));
	        if (node instanceof ASTTypeDeclaration) {
	            parentTypes.add(node);
	        }
	        parentTypes.addAll(node.getParentsOfType(ASTClassOrInterfaceBodyDeclaration.class));
	        if (node instanceof ASTClassOrInterfaceBodyDeclaration) {
	            parentTypes.add(node);
	        }
	        parentTypes.addAll(node.getParentsOfType(ASTFormalParameter.class));
	        if (node instanceof ASTFormalParameter) {
	            parentTypes.add(node);
	        }
	        parentTypes.addAll(node.getParentsOfType(ASTLocalVariableDeclaration.class));
	        if (node instanceof ASTLocalVariableDeclaration) {
	            parentTypes.add(node);
	        }
	        for (SimpleNode parentType : parentTypes) {
	            CanSuppressWarnings t = (CanSuppressWarnings) parentType;
	            if (t.hasSuppressWarningsAnnotationFor(getRule())) {
	                isSuppressed = true;
	            }
	        }
        } else {
        	className = "";
        	methodName = "";
        	packageName = "";
        	filename = "";
        }
    }


Input:
  protected void initFile(String id) throws FormatException, IOException {
    super.initFile(id);
    in = new RandomAccessInputStream(id);
    core[0].littleEndian = false;
    if (!in.readString(4).equals("8BPS")) {
      throw new FormatException("Not a valid Photoshop file.");
    }
    addGlobalMeta("Version", in.readShort());
    in.skipBytes(6);
    core[0].sizeC = in.readShort();
    core[0].sizeY = in.readInt();
    core[0].sizeX = in.readInt();
    int bits = in.readShort();
    addGlobalMeta("Bits per pixel", bits);
    core[0].pixelType = FormatTools.pixelTypeFromBytes(bits / 8, false, false);
    int colorMode = in.readShort();
    String modeString = null;
    switch (colorMode) {
      case 0:
        modeString = "monochrome";
        break;
      case 1:
        modeString = "gray-scale";
        break;
      case 2:
        modeString = "palette color";
        break;
      case 3:
        modeString = "RGB";
        break;
      case 4:
        modeString = "CMYK";
        break;
      case 6:
        modeString = "Duotone";
        break;
      case 7:
        modeString = "Multichannel color";
        break;
      case 8:
        modeString = "Duotone";
        break;
      case 9:
        modeString = "LAB color";
        break;
    }
    addGlobalMeta("Color mode", modeString);
    int modeDataLength = in.readInt();
    long fp = in.getFilePointer();
    if (modeDataLength != 0) {
      if (colorMode == 2) {
        lut = new byte[3][256];
        for (int i=0; i<lut.length; i++) {
          in.read(lut[i]);
        }
      }
      in.seek(fp + modeDataLength);
    }
    in.skipBytes(4);
    while (in.readString(4).equals("8BIM")) {
      int tag = in.readShort();
      int read = 1;
      while (in.read() != 0) read++;
      if (read % 2 == 1) in.skipBytes(1);
      int size = in.readInt();
      if (size % 2 == 1) size++;
      in.skipBytes(size);
    }
    in.seek(in.getFilePointer() - 4);
    int blockLen = in.readInt();
    if (blockLen == 0) {
      offset = in.getFilePointer();
    }
    else {
      int layerLen = in.readInt();
      int layerCount = in.readShort();
      if (layerCount < 0) {
        throw new FormatException("Vector data is not supported.");
      }
      int[] w = new int[layerCount];
      int[] h = new int[layerCount];
      int[] c = new int[layerCount];
      for (int i=0; i<layerCount; i++) {
        int top = in.readInt();
        int left = in.readInt();
        int bottom = in.readInt();
        int right = in.readInt();
        w[i] = right - left;
        h[i] = bottom - top;
        c[i] = in.readShort();
        in.skipBytes(c[i] * 6 + 12);
        int len = in.readInt();
        if (len % 2 == 1) len++;
        in.skipBytes(len);
      }
      for (int i=0; i<layerCount; i++) {
        int[] lens = new int[h[i]];
        for (int cc=0; cc<c[i]; cc++) {
          boolean compressed = in.readShort() == 1;
          if (!compressed) in.skipBytes(w[i] * h[i]);
          else {
            for (int y=0; y<h[i]; y++) {
              lens[y] = in.readShort();
            }
            for (int y=0; y<h[i]; y++) {
              in.skipBytes(lens[y]);
            }
          }
        }
      }
      while (in.read() != '8');
      in.skipBytes(7);
      int len = in.readInt();
      if ((len % 4) != 0) len += 4 - (len % 4);
      in.skipBytes(len);
      String s = in.readString(4);
      while (s.equals("8BIM")) {
        in.skipBytes(4);
        len = in.readInt();
        if ((len % 4) != 0) len += 4 - (len % 4);
        in.skipBytes(len);
        s = in.readString(4);
      }
      offset = in.getFilePointer() - 4;
    }
    core[0].sizeZ = 1;
    core[0].sizeT = 1;
    core[0].rgb = modeString.equals("RGB");
    core[0].imageCount = getSizeC() / (isRGB() ? 3 : 1);
    core[0].indexed = modeString.equals("palette color");
    core[0].falseColor = false;
    core[0].dimensionOrder = "XYCZT";
    core[0].interleaved = false;
    core[0].metadataComplete = true;
    MetadataStore store = makeFilterMetadata();
    MetadataTools.populatePixels(store, this);
    MetadataTools.setDefaultCreationDate(store, id, 0);
  }

Output:
  protected void initFile(String id) throws FormatException, IOException {
    super.initFile(id);
    in = new RandomAccessInputStream(id);
    core[0].littleEndian = false;
    if (!in.readString(4).equals("8BPS")) {
      throw new FormatException("Not a valid Photoshop file.");
    }
    addGlobalMeta("Version", in.readShort());
    in.skipBytes(6);
    core[0].sizeC = in.readShort();
    core[0].sizeY = in.readInt();
    core[0].sizeX = in.readInt();
    int bits = in.readShort();
    addGlobalMeta("Bits per pixel", bits);
    core[0].pixelType = FormatTools.pixelTypeFromBytes(bits / 8, false, false);
    int colorMode = in.readShort();
    String modeString = null;
    switch (colorMode) {
      case 0:
        modeString = "monochrome";
        break;
      case 1:
        modeString = "gray-scale";
        break;
      case 2:
        modeString = "palette color";
        break;
      case 3:
        modeString = "RGB";
        break;
      case 4:
        modeString = "CMYK";
        break;
      case 6:
        modeString = "Duotone";
        break;
      case 7:
        modeString = "Multichannel color";
        break;
      case 8:
        modeString = "Duotone";
        break;
      case 9:
        modeString = "LAB color";
        break;
    }
    addGlobalMeta("Color mode", modeString);
    int modeDataLength = in.readInt();
    long fp = in.getFilePointer();
    if (modeDataLength != 0) {
      if (colorMode == 2) {
        lut = new byte[3][256];
        for (int i=0; i<lut.length; i++) {
          in.read(lut[i]);
        }
      }
      in.seek(fp + modeDataLength);
    }
    in.skipBytes(4);
    while (in.readString(4).equals("8BIM")) {
      int tag = in.readShort();
      int read = 1;
      while (in.read() != 0) read++;
      if (read % 2 == 1) in.skipBytes(1);
      int size = in.readInt();
      if (size % 2 == 1) size++;
      in.skipBytes(size);
    }
    in.seek(in.getFilePointer() - 4);
    int blockLen = in.readInt();
    if (blockLen == 0) {
      offset = in.getFilePointer();
    }
    else {
      int layerLen = in.readInt();
      int layerCount = in.readShort();
      if (layerCount < 0) {
        throw new FormatException("Vector data is not supported.");
      }
      int[] w = new int[layerCount];
      int[] h = new int[layerCount];
      int[] c = new int[layerCount];
      for (int i=0; i<layerCount; i++) {
        int top = in.readInt();
        int left = in.readInt();
        int bottom = in.readInt();
        int right = in.readInt();
        w[i] = right - left;
        h[i] = bottom - top;
        c[i] = in.readShort();
        in.skipBytes(c[i] * 6 + 12);
        int len = in.readInt();
        if (len % 2 == 1) len++;
        in.skipBytes(len);
      }
      for (int i=0; i<layerCount; i++) {
        int[] lens = new int[h[i]];
        for (int cc=0; cc<c[i]; cc++) {
          boolean compressed = in.readShort() == 1;
          if (!compressed) in.skipBytes(w[i] * h[i]);
          else {
            for (int y=0; y<h[i]; y++) {
              lens[y] = in.readShort();
            }
            for (int y=0; y<h[i]; y++) {
              in.skipBytes(lens[y]);
            }
          }
        }
      }
      if (layerCount > 0) {
        while (in.read() != '8');
        in.skipBytes(7);
      }
      int len = in.readInt();
      if ((len % 4) != 0) len += 4 - (len % 4);
      in.skipBytes(len);
      String s = in.readString(4);
      while (s.equals("8BIM")) {
        in.skipBytes(4);
        len = in.readInt();
        if ((len % 4) != 0) len += 4 - (len % 4);
        in.skipBytes(len);
        s = in.readString(4);
      }
      offset = in.getFilePointer() - 4;
    }
    core[0].sizeZ = 1;
    core[0].sizeT = 1;
    core[0].rgb = modeString.equals("RGB");
    core[0].imageCount = getSizeC() / (isRGB() ? 3 : 1);
    core[0].indexed = modeString.equals("palette color");
    core[0].falseColor = false;
    core[0].dimensionOrder = "XYCZT";
    core[0].interleaved = false;
    core[0].metadataComplete = true;
    MetadataStore store = makeFilterMetadata();
    MetadataTools.populatePixels(store, this);
    MetadataTools.setDefaultCreationDate(store, id, 0);
  }


Input:
   private void doSaveProfile(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
      User currentUser = (User) request.getAttribute("user");
      Profile profile = Profile.findForUser(currentUser);
      if(profile == null) {
         profile = new Profile();
         Key key = KeyFactory.createKey(Profile.class.getSimpleName(), currentUser.getEmail());
         profile.setKey(key);
      }
      profile.setAboutMe(request.getParameter("profile.aboutMe"));
      profile.setUsername(request.getParameter("profile.username"));
      profile.setPets(request.getParameterValues("profile.pet"));
      profile.setGender(request.getParameter("profile.gender"));
      profile.setMaritalStatus(request.getParameter("profile.maritalStatus"));
      PersistenceManager pm = PMF.get().getPersistenceManager();
      try {
         pm.makePersistent(profile);
      } finally {
         pm.close();
      }
      response.sendRedirect("/profile/mine");
   }

Output:
   private void doSaveProfile(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
      User currentUser = (User) request.getAttribute("user");
      Profile profile = Profile.findForUser(currentUser);
      if(profile == null) {
         profile = new Profile();
         Key key = KeyFactory.createKey(Profile.class.getSimpleName(), currentUser.getUserId());
         profile.setKey(key);
      }
      profile.setAboutMe(request.getParameter("profile.aboutMe"));
      profile.setUsername(request.getParameter("profile.username"));
      profile.setPets(request.getParameterValues("profile.pet"));
      profile.setGender(request.getParameter("profile.gender"));
      profile.setMaritalStatus(request.getParameter("profile.maritalStatus"));
      PersistenceManager pm = PMF.get().getPersistenceManager();
      try {
         pm.makePersistent(profile);
      } finally {
         pm.close();
      }
      response.sendRedirect("/profile/mine");
   }


Input:
		public Collection<Namespace> elements(Language language) {
			Collection<Namespace> result = new ArrayList<Namespace>();
			try {
				for(String fqn: _namespaces) {
				  result.add(namespace(fqn, language));
				}
			} catch (LookupException e) {
				e.printStackTrace();
			}
			return result;
		}

Output:
		public Collection<Namespace> elements(Language language) {
			Collection<Namespace> result = new ArrayList<Namespace>();
			try {
				for(String fqn: _namespaces) {
				  Util.addNonNull(namespace(fqn, language),result);
				}
			} catch (LookupException e) {
				e.printStackTrace();
			}
			return result;
		}


Input:
	public void start()
	{
		GroupManager gm = this.world.getManager(GroupManager.class);
		TagManager tm = this.world.getManager(TagManager.class);
		for (int i = 0; i < data.enemyData.size; i++)
		{
			SpawnSet s = data.enemyData.get(i);
			for (int j = 0; j < s.spawns.size; j++)
			{
				Spawn enemy = s.spawns.get(j);
				Entity e = this.world.createEntity();
				e = s.atlas.createEnemy(enemy.name, e);
				Position p = (Position)e.getComponent(Position.CType);
				p.location.x = enemy.pos.x;
				p.location.y = enemy.pos.y;
				this.world.addEntity(e);
			}
		}
		for (int i = 0; i < data.background.stack.size; i++)
		{
			Entity layer = this.world.createEntity();
			FieldData f = data.background.stack.get(i);
			Texture t = Engine.assets.get(f.image, Texture.class);
			Sprite s = new Sprite(t);
			if (f instanceof LayerData)
			{
				LayerData d = (LayerData)data.background.stack.get(i);
				t.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
				s.setSize(FOV[2], FOV[3]);
				layer.addComponent(new Position(), Position.CType);
				layer.addComponent(new Scrollable(0, d.rate, Math.max(FOV[2]/(float)t.getWidth(), 1.0f), Math.max(FOV[3]/(float)t.getHeight(), 1.0f)), Scrollable.CType);
			}
			else if (f instanceof StaticData)
			{
				StaticData d = (StaticData)data.background.stack.get(i);
				layer.addComponent(new Position(d.x, d.y), Position.CType);
				layer.addComponent(new Angle(0), Angle.CType);
				layer.addComponent(new Rotation(d.dps), Rotation.CType);
			}
			layer.addComponent(new Renderable(s), Renderable.CType);
			gm.add(layer, "Field");
			this.world.addEntity(layer);
		}
		Texture t = Engine.assets.get(DataDir.Ui+"banners.png", Texture.class);
		t.setWrap(TextureWrap.Repeat, TextureWrap.ClampToEdge);
		SpriteSheet bannerTex = new SpriteSheet(t, 1, 3);
		for (int i = 0; i < 3; i++)
		{
			Entity e = this.world.createEntity();
			TextureRegion r = bannerTex.getFrame(i);
			Sprite s = new Sprite(r);
			s.setSize(FOV[3], 12);
			s.setRotation(90);
			s.setOrigin(0, 0);
			e.addComponent(new Position(0, 0, 12, 0));
			e.addComponent(new Scrollable(.35f, 0f, FOV[3]/bannerTex.getFrameWidth(), 1f, r));
			e.addComponent(new Renderable(s));
			gm.add(e, "Banner");
			gm.add(e, "Banner"+(char)(i+65));
			e.addToWorld();
			e = this.world.createEntity();
			s = new Sprite(r);
			s.setSize(FOV[3], 12);
			s.setRotation(-90);
			s.setOrigin(0, 0);
			s.flip(false, true);
			e.addComponent(new Position(FOV[2], 0, -12, FOV[3]));
			e.addComponent(new Scrollable(-.35f, 0f, 220f/bannerTex.getFrameWidth(), 1f, r));
			e.addComponent(new Renderable(s));
			gm.add(e, "Banner");
			gm.add(e, "Banner"+(char)(i+65));
			e.addToWorld();
		}
		this.world.initialize();
		Engine.score = 0f;
		Position p = (Position)Engine.player.getComponent(Position.CType);
		p.location.x = FOV[2]/2.0f;
	}

Output:
	public void start()
	{
		GroupManager gm = this.world.getManager(GroupManager.class);
		TagManager tm = this.world.getManager(TagManager.class);
		for (int i = 0; i < data.enemyData.size; i++)
		{
			SpawnSet s = data.enemyData.get(i);
			for (int j = 0; j < s.spawns.size; j++)
			{
				Spawn enemy = s.spawns.get(j);
				Entity e = this.world.createEntity();
				e = s.atlas.createEnemy(enemy.name, e);
				Position p = (Position)e.getComponent(Position.CType);
				p.location.x = enemy.pos.x;
				p.location.y = enemy.pos.y;
				this.world.addEntity(e);
			}
		}
		for (int i = 0; i < data.background.stack.size; i++)
		{
			Entity layer = this.world.createEntity();
			FieldData f = data.background.stack.get(i);
			Texture t = Engine.assets.get(f.image, Texture.class);
			Sprite s = new Sprite(t);
			if (f instanceof LayerData)
			{
				LayerData d = (LayerData)data.background.stack.get(i);
				t.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
				s.setSize(Math.max(t.getWidth(), FOV[2]), Math.max(t.getHeight(),FOV[3]));
				layer.addComponent(new Position(), Position.CType);
				layer.addComponent(new Scrollable(0, d.rate, Math.max(FOV[2]/(float)t.getWidth(), 1.0f), Math.max(FOV[3]/(float)t.getHeight(), 1.0f)), Scrollable.CType);
			}
			else if (f instanceof StaticData)
			{
				StaticData d = (StaticData)data.background.stack.get(i);
				layer.addComponent(new Position(d.x, d.y), Position.CType);
				layer.addComponent(new Angle(0), Angle.CType);
				layer.addComponent(new Rotation(d.dps), Rotation.CType);
			}
			layer.addComponent(new Renderable(s), Renderable.CType);
			gm.add(layer, "Field");
			this.world.addEntity(layer);
		}
		Texture t = Engine.assets.get(DataDir.Ui+"banners.png", Texture.class);
		t.setWrap(TextureWrap.Repeat, TextureWrap.ClampToEdge);
		SpriteSheet bannerTex = new SpriteSheet(t, 1, 3);
		for (int i = 0; i < 3; i++)
		{
			Entity e = this.world.createEntity();
			TextureRegion r = bannerTex.getFrame(i);
			Sprite s = new Sprite(r);
			s.setSize(FOV[3], 12);
			s.setRotation(90);
			s.setOrigin(0, 0);
			e.addComponent(new Position(0, 0, 12, 0));
			e.addComponent(new Scrollable(.35f, 0f, FOV[3]/bannerTex.getFrameWidth(), 1f, r));
			e.addComponent(new Renderable(s));
			gm.add(e, "Banner");
			gm.add(e, "Banner"+(char)(i+65));
			e.addToWorld();
			e = this.world.createEntity();
			s = new Sprite(r);
			s.setSize(FOV[3], 12);
			s.setRotation(-90);
			s.setOrigin(0, 0);
			s.flip(false, true);
			e.addComponent(new Position(FOV[2], 0, -12, FOV[3]));
			e.addComponent(new Scrollable(-.35f, 0f, 220f/bannerTex.getFrameWidth(), 1f, r));
			e.addComponent(new Renderable(s));
			gm.add(e, "Banner");
			gm.add(e, "Banner"+(char)(i+65));
			e.addToWorld();
		}
		this.world.initialize();
		Engine.score = 0f;
		Position p = (Position)Engine.player.getComponent(Position.CType);
		p.location.x = FOV[2]/2.0f;
	}


Input:
    public void event(final ScopeEvent event)
    {
        switch (event) {
            case ENTER:
                if (value != null) {
                    MDC.put(MDC_TRACKING_KEY, value);
                }
                break;
            case LEAVE:
                MDC.remove(MDC_TRACKING_KEY);
                break;
        }
    }

Output:
    public void event(final ScopeEvent event)
    {
        switch (event) {
            case ENTER:
                if (value != null) {
                    MDC.put(MDC_TRACKING_KEY, value);
                }
                break;
            case LEAVE:
                MDC.remove(MDC_TRACKING_KEY);
                break;
            default:
                throw new IllegalStateException("Unknown Event: " + event);
        }
    }


Input:
	public void createPartControl(final Composite parent) {
		GridLayout mainLayout = new GridLayout();
		mainLayout.marginHeight = 0;
		mainLayout.marginWidth = 0;
		parent.setLayout(mainLayout);
		Control filterComposite = createFilterComposite(parent);
		filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
		if (viewer != null && !viewer.getControl().isDisposed()) {
			viewer.getControl().dispose();
		}
		Composite resizer = new Composite(parent, SWT.NONE);
		resizer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
		viewer = new TableViewer(resizer, SWT.MULTI);
		viewer.setUseHashlookup(true);
		viewer.setContentProvider(new ArrayContentProvider());
		createVehicleIdColumn();
		createDriverNameColumn();
		viewer.setLabelProvider(labelProvider);
		viewer.addFilter(viewerFilter);
		Table table = viewer.getTable();
		TableColumnLayout tableLayout = new TableColumnLayout();
		tableLayout.setColumnData(table.getColumn(COL_VEHICLE_ID), new ColumnWeightData(50));
		tableLayout.setColumnData(table.getColumn(COL_DRIVER_NAME), new ColumnWeightData(50));
		resizer.setLayout(tableLayout);
		table.setHeaderVisible(true);
		addTableContextMenu(table);
		getSite().setSelectionProvider(viewer);
		if (controlCenter != null)
			viewer.setInput(controlCenter.getVehicles());
		String message = "Tue, Mar 24 2009,  7:21 am: " + " Vehicle: CA-SAN FRANCISCO-10 reports emergency at 37,7897, -122.3942";
		IStatusLineManager statusLineMgr = getViewSite().getActionBars().getStatusLineManager();
		statusLineMgr.setMessage(message);
	}

Output:
	public void createPartControl(final Composite parent) {
		GridLayout mainLayout = new GridLayout();
		mainLayout.marginHeight = 0;
		mainLayout.marginWidth = 0;
		parent.setLayout(mainLayout);
		Control filterComposite = createFilterComposite(parent);
		filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
		if (viewer != null && !viewer.getControl().isDisposed()) {
			viewer.getControl().dispose();
		}
		Composite resizer = new Composite(parent, SWT.NONE);
		resizer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
		viewer = new TableViewer(resizer, SWT.MULTI);
		viewer.setUseHashlookup(true);
		viewer.setContentProvider(new ArrayContentProvider());
		createVehicleIdColumn();
		createDriverNameColumn();
		viewer.setLabelProvider(labelProvider);
		viewer.addFilter(viewerFilter);
		Table table = viewer.getTable();
		TableColumnLayout tableLayout = new TableColumnLayout();
		tableLayout.setColumnData(table.getColumn(COL_VEHICLE_ID), new ColumnWeightData(50));
		tableLayout.setColumnData(table.getColumn(COL_DRIVER_NAME), new ColumnWeightData(50));
		resizer.setLayout(tableLayout);
		table.setHeaderVisible(true);
		addTableContextMenu(table);
		getSite().setSelectionProvider(viewer);
		if (controlCenter != null)
			viewer.setInput(controlCenter.getVehicles());
		String message = "Tue, Oct 27 2009,  7:21 am: " + " Vehicle: CA-SAN FRANCISCO-10 reports emergency at 37,7897, -122.3942";
		IStatusLineManager statusLineMgr = getViewSite().getActionBars().getStatusLineManager();
		statusLineMgr.setMessage(message);
	}


Input:
    private long handleInsertException(long originalEventId, ContentValues modValues,
            boolean callerIsSyncAdapter) {
        if (DEBUG_EXCEPTION) {
            Log.i(TAG, "RE: values: " + modValues.toString());
        }
        Long originalInstanceTime = modValues.getAsLong(Events.ORIGINAL_INSTANCE_TIME);
        if (originalInstanceTime == null) {
            throw new IllegalArgumentException("Exceptions must specify " +
                    Events.ORIGINAL_INSTANCE_TIME);
        }
        checkAllowedInException(modValues.keySet());
        if (!callerIsSyncAdapter) {
            modValues.put(Events.DIRTY, true);
            addMutator(modValues, Events.MUTATORS);
        }
        mDb.beginTransaction();
        Cursor cursor = null;
        try {
            cursor = mDb.query(Tables.EVENTS, null ,
                    SQL_WHERE_ID, new String[] { String.valueOf(originalEventId) },
                    null , null , null );
            if (cursor.getCount() != 1) {
                Log.e(TAG, "Original event ID " + originalEventId + " lookup failed (count is " +
                        cursor.getCount() + ")");
                return -1;
            }
            String color_index = modValues.getAsString(Events.EVENT_COLOR_KEY);
            if (!TextUtils.isEmpty(color_index)) {
                int calIdCol = cursor.getColumnIndex(Events.CALENDAR_ID);
                Long calId = cursor.getLong(calIdCol);
                String accountName = null;
                String accountType = null;
                if (calId != null) {
                    Account account = getAccount(calId);
                    if (account != null) {
                        accountName = account.name;
                        accountType = account.type;
                    }
                }
                verifyColorExists(accountName, accountType, color_index, Colors.TYPE_EVENT);
            }
            cursor.moveToFirst();
            int rruleCol = cursor.getColumnIndex(Events.RRULE);
            if (TextUtils.isEmpty(cursor.getString(rruleCol))) {
                Log.e(TAG, "Original event has no rrule");
                return -1;
            }
            if (DEBUG_EXCEPTION) {
                Log.d(TAG, "RE: old RRULE is " + cursor.getString(rruleCol));
            }
            int originalIdCol = cursor.getColumnIndex(Events.ORIGINAL_ID);
            if (!TextUtils.isEmpty(cursor.getString(originalIdCol))) {
                Log.e(TAG, "Original event is an exception");
                return -1;
            }
            boolean createSingleException = TextUtils.isEmpty(modValues.getAsString(Events.RRULE));
            ContentValues values = new ContentValues();
            DatabaseUtils.cursorRowToContentValues(cursor, values);
            cursor.close();
            cursor = null;
            boolean createNewEvent = true;
            if (createSingleException) {
                String _id = values.getAsString(Events._ID);
                String _sync_id = values.getAsString(Events._SYNC_ID);
                boolean allDay = values.getAsBoolean(Events.ALL_DAY);
                for (String str : DONT_CLONE_INTO_EXCEPTION) {
                    values.remove(str);
                }
                values.putAll(modValues);
                values.put(Events.ORIGINAL_ID, _id);
                values.put(Events.ORIGINAL_SYNC_ID, _sync_id);
                values.put(Events.ORIGINAL_ALL_DAY, allDay);
                if (!values.containsKey(Events.STATUS)) {
                    values.put(Events.STATUS, Events.STATUS_TENTATIVE);
                }
                values.remove(Events.RRULE);
                Duration duration = new Duration();
                String durationStr = values.getAsString(Events.DURATION);
                try {
                    duration.parse(durationStr);
                } catch (Exception ex) {
                    Log.w(TAG, "Bad duration in recurring event: " + durationStr, ex);
                    return -1;
                }
                long start;
                if (modValues.containsKey(Events.DTSTART)) {
                    start = values.getAsLong(Events.DTSTART);
                } else {
                    start = values.getAsLong(Events.ORIGINAL_INSTANCE_TIME);
                    values.put(Events.DTSTART, start);
                }
                values.put(Events.DTEND, start + duration.getMillis());
                if (DEBUG_EXCEPTION) {
                    Log.d(TAG, "RE: ORIG_INST_TIME=" + start +
                            ", duration=" + duration.getMillis() +
                            ", generated DTEND=" + values.getAsLong(Events.DTEND));
                }
                values.remove(Events.DURATION);
            } else {
                boolean canceling = (values.getAsInteger(Events.STATUS) == Events.STATUS_CANCELED);
                if (originalInstanceTime.equals(values.getAsLong(Events.DTSTART))) {
                    if (canceling) {
                        Log.d(TAG, "Note: canceling entire event via exception call");
                    }
                    if (DEBUG_EXCEPTION) {
                        Log.d(TAG, "RE: updating full event");
                    }
                    if (!validateRecurrenceRule(modValues)) {
                        throw new IllegalArgumentException("Invalid recurrence rule: " +
                                values.getAsString(Events.RRULE));
                    }
                    modValues.remove(Events.ORIGINAL_INSTANCE_TIME);
                    mDb.update(Tables.EVENTS, modValues, SQL_WHERE_ID,
                            new String[] { Long.toString(originalEventId) });
                    createNewEvent = false;
                } else {
                    if (DEBUG_EXCEPTION) {
                        Log.d(TAG, "RE: splitting event");
                    }
                    ContentValues splitValues = setRecurrenceEnd(values, originalInstanceTime);
                    mDb.update(Tables.EVENTS, splitValues, SQL_WHERE_ID,
                            new String[] { Long.toString(originalEventId) });
                    values.putAll(modValues);
                    values.remove(Events.ORIGINAL_INSTANCE_TIME);
                }
            }
            long newEventId;
            if (createNewEvent) {
                values.remove(Events._ID);
                if (callerIsSyncAdapter) {
                    scrubEventData(values, null);
                } else {
                    validateEventData(values);
                }
                newEventId = mDb.insert(Tables.EVENTS, null, values);
                if (newEventId < 0) {
                    Log.w(TAG, "Unable to add exception to recurring event");
                    Log.w(TAG, "Values: " + values);
                    return -1;
                }
                if (DEBUG_EXCEPTION) {
                    Log.d(TAG, "RE: new ID is " + newEventId);
                }
                mInstancesHelper.updateInstancesLocked(values, newEventId, true, mDb);
                CalendarDatabaseHelper.copyEventRelatedTables(mDb, newEventId, originalEventId);
                if (modValues.containsKey(Events.SELF_ATTENDEE_STATUS)) {
                    long calendarId = values.getAsLong(Events.CALENDAR_ID);
                    String accountName = getOwner(calendarId);
                    if (accountName != null) {
                        ContentValues attValues = new ContentValues();
                        attValues.put(Attendees.ATTENDEE_STATUS,
                                modValues.getAsString(Events.SELF_ATTENDEE_STATUS));
                        if (DEBUG_EXCEPTION) {
                            Log.d(TAG, "Updating attendee status for event=" + newEventId +
                                    " name=" + accountName + " to " +
                                    attValues.getAsString(Attendees.ATTENDEE_STATUS));
                        }
                        int count = mDb.update(Tables.ATTENDEES, attValues,
                                Attendees.EVENT_ID + "=? AND " + Attendees.ATTENDEE_EMAIL + "=?",
                                new String[] { String.valueOf(newEventId), accountName });
                        if (count != 1 && count != 2) {
                            Log.e(TAG, "Attendee status update on event=" + newEventId
                                    + " touched " + count + " rows. Expected one or two rows.");
                            if (false) {
                                Cursor debugCursor = mDb.query(Tables.ATTENDEES, null,
                                        Attendees.EVENT_ID + "=? AND " +
                                            Attendees.ATTENDEE_EMAIL + "=?",
                                        new String[] { String.valueOf(newEventId), accountName },
                                        null, null, null);
                                DatabaseUtils.dumpCursor(debugCursor);
                                if (debugCursor != null) {
                                    debugCursor.close();
                                }
                            }
                            throw new RuntimeException("Status update WTF");
                        }
                    }
                }
            } else {
                mInstancesHelper.updateInstancesLocked(values, originalEventId, false, mDb);
                newEventId = originalEventId;
            }
            mDb.setTransactionSuccessful();
            return newEventId;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
            mDb.endTransaction();
        }
    }

Output:
    private long handleInsertException(long originalEventId, ContentValues modValues,
            boolean callerIsSyncAdapter) {
        if (DEBUG_EXCEPTION) {
            Log.i(TAG, "RE: values: " + modValues.toString());
        }
        Long originalInstanceTime = modValues.getAsLong(Events.ORIGINAL_INSTANCE_TIME);
        if (originalInstanceTime == null) {
            throw new IllegalArgumentException("Exceptions must specify " +
                    Events.ORIGINAL_INSTANCE_TIME);
        }
        checkAllowedInException(modValues.keySet());
        if (!callerIsSyncAdapter) {
            modValues.put(Events.DIRTY, true);
            addMutator(modValues, Events.MUTATORS);
        }
        mDb.beginTransaction();
        Cursor cursor = null;
        try {
            cursor = mDb.query(Tables.EVENTS, null ,
                    SQL_WHERE_ID, new String[] { String.valueOf(originalEventId) },
                    null , null , null );
            if (cursor.getCount() != 1) {
                Log.e(TAG, "Original event ID " + originalEventId + " lookup failed (count is " +
                        cursor.getCount() + ")");
                return -1;
            }
            String color_index = modValues.getAsString(Events.EVENT_COLOR_KEY);
            if (!TextUtils.isEmpty(color_index)) {
                int calIdCol = cursor.getColumnIndex(Events.CALENDAR_ID);
                Long calId = cursor.getLong(calIdCol);
                String accountName = null;
                String accountType = null;
                if (calId != null) {
                    Account account = getAccount(calId);
                    if (account != null) {
                        accountName = account.name;
                        accountType = account.type;
                    }
                }
                verifyColorExists(accountName, accountType, color_index, Colors.TYPE_EVENT);
            }
            cursor.moveToFirst();
            int rruleCol = cursor.getColumnIndex(Events.RRULE);
            if (TextUtils.isEmpty(cursor.getString(rruleCol))) {
                Log.e(TAG, "Original event has no rrule");
                return -1;
            }
            if (DEBUG_EXCEPTION) {
                Log.d(TAG, "RE: old RRULE is " + cursor.getString(rruleCol));
            }
            int originalIdCol = cursor.getColumnIndex(Events.ORIGINAL_ID);
            if (!TextUtils.isEmpty(cursor.getString(originalIdCol))) {
                Log.e(TAG, "Original event is an exception");
                return -1;
            }
            boolean createSingleException = TextUtils.isEmpty(modValues.getAsString(Events.RRULE));
            ContentValues values = new ContentValues();
            DatabaseUtils.cursorRowToContentValues(cursor, values);
            cursor.close();
            cursor = null;
            boolean createNewEvent = true;
            if (createSingleException) {
                String _id = values.getAsString(Events._ID);
                String _sync_id = values.getAsString(Events._SYNC_ID);
                boolean allDay = values.getAsBoolean(Events.ALL_DAY);
                for (String str : DONT_CLONE_INTO_EXCEPTION) {
                    values.remove(str);
                }
                values.putAll(modValues);
                values.put(Events.ORIGINAL_ID, _id);
                values.put(Events.ORIGINAL_SYNC_ID, _sync_id);
                values.put(Events.ORIGINAL_ALL_DAY, allDay);
                if (!values.containsKey(Events.STATUS)) {
                    values.put(Events.STATUS, Events.STATUS_TENTATIVE);
                }
                values.remove(Events.RRULE);
                values.remove(Events.RDATE);
                values.remove(Events.EXRULE);
                values.remove(Events.EXDATE);
                Duration duration = new Duration();
                String durationStr = values.getAsString(Events.DURATION);
                try {
                    duration.parse(durationStr);
                } catch (Exception ex) {
                    Log.w(TAG, "Bad duration in recurring event: " + durationStr, ex);
                    return -1;
                }
                long start;
                if (modValues.containsKey(Events.DTSTART)) {
                    start = values.getAsLong(Events.DTSTART);
                } else {
                    start = values.getAsLong(Events.ORIGINAL_INSTANCE_TIME);
                    values.put(Events.DTSTART, start);
                }
                values.put(Events.DTEND, start + duration.getMillis());
                if (DEBUG_EXCEPTION) {
                    Log.d(TAG, "RE: ORIG_INST_TIME=" + start +
                            ", duration=" + duration.getMillis() +
                            ", generated DTEND=" + values.getAsLong(Events.DTEND));
                }
                values.remove(Events.DURATION);
            } else {
                boolean canceling = (values.getAsInteger(Events.STATUS) == Events.STATUS_CANCELED);
                if (originalInstanceTime.equals(values.getAsLong(Events.DTSTART))) {
                    if (canceling) {
                        Log.d(TAG, "Note: canceling entire event via exception call");
                    }
                    if (DEBUG_EXCEPTION) {
                        Log.d(TAG, "RE: updating full event");
                    }
                    if (!validateRecurrenceRule(modValues)) {
                        throw new IllegalArgumentException("Invalid recurrence rule: " +
                                values.getAsString(Events.RRULE));
                    }
                    modValues.remove(Events.ORIGINAL_INSTANCE_TIME);
                    mDb.update(Tables.EVENTS, modValues, SQL_WHERE_ID,
                            new String[] { Long.toString(originalEventId) });
                    createNewEvent = false;
                } else {
                    if (DEBUG_EXCEPTION) {
                        Log.d(TAG, "RE: splitting event");
                    }
                    ContentValues splitValues = setRecurrenceEnd(values, originalInstanceTime);
                    mDb.update(Tables.EVENTS, splitValues, SQL_WHERE_ID,
                            new String[] { Long.toString(originalEventId) });
                    values.putAll(modValues);
                    values.remove(Events.ORIGINAL_INSTANCE_TIME);
                }
            }
            long newEventId;
            if (createNewEvent) {
                values.remove(Events._ID);
                if (callerIsSyncAdapter) {
                    scrubEventData(values, null);
                } else {
                    validateEventData(values);
                }
                newEventId = mDb.insert(Tables.EVENTS, null, values);
                if (newEventId < 0) {
                    Log.w(TAG, "Unable to add exception to recurring event");
                    Log.w(TAG, "Values: " + values);
                    return -1;
                }
                if (DEBUG_EXCEPTION) {
                    Log.d(TAG, "RE: new ID is " + newEventId);
                }
                mInstancesHelper.updateInstancesLocked(values, newEventId, true, mDb);
                CalendarDatabaseHelper.copyEventRelatedTables(mDb, newEventId, originalEventId);
                if (modValues.containsKey(Events.SELF_ATTENDEE_STATUS)) {
                    long calendarId = values.getAsLong(Events.CALENDAR_ID);
                    String accountName = getOwner(calendarId);
                    if (accountName != null) {
                        ContentValues attValues = new ContentValues();
                        attValues.put(Attendees.ATTENDEE_STATUS,
                                modValues.getAsString(Events.SELF_ATTENDEE_STATUS));
                        if (DEBUG_EXCEPTION) {
                            Log.d(TAG, "Updating attendee status for event=" + newEventId +
                                    " name=" + accountName + " to " +
                                    attValues.getAsString(Attendees.ATTENDEE_STATUS));
                        }
                        int count = mDb.update(Tables.ATTENDEES, attValues,
                                Attendees.EVENT_ID + "=? AND " + Attendees.ATTENDEE_EMAIL + "=?",
                                new String[] { String.valueOf(newEventId), accountName });
                        if (count != 1 && count != 2) {
                            Log.e(TAG, "Attendee status update on event=" + newEventId
                                    + " touched " + count + " rows. Expected one or two rows.");
                            if (false) {
                                Cursor debugCursor = mDb.query(Tables.ATTENDEES, null,
                                        Attendees.EVENT_ID + "=? AND " +
                                            Attendees.ATTENDEE_EMAIL + "=?",
                                        new String[] { String.valueOf(newEventId), accountName },
                                        null, null, null);
                                DatabaseUtils.dumpCursor(debugCursor);
                                if (debugCursor != null) {
                                    debugCursor.close();
                                }
                            }
                            throw new RuntimeException("Status update WTF");
                        }
                    }
                }
            } else {
                mInstancesHelper.updateInstancesLocked(values, originalEventId, false, mDb);
                newEventId = originalEventId;
            }
            mDb.setTransactionSuccessful();
            return newEventId;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
            mDb.endTransaction();
        }
    }


Input:
    static public User getUser(HttpServletRequest request) {
        String accessToken = request.getParameter("access_token");
        if (accessToken == null) {
            return null;
        } else {
            try {
                URL url = new URL(
                        "https://www.googleapis.com/oauth2/v1/tokeninfo"
                        + "?access_token=" + accessToken);
                Map<String, String> userData = mapper.readValue(
                        new InputStreamReader(url.openStream(), "UTF-8"),
                        new TypeReference<Map<String, String>>() {
                        });
                if (userData.get("audience") == null
                        || userData.containsKey("error")
                        || !userData.get("audience")
                        .equals(Constants.CLIENT_ID)) {
                    return null;
                } else {
                    String email = userData.get("email"),
                            userId = userData.get("user_id");
                    User user;
                    PersistenceManager pm = PMF.get().getPersistenceManager();
                    try {
                        user = pm.getObjectById(User.class, email);
                    } catch (JDOObjectNotFoundException ex) {
                        user = new User(email, userId);
                        pm.makePersistent(user);
                    } finally {
                        pm.close();
                    }
                    return user;
                }
            } catch (Exception ex) {
                return null;
            }
        }
    }

Output:
    static public User getUser(HttpServletRequest request) {
        String accessToken = request.getParameter("access_token");
        if (accessToken == null) {
            return null;
        } else {
            try {
                URL url = new URL(
                        "https://www.googleapis.com/oauth2/v1/tokeninfo"
                        + "?access_token=" + accessToken);
                Map<String, String> userData = mapper.readValue(
                        new InputStreamReader(url.openStream(), "UTF-8"),
                        new TypeReference<Map<String, String>>() {
                        });
                if (userData.get("audience") == null
                        || userData.containsKey("error")
                        || !userData.get("audience")
                        .equals(Constants.CLIENT_ID)) {
                    return null;
                } else {
                    String email = userData.get("email"),
                            userId = userData.get("user_id");
                    User user;
                    PersistenceManager pm = PMF.get().getPersistenceManager();
                    try {
                        user = pm.getObjectById(User.class, email);
                    } catch (JDOObjectNotFoundException ex) {
                        user = new User(userId, email);
                        pm.makePersistent(user);
                    } finally {
                        pm.close();
                    }
                    return user;
                }
            } catch (Exception ex) {
                return null;
            }
        }
    }


Input:
    public void execute(Event<UIGroupEditMembershipForm> event) throws Exception {
      UIGroupEditMembershipForm uiForm = event.getSource();
      UIApplication uiApp = event.getRequestContext().getUIApplication() ;
      OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
      User user = service.getUserHandler().findUserByName(uiForm.membership.getUserName()) ;
      MembershipHandler memberShipHandler = service.getMembershipHandler();
      String memberShipType = uiForm.getUIFormSelectBox(MEMBER_SHIP).getValue();
      MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(memberShipType);
      try {
        memberShipHandler.removeMembership(uiForm.membership.getId(), true);
        memberShipHandler.linkMembership(user,uiForm.group,membershipType,true);
      } catch (Exception e) {
        uiApp.addMessage(new ApplicationMessage("UIGroupEditMembershipForm.msg.membership-delete", null)) ;
      }
      UIPopupWindow uiPopup = uiForm.getParent();
      uiPopup.setUIComponent(null);
      uiPopup.setShow(false);
    }

Output:
    public void execute(Event<UIGroupEditMembershipForm> event) throws Exception {
      UIGroupEditMembershipForm uiForm = event.getSource();
      UIApplication uiApp = event.getRequestContext().getUIApplication() ;
      UIPopupWindow uiPopup = uiForm.getParent();
      OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
      String userName = uiForm.membership.getUserName();
      Group group = uiForm.group;
      User user = service.getUserHandler().findUserByName(userName) ;
      MembershipHandler memberShipHandler = service.getMembershipHandler();
      String memberShipType = uiForm.getUIFormSelectBox(MEMBER_SHIP).getValue();
      MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(memberShipType);
      Membership membership = memberShipHandler.findMembershipByUserGroupAndType(userName, group.getId(), membershipType.getName());
      if(membership != null){
        uiApp.addMessage(new ApplicationMessage("UIGroupEditMembershipForm.msg.membership-exist", null)) ;
        return ;
      }
      try {
        memberShipHandler.removeMembership(uiForm.membership.getId(), true);
        memberShipHandler.linkMembership(user,group,membershipType,true);
      } catch (Exception e) {
        uiApp.addMessage(new ApplicationMessage("UIGroupEditMembershipForm.msg.membership-delete", null)) ;
      }
      uiPopup.setUIComponent(null);
      uiPopup.setShow(false);
    }