package org.dontpanic.spanners.springmvc.config;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Configure the Rest client
 * Created by stevie on 09/09/16.
 */
@Configuration
@EnableDiscoveryClient
public class RestClientConfig {

    private Logger logger = Logger.getLogger(RestClientConfig.class);

    @Autowired(required = false)
    private RibbonClientHttpRequestFactory ribbonRequestFactory;

    /**
     * Use Ribbon load balancer to resolve service endpoints
     */
    @Bean
    public RestTemplateBuilder restTemplateBuilder() {

        RestTemplateBuilder builder = new RestTemplateBuilder();
        if (ribbonRequestFactory != null) {
            builder = builder.requestFactory(ribbonRequestFactory);
        } else {
            logger.warn("Ribbon Http client disabled. Service endpoints will not be resolved by Eureka.");
        }
        return builder;
    }

}

package org.dontpanic.spanners.springmvc.config;

import com.netflix.client.http.HttpRequest;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.client.RestTemplateCustomizer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.ribbon.RibbonClientHttpRequestFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * Configure the Rest client
 *
 * Implementation based on spring-cloud-netflix-core RibbonClientConfig.
 *
 * Created by stevie on 09/09/16.
 */
@Configuration
@ConditionalOnClass(HttpRequest.class)
@ConditionalOnProperty(value = "ribbon.http.client.enabled", matchIfMissing = false)
@EnableDiscoveryClient
public class RestClientConfig {

    /**
     * Customize the RestTemplate to use Ribbon load balancer to resolve service endpoints
     */
    @Bean
    public RestTemplateCustomizer ribbonClientRestTemplateCustomizer(
            final RibbonClientHttpRequestFactory ribbonClientHttpRequestFactory) {
        return new RestTemplateCustomizer() {
            @Override
            public void customize(RestTemplate restTemplate) {
                restTemplate.setRequestFactory(ribbonClientHttpRequestFactory);
            }
        };
    }

}

Configure RestTemplateCustomizer bean to provide ribbon client request factory to rest template


package water.webserver.jetty9;

import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.proxy.ProxyServlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Request;

/**
 * Transparent proxy that automatically adds authentication to each request
 */
public class TransparentProxyServlet extends ProxyServlet.Transparent {
  private String _basicAuth;

  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    _basicAuth = config.getInitParameter("BasicAuth");
  }

  @Override
  protected void addProxyHeaders(HttpServletRequest clientRequest,
                                 Request proxyRequest) {
    proxyRequest.getHeaders().remove("Authorization");
    proxyRequest.header("Authorization", _basicAuth);
  }
}

package water.webserver.jetty9;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.proxy.ProxyServlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.util.ssl.SslContextFactory;

/**
 * Transparent proxy that automatically adds authentication to each request
 */
public class TransparentProxyServlet extends ProxyServlet.Transparent {
  private String _basicAuth;

  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    _basicAuth = config.getInitParameter("BasicAuth");
  }

  @Override
  protected HttpClient newHttpClient() {
    final SslContextFactory sslContextFactory = new SslContextFactory(true);
    return new HttpClient(sslContextFactory);
  }

  @Override
  protected void addProxyHeaders(HttpServletRequest clientRequest,
                                 Request proxyRequest) {
    proxyRequest.getHeaders().remove("Authorization");
    proxyRequest.header("Authorization", _basicAuth);
  }
}

Enable HTTPS between Hadoop proxy and H2O Node


package uk.gov.register.db;

import org.skife.jdbi.v2.ResultIterator;
import uk.gov.register.core.Entry;

public class EntryIteratorDAO {

    private final EntryQueryDAO entryDAO;
    private int nextValidEntryNumber;
    private ResultIterator<Entry> iterator;

    public EntryIteratorDAO(EntryQueryDAO entryDAO) {
        this.entryDAO = entryDAO;
        this.nextValidEntryNumber = -1;
    }

    public Entry findByEntryNumber(int entryNumber) {
        if (iterator == null || entryNumber != nextValidEntryNumber) {
            if (iterator != null) {
                iterator.close();
            }
            iterator = entryDAO.entriesIteratorFrom(entryNumber);
            nextValidEntryNumber = entryNumber;
        }
        nextValidEntryNumber++;
        return iterator.next();
    }
}

package uk.gov.register.db;

import org.skife.jdbi.v2.ResultIterator;
import uk.gov.register.core.Entry;

public class EntryIteratorDAO {

    private final EntryQueryDAO entryDAO;
    private int nextValidEntryNumber;
    private ResultIterator<Entry> iterator;

    public EntryIteratorDAO(EntryQueryDAO entryDAO) {
        this.entryDAO = entryDAO;
        this.nextValidEntryNumber = -1;
    }

    public Entry findByEntryNumber(int entryNumber) {
        if (iterator == null || !iterator.hasNext() || entryNumber != nextValidEntryNumber) {
            if (iterator != null) {
                iterator.close();
            }
            iterator = entryDAO.entriesIteratorFrom(entryNumber);
            nextValidEntryNumber = entryNumber;
        }
        nextValidEntryNumber++;
        return iterator.next();
    }
}

Check whether iterator is already closed


package com.phsshp.config;

import org.apache.commons.cli.*;

public class CommandLineParser {

    private final Options options;

    public CommandLineParser() {
        options = new Options();
    }

    public String parse(String args[]) {
        DefaultParser parser = new DefaultParser();

        try {
            CommandLine commandLine = parser.parse(options, args);
            if (commandLine.getArgList().size() == 0) {
                printHelpAndExit();
            }
            return commandLine.getArgList().get(0);
        } catch (ParseException e) {
            System.out.println("Could not parse: " + e.getMessage());
            printHelpAndExit();
            return null;
        }
    }

    private void printHelpAndExit() {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("java-code-metrics", "Code metrics for Java source code", options, "");
        System.exit(1);
    }
}

package com.phsshp.config;

import org.apache.commons.cli.*;

public class CommandLineParser {

    private final Options options;

    public CommandLineParser() {
        options = new Options();
        options.addOption("output", true, "Filename to save output (default is stdout)");
    }

    public String parse(String args[]) {
        DefaultParser parser = new DefaultParser();

        try {
            CommandLine commandLine = parser.parse(options, args);
            if (commandLine.getArgList().size() == 0) {
                printHelpAndExit();
            }
            return commandLine.getArgList().get(0);
        } catch (ParseException e) {
            System.out.println("Could not parse: " + e.getMessage());
            printHelpAndExit();
            return null;
        }
    }

    private void printHelpAndExit() {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("java-code-metrics  [OPTION]... [FILE]",
                "Code metrics for Java source code", options, "");
        System.exit(1);
    }
}

Add output option to list of allowed parameters


package com.apexmob.skink.listeners;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.apexmob.skink.EndElement;
import com.apexmob.skink.NodeListener;
import com.apexmob.skink.StartElement;
import com.apexmob.skink.Text;

public class DebugNodeListener implements NodeListener {

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

	public void onStartElement(StartElement start) {
		logger.debug(start.getContent());
	}

	public void onText(Text text) {
		logger.debug(text.getContent());
	}

	public void onEndElement(EndElement end) {
		logger.debug(end.getContent());
	}

}

package com.apexmob.skink.listeners;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.apexmob.skink.EndElement;
import com.apexmob.skink.StartElement;
import com.apexmob.skink.Text;

/**
 * The DebugNodeListener logs the contents of all events at the debug level.
 */
public class DebugNodeListener extends AbstractNodeListener {

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

	/**
	 * {@inheritDoc}
	 * Log the contents of the event at debug level.
	 */
	public void onStartElement(StartElement start) {
		logger.debug(start.getContent());
	}

	/**
	 * {@inheritDoc}
	 * Log the contents of the event at debug level.
	 */
	public void onText(Text text) {
		logger.debug(text.getContent());
	}

	/**
	 * {@inheritDoc}
	 * Log the contents of the event at debug level.
	 */
	public void onEndElement(EndElement end) {
		logger.debug(end.getContent());
	}

}

Add javadoc, Update to extend AbstractNodeListener


/*******************************************************************************
 * Copyright (c) 2013, 2014 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * 	Contributors:
 * 		 Red Hat Inc. - initial API and implementation and/or initial documentation
 *******************************************************************************/
package org.eclipse.thym.android.core.adt;

import java.util.Comparator;

public class AndroidAPILevelComparator implements Comparator<String>{

	@Override
	public int compare(String sdk1, String sdk2) {
		if(sdk1 == null && sdk2 == null ){
			throw new NullPointerException("comparator arguments can not be null");
		}
		char[] l1 = sdk1.toCharArray();
		char[] l2 = sdk2.toCharArray();
		for (int i = 0; i < Math.min(l1.length, l2.length); i++) {
			if(l1[i] > l2[i]){
				return 1;
			}
			if(l1[i] < l2[i]){
				return -1;
			}
		}
		if(l1.length > l2.length ){
			return 1;
		}
		if(l1.length < l2.length ){
			return -1;
		}
		return 0;
	}

}

/*******************************************************************************
 * Copyright (c) 2013, 2014 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * 	Contributors:
 * 		 Red Hat Inc. - initial API and implementation and/or initial documentation
 *******************************************************************************/
package org.eclipse.thym.android.core.adt;

import java.util.Comparator;

public class AndroidAPILevelComparator implements Comparator<String>{

	@Override
	public int compare(String sdk1, String sdk2) {
		if(sdk1 == null || sdk2 == null ){
			throw new NullPointerException("comparator arguments can not be null");
		}
		char[] l1 = sdk1.toCharArray();
		char[] l2 = sdk2.toCharArray();
		for (int i = 0; i < Math.min(l1.length, l2.length); i++) {
			if(l1[i] > l2[i]){
				return 1;
			}
			if(l1[i] < l2[i]){
				return -1;
			}
		}
		if(l1.length > l2.length ){
			return 1;
		}
		if(l1.length < l2.length ){
			return -1;
		}
		return 0;
	}

}

Fix for a potential NPE


/*
 * Copyright (C)2015 D. Plaindoux.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.smallibs.suitcase.cases.genlex;

public class UnexpectedCharException extends Exception {
    public UnexpectedCharException(int index, char c) {
        sper("char <" + c + "> at position <" + index + ">");
    }
}

/*
 * Copyright (C)2015 D. Plaindoux.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.smallibs.suitcase.cases.genlex;

public class UnexpectedCharException extends Exception {
    public UnexpectedCharException(int index, char c) {
        super("char <" + c + "> at position <" + index + ">");
    }
}

Fix error / keyboard side effect because of problem between the chair and the keyboard


/***********************************************************************************************************************
 *
 *  *
 *  *   Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *  *
 *  *   WSO2 Inc. licenses this file to you under the Apache License,
 *  *   Version 2.0 (the "License"); you may not use this file except
 *  *   in compliance with the License.
 *  *   You may obtain a copy of the License at
 *  *
 *  *     http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *  Unless required by applicable law or agreed to in writing,
 *  *  software distributed under the License is distributed on an
 *  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  *  KIND, either express or implied.  See the License for the
 *  *  specific language governing permissions and limitations
 *  *  under the License.
 *  *
 *
 */

package org.wso2.carbon.apimgt.core.models;

/**
 * Status of an API can be anyone from following list.
 */
public enum APIStatus {

    CREATED("CREATED"), PUBLISHED("PUBLISHED"),
    DEPRECATED("DEPRECATED"), RETIRED("RETIRED"), MAINTENANCE("MAINTENANCE"), PROTOTYPED("PROTOTYPED");

    private String status;

    APIStatus(String status) {
        this.status = status;
    }

    public String getStatus() {
        return status;
    }
}

/***********************************************************************************************************************
 *
 *  *
 *  *   Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *  *
 *  *   WSO2 Inc. licenses this file to you under the Apache License,
 *  *   Version 2.0 (the "License"); you may not use this file except
 *  *   in compliance with the License.
 *  *   You may obtain a copy of the License at
 *  *
 *  *     http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *  Unless required by applicable law or agreed to in writing,
 *  *  software distributed under the License is distributed on an
 *  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  *  KIND, either express or implied.  See the License for the
 *  *  specific language governing permissions and limitations
 *  *  under the License.
 *  *
 *
 */

package org.wso2.carbon.apimgt.core.models;

/**
 * Status of an API can be anyone from following list.
 */
public enum APIStatus {

    CREATED("Created"), PUBLISHED("Published"),
    DEPRECATED("Deprecated"), RETIRED("Retired"), MAINTENANCE("Maintenance"), PROTOTYPED("Prototyped");
    private String status;

    APIStatus(String status) {
        this.status = status;
    }

    public String getStatus() {
        return status;
    }
}

Fix can not view apis in store


package tools.vitruv.testutils.domains;

import java.util.List;

import allElementTypes.AllElementTypesPackage;

public final class AllElementTypesDomain extends VitruvTestDomain {
	public static final String METAMODEL_NAME = "AllElementTypes";
	public static final String FILE_EXTENSION = "allElementTypes";

	AllElementTypesDomain() {
		super(METAMODEL_NAME, AllElementTypesPackage.eINSTANCE, List.of(AllElementTypesPackage.Literals.IDENTIFIED__ID),
				FILE_EXTENSION);
	}

}

package tools.vitruv.testutils.domains;

import java.util.List;

import allElementTypes.AllElementTypesPackage;

public final class AllElementTypesDomain extends VitruvTestDomain {
	public static final String METAMODEL_NAME = "AllElementTypes";
	public static final String FILE_EXTENSION = "allElementTypes";
	private boolean shouldTransitivelyPropagateChanges = false;

	AllElementTypesDomain() {
		super(METAMODEL_NAME, AllElementTypesPackage.eINSTANCE, List.of(AllElementTypesPackage.Literals.IDENTIFIED__ID),
				FILE_EXTENSION);
	}

	@Override
	public boolean shouldTransitivelyPropagateChanges() {
		return shouldTransitivelyPropagateChanges;
	}

	/**
	 * Calling this method enables the per default disabled transitive change
	 * propagation. Should only be called for test purposes!
	 */
	public void enableTransitiveChangePropagation() {
		shouldTransitivelyPropagateChanges = true;
	}

	/**
	 * Calling this method disables the transitive change propagation which may have
	 * been enabled calling {@link #enableTransitiveChangePropagation()}. Should
	 * only be called for test purposes!
	 */
	public void disableTransitiveChangePropagation() {
		shouldTransitivelyPropagateChanges = false;
	}

}

Allow enabling transitive change propagation in test metamodel domain


// Copyright 2014, Kevin Ko <kevin@faveset.com>

package com.faveset.khttpserver;

import java.io.IOException;
import sun.misc.Signal;
import sun.misc.SignalHandler;

import com.faveset.log.OutputStreamLog;

public class HttpServer {
    public static void main(String[] args) throws IOException {
        if (args.length < 1) {
            System.out.println("<port>");
            return;
        }

        int port = new Integer(args[0]);

        OutputStreamLog log = new OutputStreamLog(System.out);

        final com.faveset.khttp.HttpServer server = new com.faveset.khttp.HttpServer();
        server.setLog(log);

        // Set up the signal handler.
        Signal.handle(new Signal("INT"), new SignalHandler() {
            @Override
            public void handle(Signal sig) {
                server.stop();
            }
        });
        server.listenAndServe("::", port);

        log.close();
    }
}

// Copyright 2014, Kevin Ko <kevin@faveset.com>

package com.faveset.khttpserver;

import java.io.IOException;
import sun.misc.Signal;
import sun.misc.SignalHandler;

import com.faveset.khttp.HttpHandler;
import com.faveset.khttp.HttpRequest;
import com.faveset.khttp.HttpResponseWriter;

import com.faveset.log.OutputStreamLog;

public class HttpServer {
    public static void main(String[] args) throws IOException {
        if (args.length < 1) {
            System.out.println("<port>");
            return;
        }

        int port = new Integer(args[0]);

        OutputStreamLog log = new OutputStreamLog(System.out);

        final com.faveset.khttp.HttpServer server = new com.faveset.khttp.HttpServer();
        server.setLog(log);

        // Set up the signal handler for exiting the server.
        Signal.handle(new Signal("INT"), new SignalHandler() {
            @Override
            public void handle(Signal sig) {
                server.stop();
            }
        });

        // Register handlers.

        server.registerHandler("/", new HttpHandler() {
            public void onRequest(HttpRequest req, HttpResponseWriter w) {
                w.getHeadersBuilder().set("Content-Type", "text/html");
                w.write("Hello");
            }
        });
        server.listenAndServe("::", port);

        log.close();
    }
}

Add simple handler for demonstrating usage.


package io.cine.android;

import android.util.Log;

/**
 * Created by thomas on 1/16/15.
 */
public class BroadcastConfig {
    private int width;
    private int height;
    private String requestedCamera;
    private String lockedOrientation;

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public String getLockedOrientation() {
        return lockedOrientation;
    }

    public void lockOrientation(String lockedOrientation) {
        if(lockedOrientation.equals("landscape") || lockedOrientation.equals("portrait") || lockedOrientation == null){
            this.lockedOrientation = lockedOrientation;
        } else {
            throw new RuntimeException("Orientation must be \"landscape\" or \"portrait\"");
        }
    }

    public String getRequestedCamera() {
        return requestedCamera;
    }

    public void selectCamera(String camera) {
        if(camera.equals("back") || camera.equals("front") || camera == null){
            this.requestedCamera = camera;
        } else {
            throw new RuntimeException("Camera must be \"front\" or \"back\"");
        }
    }
}

package io.cine.android;

import android.util.Log;

/**
 * Created by thomas on 1/16/15.
 */
public class BroadcastConfig {
    private Integer width;
    private Integer height;
    private String requestedCamera;
    private String lockedOrientation;

    public int getWidth() {
        if (width == null){
            return -1;
        }else{
            return width;
        }
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        if (height == null){
            return -1;
        }else{
            return height;
        }
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public String getLockedOrientation() {
        return lockedOrientation;
    }

    public void lockOrientation(String lockedOrientation) {
        if(lockedOrientation.equals("landscape") || lockedOrientation.equals("portrait") || lockedOrientation == null){
            this.lockedOrientation = lockedOrientation;
        } else {
            throw new RuntimeException("Orientation must be \"landscape\" or \"portrait\"");
        }
    }

    public String getRequestedCamera() {
        return requestedCamera;
    }

    public void selectCamera(String camera) {
        if(camera.equals("back") || camera.equals("front") || camera == null){
            this.requestedCamera = camera;
        } else {
            throw new RuntimeException("Camera must be \"front\" or \"back\"");
        }
    }
}

Set BroadCastConfig width and height to Integers, and check for null values; return -1 if null. This allows us to avoid the problem of ints defaulting to 0 which messes up the default settings for screen width/height


package anaware.leakcanarysample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.squareup.leakcanary.RefWatcher;

public class AnotherActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_another);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        RefWatcher refWatcher = MyApplication.getRefWatcher(this);
        refWatcher.watch(this);
    }
}

package anaware.leakcanarysample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.squareup.leakcanary.RefWatcher;

public class AnotherActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_another);

        // Invoke the GC to accelerate the analysis.
        System.gc();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        RefWatcher refWatcher = MyApplication.getRefWatcher(this);
        refWatcher.watch(this);
    }
}

Call GC to accelerate the analysis


package org.wisdom.content.bodyparsers;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Provides;
import org.wisdom.api.content.BodyParser;
import org.wisdom.api.http.Context;
import org.wisdom.api.http.MimeTypes;
import org.wisdom.content.json.Json;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

@Component
@Provides
@Instantiate
public class BodyParserJson implements BodyParser {

    private final Logger logger = LoggerFactory.getLogger(BodyParserJson.class);

    public <T> T invoke(Context context, Class<T> classOfT) {
        T t = null;
        try {
            t = Json.mapper().readValue(context.getReader(), classOfT);
        } catch (IOException e) {
            logger.error("Error parsing incoming Json", e);
        }

        return t;
    }

    @Override
    public <T> T invoke(byte[] bytes, Class<T> classOfT) {
        T t = null;
        try {
            t = Json.mapper().readValue(bytes, classOfT);
        } catch (IOException e) {
            logger.error("Error parsing incoming Json", e);
        }

        return t;
    }

    public String getContentType() {
        return MimeTypes.JSON;
    }

}

package org.wisdom.content.bodyparsers;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wisdom.api.content.BodyParser;
import org.wisdom.api.http.Context;
import org.wisdom.api.http.MimeTypes;
import org.wisdom.content.json.Json;

import java.io.IOException;

@Component
@Provides
@Instantiate
public class BodyParserJson implements BodyParser {

    private final Logger logger = LoggerFactory.getLogger(BodyParserJson.class);

    public <T> T invoke(Context context, Class<T> classOfT) {
        T t = null;
        try {
            final String content = context.body();
            if (content == null  || content.length() == 0) {
                return null;
            }
            t = Json.mapper().readValue(content, classOfT);
        } catch (IOException e) {
            logger.error("Error parsing incoming Json", e);
        }

        return t;
    }

    @Override
    public <T> T invoke(byte[] bytes, Class<T> classOfT) {
        T t = null;
        try {
            t = Json.mapper().readValue(bytes, classOfT);
        } catch (IOException e) {
            logger.error("Error parsing incoming Json", e);
        }

        return t;
    }

    public String getContentType() {
        return MimeTypes.JSON;
    }

}

Check for null and empty body before trying to map a json string to an object.


package org.verapdf.model.impl.pb.cos;

import org.apache.log4j.Logger;
import org.apache.pdfbox.cos.COSString;
import org.verapdf.model.coslayer.CosString;

/**
 * Created by Evgeniy Muravitskiy on 4/28/15.
 * <p>
 *     Current class is representation of CosString interface of abstract model.
 *     This class is analogue of COSString in pdfbox.
 * </p>
 */
public class PBCosString extends PBCosObject implements CosString {

    public PBCosString(COSString value) {
        super(value);
        setType("CosString");
    }

    /** Get Unicode string value stored in the PDF object
     */
    @Override
    public String getvalue() {
        return ((COSString) baseObject).getString();
    }

    /** true if the string is stored in Hex format
     */
    @Override
    public Boolean getisHex() {
        return ((COSString) baseObject).isHex() != null;
    }

    /** Get original string value of the string before applying Hex decoding
     *  and any encodings (but after ignoring all white spaces)
     */
    @Override
    public String getorigValue() {
        return new String(((COSString) baseObject).getBytes());
    }
}

package org.verapdf.model.impl.pb.cos;

import org.apache.log4j.Logger;
import org.apache.pdfbox.cos.COSString;
import org.verapdf.model.coslayer.CosString;

/**
 * Created by Evgeniy Muravitskiy on 4/28/15.
 * <p>
 *     Current class is representation of CosString interface of abstract model.
 *     This class is analogue of COSString in pdfbox.
 * </p>
 */
public class PBCosString extends PBCosObject implements CosString {

    public PBCosString(COSString value) {
        super(value);
        setType("CosString");
    }

    /** Get Unicode string value stored in the PDF object
     */
    @Override
    public String getvalue() {
        return ((COSString) baseObject).getString();
    }

    /** true if the string is stored in Hex format
     */
    @Override
    public Boolean getisHex() {
        return ((COSString) baseObject).isHex() != null;
    }

    /** true if all symbols below range 0-9,a-f,A-F
     */
    public Boolean getisHexSymbols() {
        for (byte symbol : ((COSString) baseObject).getBytes()) {
            if (Character.digit(symbol, 16) == -1) {
                return false;
            }
        }
        return true;
    }

    /** Get original string value of the string before applying Hex decoding
     *  and any encodings (but after ignoring all white spaces)
     */
    @Override
    public String getorigValue() {
        return new String(((COSString) baseObject).getBytes());
    }
}

Add support of hexadecimal string for CosString


package org.apache.maven.plugin.version;

/*
 * Copyright 2001-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Settings;
import org.apache.maven.execution.MavenSession;

public interface PluginVersionManager
{
    String ROLE = PluginVersionManager.class.getName();

    String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;

    String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;

}

package org.apache.maven.plugin.version;

/*
 * Copyright 2001-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.project.MavenProject;

public interface PluginVersionManager
{
    String ROLE = PluginVersionManager.class.getName();

    String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;

    String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;

}

Remove unused and unavailable imports


/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package java.util;

public interface Map {

	interface Entry {
		Object getKey();
		Object getValue();
		Object setValue(Object value);
		boolean equals(Object o);
		int hashCode();
	}

	int size();
	boolean isEmpty();
	boolean containsKey(Object o);
	boolean containsValue(Object o);
	Object get(Object key);
	Object put(Object key, Object value);
	void putAll(Map m);
	void clear();
	Set keySet();
	Set entrySet();
	Collection values();
	boolean equals(Object o);
	int hashCode();
	Object remove(Object o);

}

/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package java.util;

public interface Map {

	public interface Entry {
		Object getKey();
		Object getValue();
		Object setValue(Object value);
		boolean equals(Object o);
		int hashCode();
	}

	int size();
	boolean isEmpty();
	boolean containsKey(Object o);
	boolean containsValue(Object o);
	Object get(Object key);
	Object put(Object key, Object value);
	void putAll(Map m);
	void clear();
	Set keySet();
	Set entrySet();
	Collection values();
	boolean equals(Object o);
	int hashCode();
	Object remove(Object o);

}

Make nested interface 'Entry' public again, or else the nightly build seems to break. Not sure if this is a compiler bug or not.


package com.slicingdice.jslicer.exceptions.api.index;

import com.slicingdice.jslicer.exceptions.api.SlicingDiceException;

public class IndexInvalidRangeException extends SlicingDiceException {
    public IndexInvalidRangeException(String message) {
        super(message);
    }
}

package com.slicingdice.jslicer.exceptions.api.index;

import com.slicingdice.jslicer.exceptions.api.SlicingDiceException;

public class IndexInvalidRangeException extends SlicingDiceException {
    public IndexInvalidRangeException(final String message) {
        super(message);
    }
}

Make changes according to review


package com.neoranga55.cleanguitestarchitecture.test;

import cucumber.api.CucumberOptions;

/**
 * This class configures the Cucumber test framework and Java glue code
 */
@CucumberOptions(features = "features", // Test scenarios
        glue = {"com.neoranga55.cleanguitestarchitecture.cucumber.steps"}, // Steps definitions
        format = {"pretty", // Cucumber report formats and location to store them in phone
                "html:/mnt/sdcard/cucumber-reports/report.html",
                "json:/mnt/sdcard/cucumber-reports/cucumber.json",
                "junit:/mnt/sdcard/cucumber-reports/cucumber.xml"
        },
        tags={"~@manual", "@login-scenarios"}
)
public class CucumberTestCase {
}

package com.neoranga55.cleanguitestarchitecture.test;

import cucumber.api.CucumberOptions;

/**
 * This class configures the Cucumber test framework and Java glue code
 */
@CucumberOptions(features = "features", // Test scenarios
        glue = {"com.neoranga55.cleanguitestarchitecture.cucumber.steps"}, // Steps definitions
        format = {"pretty", // Cucumber report formats and location to store them in phone
                "html:/mnt/sdcard/cucumber-reports/html-report",
                "json:/mnt/sdcard/cucumber-reports/cucumber.json",
                "junit:/mnt/sdcard/cucumber-reports/cucumber.xml"
        },
        tags={"~@manual", "@login-scenarios"}
)
public class CucumberTestCase {
}

Fix cucumber test results location on device


package com.braintreepayments.popupbridge.example;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

import com.braintreepayments.popupbridge.PopupBridge;

public class MainActivity extends Activity {

    private static final String URL = "https://braintree.github.io/popup-bridge-example/";

    private WebView mWebView;
    private PopupBridge mPopupBridge;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mWebView = (WebView) findViewById(R.id.web_view);
        mWebView.getSettings().setJavaScriptEnabled(true);

        mPopupBridge = PopupBridge.newInstance(this, mWebView);

        mWebView.loadUrl(URL);
    }
}

package com.braintreepayments.popupbridge.example;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

import com.braintreepayments.popupbridge.PopupBridge;

public class MainActivity extends Activity {

    private static final String URL = "https://braintree.github.io/popup-bridge-example/";

    private WebView mWebView;
    private PopupBridge mPopupBridge;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mWebView = (WebView) findViewById(R.id.web_view);

        mPopupBridge = PopupBridge.newInstance(this, mWebView);

        mWebView.loadUrl(URL);
    }
}

Remove unneeded code in example app


package org.vaadin.elements;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.vaadin.elements.impl.RootImpl;

import com.vaadin.ui.Label;

import elemental.json.JsonArray;

public class RootTest {

    private RootImpl root;
    private Element child;

    @Before
    public void init() {
        child = Elements.create("div");
        root = (RootImpl) ElementIntegration.getRoot(new Label());
    }

    @Test
    public void testAppendChild() {
        root.appendChild(child);

        JsonArray pendingCommands = root.flushPendingCommands();

        Assert.assertEquals(
                "[[\"createElement\",3,\"div\"],[\"appendChild\",0,3]]",
                pendingCommands.toJson());
    }

    @Test
    public void testRemoveChild() {
        root.appendChild(child);
        root.flushPendingCommands();

        child.remove();

        JsonArray pendingCommands = root.flushPendingCommands();

        Assert.assertEquals("[[\"remove\",3]]", pendingCommands.toJson());
    }

}

package org.vaadin.elements;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.vaadin.elements.impl.RootImpl;

import com.vaadin.ui.Label;

import elemental.json.JsonArray;

public class RootTest {

    private RootImpl root;
    private Element child;

    @Before
    public void init() {
        child = Elements.create("div");
        root = (RootImpl) ElementIntegration.getRoot(new Label());
    }

    @Test
    public void testAppendChild() {
        root.appendChild(child);

        JsonArray pendingCommands = root.flushPendingCommands();

        Assert.assertEquals(
                "[[\"createElement\",2,\"div\"],[\"appendChild\",0,2]]",
                pendingCommands.toJson());
    }

    @Test
    public void testRemoveChild() {
        root.appendChild(child);
        root.flushPendingCommands();

        child.remove();

        JsonArray pendingCommands = root.flushPendingCommands();

        Assert.assertEquals("[[\"remove\",2]]", pendingCommands.toJson());
    }

}

Update test for changed indexing


package com.smartdevicelink.managers.file;

import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.managers.file.filetypes.SdlFile;
import com.smartdevicelink.proxy.rpc.enums.StaticIconName;
import com.smartdevicelink.test.Test;

public class SdlArtworkTests extends AndroidTestCase2 {

    public void testClone(){
        SdlArtwork original = Test.GENERAL_ARTWORK;
        SdlArtwork clone = original.clone();

        assertNotNull(clone);
        assertNotSame(original,clone);

        assertEquals(original.getResourceId(), clone.getResourceId());

        assertEquals(original.getFileData(), clone.getFileData());

        assertNotNull(original.getImageRPC());
        assertNotNull(clone.getImageRPC());

        assertNotSame(original.getImageRPC(),clone.getImageRPC());
        assertEquals(original.getImageRPC().getIsTemplate(), clone.getImageRPC().getIsTemplate());
        assertEquals(original.getImageRPC().getValue(), clone.getImageRPC().getValue());
        assertEquals(original.getImageRPC().getImageType(), clone.getImageRPC().getImageType());

        SdlArtwork artwork = new SdlArtwork(StaticIconName.ALBUM);
        assertNotNull(artwork);

        SdlArtwork staticIconClone = artwork.clone();
        assertNotNull(staticIconClone);

        assertTrue(clone instanceof Cloneable);
        assertTrue(artwork instanceof Cloneable);

    }
}

package com.smartdevicelink.managers.file;

import com.smartdevicelink.AndroidTestCase2;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.managers.file.filetypes.SdlFile;
import com.smartdevicelink.proxy.rpc.enums.StaticIconName;
import com.smartdevicelink.test.Test;

public class SdlArtworkTests extends AndroidTestCase2 {

    public void testClone(){
        SdlArtwork original = Test.GENERAL_ARTWORK;
        SdlArtwork clone = original.clone();

        equalTest(original, clone);

        SdlArtwork artwork = new SdlArtwork(StaticIconName.ALBUM);
        assertNotNull(artwork);

        SdlArtwork staticIconClone = artwork.clone();
        assertNotNull(staticIconClone);

        assertTrue(clone instanceof Cloneable);
        assertTrue(artwork instanceof Cloneable);

    }

    public static boolean equalTest(SdlArtwork original, SdlArtwork clone){

        assertNotNull(original);
        assertNotNull(clone);
        assertNotSame(original,clone);

        assertEquals(original.getResourceId(), clone.getResourceId());

        assertEquals(original.getFileData(), clone.getFileData());

        assertNotNull(original.getImageRPC());
        assertNotNull(clone.getImageRPC());

        assertNotSame(original.getImageRPC(),clone.getImageRPC());
        assertEquals(original.getImageRPC().getIsTemplate(), clone.getImageRPC().getIsTemplate());
        assertEquals(original.getImageRPC().getValue(), clone.getImageRPC().getValue());
        assertEquals(original.getImageRPC().getImageType(), clone.getImageRPC().getImageType());

        return true;
    }
}

Update SdlArtwork test to have reusable equalTest


/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.security.option;

import com.opengamma.financial.Currency;
import com.opengamma.id.Identifier;
import com.opengamma.id.UniqueIdentifier;
import com.opengamma.util.time.Expiry;

/**
 * An American equity option security.
 */
public class AmericanVanillaEquityOptionSecurity extends EquityOptionSecurity implements AmericanVanillaOption {

  /**
   * Creates the security.
   * @param optionType
   * @param strike
   * @param expiry
   * @param underlyingIdentifier
   * @param currency
   * @param exchange
   */
  public AmericanVanillaEquityOptionSecurity(final OptionType optionType, final double strike, final Expiry expiry, final Identifier underlyingIdentifier,
      final Currency currency, final double pointValue, final String exchange) {
    super(optionType, strike, expiry, underlyingIdentifier, currency, pointValue, exchange);
  }

  //-------------------------------------------------------------------------
  @Override
  public <T> T accept(final OptionVisitor<T> visitor) {
    return visitor.visitAmericanVanillaOption(this);
  }

  @Override
  public <T> T accept(final EquityOptionSecurityVisitor<T> visitor) {
    return visitor.visitAmericanVanillaEquityOptionSecurity(this);
  }

}

/**
 * Copyright (C) 2009 - 2010 by OpenGamma Inc.
 *
 * Please see distribution for license.
 */
package com.opengamma.financial.security.option;

import com.opengamma.financial.Currency;
import com.opengamma.id.Identifier;
import com.opengamma.util.time.Expiry;

/**
 * An American equity option security.
 */
public class AmericanVanillaEquityOptionSecurity extends EquityOptionSecurity implements AmericanVanillaOption {

  /**
   * Creates the security.
   * @param optionType the type of option CALL or PUT
   * @param strike the strike price
   * @param expiry the expire date
   * @param underlyingIdentifier Identifier for underlying equity
   * @param currency currency in which it trades
   * @param pointValue the option point value
   * @param exchange exchange where the option trades
   */
  public AmericanVanillaEquityOptionSecurity(final OptionType optionType, final double strike, final Expiry expiry, final Identifier underlyingIdentifier,
      final Currency currency, final double pointValue, final String exchange) {
    super(optionType, strike, expiry, underlyingIdentifier, currency, pointValue, exchange);
  }

  //-------------------------------------------------------------------------
  @Override
  public <T> T accept(final OptionVisitor<T> visitor) {
    return visitor.visitAmericanVanillaOption(this);
  }

  @Override
  public <T> T accept(final EquityOptionSecurityVisitor<T> visitor) {
    return visitor.visitAmericanVanillaEquityOptionSecurity(this);
  }

}

Make code conform to Checkstyle standards


package org.jenkinsci.plugins.github.pullrequest;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.TransientProjectActionFactory;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Kanstantsin Shautsou
 */
@Extension
public class GitHubPRRepositoryFactory extends TransientProjectActionFactory {
    private final static Logger LOGGER = Logger.getLogger(GitHubPRRepositoryFactory.class.getName());

    @Override
    public Collection<? extends Action> createFor(AbstractProject project) {
        if (project.getTrigger(GitHubPRTrigger.class) != null) {
            return Collections.singleton(GitHubPRRepository.forProject(project));
        }

        return Collections.emptyList();
    }

}

package org.jenkinsci.plugins.github.pullrequest;

import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.TransientProjectActionFactory;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Kanstantsin Shautsou
 */
@Extension
public class GitHubPRRepositoryFactory extends TransientProjectActionFactory {
    private final static Logger LOGGER = Logger.getLogger(GitHubPRRepositoryFactory.class.getName());

    @Override
    public Collection<? extends Action> createFor(AbstractProject project) {
        try {
            if (project.getTrigger(GitHubPRTrigger.class) != null) {
                return Collections.singleton(GitHubPRRepository.forProject(project));
            }
        } catch (Throwable t) {
            // bad configured project i.e. github project property wrong
            return Collections.emptyList();
        }

        return Collections.emptyList();
    }

}

Allow save job that had no GH project property before.


/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms.util;

import jssc.SerialPortEvent;

/**
 * This class is used to configure and manage the serial port for receiving EKG channel data.
 *
 * @since December 12, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
public class EKGSerialPort extends AbstractSerialPort {

    public EKGSerialPort() {
        super("src/main/resources/util/EKGSerialPort.properties");
    }

    @Override
    public void serialEvent(SerialPortEvent serialPortEvent) {
        // TODO
    }

}

/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms.util;

import jssc.SerialPortEvent;

/**
 * This class is used to configure and manage the serial port for receiving EKG channel data.
 *
 * @since December 12, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
public class EKGSerialPort extends AbstractSerialPort {

    public EKGSerialPort() {
        super("util/EKGSerialPort.properties");
    }

    @Override
    public void serialEvent(SerialPortEvent serialPortEvent) {
        // TODO
    }

}

Correct filename argument in constructor


package interactivelearner.gui;

import interactivelearner.classifier.NaiveBayesianClassifier;
import interactivelearner.data.Corpus;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

import java.io.File;

public class NaiveBayesGUI extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/TrainGUI.fxml"));
        Parent train = loader.load();
        TrainController controller = loader.getController();
        controller.getStage(primaryStage);
        primaryStage.setTitle("Naive bayesian classifier");
        Scene trainScene = new Scene(train, 600, 400);
        primaryStage.setScene(trainScene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

package interactivelearner.gui;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class NaiveBayesGUI extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/gui/TrainGUI.fxml"));
        Parent train = loader.load();
        TrainController controller = loader.getController();
        controller.getStage(primaryStage);
        primaryStage.setTitle("Naive bayesian classifier");
        Scene trainScene = new Scene(train, 600, 400);
        primaryStage.setScene(trainScene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Remove unused imports in GUI class


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.extractor;

/**
 * Composite text extractor that by default contains the standard
 * text extractors found in this package.
 */
public class DefaultTextExtractor extends CompositeTextExtractor {

    /**
     * Creates the default text extractor by adding instances of the standard
     * text extractors as components.
     */
    public DefaultTextExtractor() {
        addTextExtractor(new PlainTextExtractor());
        addTextExtractor(new XMLTextExtractor());
    }

}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.extractor;

/**
 * Composite text extractor that by default contains the standard
 * text extractors found in this package.
 *
 * @deprecated Use {@link TikaTextExtractor} instead
 */
public class DefaultTextExtractor extends TikaTextExtractor {
}

Use Apache Tika for text extraction


package seedu.todo.guitests;

import static org.junit.Assert.*;

import org.junit.Test;

import seedu.todo.guitests.guihandles.AliasItemHandle;

// @@author A0139812A
public class AliasCommandTest extends GuiTest {

    @Test
    public void alias_view_success() {
        console.runCommand("alias");
        assertTrue(aliasView.hasLoaded());
    }

    @Test
    public void alias_toList_success() {
        console.runCommand("alias list ls");
        System.out.println("hello");
        assertAliasItemVisible("list", "ls");
    }

    /**
     * Helper function to assert that AliasItem is visible.
     */
    private void assertAliasItemVisible(String aliasKey, String aliasValue) {
        // Make sure we can see the Alias View.
        assertTrue(aliasView.hasLoaded());

        // Gets the matching AliasItem. Since it matches, if it's not null -> it definitely exists.
        AliasItemHandle aliasItem = aliasView.getAliasItem(aliasKey, aliasValue);
        assertNotNull(aliasItem);
    }

}

package seedu.todo.guitests;

import static org.junit.Assert.*;

import org.junit.Test;

import seedu.todo.guitests.guihandles.AliasItemHandle;
import seedu.todo.models.Task;

// @@author A0139812A
public class AliasCommandTest extends GuiTest {

    @Test
    public void alias_view_success() {
        console.runCommand("alias");
        assertTrue(aliasView.hasLoaded());
    }

    @Test
    public void alias_toList_success() {
        console.runCommand("alias list ls");
        assertAliasItemVisible("list", "ls");

        console.runCommand("add Buy milk");
        Task testTask = new Task();
        testTask.setName("Buy milk");
        assertTaskVisibleAfterCmd("ls", testTask);
    }

    /**
     * Helper function to assert that AliasItem is visible.
     */
    private void assertAliasItemVisible(String aliasKey, String aliasValue) {
        // Make sure we can see the Alias View.
        assertTrue(aliasView.hasLoaded());

        // Gets the matching AliasItem. Since it matches, if it's not null -> it definitely exists.
        AliasItemHandle aliasItem = aliasView.getAliasItem(aliasKey, aliasValue);
        assertNotNull(aliasItem);
    }

}

Complete alias list test case


package org.realityforge.arez.processor;

import javax.annotation.Nonnull;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import org.realityforge.arez.annotations.Container;

final class ContainerDescriptorParser
{
  private ContainerDescriptorParser()
  {
  }

  static ContainerDescriptor parse( @Nonnull final Element element,
                                    @Nonnull final Elements elementUtils,
                                    @Nonnull final Types typeUtils )
    throws ArezProcessorException
  {
    final PackageElement packageElement = elementUtils.getPackageOf( element );
    final TypeElement typeElement = (TypeElement) element;
    if ( !element.getKind().isClass() )
    {
      throw new ArezProcessorException( "@Container target must be a class", element );
    }
    else if ( element.getModifiers().contains( Modifier.ABSTRACT ) )
    {
      throw new ArezProcessorException( "@Container target must not be abstract", element );
    }
    else if ( element.getModifiers().contains( Modifier.FINAL ) )
    {
      throw new ArezProcessorException( "@Container target must not be final", element );
    }
    final Container container = typeElement.getAnnotation( Container.class );
    final String name =
      container.name().equals( "<default>" ) ? typeElement.getSimpleName().toString() : container.name();

    return new ContainerDescriptor( name, container.singleton(), packageElement, typeElement );
  }
}

package org.realityforge.arez.processor;

import javax.annotation.Nonnull;
import javax.lang.model.element.Element;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import org.realityforge.arez.annotations.Container;

final class ContainerDescriptorParser
{
  private ContainerDescriptorParser()
  {
  }

  static ContainerDescriptor parse( @Nonnull final Element element,
                                    @Nonnull final Elements elementUtils,
                                    @Nonnull final Types typeUtils )
    throws ArezProcessorException
  {
    final PackageElement packageElement = elementUtils.getPackageOf( element );
    final TypeElement typeElement = (TypeElement) element;
    if ( !element.getKind().isClass() )
    {
      throw new ArezProcessorException( "@Container target must be a class", element );
    }
    else if ( element.getModifiers().contains( Modifier.ABSTRACT ) )
    {
      throw new ArezProcessorException( "@Container target must not be abstract", element );
    }
    else if ( element.getModifiers().contains( Modifier.FINAL ) )
    {
      throw new ArezProcessorException( "@Container target must not be final", element );
    }
    final Container container = typeElement.getAnnotation( Container.class );
    final String name =
      container.name().equals( "<default>" ) ? typeElement.getSimpleName().toString() : container.name();

    final ContainerDescriptor descriptor =
      new ContainerDescriptor( name, container.singleton(), packageElement, typeElement );
    return descriptor;
  }
}

Save descriptor into field so can start parsing other elkements


/*
 * Copyright 2016 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package stroom.data.client.presenter;

public final class ColumnSizeConstants {

    public static final int CHECKBOX_COL = 16;
    public static final int ICON_COL = 23;
    public static final int SMALL_COL = 70;
    public static final int MEDIUM_COL = 100;
    public static final int BIG_COL = 400;
    public static final int DATE_COL = 160;

    private ColumnSizeConstants() {
        // Constants.
    }
}

/*
 * Copyright 2016 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package stroom.data.client.presenter;

public final class ColumnSizeConstants {

    public static final int CHECKBOX_COL = 16;
    public static final int ICON_COL = 23;
    public static final int SMALL_COL = 70;
    public static final int MEDIUM_COL = 100;
    public static final int BIG_COL = 400;
    public static final int DATE_COL = 200;

    private ColumnSizeConstants() {
        // Constants.
    }
}

Increase `Created` column width to accommodate timezone ID


package info.elexis.server.core.rest.test.swagger;

import static info.elexis.server.core.rest.test.AllTests.REST_URL;
import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.net.HttpURLConnection;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import info.elexis.server.core.rest.test.AllTests;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class SwaggerTest {

	private OkHttpClient client = AllTests.getDefaultOkHttpClient();
	private Response response;

	Gson gson = new Gson();

	@Test
	public void testGetSwaggerConfiguration() throws IOException {
		Request request = new Request.Builder().url(REST_URL + "/swagger.json").get().build();
		response = client.newCall(request).execute();
		assertEquals(HttpURLConnection.HTTP_OK, response.code());

		String swaggerJson = response.body().string();
		JsonElement jelem = gson.fromJson(swaggerJson, JsonElement.class);
		JsonObject swagger = jelem.getAsJsonObject();

		JsonObject securityDefinitions = swagger.getAsJsonObject("securityDefinitions");
		JsonObject esoAuth = securityDefinitions.get("esoauth").getAsJsonObject();
		assertEquals("oauth2", esoAuth.get("type").getAsString());
	}

}

package info.elexis.server.core.rest.test.swagger;

import static info.elexis.server.core.rest.test.AllTests.REST_URL;
import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.net.HttpURLConnection;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import info.elexis.server.core.rest.test.AllTests;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class SwaggerTest {

	private OkHttpClient client = AllTests.getDefaultOkHttpClient();
	private Response response;

	Gson gson = new Gson();

	@Test
	public void testGetSwaggerConfiguration() throws IOException {
		Request request = new Request.Builder().url(REST_URL + "/swagger.json").get().build();
		response = client.newCall(request).execute();
		assertEquals(HttpURLConnection.HTTP_OK, response.code());

		String swaggerJson = response.body().string();
		JsonElement jelem = gson.fromJson(swaggerJson, JsonElement.class);
//		JsonObject swagger = jelem.getAsJsonObject();

//		JsonObject securityDefinitions = swagger.getAsJsonObject("securityDefinitions");
//		JsonObject esoAuth = securityDefinitions.get("esoauth").getAsJsonObject();
//		assertEquals("oauth2", esoAuth.get("type").getAsString());
	}

}

Remove HTTPS support, fix swagger test


/**
 * @Company Facebook
 *
 * Given two strings, str and pattern, return true if the str has a valid mapping between the words in str and the characters in the pattern.
 * The str will be whitespace separated and the pattern will be depicted using characters.
 *
 * Problem Ex.
 *   Input: 'cat dog dog cat', 'abba'
 *   Output: true because cat = a and dog = b.
 *
 *   Input: 'cat dog dog foo', 'abba'
 *   Output: false because cat = a so foo cannot == a
 */
public boolean isValidPattern(String str, String pattern) { }

/**
 * @Company Facebook
 *
 * Given two strings, str and pattern, return true if the str has a valid mapping between the words in str and the characters in the pattern.
 * The str will be whitespace separated and the pattern will be depicted using characters.
 *
 * Problem Ex.
 *   Input: 'cat dog dog cat', 'abba'
 *   Output: true because cat = a and dog = b.
 *
 *   Input: 'cat dog dog foo', 'abba'
 *   Output: false because cat = a so foo cannot == a
 *
 * Note: use may assume the pattern string will only contain lowercase alphabet letters.
 */
public boolean wordPattern(String pattern, String str) {
  // map each letter to a string.
  String[] strs = str.split("\\s");
  // character -> string mapping
  String[] map = new String[26];
  HashSet<String> set = new HashSet<String>();

  // Must be equal in length.
  if (strs.length != pattern.length()) return false;

  for (int i = 0; i < strs.length; i ++) {
    String string = strs[i];
    char c = pattern.charAt(i);
    int index = c - 'a';

    // First occurence of the character.
    if (map[index] == null && !set.contains(string)) {
      map[index] = string;
      set.add(string);

    // Valid pattern match
    } else if (map[index] != null && map[index].equals(string)) {
      continue;
    } else {
      return false;
    }
  }

  return true;
}

Add bipartite pattern matching solution


package ru.nsu.ccfit.bogush.view;

import ru.nsu.ccfit.bogush.CarFactoryModel;

import javax.swing.*;

public class FactoryView extends JPanel {
	private JPanel mainPanel;
	private ControlPanel controlPanel;
	private InformationPanel infoPanel;
	private ButtonPanel buttonPanel;

	private CarFactoryModel model;

	public FactoryView(CarFactoryModel model) {
		this.model = model;
		JFrame frame = new JFrame("Car Factory");
		frame.setContentPane(mainPanel);
		frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		frame.setResizable(false);
		frame.setLocation(0, 0);
		frame.pack();
		frame.setVisible(true);
	}

	private void createUIComponents() {
		controlPanel = new ControlPanel(model);
		infoPanel = new InformationPanel(model);
		buttonPanel = new ButtonPanel(model);
	}
}

package ru.nsu.ccfit.bogush.view;

import ru.nsu.ccfit.bogush.CarFactoryModel;
import ru.nsu.ccfit.bogush.factory.Supplier;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class FactoryView extends JPanel {
	private JPanel mainPanel;
	private ControlPanel controlPanel;
	private InformationPanel infoPanel;
	private ButtonPanel buttonPanel;

	private CarFactoryModel model;

	public FactoryView(CarFactoryModel model) {
		this.model = model;
		JFrame frame = new JFrame("Car Factory");
		frame.setContentPane(mainPanel);
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent e) {
				model.getStore().stop();
				model.getEngineSupplier().getThread().interrupt();
				model.getBodySupplier().getThread().interrupt();
				for (Supplier s : model.getAccessorySuppliers()) {
					s.getThread().interrupt();
				}
				model.getCarFactory().getThreadPool().stop();
			}
		});
		frame.setResizable(false);
		frame.setLocation(0, 0);
		frame.pack();
		frame.setVisible(true);
	}

	private void createUIComponents() {
		controlPanel = new ControlPanel(model);
		infoPanel = new InformationPanel(model);
		buttonPanel = new ButtonPanel(model);
	}
}

Change default close operation of main window to "dispose" Add windowClosed listener which interrupts all model threads


package org.yakindu.sct.generator.core;

import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.yakindu.sct.model.sgen.GeneratorEntry;

import com.google.inject.Inject;
import com.google.inject.Injector;

/**
 *  @author oliver bohl
 *
 */

public abstract class AbstractSGenGenerator implements ISCTGenerator {

	@Inject protected IWorkspaceRoot root;
	@Inject protected JavaIoFileSystemAccess fsa;
	@Inject protected Injector injector;

	protected abstract void generateContent(GeneratorEntry entry,
			JavaIoFileSystemAccess fsa, String targetProjectPath);

	public void generate(GeneratorEntry entry) {
		// Does actually nothing
		// generateInternal(entry);
	}

//	private void generateInternal(GeneratorEntry entry) {
//
//
//		 String targetProject = GeneratorUtils.getTargetProject(entry).toString();
//		 targetProject = targetProject.substring(1);
//
//		 IProject targetProjectRoot = root.getProject(targetProject);
//
//		 if(targetProjectRoot.exists() && targetProjectRoot.isOpen()){
//		 String targetFolder =
//		 GeneratorUtils.getTargetFolder(entry).toString();
//		 fsa.setOutputPath(IFileSystemAccess.DEFAULT_OUTPUT, targetFolder);
//
//		 String targetProjectPath = targetProject.replaceAll("\\.", "/");
//		 generateContent(entry, fsa, targetProjectPath);
//		 }
//	}

}

Create abstract SGenGenerator for SCTUnit -added generated Code


package de.gurkenlabs.litiengine.environment.tilemap.xml;

import org.junit.Test;

import junit.framework.Assert;

public class CustomPropertyProviderTests {

  @Test
  public void testSetCustomProperty() {
    CustomPropertyProvider propProvider = new CustomPropertyProvider();
    propProvider.setCustomProperty("test", "testvalue");

    Assert.assertEquals("testvalue", propProvider.getCustomProperty("test"));
    Assert.assertNull(propProvider.getCustomProperty("test2"));
    Assert.assertEquals(1, propProvider.getAllCustomProperties().size());

    propProvider.setCustomProperty("test", "testvalue2");

    Assert.assertEquals("testvalue2", propProvider.getCustomProperty("test"));
  }
}

package de.gurkenlabs.litiengine.environment.tilemap.xml;

import java.util.ArrayList;

import org.junit.Test;

import junit.framework.Assert;

public class CustomPropertyProviderTests {

  @Test
  public void testSetCustomProperty() {
    CustomPropertyProvider propProvider = new CustomPropertyProvider();
    propProvider.setCustomProperty("test", "testvalue");

    Assert.assertEquals("testvalue", propProvider.getCustomProperty("test"));
    Assert.assertNull(propProvider.getCustomProperty("test2"));
    Assert.assertEquals(1, propProvider.getAllCustomProperties().size());

    propProvider.setCustomProperty("test", "testvalue2");

    Assert.assertEquals("testvalue2", propProvider.getCustomProperty("test"));

    ArrayList<Property> props = new ArrayList<>();
    props.add(new Property("test2", "testvalue3"));
    props.add(new Property("test3", "testvalue4"));

    propProvider.setCustomProperties(props);

    Assert.assertEquals(2, propProvider.getAllCustomProperties().size());
    Assert.assertEquals("testvalue3", propProvider.getCustomProperty("test2"));
    Assert.assertEquals("testvalue4", propProvider.getCustomProperty("test3"));
  }
}

Add additional test case for setting custom properties by a collection.


package eu.liveandgov.wp1.human_activity_recognition;

import eu.liveandgov.wp1.human_activity_recognition.containers.CountWindow;
import eu.liveandgov.wp1.human_activity_recognition.containers.TaggedWindow;
import eu.liveandgov.wp1.human_activity_recognition.helper.Persistor;
import eu.liveandgov.wp1.human_activity_recognition.producers.*;

/**
 * Created with IntelliJ IDEA.
 * User: cehlen
 * Date: 06/01/14
 * Time: 21:23
 * To change this template use File | Settings | File Templates.
 */
public class Main {

    public static void main(String args[]) {
        CSVReader csvReader = new CSVReader();

        WindowProducer windowProducer = new WindowProducer(5000, 4995);
        csvReader.setConsumer(windowProducer);

        QualityFilter qualityFilter = new QualityFilter(50.0, 1.0, "windowFreq.log");
        windowProducer.setConsumer(qualityFilter);

        Interpolator interpolator = new Interpolator(50.0);
        qualityFilter.setConsumer(interpolator);

        Persistor<CountWindow> p = new Persistor("out.csv");
        interpolator.setConsumer(p);

        csvReader.read("/Users/cehlen/TrainingData/WALKING/12");
    }

}

package eu.liveandgov.wp1.human_activity_recognition;

import eu.liveandgov.wp1.human_activity_recognition.containers.CountWindow;
import eu.liveandgov.wp1.human_activity_recognition.containers.TaggedWindow;
import eu.liveandgov.wp1.human_activity_recognition.helper.Persistor;
import eu.liveandgov.wp1.human_activity_recognition.producers.*;

/**
 * Created with IntelliJ IDEA.
 * User: cehlen
 * Date: 06/01/14
 * Time: 21:23
 * To change this template use File | Settings | File Templates.
 */
public class Main {

    public static void main(String args[]) {
        CSVReader csvReader = new CSVReader();

        WindowProducer windowProducer = new WindowProducer(1001, 995);
        csvReader.setConsumer(windowProducer);

        QualityFilter qualityFilter = new QualityFilter(50.0, 10, "windowFreq.log");
        windowProducer.setConsumer(qualityFilter);

        Interpolator interpolator = new Interpolator(50.0);
        qualityFilter.setConsumer(interpolator);

        PrintProducer<CountWindow> pp = new PrintProducer<CountWindow>("InterpolatedWindow");
        interpolator.setConsumer(pp);

        Persistor<CountWindow> pers = new Persistor<CountWindow>("out.csv");
        pp.setConsumer(pers);

        csvReader.read("Test/test.csv");
    }

}

Set main() to test data.


/*
 * Copyright 1999-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.fop.area;

/**
 * The normal-flow-reference-area class.
 * Each span-reference-area contains one or more of these objects
 * See fo:region-body definition in the XSL Rec for more information.
 */
public class NormalFlow extends BlockParent {
    /**
     * Constructor.
     * @param ipd of Normal flow object
     */
    public NormalFlow(int ipd) {
        addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
        setIPD(ipd);
    }
}

/*
 * Copyright 1999-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package org.apache.fop.area;

/**
 * The normal-flow-reference-area class.
 * Each span-reference-area contains one or more of these objects
 * See fo:region-body definition in the XSL Rec for more information.
 */
public class NormalFlow extends BlockParent {
    /**
     * Constructor.
     * @param ipd of Normal flow object
     */
    public NormalFlow(int ipd) {
        addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
        setIPD(ipd);
    }

    /** @see org.apache.fop.area.BlockParent#addBlock(org.apache.fop.area.Block) */
    public void addBlock(Block block) {
        super.addBlock(block);
        bpd += block.getAllocBPD();
    }
}

Accumulate the BPD extent used by the normal flow's children.


package constant;

/*
 * Copyright 2015 Taylor Caldwell
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public enum PlatformId {

		NA("NA1"),
		BR("BR1"),
		LAN("LA1"),
		LAS("LA2"),
		OCE("OC1"),
		EUNE("EUN1"),
		EUW("EUW1"),
		KR("KR"),
		RU("RU"),
		TR("TR1");

	    private String id;

	    PlatformId(String id) {
	        this.id = id;
	    }

	    public String getId() {
	        return id;
	    }
}

package constant;

/*
 * Copyright 2015 Taylor Caldwell
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public enum PlatformId {

		NA("NA1", "na"),
		BR("BR1", "br"),
		LAN("LA1", "lan"),
		LAS("LA2", "las"),
		OCE("OC1", "oce"),
		EUNE("EUN1", "eune"),
		EUW("EUW1", "euw"),
		KR("KR", "kr"),
		RU("RU", "ru"),
		TR("TR1", "tr");

	    private String id;
	    private String name;

	    PlatformId(String id, String name) {
	        this.id = id;
	        this.name = name;
	    }

	    public String getId() {
	        return id;
	    }

	    public String getName() {
	    	return name;
	    }
}

Add region names to platform id constants


package org.nwapw.abacus.number;

import java.util.HashMap;

public class FunctionDatabase {

    private HashMap<String, Function> functions;

    private void registerDefault(){

    }

    public FunctionDatabase(){
        functions = new HashMap<>();
    }

    public Function getFunction(String name){
        return functions.get(name);
    }

}

package org.nwapw.abacus.number;

import java.util.HashMap;

public class FunctionDatabase {

    private HashMap<String, Function> functions;

    private void registerDefault(){

        functions.put("+", new Function() {
            @Override
            protected boolean matchesParams(Number[] params) {
                return params.length >= 1;
            }

            @Override
            protected Number applyInternal(Number[] params) {
                Number sum = params[0];
                for(int i = 1; i < params.length; i++){
                    sum = sum.add(params[i]);
                }
                return sum;
            }
        });

        functions.put("-", new Function() {
            @Override
            protected boolean matchesParams(Number[] params) {
                return params.length == 2;
            }

            @Override
            protected Number applyInternal(Number[] params) {
                return params[0].subtract(params[1]);
            }
        });

        functions.put("*", new Function() {
            @Override
            protected boolean matchesParams(Number[] params) {
                return params.length >= 1;
            }

            @Override
            protected Number applyInternal(Number[] params) {
                Number product = params[1];
                for(int i = 1; i < params.length; i++){
                    product = product.multiply(params[i]);
                }
                return product;
            }
        });

        functions.put("/", new Function() {
            @Override
            protected boolean matchesParams(Number[] params) {
                return params.length == 2;
            }

            @Override
            protected Number applyInternal(Number[] params) {
                return params[0].divide(params[1]);
            }
        });
    }

    public FunctionDatabase(){
        functions = new HashMap<>();
        registerDefault();
    }

    public Function getFunction(String name){
        return functions.get(name);
    }

}

Add the four external essential functions.


/**
 *
 */
package main;

<<<<<<< Updated upstream
/**
 * @author Bart
 *
 */
public class MainClass {

	/**
	 * @param arg - the main arguments
	 */
	public static void main(String[] args) {

		System.out.println("Welcom to the main class of goto-fail;");

	}

=======
import lombok.Getter;
import lombok.Setter;

public class MainClass {
    @Getter
    @Setter
    public static int counter;

    /**
     * @param args - the main arguments.
     */
    public static void main(String[] args) {
        setCounter(5);
        System.out.println(getCounter());
    System.out.println("Welcome to the main class of goto-fail;");
    }
>>>>>>> Stashed changes
}

package main;

import lombok.Getter;
import lombok.Setter;

public class MainClass {
    @Getter @Setter
    public static int counter;

    /**
     * @param args - the main arguments.
     */
    public static void main(String[] args) {
        setCounter(5);
        System.out.println(getCounter());
        System.out.println("Welcome to the main class of goto-fail;");
    }
}

Remove wierd git behaviour & Fix name javadoc


package com.stripe.model;

import java.util.List;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public final class ChargeLevel3 extends StripeObject {
  protected List<ChargeLevel3LineItem> lineItems;
  protected String merchantReference;
  protected String shippingAddressZip;
  protected Long shippingAmount;
}

package com.stripe.model;

import java.util.List;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public final class ChargeLevel3 extends StripeObject {
  protected String customerReference;
  protected List<ChargeLevel3LineItem> lineItems;
  protected String merchantReference;
  protected String shippingAddressZip;
  protected String shippingFromZip;
  protected Long shippingAmount;
}

Add extra properties to the Level III data on a Charge


import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class HelloWorldTest {

    @Test
    public void helloNoName() {
        assertEquals("Hello, World!", HelloWorld.hello(""));
        assertEquals("Hello, World!", HelloWorld.hello(null));
    }

    @Test
    public void helloSampleName() {
        assertEquals("Hello, Alice!", HelloWorld.hello("Alice"));
    }

    @Test
    public void helloAnotherSampleName() throws Exception {
        assertEquals("Hello, Bob!", HelloWorld.hello("Bob"));
    }
}

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class HelloWorldTest {

    @Test
    public void helloNoName() {
        assertEquals("Hello, World!", HelloWorld.hello(""));
        assertEquals("Hello, World!", HelloWorld.hello(null));
    }

    @Test
    public void helloSampleName() {
        assertEquals("Hello, Alice!", HelloWorld.hello("Alice"));
    }

    @Test
    public void helloAnotherSampleName() {
        assertEquals("Hello, Bob!", HelloWorld.hello("Bob"));
    }
}

Remove needless Exception from method signature


// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

package org.openqa.selenium.grid;public class ActualMain {
}

Add missing copyright file. No logical changes


package io.freefair.gradle.plugins.github;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;

/**
 * @author Lars Grefer
 */
public class GithubPackageRegistryMavenPublishPlugin implements Plugin<Project> {
    @Override
    public void apply(Project project) {

        project.getPlugins().apply(MavenPublishPlugin.class);
        project.getPlugins().apply(GithubPomPlugin.class);

        GithubExtension githubExtension = project.getRootProject().getExtensions().getByType(GithubExtension.class);

        project.afterEvaluate(p -> p.getExtensions().getByType(PublishingExtension.class)
                .getRepositories()
                .maven(githubRepo -> {
                    String owner = githubExtension.getOwner().get();
                    githubRepo.setName("GitHub " + owner + " Maven Packages");
                    githubRepo.setUrl("https://maven.pkg.github.com/" + owner);

                    if (githubExtension.getUsername().isPresent() && githubExtension.getToken().isPresent()) {
                        githubRepo.credentials(passwordCredentials -> {
                            passwordCredentials.setUsername(githubExtension.getUsername().get());
                            passwordCredentials.setPassword(githubExtension.getToken().get());
                        });
                    }

                }));

    }
}

package io.freefair.gradle.plugins.github;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.publish.PublishingExtension;
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;

/**
 * @author Lars Grefer
 */
public class GithubPackageRegistryMavenPublishPlugin implements Plugin<Project> {
    @Override
    public void apply(Project project) {

        project.getPlugins().apply(MavenPublishPlugin.class);
        project.getPlugins().apply(GithubPomPlugin.class);

        GithubExtension githubExtension = project.getRootProject().getExtensions().getByType(GithubExtension.class);

        project.afterEvaluate(p -> p.getExtensions().getByType(PublishingExtension.class)
                .getRepositories()
                .maven(githubRepo -> {
                    String owner = githubExtension.getOwner().get();
                    githubRepo.setName("GitHub " + owner + " Maven Packages");
                    githubRepo.setUrl("https://maven.pkg.github.com/" + githubExtension.getSlug());

                    if (githubExtension.getUsername().isPresent() && githubExtension.getToken().isPresent()) {
                        githubRepo.credentials(passwordCredentials -> {
                            passwordCredentials.setUsername(githubExtension.getUsername().get());
                            passwordCredentials.setPassword(githubExtension.getToken().get());
                        });
                    }

                }));

    }
}

Add the repo name to the github package repo url


/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.prestosql.tests.product.launcher.env;

public final class EnvironmentDefaults
{
    public static final String DOCKER_IMAGES_VERSION = "33";
    public static final String HADOOP_BASE_IMAGE = "prestodev/hdp2.6-hive";
    public static final String HADOOP_IMAGES_VERSION = DOCKER_IMAGES_VERSION;
    public static final String TEMPTO_ENVIRONMENT_CONFIG = "/dev/null";

    private EnvironmentDefaults() {}
}

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.prestosql.tests.product.launcher.env;

public final class EnvironmentDefaults
{
    public static final String DOCKER_IMAGES_VERSION = "34";
    public static final String HADOOP_BASE_IMAGE = "prestodev/hdp2.6-hive";
    public static final String HADOOP_IMAGES_VERSION = DOCKER_IMAGES_VERSION;
    public static final String TEMPTO_ENVIRONMENT_CONFIG = "/dev/null";

    private EnvironmentDefaults() {}
}

Update docker images to version 34


package axiom.delauth.token;

public class DemoAuthenticator implements Authenticator {

	public boolean authenticate(String username, String password) {
		return password.equals("123456");
	}

}

package axiom.delauth.token;

public class DemoAuthenticator implements Authenticator {

	public boolean authenticate(String username, String password) {
        return !(null == username || null == password) && password.equals("123456");
    }

}

Fix DemoAuthenicator to require username and password not be null. (eclipse)


package net.md_5.gauge.monitor;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class PlayersMonitor implements Runnable
{

    @Override
    public void run()
    {
        Player[] players = Bukkit.getServer().getOnlinePlayers();
    }
}

package net.md_5.gauge.monitor;

import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class PlayersMonitor implements Runnable
{

    private final Set<String> seen = new HashSet<>();

    @Override
    public void run()
    {
        Player[] players = Bukkit.getServer().getOnlinePlayers();
        Set<String> joined = new HashSet<>();
        Set<String> left = new HashSet<>( seen );

        for ( Player player : players )
        {
            String name = player.getName();
            if ( !seen.contains( name ) )
            {
                joined.add( name );
            }
            left.remove( name );
        }

        int joinedCount = joined.size();
        int leftCount = left.size();
        int onlineCount = players.length;
    }
}

Add player join / parts + online count.


package shadow.test.doctool;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import shadow.doctool.DocumentationTool;

public class DocumentationTest
{
	private ArrayList<String> args = new ArrayList<String>();

	@Before
	public void setup() throws Exception
	{
		if (System.getProperty("os.name").contains("Windows")) {
			args.add("-c");
			args.add("windows.xml");
		}
	}

	@Test public void misplacedTest() throws Exception
	{
		args.add("shadow/test/doctool/Misplaced.shadow");
		DocumentationTool.main(args.toArray(new String[] { }));
	}
}

package shadow.test.doctool;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import shadow.doctool.DocumentationTool;

public class DocumentationTest
{
	private ArrayList<String> args = new ArrayList<String>();

	@Before
	public void setup() throws Exception
	{
		if (System.getProperty("os.name").contains("Windows")) {
			args.add("-c");
			args.add("windows.xml");
		}
	}

	@Test public void misplacedTest() throws Exception
	{
		args.add("shadow/test/doctool/Misplaced.shadow");
		DocumentationTool.document(args.toArray(new String[] { }));
	}
}

Correct crash caused by the documentation test


package mmarquee.automation;

import mmarquee.automation.uiautomation.IUIAutomation;
import mmarquee.automation.uiautomation.IUIAutomationElement;

/**
 * Created by inpwt on 26/01/2016.
 */
public class AutomationEditBox extends AutomationBase implements IAutomationEditBox {
    public String text() {
        return this.name();
    }

    public AutomationEditBox(IUIAutomation uiAuto, IUIAutomationElement element) {
        this.element = element;
        this.uiAuto = uiAuto;
    }
}

package mmarquee.automation;

import mmarquee.automation.uiautomation.*;

/**
 * Created by inpwt on 26/01/2016.
 */
public class AutomationEditBox extends AutomationBase implements IAutomationEditBox {
    public String text() {
        //return this.name();
        com4j.Com4jObject unknown = this.element.getCurrentPattern(PatternID.ValuePatternId);

        String value = "";

        if (unknown != null) {
            IUIAutomationValuePattern pattern =
                    unknown.queryInterface(IUIAutomationValuePattern.class);

            if (pattern != null) {
                value = pattern.currentValue();
            }
        }

        return value;
    }

    public AutomationEditBox(IUIAutomation uiAuto, IUIAutomationElement element) {
        this.element = element;
        this.uiAuto = uiAuto;
    }
}

Fix issue with the value of editboxes


package org.ovirt.engine.core.common.action;

import org.ovirt.engine.core.common.businessentities.Network;
import org.ovirt.engine.core.common.businessentities.VDSGroup;
import org.ovirt.engine.core.common.businessentities.network_cluster;

public class AttachNetworkToVdsGroupParameter extends NetworkClusterParameters {
    private static final long serialVersionUID = -2874549285727269806L;
    private Network _network;

    public AttachNetworkToVdsGroupParameter(VDSGroup group, Network net) {
        super(new network_cluster(group.getId(),
                net.getId(),
                null,

                // Cluster attachment data can sometimes be missing, so use defaults in that case.
                net.getCluster() == null ? false : net.getCluster().getis_display(),
                net.getCluster() == null ? true : net.getCluster().isRequired()));
        _network = net;
    }

    public Network getNetwork() {
        return _network;
    }

    public AttachNetworkToVdsGroupParameter() {
    }
}

package org.ovirt.engine.core.common.action;

import org.ovirt.engine.core.common.businessentities.Network;
import org.ovirt.engine.core.common.businessentities.NetworkStatus;
import org.ovirt.engine.core.common.businessentities.VDSGroup;
import org.ovirt.engine.core.common.businessentities.network_cluster;

public class AttachNetworkToVdsGroupParameter extends NetworkClusterParameters {
    private static final long serialVersionUID = -2874549285727269806L;
    private Network _network;

    public AttachNetworkToVdsGroupParameter(VDSGroup group, Network net) {
        super(new network_cluster(group.getId(),
                net.getId(),
                NetworkStatus.NonOperational,

                // Cluster attachment data can sometimes be missing, so use defaults in that case.
                net.getCluster() == null ? false : net.getCluster().getis_display(),
                net.getCluster() == null ? true : net.getCluster().isRequired()));
        _network = net;
    }

    public Network getNetwork() {
        return _network;
    }

    public AttachNetworkToVdsGroupParameter() {
    }
}

Fix default network status on attach