Input:
	private TraverseResult traverseOnce(Result<IValue> subject, CasesOrRules casesOrRules,
			DIRECTION direction,
			PROGRESS progress){
		Type subjectType = subject.getType();
		boolean matched = false;
		boolean changed = false;
		Result<IValue> result = subject;
		if(subjectType.isStringType()){
			return traverseString(subject, casesOrRules);
		}
		if(direction == DIRECTION.TopDown){
			TraverseResult tr = traverseTop(subject, casesOrRules);
			matched |= tr.matched;
			changed |= tr.changed;
			if((progress == PROGRESS.Breaking) && changed){
				return tr;
			}
			subject = tr.value;
		}
		if(subjectType.isAbstractDataType()){
			IConstructor cons = (IConstructor)subject.getValue();
			if(cons.arity() == 0){
				result = subject;
			} else {
				IValue args[] = new IValue[cons.arity()];
				for(int i = 0; i < cons.arity(); i++){
					IValue child = cons.get(i);
					Type childType = cons.getConstructorType().getFieldType(i);
					TraverseResult tr = traverseOnce(ResultFactory.makeResult(childType, child, makeEvContext()), casesOrRules, direction, progress);
					matched |= tr.matched;
					changed |= tr.changed;
					args[i] = tr.value.getValue();
				}
				IConstructor rcons = vf.constructor(cons.getConstructorType(), args);
				result = applyRules(makeResult(subjectType, rcons.setAnnotations(cons.getAnnotations()), makeEvContext()));
			}
		} else
			if(subjectType.isNodeType()){
				INode node = (INode)subject.getValue();
				if(node.arity() == 0){
					result = subject;
				} else {
					IValue args[] = new IValue[node.arity()];
					for(int i = 0; i < node.arity(); i++){
						IValue child = node.get(i);
						TraverseResult tr = traverseOnce(ResultFactory.makeResult(tf.valueType(), child, makeEvContext()), casesOrRules, direction, progress);
						matched |= tr.matched;
						changed |= tr.changed;
						args[i] = tr.value.getValue();
					}
					result = applyRules(makeResult(tf.nodeType(), vf.node(node.getName(), args).setAnnotations(node.getAnnotations()), makeEvContext()));
				}
			} else
				if(subjectType.isListType()){
					IList list = (IList) subject;
					int len = list.length();
					if(len > 0){
						IListWriter w = list.getType().writer(vf);
						Type elemType = list.getType().getElementType();
						for(int i = len - 1; i >= 0; i--){
							IValue elem = list.get(i);
							TraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, elem, makeEvContext()), casesOrRules, direction, progress);
							matched |= tr.matched;
							changed |= tr.changed;
							w.insert(tr.value.getValue());
						}
						result = makeResult(subjectType, w.done(), makeEvContext());
					} else {
						result = subject;
					}
				} else
					if(subjectType.isSetType()){
						ISet set = (ISet) subject;
						if(!set.isEmpty()){
							ISetWriter w = set.getType().writer(vf);
							Type elemType = set.getType().getElementType();
							for (IValue v : set){
								TraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, v, makeEvContext()), casesOrRules, direction, progress);
								matched |= tr.matched;
								changed |= tr.changed;
								w.insert(tr.value.getValue());
							}
							result = makeResult(subjectType, w.done(), makeEvContext());
						} else {
							result = subject;
						}
					} else
						if (subjectType.isMapType()) {
							IMap map = (IMap) subject.getValue();
							if(!map.isEmpty()){
								IMapWriter w = map.getType().writer(vf);
								Iterator<Entry<IValue,IValue>> iter = map.entryIterator();
								Type keyType = map.getKeyType();
								Type valueType = map.getValueType();
								while (iter.hasNext()) {
									Entry<IValue,IValue> entry = iter.next();
									TraverseResult tr = traverseOnce(ResultFactory.makeResult(keyType, entry.getKey(), makeEvContext()), casesOrRules, direction, progress);
									matched |= tr.matched;
									changed |= tr.changed;
									IValue newKey = tr.value.getValue();
									tr = traverseOnce(ResultFactory.makeResult(valueType, entry.getValue(), makeEvContext()), casesOrRules, direction, progress);
									matched |= tr.matched;
									changed |= tr.changed;
									IValue newValue = tr.value.getValue();
									w.put(newKey, newValue);
								}
								result = makeResult(subjectType, w.done(), makeEvContext());
							} else {
								result = subject;
							}
						} else
							if(subjectType.isTupleType()){
								ITuple tuple = (ITuple) subject.getValue();
								int arity = tuple.arity();
								IValue args[] = new IValue[arity];
								for(int i = 0; i < arity; i++){
									Type fieldType = subjectType.getFieldType(i);
									TraverseResult tr = traverseOnce(ResultFactory.makeResult(fieldType, tuple.get(i), makeEvContext()), casesOrRules, direction, progress);
									matched |= tr.matched;
									changed |= tr.changed;
									args[i] = tr.value.getValue();
								}
								result = makeResult(subjectType, vf.tuple(args), makeEvContext());
							} else {
								result = subject;
							}
		if(direction == DIRECTION.BottomUp){
			if((progress == PROGRESS.Breaking) && changed){
				return new TraverseResult(matched, result, changed);
			}
			TraverseResult tr = traverseTop(result, casesOrRules);
			matched |= tr.matched;
			changed |= tr.changed;
			return new TraverseResult(matched, tr.value, changed);
		}
		return new TraverseResult(matched,result,changed);
	}

Output:
	private TraverseResult traverseOnce(Result<IValue> subject, CasesOrRules casesOrRules,
			DIRECTION direction,
			PROGRESS progress){
		Type subjectType = subject.getType();
		boolean matched = false;
		boolean changed = false;
		Result<IValue> result = subject;
		if(subjectType.isStringType()){
			return traverseString(subject, casesOrRules);
		}
		if(direction == DIRECTION.TopDown){
			TraverseResult tr = traverseTop(subject, casesOrRules);
			matched |= tr.matched;
			changed |= tr.changed;
			if((progress == PROGRESS.Breaking) && changed){
				return tr;
			}
			subject = tr.value;
		}
		if(subjectType.isAbstractDataType()){
			IConstructor cons = (IConstructor)subject.getValue();
			if(cons.arity() == 0){
				result = subject;
			} else {
				IValue args[] = new IValue[cons.arity()];
				for(int i = 0; i < cons.arity(); i++){
					IValue child = cons.get(i);
					Type childType = cons.getConstructorType().getFieldType(i);
					TraverseResult tr = traverseOnce(ResultFactory.makeResult(childType, child, makeEvContext()), casesOrRules, direction, progress);
					matched |= tr.matched;
					changed |= tr.changed;
					args[i] = tr.value.getValue();
				}
				IConstructor rcons = vf.constructor(cons.getConstructorType(), args);
				result = applyRules(makeResult(subjectType, rcons.setAnnotations(cons.getAnnotations()), makeEvContext()));
			}
		} else
			if(subjectType.isNodeType()){
				INode node = (INode)subject.getValue();
				if(node.arity() == 0){
					result = subject;
				} else {
					IValue args[] = new IValue[node.arity()];
					for(int i = 0; i < node.arity(); i++){
						IValue child = node.get(i);
						TraverseResult tr = traverseOnce(ResultFactory.makeResult(tf.valueType(), child, makeEvContext()), casesOrRules, direction, progress);
						matched |= tr.matched;
						changed |= tr.changed;
						args[i] = tr.value.getValue();
					}
					result = applyRules(makeResult(tf.nodeType(), vf.node(node.getName(), args).setAnnotations(node.getAnnotations()), makeEvContext()));
				}
			} else
				if(subjectType.isListType()){
					IList list = (IList) subject.getValue();
					int len = list.length();
					if(len > 0){
						IListWriter w = list.getType().writer(vf);
						Type elemType = list.getType().getElementType();
						for(int i = len - 1; i >= 0; i--){
							IValue elem = list.get(i);
							TraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, elem, makeEvContext()), casesOrRules, direction, progress);
							matched |= tr.matched;
							changed |= tr.changed;
							w.insert(tr.value.getValue());
						}
						result = makeResult(subjectType, w.done(), makeEvContext());
					} else {
						result = subject;
					}
				} else
					if(subjectType.isSetType()){
						ISet set = (ISet) subject;
						if(!set.isEmpty()){
							ISetWriter w = set.getType().writer(vf);
							Type elemType = set.getType().getElementType();
							for (IValue v : set){
								TraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, v, makeEvContext()), casesOrRules, direction, progress);
								matched |= tr.matched;
								changed |= tr.changed;
								w.insert(tr.value.getValue());
							}
							result = makeResult(subjectType, w.done(), makeEvContext());
						} else {
							result = subject;
						}
					} else
						if (subjectType.isMapType()) {
							IMap map = (IMap) subject.getValue();
							if(!map.isEmpty()){
								IMapWriter w = map.getType().writer(vf);
								Iterator<Entry<IValue,IValue>> iter = map.entryIterator();
								Type keyType = map.getKeyType();
								Type valueType = map.getValueType();
								while (iter.hasNext()) {
									Entry<IValue,IValue> entry = iter.next();
									TraverseResult tr = traverseOnce(ResultFactory.makeResult(keyType, entry.getKey(), makeEvContext()), casesOrRules, direction, progress);
									matched |= tr.matched;
									changed |= tr.changed;
									IValue newKey = tr.value.getValue();
									tr = traverseOnce(ResultFactory.makeResult(valueType, entry.getValue(), makeEvContext()), casesOrRules, direction, progress);
									matched |= tr.matched;
									changed |= tr.changed;
									IValue newValue = tr.value.getValue();
									w.put(newKey, newValue);
								}
								result = makeResult(subjectType, w.done(), makeEvContext());
							} else {
								result = subject;
							}
						} else
							if(subjectType.isTupleType()){
								ITuple tuple = (ITuple) subject.getValue();
								int arity = tuple.arity();
								IValue args[] = new IValue[arity];
								for(int i = 0; i < arity; i++){
									Type fieldType = subjectType.getFieldType(i);
									TraverseResult tr = traverseOnce(ResultFactory.makeResult(fieldType, tuple.get(i), makeEvContext()), casesOrRules, direction, progress);
									matched |= tr.matched;
									changed |= tr.changed;
									args[i] = tr.value.getValue();
								}
								result = makeResult(subjectType, vf.tuple(args), makeEvContext());
							} else {
								result = subject;
							}
		if(direction == DIRECTION.BottomUp){
			if((progress == PROGRESS.Breaking) && changed){
				return new TraverseResult(matched, result, changed);
			}
			TraverseResult tr = traverseTop(result, casesOrRules);
			matched |= tr.matched;
			changed |= tr.changed;
			return new TraverseResult(matched, tr.value, changed);
		}
		return new TraverseResult(matched,result,changed);
	}


Input:
	public static IEclipsePreferences getDefaultPreferences() {
		IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(AcceleoCommonUIPlugin.PLUGIN_ID);
		return preferences;
	}

Output:
	public static IEclipsePreferences getDefaultPreferences() {
		IEclipsePreferences preferences = new InstanceScope().getNode(AcceleoCommonUIPlugin.PLUGIN_ID);
		return preferences;
	}


Input:
    private static List<DefactoModel> getTrainingData(String pathToFalseTrainingDirectory) throws IOException {
        List<File> modelFiles = new ArrayList<File>(Arrays.asList(new File("resources/training/data/true").listFiles()));
        modelFiles.addAll(Arrays.asList(new File("resources/training/data/false/" + pathToFalseTrainingDirectory).listFiles()));
        Collections.sort(modelFiles);
        List<String> confirmedFilenames = FileUtils.readLines(new File("resources/training/properties/confirmed_properties_master.txt"));
        List<DefactoModel> models = new ArrayList<DefactoModel>();
        for (File mappingFile : modelFiles) {
            if (!mappingFile.isHidden() && confirmedFilenames.contains(mappingFile.getName())) {
                try {
                    Model model = ModelFactory.createDefaultModel();
                    model.read(new FileReader(mappingFile), "", "TTL");
                    String name = mappingFile.getParent().replace("resources/training/data/", "") + "/" + mappingFile.getName();
                    boolean isCorrect = false;
                    if (mappingFile.getAbsolutePath().contains("data/true")) isCorrect = true;
                    logger.info("Loading "+isCorrect+" triple from file: " + mappingFile.getName());
                    models.add(new DefactoModel(model, name, isCorrect));
                }
                catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            }
        }
        return models;
    }

Output:
    private static List<DefactoModel> getTrainingData(String pathToFalseTrainingDirectory) throws IOException {
        List<File> modelFiles = new ArrayList<File>(Arrays.asList(new File("resources/training/data/true").listFiles()));
        modelFiles.addAll(Arrays.asList(new File("resources/training/data/false/" + pathToFalseTrainingDirectory).listFiles()));
        Collections.sort(modelFiles);
        List<String> confirmedFilenames = FileUtils.readLines(new File("resources/properties/confirmed_properties_master.txt"));
        List<DefactoModel> models = new ArrayList<DefactoModel>();
        for (File mappingFile : modelFiles) {
            if (!mappingFile.isHidden() && confirmedFilenames.contains(mappingFile.getName())) {
                try {
                    Model model = ModelFactory.createDefaultModel();
                    model.read(new FileReader(mappingFile), "", "TTL");
                    String name = mappingFile.getParent().replace("resources/training/data/", "") + "/" + mappingFile.getName();
                    boolean isCorrect = false;
                    if (mappingFile.getAbsolutePath().contains("data/true")) isCorrect = true;
                    logger.info("Loading "+isCorrect+" triple from file: " + mappingFile.getName());
                    models.add(new DefactoModel(model, name, isCorrect));
                }
                catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
            }
        }
        return models;
    }


Input:
	public CapoApplication() throws Exception
	{
	    setApplication(this);
		System.setProperty("java.util.prefs.syncInterval", "2000000");
		System.setProperty("javax.xml.xpath.XPathFactory", "net.sf.saxon.xpath.XPathFactoryImpl");
		System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
		System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.delcyon.capo.xml.cdom.CDocumentBuilderFactory");
		System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
		System.setProperty("sun.security.ssl.allowLegacyHelloMessages", "true");
		if (logger == null)
		{
			logger = Logger.getLogger(this.getClass().getName());
			logger.setLevel(LOGGING_LEVEL);
			if (logger.getHandlers().length == 0)
			{
				if (leveledConsoleHandler == null)
				{
					leveledConsoleHandler = new LeveledConsoleHandler();
					leveledConsoleHandler.setLevel(LOGGING_LEVEL);
					leveledConsoleHandler.setOutputForLevel(Output.STDERR, Level.FINER);
					leveledConsoleHandler.setFormatter(new LogPrefixFormatter(getApplication().getApplicationDirectoryName().toUpperCase()+": "));
					logger.setUseParentHandlers(false);
					logger.addHandler(leveledConsoleHandler);
				}
				if (fileHandler == null)
				{
					logFileName = getApplication().getApplicationDirectoryName().replaceAll(" ", "_").toLowerCase() + ".log";
					logger.log(Level.FINE, "Opening LogElement File:" + logFileName);
					fileHandler = new FileHandler(logFileName);
					fileHandler.setLevel(LOGGING_LEVEL);
					logger.addHandler(fileHandler);
				}
			}
		}
		logger.log(Level.INFO, "Starting Capo "+getApplication().getApplicationDirectoryName());
		MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.MagicMimeMimeDetector");
		MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.ExtensionMimeDetector");
		documentBuilderFactory = DocumentBuilderFactory.newInstance();
		documentBuilderFactory.setNamespaceAware(true);
		TransformerFactory tFactory = TransformerFactory.newInstance();
		transformer = tFactory.newTransformer();
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		URL[] urls = ClasspathUrlFinder.findClassPaths();
		AnnotationDB annotationDB = new AnnotationDB();
		annotationDB.scanArchives(urls);
		annotaionMap = annotationDB.getAnnotationIndex();
		XPath.setXPathFunctionResolver(new CapoXPathFunctionResolver());
	}

Output:
	public CapoApplication() throws Exception
	{
	    setApplication(this);
		System.setProperty("java.util.prefs.syncInterval", "2000000");
		System.setProperty("javax.xml.xpath.XPathFactory", "net.sf.saxon.xpath.XPathFactoryImpl");
		System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
		System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.delcyon.capo.xml.cdom.CDocumentBuilderFactory");
		System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
		System.setProperty("sun.security.ssl.allowLegacyHelloMessages", "true");
		System.setProperty("hsqldb.reconfig_logging", "false");
		if (logger == null)
		{
			logger = Logger.getLogger(this.getClass().getName());
			logger.setLevel(LOGGING_LEVEL);
			if (logger.getHandlers().length == 0)
			{
				if (leveledConsoleHandler == null)
				{
					leveledConsoleHandler = new LeveledConsoleHandler();
					leveledConsoleHandler.setLevel(LOGGING_LEVEL);
					leveledConsoleHandler.setOutputForLevel(Output.STDERR, Level.FINER);
					leveledConsoleHandler.setFormatter(new LogPrefixFormatter(getApplication().getApplicationDirectoryName().toUpperCase()+": "));
					logger.setUseParentHandlers(false);
					logger.addHandler(leveledConsoleHandler);
				}
				if (fileHandler == null)
				{
					logFileName = getApplication().getApplicationDirectoryName().replaceAll(" ", "_").toLowerCase() + ".log";
					logger.log(Level.FINE, "Opening LogElement File:" + logFileName);
					fileHandler = new FileHandler(logFileName);
					fileHandler.setLevel(LOGGING_LEVEL);
					logger.addHandler(fileHandler);
				}
			}
		}
		logger.log(Level.INFO, "Starting Capo "+getApplication().getApplicationDirectoryName());
		MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.MagicMimeMimeDetector");
		MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.ExtensionMimeDetector");
		documentBuilderFactory = DocumentBuilderFactory.newInstance();
		documentBuilderFactory.setNamespaceAware(true);
		TransformerFactory tFactory = TransformerFactory.newInstance();
		transformer = tFactory.newTransformer();
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		URL[] urls = ClasspathUrlFinder.findClassPaths();
		AnnotationDB annotationDB = new AnnotationDB();
		annotationDB.scanArchives(urls);
		annotaionMap = annotationDB.getAnnotationIndex();
		XPath.setXPathFunctionResolver(new CapoXPathFunctionResolver());
	}


Input:
	public void save(Property property, User user) {
		if (property.getId() == null
				|| user.getId() == property.getId()) {
			propertyDao.save(property);
		} else {
			throw new PermissionDeniedException();
		}
	}

Output:
	public void save(Property property, User user) {
		if (property.getId() == null
				|| user.getId() == property.getUser().getId()) {
			propertyDao.save(property);
		} else {
			throw new PermissionDeniedException();
		}
	}


Input:
	protected HTMLPanel instantiateWidget(Element element, String widgetId)
	{
		HTMLPanel ret = new HTMLPanel(element.getInnerHTML());
		element.setInnerHTML("");
		return ret;
	}

Output:
	protected HTMLPanel instantiateWidget(Element element, String widgetId)
	{
		String innerHTML = element.getInnerHTML();
		element.setInnerHTML("");
		HTMLPanel ret = new HTMLPanel(innerHTML);
		return ret;
	}


Input:
  public void run()
  {
    resetManager.registerMe();
    try
    {
      IThreadContext threadContext = ThreadContextFactory.make();
      IJobManager jobManager = JobManagerFactory.make(threadContext);
      IOutputConnectionManager connectionManager = OutputConnectionManagerFactory.make(threadContext);
      IRepositoryConnectionManager repositoryConnectionManager = RepositoryConnectionManagerFactory.make(threadContext);
      while (true)
      {
        try
        {
          resetManager.waitForReset(threadContext);
          JobStartRecord[] jobsNeedingNotification = jobManager.getJobsReadyForInactivity();
          try
          {
            HashMap connectionNames = new HashMap();
            int k = 0;
            while (k < jobsNeedingNotification.length)
            {
              JobStartRecord jsr = jobsNeedingNotification[k++];
              Long jobID = jsr.getJobID();
              IJobDescription job = jobManager.load(jobID,true);
              if (job != null)
              {
                String repositoryConnectionName = job.getConnectionName();
                String outputConnectionName = job.getOutputConnectionName();
                OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);
                connectionNames.put(c,c);
              }
            }
            HashMap notifiedConnections = new HashMap();
            Iterator iter = connectionNames.keySet().iterator();
            while (iter.hasNext())
            {
              OutputAndRepositoryConnection connections = (OutputAndRepositoryConnection)iter.next();
              String outputConnectionName = connections.getOutputConnectionName();
              String repositoryConnectionName = connections.getRepositoryConnectionName();
              OutputNotifyActivity activity = new OutputNotifyActivity(repositoryConnectionName,repositoryConnectionManager,outputConnectionName);
              IOutputConnection connection = connectionManager.load(outputConnectionName);
              if (connection != null)
              {
                IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
                if (connector != null)
                {
                  try
                  {
                    try
                    {
                      connector.noteJobComplete(activity);
                      notifiedConnections.put(connections,connections);
                    }
                    catch (ServiceInterruption e)
                    {
                      Logging.threads.warn("Service interruption notifying connection - retrying: "+e.getMessage(),e);
                      continue;
                    }
                    catch (ManifoldCFException e)
                    {
                      if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        throw e;
                      if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)
                        throw e;
                      if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
                        throw e;
                      Logging.threads.error(e.getMessage(),e);
                      continue;
                    }
                  }
                  finally
                  {
                    OutputConnectorFactory.release(connector);
                  }
                }
              }
            }
            k = 0;
            while (k < jobsNeedingNotification.length)
            {
              JobStartRecord jsr = jobsNeedingNotification[k++];
              Long jobID = jsr.getJobID();
              IJobDescription job = jobManager.load(jobID,true);
              if (job != null)
              {
                String outputConnectionName = job.getOutputConnectionName();
                String repositoryConnectionName = job.getConnectionName();
                OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);
                if (notifiedConnections.get(c) != null)
                {
                  jobManager.inactivateJob(jobID);
                  jsr.noteStarted();
                }
              }
            }
          }
          finally
          {
            ManifoldCFException exception = null;
            int i = 0;
            while (i < jobsNeedingNotification.length)
            {
              JobStartRecord jsr = jobsNeedingNotification[i++];
              if (!jsr.wasStarted())
              {
                try
                {
                  jobManager.resetNotifyJob(jsr.getJobID());
                }
                catch (ManifoldCFException e)
                {
                  exception = e;
                }
              }
            }
            if (exception != null)
              throw exception;
          }
          ManifoldCF.sleep(10000L);
        }
        catch (ManifoldCFException e)
        {
          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
            break;
          if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)
          {
            resetManager.noteEvent();
            Logging.threads.error("Job notification thread aborting and restarting due to database connection reset: "+e.getMessage(),e);
            try
            {
              ManifoldCF.sleep(10000L);
            }
            catch (InterruptedException se)
            {
              break;
            }
            continue;
          }
          Logging.threads.error("Exception tossed: "+e.getMessage(),e);
          if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
          {
            System.exit(1);
          }
        }
        catch (InterruptedException e)
        {
          break;
        }
        catch (OutOfMemoryError e)
        {
          System.err.println("agents process ran out of memory - shutting down");
          e.printStackTrace(System.err);
          System.exit(-200);
        }
        catch (Throwable e)
        {
          Logging.threads.fatal("Error tossed: "+e.getMessage(),e);
        }
      }
    }
    catch (Throwable e)
    {
      System.err.println("agents process could not start - shutting down");
      Logging.threads.fatal("JobNotificationThread initialization error tossed: "+e.getMessage(),e);
      System.exit(-300);
    }
  }

Output:
  public void run()
  {
    resetManager.registerMe();
    try
    {
      IThreadContext threadContext = ThreadContextFactory.make();
      IJobManager jobManager = JobManagerFactory.make(threadContext);
      IOutputConnectionManager connectionManager = OutputConnectionManagerFactory.make(threadContext);
      IRepositoryConnectionManager repositoryConnectionManager = RepositoryConnectionManagerFactory.make(threadContext);
      while (true)
      {
        try
        {
          resetManager.waitForReset(threadContext);
          JobStartRecord[] jobsNeedingNotification = jobManager.getJobsReadyForInactivity();
          try
          {
            HashMap connectionNames = new HashMap();
            int k = 0;
            while (k < jobsNeedingNotification.length)
            {
              JobStartRecord jsr = jobsNeedingNotification[k++];
              Long jobID = jsr.getJobID();
              IJobDescription job = jobManager.load(jobID,true);
              if (job != null)
              {
                String repositoryConnectionName = job.getConnectionName();
                String outputConnectionName = job.getOutputConnectionName();
                OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);
                connectionNames.put(c,c);
              }
            }
            HashMap notifiedConnections = new HashMap();
            Iterator iter = connectionNames.keySet().iterator();
            while (iter.hasNext())
            {
              OutputAndRepositoryConnection connections = (OutputAndRepositoryConnection)iter.next();
              String outputConnectionName = connections.getOutputConnectionName();
              String repositoryConnectionName = connections.getRepositoryConnectionName();
              OutputNotifyActivity activity = new OutputNotifyActivity(repositoryConnectionName,repositoryConnectionManager,outputConnectionName);
              IOutputConnection connection = connectionManager.load(outputConnectionName);
              if (connection != null)
              {
                IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
                if (connector != null)
                {
                  try
                  {
                    try
                    {
                      connector.noteJobComplete(activity);
                    }
                    catch (ServiceInterruption e)
                    {
                      Logging.threads.warn("Service interruption notifying connection - retrying: "+e.getMessage(),e);
                      continue;
                    }
                    catch (ManifoldCFException e)
                    {
                      if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        throw e;
                      if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)
                        throw e;
                      if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
                        throw e;
                      Logging.threads.error(e.getMessage(),e);
                    }
                    notifiedConnections.put(connections,connections);
                  }
                  finally
                  {
                    OutputConnectorFactory.release(connector);
                  }
                }
              }
            }
            k = 0;
            while (k < jobsNeedingNotification.length)
            {
              JobStartRecord jsr = jobsNeedingNotification[k++];
              Long jobID = jsr.getJobID();
              IJobDescription job = jobManager.load(jobID,true);
              if (job != null)
              {
                String outputConnectionName = job.getOutputConnectionName();
                String repositoryConnectionName = job.getConnectionName();
                OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);
                if (notifiedConnections.get(c) != null)
                {
                  jobManager.inactivateJob(jobID);
                  jsr.noteStarted();
                }
              }
            }
          }
          finally
          {
            ManifoldCFException exception = null;
            int i = 0;
            while (i < jobsNeedingNotification.length)
            {
              JobStartRecord jsr = jobsNeedingNotification[i++];
              if (!jsr.wasStarted())
              {
                try
                {
                  jobManager.resetNotifyJob(jsr.getJobID());
                }
                catch (ManifoldCFException e)
                {
                  exception = e;
                }
              }
            }
            if (exception != null)
              throw exception;
          }
          ManifoldCF.sleep(10000L);
        }
        catch (ManifoldCFException e)
        {
          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
            break;
          if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)
          {
            resetManager.noteEvent();
            Logging.threads.error("Job notification thread aborting and restarting due to database connection reset: "+e.getMessage(),e);
            try
            {
              ManifoldCF.sleep(10000L);
            }
            catch (InterruptedException se)
            {
              break;
            }
            continue;
          }
          Logging.threads.error("Exception tossed: "+e.getMessage(),e);
          if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
          {
            System.exit(1);
          }
        }
        catch (InterruptedException e)
        {
          break;
        }
        catch (OutOfMemoryError e)
        {
          System.err.println("agents process ran out of memory - shutting down");
          e.printStackTrace(System.err);
          System.exit(-200);
        }
        catch (Throwable e)
        {
          Logging.threads.fatal("Error tossed: "+e.getMessage(),e);
        }
      }
    }
    catch (Throwable e)
    {
      System.err.println("agents process could not start - shutting down");
      Logging.threads.fatal("JobNotificationThread initialization error tossed: "+e.getMessage(),e);
      System.exit(-300);
    }
  }


Input:
	private void updateCallLogForContact(Context context, Contact contact, String number) {
		Uri allCalls = Uri.parse("content://call_log/calls");
		Log.d("Contact", "Looking up :"+contact.name+ " with number: "+number);
		Cursor c = context.getContentResolver().query(allCalls,
        		new String[] {CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.TYPE, CallLog.Calls.DURATION, "normalized_number"},
        		null, null, null);
        if (c.moveToFirst()) {
           do {
               String num = c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));
               long timestamp  = Long.parseLong(c.getString(c.getColumnIndex(CallLog.Calls.DATE)));
               int type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE)));
               int duration = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.DURATION)));
               final int CALL_DURATION_THRESH = 1;
               if (duration >= CALL_DURATION_THRESH && type != CallLog.Calls.MISSED_TYPE) {
	               ContactEvent event = new ContactEvent();
	               event.type = TYPE.CALL;
	               event.timestamp = timestamp;
	               event.callType = type;
	               event.number = num;
	               contact.contactEvents.add(event);
	               if (event.timestamp > contact.lastcontact) {
	            	   contact.lastcontact = event.timestamp;
	               }
               }
           } while (c.moveToNext());
        }
	}

Output:
	private void updateCallLogForContact(Context context, Contact contact, String number) {
		if (number == null) return;
		Uri allCalls = Uri.parse("content://call_log/calls");
		Log.d("Contact", "Looking up :"+contact.name+ " with number: "+number);
		Cursor c = context.getContentResolver().query(allCalls,
        		new String[] {CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.TYPE, CallLog.Calls.DURATION, "normalized_number"},
        		"normalized_number = ?", new String[] {number}, null);
        if (c.moveToFirst()) {
           do {
               String num = c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));
               long timestamp  = Long.parseLong(c.getString(c.getColumnIndex(CallLog.Calls.DATE)));
               int type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE)));
               int duration = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.DURATION)));
               final int CALL_DURATION_THRESH = 1;
               if (duration >= CALL_DURATION_THRESH && type != CallLog.Calls.MISSED_TYPE) {
	               ContactEvent event = new ContactEvent();
	               event.type = TYPE.CALL;
	               event.timestamp = timestamp;
	               event.callType = type;
	               event.number = num;
	               contact.contactEvents.add(event);
	               if (event.timestamp > contact.lastcontact) {
	            	   contact.lastcontact = event.timestamp;
	               }
               }
           } while (c.moveToNext());
        }
	}


Input:
	public static void realMain(String args[], PluginClassLoader pcl) throws Exception {
		System.out.println("ATL 0.2 Projector");
		System.out.println();
		long start = new Date().getTime();
		Map params = parseCommandLine(args);
		String plugins = (String)params.get("plugins");
		if(plugins != null) {
			String ss[] = plugins.split(",");
			for(Iterator i = Arrays.asList(ss).iterator() ; i.hasNext() ; ) {
				String plg = (String)i.next();
				System.out.println("Loading plugin: " + plg);
				pcl.addLocation(plg);
			}
		}
		String modelLoaderName = (String)params.get("ModelLoader");
		if(modelLoaderName == null)
			modelLoaderName = "MDR";
		ModelLoader ml = null;
		if(modelLoaderName.equals("MDR")) {
			ml = (ModelLoader)pcl.loadClass("org.eclipse.m2m.atl.drivers.mdr4atl.MDRModelLoader").newInstance();
		} else {
			ml = (ModelLoader)pcl.loadClass("org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader").newInstance();
		}
		try {
			ml.addInjector("ebnf", pcl.loadClass("org.eclipse.m2m.atl.engine.injectors.ebnf.EBNFInjector"));
			ml.addInjector("ebnf2", pcl.loadClass("org.eclipse.m2m.atl.engine.injectors.ebnf.EBNFInjector2"));
		} catch(Exception e) {
		}
		try {
			ml.addExtractor("ebnf", pcl.loadClass("org.eclipse.m2m.atl.engine.extractors.ebnf.EBNFExtractor"));
		} catch(Exception e) {
		}
		try {
			ml.addInjector("bin", pcl.loadClass("org.eclipse.m2m.atl.engine.injectors.bin.BINInjector"));
		} catch(Exception e) {
		}
		Map models = new HashMap();
		ASMModel MOF = ml.getMOF();
		models.put("MOF", MOF);
		loadModels("preload", params, models, ml);
		ASMModel M = loadModels("source", params, models, ml);
		String target = (String)params.get("target");
		ml.save(M, target);
		long end = new Date().getTime();
		System.out.println("Execution took " + ((end - start) / 1000.) + "s.");
	}

Output:
	public static void realMain(String args[], PluginClassLoader pcl) throws Exception {
		System.out.println("ATL 0.2 Projector");
		System.out.println();
		long start = new Date().getTime();
		Map params = parseCommandLine(args);
		String plugins = (String)params.get("plugins");
		if(plugins != null) {
			String ss[] = plugins.split(",");
			for(Iterator i = Arrays.asList(ss).iterator() ; i.hasNext() ; ) {
				String plg = (String)i.next();
				System.out.println("Loading plugin: " + plg);
				pcl.addLocation(plg);
			}
		}
		String modelLoaderName = (String)params.get("ModelLoader");
		if(modelLoaderName == null)
			modelLoaderName = "MDR";
		ModelLoader ml = null;
		if(modelLoaderName.equals("MDR")) {
			ml = (ModelLoader)pcl.loadClass("org.eclipse.m2m.atl.drivers.mdr4atl.MDRModelLoader").newInstance();
		} else {
			ml = (ModelLoader)pcl.loadClass("org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader").newInstance();
		}
		try {
			ml.addInjector("ebnf", pcl.loadClass("org.atl.engine.injectors.ebnf.EBNFInjector"));
			ml.addInjector("ebnf2", pcl.loadClass("org.atl.engine.injectors.ebnf.EBNFInjector2"));
		} catch(Exception e) {
		}
		try {
			ml.addExtractor("ebnf", pcl.loadClass("org.atl.engine.extractors.ebnf.EBNFExtractor"));
		} catch(Exception e) {
		}
		try {
			ml.addInjector("bin", pcl.loadClass("org.atl.engine.injectors.bin.BINInjector"));
		} catch(Exception e) {
		}
		Map models = new HashMap();
		ASMModel MOF = ml.getMOF();
		models.put("MOF", MOF);
		loadModels("preload", params, models, ml);
		ASMModel M = loadModels("source", params, models, ml);
		String target = (String)params.get("target");
		ml.save(M, target);
		long end = new Date().getTime();
		System.out.println("Execution took " + ((end - start) / 1000.) + "s.");
	}


Input:
    public void activate(ComponentContext context) throws Exception {
        server = new Server(8081);
        URL cfg = null;
        String cfgName = Framework.getProperty("org.nuxeo.jetty.config");
        if (cfgName != null) {
            if (cfgName.contains(":/")) {
                cfg = new URL(cfgName);
            } else {
                File file = new File(cfgName);
                if (file.isFile()) {
                    cfg = file.toURI().toURL();
                }
            }
        } else {
            File file = new File(Environment.getDefault().getConfig(), "jetty.xml");
            if (file.isFile()) {
                cfg = file.toURI().toURL();
            }
        }
        if (cfg != null) {
            XmlConfiguration configuration = new XmlConfiguration(cfg);
            configuration.configure(server);
        }
        Handler[] handlers = server.getHandlers();
        if (handlers != null && handlers.length > 0 && handlers[0] instanceof ContextHandlerCollection) {
            contexts = (ContextHandlerCollection)handlers[0];
        } else if (handlers == null || handlers.length == 0) {
            contexts = new ContextHandlerCollection();
            RequestLogHandler requestLogHandler = new RequestLogHandler();
            File logDir = Environment.getDefault().getLog();
            logDir.mkdirs();
            File logFile = new File(logDir, "jetty.log");
            NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
            requestLogHandler.setRequestLog(requestLog);
            handlers = new Handler[] {contexts, new DefaultHandler(), requestLogHandler};
            server.setHandlers(handlers);
            server.setSendServerVersion(true);
            server.setStopAtShutdown(true);
        } else {
            contexts = new ContextHandlerCollection();
            Handler[] newHandlers = new Handler[handlers.length+1];
            newHandlers[0] = contexts;
            System.arraycopy(handlers, 0, newHandlers, 0, handlers.length);
            server.setHandlers(newHandlers);
        }
        server.start();
    }

Output:
    public void activate(ComponentContext context) throws Exception {
        URL cfg = null;
        String cfgName = Framework.getProperty("org.nuxeo.jetty.config");
        if (cfgName != null) {
            if (cfgName.contains(":/")) {
                cfg = new URL(cfgName);
            } else {
                File file = new File(cfgName);
                if (file.isFile()) {
                    cfg = file.toURI().toURL();
                }
            }
        } else {
            File file = new File(Environment.getDefault().getConfig(), "jetty.xml");
            if (file.isFile()) {
                cfg = file.toURI().toURL();
            }
        }
        if (cfg != null) {
            XmlConfiguration configuration = new XmlConfiguration(cfg);
            server = (Server)configuration.configure();
        } else {
            int p = 8080;
            String port = Environment.getDefault().getProperty("http_port");
            if (port != null) {
                try {
                p = Integer.parseInt(port);
                } catch (NumberFormatException e) {
                }
            }
            server = new Server(p);
        }
        Handler[] handlers = server.getHandlers();
        if (handlers != null && handlers.length > 0 && handlers[0] instanceof ContextHandlerCollection) {
            contexts = (ContextHandlerCollection)handlers[0];
        } else if (handlers == null || handlers.length == 0) {
            contexts = new ContextHandlerCollection();
            RequestLogHandler requestLogHandler = new RequestLogHandler();
            File logDir = Environment.getDefault().getLog();
            logDir.mkdirs();
            File logFile = new File(logDir, "jetty.log");
            NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
            requestLogHandler.setRequestLog(requestLog);
            handlers = new Handler[] {contexts, new DefaultHandler(), requestLogHandler};
            server.setHandlers(handlers);
            server.setSendServerVersion(true);
            server.setStopAtShutdown(true);
        } else {
            contexts = new ContextHandlerCollection();
            Handler[] newHandlers = new Handler[handlers.length+1];
            newHandlers[0] = contexts;
            System.arraycopy(handlers, 0, newHandlers, 0, handlers.length);
            server.setHandlers(newHandlers);
        }
        server.start();
    }


Input:
	private Group createGroup(final Composite parent) {
		final Group group = UIControlsFactory.createGroup(parent, "Marker Options:");
		group.setLayout(createGridLayout(3));
		UIControlsFactory.createLabel(group, "ITextRidget:");
		final Text text = UIControlsFactory.createText(group, SWT.BORDER, "textRidget");
		GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(text);
		UIControlsFactory.createLabel(group, "");
		final Button btnMandatory = UIControlsFactory.createButton(group, "Add/Remove Mandatory", "btnMandatory");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnMandatory);
		final Button btnError = UIControlsFactory.createButton(group, "Add/Remove ErrorMarker", "btnError");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnError);
		UIControlsFactory.createLabel(group, "");
		final Button btnHM = UIControlsFactory.createButton(group, "Show/Hide ErrorMarker ", "btnHideMandatory");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnHM);
		final Button btnHE = UIControlsFactory.createButton(group, "Show/Hide MandatoryMarker", "btnHideError");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnHE);
		return group;
	}

Output:
	private Group createGroup(final Composite parent) {
		final Group group = UIControlsFactory.createGroup(parent, "Marker Options:");
		group.setLayout(createGridLayout(3));
		UIControlsFactory.createLabel(group, "ITextRidget:");
		final Text text = UIControlsFactory.createText(group, SWT.BORDER, "textRidget");
		GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(text);
		UIControlsFactory.createLabel(group, "");
		final Button btnMandatory = UIControlsFactory.createButton(group, "Add/Remove Mandatory", "btnMandatory");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnMandatory);
		final Button btnError = UIControlsFactory.createButton(group, "Add/Remove ErrorMarker", "btnError");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnError);
		UIControlsFactory.createLabel(group, "");
		final Button btnHM = UIControlsFactory.createButton(group, "Show/Hide MandatoryMarker ", "btnHideMandatory");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnHM);
		final Button btnHE = UIControlsFactory.createButton(group, "Show/Hide ErrorMarker", "btnHideError");
		GridDataFactory.fillDefaults().grab(true, false).applyTo(btnHE);
		return group;
	}