/*
 * Copyright 2010 JBoss Inc
 *
 * 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 org.optaplanner.core.score.holder;

import java.io.Serializable;

import org.drools.common.AgendaItem;
import org.kie.event.rule.ActivationUnMatchListener;
import org.kie.runtime.rule.RuleContext;
import org.kie.runtime.rule.Session;

/**
 * Abstract superclass for {@link ScoreHolder}.
 */
public abstract class AbstractScoreHolder implements ScoreHolder, Serializable {

    protected void registerUndoListener(RuleContext kcontext, ActivationUnMatchListener undoListener) {
        AgendaItem agendaItem = (AgendaItem) kcontext.getMatch();
        if (agendaItem.getActivationUnMatchListener() != null) {
            Session workingMemory = null; // Should not be used by the undoListener anyway
            agendaItem.getActivationUnMatchListener().unMatch(workingMemory, agendaItem);
        }
        agendaItem.setActivationUnMatchListener(undoListener);
    }

}

/*
 * Copyright 2010 JBoss Inc
 *
 * 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 org.optaplanner.core.score.holder;

import java.io.Serializable;

import org.drools.core.common.AgendaItem;
import org.kie.event.rule.ActivationUnMatchListener;
import org.kie.runtime.rule.RuleContext;
import org.kie.runtime.rule.Session;

/**
 * Abstract superclass for {@link ScoreHolder}.
 */
public abstract class AbstractScoreHolder implements ScoreHolder, Serializable {

    protected void registerUndoListener(RuleContext kcontext, ActivationUnMatchListener undoListener) {
        AgendaItem agendaItem = (AgendaItem) kcontext.getMatch();
        if (agendaItem.getActivationUnMatchListener() != null) {
            Session workingMemory = null; // Should not be used by the undoListener anyway
            agendaItem.getActivationUnMatchListener().unMatch(workingMemory, agendaItem);
        }
        agendaItem.setActivationUnMatchListener(undoListener);
    }

}

Resolve split-packages: move everything from drools-core under org.drools.core: move org.drools.common


/*-
 * Copyright 2015 Diamond Light Source Ltd.
 *
 * 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
 */

package org.eclipse.dawnsci.analysis.api.tree;

public class TreeUtils {

	/**
	 * Get the path
	 * @param tree
	 * @param node
	 * @return path to node, return null if not found
	 */
	public static String getPath(Tree tree, Node node) {
		return getPathDepthFirst(tree.getGroupNode(), node);
	}

	private static String getPathDepthFirst(final GroupNode group, final Node node) {
		for (NodeLink l : group) {
			if (l.getDestination() == node) {
				return l.getFullName();
			} else if (l.isDestinationGroup()) {
				String p = getPathDepthFirst((GroupNode) l.getDestination(), node);
				if (p != null)
					return p;
			}
		}
		return null;
	}
}

/*-
 * Copyright 2015 Diamond Light Source Ltd.
 *
 * 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
 */

package org.eclipse.dawnsci.analysis.api.tree;

public class TreeUtils {

	/**
	 * Get the path
	 * @param tree
	 * @param node
	 * @return path to node, return null if not found
	 */
	public static String getPath(Tree tree, Node node) {
		GroupNode g = tree.getGroupNode();
		if (g == node) {
			return tree.getNodeLink().getFullName();
		}
		return getPathDepthFirst(tree.getGroupNode(), node);
	}

	private static String getPathDepthFirst(final GroupNode group, final Node node) {
		for (NodeLink l : group) {
			if (l.getDestination() == node) {
				return l.getFullName();
			} else if (l.isDestinationGroup()) {
				String p = getPathDepthFirst((GroupNode) l.getDestination(), node);
				if (p != null)
					return p;
			}
		}
		return null;
	}
}

Fix case of finding the top of tree node


package model.transform.tasks;

import model.transform.base.ImageTransformTask;

public class StoreOptions extends ImageTransformTask {

    public StoreOptions() {
        super("store");
    }

    public static class Builder {
        private StoreOptions storeOptions;

        public Builder() {
            this.storeOptions = new StoreOptions();
        }

        public Builder filename(String filename) {
            storeOptions.addOption("filename", filename);
            return this;
        }

        public Builder location(String location) {
            storeOptions.addOption("location", location);
            return this;
        }

        public Builder path(String path) {
            storeOptions.addOption("path", path);
            return this;
        }

        public Builder container(String container) {
            storeOptions.addOption("container", container);
            return this;
        }

        public Builder region(String region) {
            storeOptions.addOption("region", region);
            return this;
        }

        public Builder access(String access) {
            storeOptions.addOption("access", access);
            return this;
        }

        public Builder base64Decode(boolean base64Decode) {
            storeOptions.addOption("base64decode", base64Decode);
            return this;
        }

        public StoreOptions build() {
            return storeOptions;
        }
    }
}

package model.transform.tasks;

import model.transform.base.ImageTransformTask;

public class StoreOptions extends ImageTransformTask {

    // Constructor left public because this task can be used with default options
    public StoreOptions() {
        super("store");
    }

    public static class Builder {
        private StoreOptions storeOptions;

        public Builder() {
            this.storeOptions = new StoreOptions();
        }

        public Builder filename(String filename) {
            storeOptions.addOption("filename", filename);
            return this;
        }

        public Builder location(String location) {
            storeOptions.addOption("location", location);
            return this;
        }

        public Builder path(String path) {
            storeOptions.addOption("path", path);
            return this;
        }

        public Builder container(String container) {
            storeOptions.addOption("container", container);
            return this;
        }

        public Builder region(String region) {
            storeOptions.addOption("region", region);
            return this;
        }

        public Builder access(String access) {
            storeOptions.addOption("access", access);
            return this;
        }

        public Builder base64Decode(boolean base64Decode) {
            storeOptions.addOption("base64decode", base64Decode);
            return this;
        }

        public StoreOptions build() {
            return storeOptions;
        }
    }
}

Add comment to clarify constructor access


/**
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 *
 */

import junit.framework.*;

/**
 * JUnits tests for the Java subversion binding helper functions
 */
public class AllTests {

    public static void main( String [] args )
	{
	    junit.textui.TestRunner.run( suite() );
	}

    public static Test suite( )
	{
	    TestSuite suite = new TestSuite(
		"All JUnit tests for the Java Subversion binding");

	    //add tests here
	    //example:
	    //suite.addTest( new StatusTest() );
	    suite.addTestSuite( DateTests.class );
	    suite.addTestSuite( EntryTests.class );
	    suite.addTestSuite( VectorTests.class );

	    return suite;
	}
}

/**
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 *
 */

import junit.framework.*;

/**
 * JUnits tests for the Java subversion binding helper functions
 */
public class AllTests {

    public static void main( String [] args )
	{
	    junit.textui.TestRunner.run( suite() );
	}

    public static Test suite( )
	{
	    TestSuite suite = new TestSuite(
		"All JUnit tests for the Java Subversion binding");

	    //add tests here
	    //example:
	    //suite.addTest( new StatusTest() );
	    suite.addTestSuite( DateTests.class );
	    suite.addTestSuite( EntryTests.class );
	    suite.addTestSuite( VectorTests.class );
	    suite.addTestSuite( HashtableTests.class );

	    return suite;
	}
}

Integrate the hashtable Unit testcases.

Integrate the hashtable Unit testcases.

* tests/AllTests.java (suite): added HashtableTests


/*
 * Copyright 2013-2019 the original author or authors.
 *
 * 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 org.cloudfoundry.client.v3.builds;

import org.cloudfoundry.client.v3.FilterParameter;
import org.cloudfoundry.client.v3.PaginatedRequest;
import org.immutables.value.Value;

import java.util.List;

/**
 * The request payload for the List Builds operation
 */
@Value.Immutable
abstract class _ListBuildsRequest extends PaginatedRequest {

    /**
     * The application ids
     */
    @FilterParameter("app_guids")
    abstract List<String> getApplicationIds();

    /**
     * The build states
     */
    @FilterParameter("states")
    abstract List<String> getStates();

}

/*
 * Copyright 2013-2019 the original author or authors.
 *
 * 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 org.cloudfoundry.client.v3.builds;

import org.cloudfoundry.client.v3.FilterParameter;
import org.cloudfoundry.client.v3.PaginatedRequest;
import org.immutables.value.Value;

import java.util.List;

/**
 * The request payload for the List Builds operation
 */
@Value.Immutable
abstract class _ListBuildsRequest extends PaginatedRequest {

    /**
     * The application ids
     */
    @FilterParameter("app_guids")
    abstract List<String> getApplicationIds();

    /**
     * The package ids
     */
    @FilterParameter("package_guids")
    abstract List<String> getPackageIds();

    /**
     * The build states
     */
    @FilterParameter("states")
    abstract List<String> getStates();

}

Implement filtering of builds based on package IDs


package seedu.ezdo.model;

import java.util.EmptyStackException;

/*
 * Array-based implementation for a stack with fixed size. Used for undo & redo stacks.
 * If stack goes past max capacity, the oldest item to be pushed is replaced.
 */
public class FixedStack<T> {
    private int index;
    private T[] array;

    public FixedStack(int capacity) {
        array = (T[]) new Object[capacity];
        index = -1;
    }

    public void push(T item) {
        index = (index + 1) % 5; // wraps around
        array[index] = item;
        System.out.println("item added at index: " + index);
    }

    public T pop() throws EmptyStackException {
        if (index == -1 || array[index] == null) {
            throw new EmptyStackException();
        }
        T item = array[index];
        array[index] = null;
        System.out.println(item + " at index " + index + " removed");
        if (index == 0) {
            index = array.length - 1;
            System.out.println("index now: " + index);
        } else {
            index = index - 1;
            System.out.println("index now: " + index);
        }
        return item;
    }

    public boolean isEmpty() {
        for (int i = 0; i < array.length; i++) {
            if (array[i] != null) {
                return false;
            }
        }
        return true;
    }

    public void clear() {
        for (int i = 0; i < array.length; i++) {
            array[i] = null;
        }
        index = -1;
    }
}

package seedu.ezdo.model;

import java.util.EmptyStackException;

/*
 * Array-based implementation for a stack with fixed size. Used for undo & redo stacks.
 * If stack goes past max capacity, the oldest item to be pushed is replaced.
 */
public class FixedStack<T> {
    private int index;
    private T[] array;

    public FixedStack(int capacity) {
        array = (T[]) new Object[capacity];
        index = -1;
    }

    public void push(T item) {
        index = (index + 1) % ModelManager.STACK_CAPACITY; // wraps around
        array[index] = item;
    }

    public T pop() throws EmptyStackException {
        if (index == -1 || array[index] == null) {
            throw new EmptyStackException();
        }
        T item = array[index];
        array[index] = null;
        if (index == 0) {
            index = array.length - 1;
        } else {
            index = index - 1;
        }
        return item;
    }

    public boolean isEmpty() {
        for (int i = 0; i < array.length; i++) {
            if (array[i] != null) {
                return false;
            }
        }
        return true;
    }

    public void clear() {
        for (int i = 0; i < array.length; i++) {
            array[i] = null;
        }
        index = -1;
    }
}

Remove magic numbers and print statements


package tc.oc.projectares.api;

import java.util.Collection;
import java.util.Set;
import java.util.UUID;

import javax.annotation.Nonnull;

import org.bukkit.World;

public interface Match {
    @Nonnull World getWorld();

    @Nonnull UUID getUUID();

    @Nonnull boolean isRunning();

    @Nonnull boolean start();

    @Nonnull boolean end();

    @Nonnull boolean end(@Nonnull Team winningTeam);

    @Nonnull Collection<Player> getPlayers();

    @Nonnull Set<Player> getParticipatingPlayers();

    @Nonnull Set<Player> getObservingPlayers();

    Player getPlayer(org.bukkit.entity.Player player);

    @Nonnull Player addPlayer(org.bukkit.entity.Player player);

    void removePlayer(org.bukkit.entity.Player player);

    void removeAllPlayers();

    void broadcast(String message);

    @Nonnull Set<Team> getTeams();

    @Nonnull Set<Team> getParticipatingTeams();

    @Nonnull Set<Team> getObservingTeams();

    Team getFirstOther(Team exclude);
}

package tc.oc.projectares.api;

import java.util.Collection;
import java.util.Set;
import java.util.UUID;

import javax.annotation.Nonnull;

import org.bukkit.World;

public interface Match {
    @Nonnull World getWorld();

    @Nonnull UUID getUUID();

    @Nonnull boolean isRunning();

    @Nonnull boolean start();

    @Nonnull boolean end();

    @Nonnull boolean end(@Nonnull Team winningTeam);

    @Nonnull Collection<Player> getPlayers();

    @Nonnull Set<Player> getParticipatingPlayers();

    @Nonnull Set<Player> getObservingPlayers();

    void broadcast(String message);

    @Nonnull Set<Team> getTeams();

    @Nonnull Set<Team> getParticipatingTeams();

    @Nonnull Set<Team> getObservingTeams();

    Team getFirstOther(Team exclude);
}

Remove some methods that shouldn't have been exposed


// Copyright 2019 Google LLC
//
// 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
//
//     https://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 com.google.sps;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public final class SearchTest {

}

Add new line at EOF

Add new line at EOF


package edu.stuy.starlorn.entities;

import edu.stuy.starlorn.upgrades.GunUpgrade;

import java.util.LinkedList;

public class Ship extends Entity {
    protected LinkedList<GunUpgrade> _gunupgrades;
    protected int _baseDamage, _baseShotSpeed, _health;
    protected double _baseAim;

    public Ship() {
        super();
        _gunupgrades = new LinkedList<GunUpgrade>();
        _baseDamage = 1;
        _baseShotSpeed = 1;
        _health = 10;
        _baseAim = Math.PI/2; //Aim up by default
    }

    public void addUpgrade(GunUpgrade upgrade) {
        _gunupgrades.add(upgrade);
    }

    /*
     * Create the shots based on the available GunUpgrades
     */
    public void shoot() {
        GunUpgrade topShot = _gunupgrades.get(0);
        int damage = _baseDamage;
        int shotSpeed = _baseShotSpeed;
        for (GunUpgrade up : _gunupgrades) {
            if (up.getNumShots() > topShot.getNumShots())
                topShot = up;
            damage = up.getDamage(damage);
            shotSpeed = up.getShotSpeed(shotSpeed);
        }
        // Create new shots, based on dem vars
        int numShots = topShot.getNumShots();
        for (int i = 0; i < numShots; i++) {
            new Bullet(_baseAim + topShot.getAimAngle(), damage, shotSpeed);
        }
    }
}

package edu.stuy.starlorn.entities;

import edu.stuy.starlorn.upgrades.GunUpgrade;

import java.util.LinkedList;

public class Ship extends Entity {
    protected LinkedList<GunUpgrade> _gunupgrades;
    protected int _baseDamage, _baseShotSpeed, _health;
    protected double _baseAim;

    public Ship() {
        super();
        _gunupgrades = new LinkedList<GunUpgrade>();
        _baseDamage = 1;
        _baseShotSpeed = 1;
        _health = 10;
        _baseAim = Math.PI/2; //Aim up by default
    }

    public void addUpgrade(GunUpgrade upgrade) {
        _gunupgrades.add(upgrade);
    }

    /*
     * Create the shots based on the available GunUpgrades
     */
    public void shoot() {
        GunUpgrade topShot = _gunupgrades.get(0);
        int damage = _baseDamage;
        int shotSpeed = _baseShotSpeed;
        for (GunUpgrade up : _gunupgrades) {
            if (up.getNumShots() > topShot.getNumShots())
                topShot = up;
            damage = up.getDamage(damage);
            shotSpeed = up.getShotSpeed(shotSpeed);
        }
        // Create new shots, based on dem vars
        int numShots = topShot.getNumShots();
        for (int i = 0; i < numShots; i++) {
            Bullet b = new Bullet(_baseAim + topShot.getAimAngle(), damage, shotSpeed);
            b.setWorld(this.getWorld());
        }
    }
}

Add bullet to world when it's created

Add bullet to world when it's created


package io.khasang.wlogs.controller;

import io.khasang.wlogs.model.InsertDataTable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AppController {
    @RequestMapping("/")
    public String welcome(Model model) {
        model.addAttribute("greeting", "Welcome to our best wLogs!");
        model.addAttribute("tagline", "The one and only amazing logs system!");
        return "welcome";
    }

    @RequestMapping("/backup")
    public String backup(Model model) {
        model.addAttribute("backup", "Success");
        return "backup";
    }

    @RequestMapping("/admin")
    public String admin(Model model) {
        model.addAttribute("admin", "You are number 1!");
        return "admin";
    }

    @RequestMapping("/createtable")
    public String crateTable(Model model) {
        InsertDataTable sql = new InsertDataTable();
        model.addAttribute("createtable", sql.sqlInsertCheck());
        return "createtable";
    }
}

package io.khasang.wlogs.controller;

import io.khasang.wlogs.model.InsertDataTable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AppController {
    @RequestMapping("/")
    public String welcome(Model model) {
        model.addAttribute("greeting", "Welcome to our best wLogs!");
        model.addAttribute("tagline", "The one and only amazing logs system!");
        return "welcome";
    }

    @RequestMapping("/backup")
    public String backup(Model model) {
        model.addAttribute("backup", "Success");
        return "backup";
    }

    @RequestMapping("/admin")
    public String admin(Model model) {
        model.addAttribute("admin", "You are number 1!");
        return "admin";
    }

    @RequestMapping("/createtable")
    public String crateTable(Model model) {
        InsertDataTable sql = new InsertDataTable();
        model.addAttribute("createtable", sql.sqlInsertCheck());
        return "createtable";
    }

    @RequestMapping("/mainmenu")
    public String mainMenu(Model model) {
        return "mainmenu";
    }
}

Add menu jsp and controller function

Add menu jsp and controller function


package eu.nerro.wolappla.model;

public class Device {
  private String name;
  private String macAddress;
  private String ipAddress;
  private int port;
  private String ssid;
}

package eu.nerro.wolappla.model;

public class Device {
  private String name;
  private String macAddress;
  private String ipAddress;
  private int port;
}

Remove currently not used 'ssid' field in device model


package org.nwapw.abacus.tests;

import org.nwapw.abacus.lexing.Lexer;
import org.nwapw.abacus.tree.TokenType;

public class LexerTests {

    Lexer<TokenType> lexer = new Lexer<TokenType>(){{

    }};

}

package org.nwapw.abacus.tests;

import org.junit.Assert;
import org.junit.Test;
import org.nwapw.abacus.lexing.Lexer;
import org.nwapw.abacus.lexing.pattern.Match;

import java.util.List;

public class LexerTests {

    @Test
    public void testBasicSuccess(){
        Lexer<Integer> lexer = new Lexer<>();
        lexer.register("abc", 0);
        lexer.register("def", 1);
        List<Match<Integer>> matchedIntegers = lexer.lexAll("abcdefabc", 0, Integer::compare);
        Assert.assertEquals(matchedIntegers.get(0).getType(), Integer.valueOf(0));
        Assert.assertEquals(matchedIntegers.get(1).getType(), Integer.valueOf(1));
        Assert.assertEquals(matchedIntegers.get(2).getType(), Integer.valueOf(0));
    }

    @Test
    public void testBasicFailure(){
        Lexer<Integer> lexer = new Lexer<>();
        lexer.register("abc", 0);
        lexer.register("def", 1);
        Assert.assertNull(lexer.lexAll("abcdefabcz", 0, Integer::compare));
    }

}

Write basic tests for string matching.

Write basic tests for string matching.


package kawa.standard;
import kawa.lang.*;

/**
 * The Syntax transformer that re-writes the "define" Scheme primitive.
 * Currently, only handles top-level definitions.
 * @author	Per Bothner
 */

public class define extends Syntax implements Printable
{
  public Expression rewrite (Object obj, Interpreter interp)
       throws kawa.lang.WrongArguments
  {
    if (obj instanceof Pair)
      {
	Pair p1 = (Pair) obj;
	if (p1.car instanceof Symbol && p1.cdr instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.cdr;
	    if (p2.cdr == List.Empty)
	      {
		SetExp result = new SetExp ((Symbol)p1.car,
					    interp.rewrite (p2.car));
		result.setDefining (true);
		return result;
	      }
	  }
	else if (p1.car instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.car;
	    if (p2.car instanceof Symbol)
	      {
		Symbol name = (Symbol) p2.car;
		LambdaExp lexp = new LambdaExp (p2.cdr, p1.cdr, interp);
		lexp.setName (name.toString ());
		SetExp result = new SetExp (name, lexp);
		result.setDefining (true);
		return result;
	      }
	  }
      }
    return interp.syntaxError ("invalid syntax for define");
  }

  public void print(java.io.PrintStream ps)
  {
    ps.print("#<builtin define>");
  }
}

package kawa.standard;
import kawa.lang.*;

/**
 * The Syntax transformer that re-writes the "define" Scheme primitive.
 * Currently, only handles top-level definitions.
 * @author	Per Bothner
 */

public class define extends Syntax implements Printable
{
  public Expression rewrite (Object obj, Interpreter interp)
       throws kawa.lang.WrongArguments
  {
    if (obj instanceof Pair)
      {
	Pair p1 = (Pair) obj;
	if (p1.car instanceof Symbol && p1.cdr instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.cdr;
	    if (p2.cdr == List.Empty)
	      {
		SetExp result = new SetExp ((Symbol)p1.car,
					    interp.rewrite (p2.car));
		result.setDefining (true);
		return result;
	      }
	  }
	else if (p1.car instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.car;
	    if (p2.car instanceof Symbol)
	      {
		Symbol name = (Symbol) p2.car;
		LambdaExp lexp = new LambdaExp (p2.cdr, p1.cdr, interp);
		lexp.setName (name.toString ());
		SetExp result = new SetExp (name, lexp);
		result.setDefining (true);
		return result;
	      }
	  }
      }
    return interp.syntaxError ("invalid syntax for define");
  }
}

Remove print method. No longer needed.

	Remove print method.  No longer needed.

git-svn-id: 169764d5f12c41a1cff66b81d896619f3ce5473d@126 5e0a886f-7f45-49c5-bc19-40643649e37f


package org.revapi.maven;

import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
 * @author Lukas Krejci
 * @since 0.7.0
 */
@Mojo(name = "report-fork", defaultPhase = LifecyclePhase.SITE,
        requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Execute(phase = LifecyclePhase.PACKAGE)
public class ReportForkMojo {
}

package org.revapi.maven;

import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
 * @author Lukas Krejci
 * @since 0.7.0
 */
@Mojo(name = "report-fork", defaultPhase = LifecyclePhase.SITE,
        requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Execute(phase = LifecyclePhase.PACKAGE)
public class ReportForkMojo extends ReportMojo {
}

Make report-fork goal actually do something.


package com.emc.ecs.managementClient;

import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;

import com.emc.ecs.managementClient.model.DataServiceReplicationGroup;
import com.emc.ecs.managementClient.model.DataServiceReplicationGroupList;
import com.emc.ecs.serviceBroker.EcsManagementClientException;
import com.emc.ecs.serviceBroker.EcsManagementResourceNotFoundException;

public class ReplicationGroupAction {

	public static List<DataServiceReplicationGroup> list(Connection connection)
			throws EcsManagementClientException {
		UriBuilder uri = connection.getUriBuilder().segment("vdc",
				"data-service", "vpools");
		Response response = connection.handleRemoteCall("get", uri, null);
		DataServiceReplicationGroupList rgList = response
				.readEntity(DataServiceReplicationGroupList.class);
		return rgList.getReplicationGroups();
	}

	public static DataServiceReplicationGroup get(Connection connection,
			String id) throws EcsManagementClientException,
					EcsManagementResourceNotFoundException {
		List<DataServiceReplicationGroup> repGroups = list(connection);
		Optional<DataServiceReplicationGroup> optionalRg = repGroups.stream()
				.filter(rg -> rg.getName().equals(id)).findFirst();
		try {
			return optionalRg.get();
		} catch (NoSuchElementException e) {
			throw new EcsManagementResourceNotFoundException(e.getMessage());
		}
	}

}

package com.emc.ecs.managementClient;

import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;

import com.emc.ecs.managementClient.model.DataServiceReplicationGroup;
import com.emc.ecs.managementClient.model.DataServiceReplicationGroupList;
import com.emc.ecs.serviceBroker.EcsManagementClientException;
import com.emc.ecs.serviceBroker.EcsManagementResourceNotFoundException;

public class ReplicationGroupAction {

	public static List<DataServiceReplicationGroup> list(Connection connection)
			throws EcsManagementClientException {
		UriBuilder uri = connection.getUriBuilder().segment("vdc",
				"data-service", "vpools");
		Response response = connection.handleRemoteCall("get", uri, null);
		DataServiceReplicationGroupList rgList = response
				.readEntity(DataServiceReplicationGroupList.class);
		return rgList.getReplicationGroups();
	}

	public static DataServiceReplicationGroup get(Connection connection,
			String id) throws EcsManagementClientException,
					EcsManagementResourceNotFoundException {
		List<DataServiceReplicationGroup> repGroups = list(connection);
		Optional<DataServiceReplicationGroup> optionalRg = repGroups.stream()
				.filter(rg -> rg.getId().equals(id)).findFirst();
		try {
			return optionalRg.get();
		} catch (NoSuchElementException e) {
			throw new EcsManagementResourceNotFoundException(e.getMessage());
		}
	}

}

Return by ID in client model

Return by ID in client model


package com.blabbertabber.blabbertabber;

import junit.framework.TestCase;

/**
 * Created by cunnie on 8/9/15.
 */
public class MainActivityTest extends TestCase {

    public void setUp() throws Exception {
        super.setUp();

    }

    public void tearDown() throws Exception {

    }

    public void testOnCreate() throws Exception {

    }

    public void testOnCreateOptionsMenu() throws Exception {

    }

    public void testOnOptionsItemSelected() throws Exception {

    }
}

package com.blabbertabber.blabbertabber;

import junit.framework.TestCase;

/**
 * Created by cunnie on 8/9/15.
 */
public class MainActivityTest extends TestCase {

    public void setUp() throws Exception {
        super.setUp();

    }

    public void tearDown() throws Exception {
    }

    public void testOnCreate() throws Exception {
        throw new Exception("Holy cow!!!  What went wrong here?");
    }

    public void testOnCreateOptionsMenu() throws Exception {

    }

    public void testOnOptionsItemSelected() throws Exception {

    }
}

Create new TDD unit test: test failure

Create new TDD unit test: test failure


/**
 *
 */
package org.mwc.cmap.core.DataTypes.TrackData;

import Debrief.Tools.Tote.WatchableList;

/**
 * @author ian.mayo
 *
 */
public interface TrackDataProvider
{
	public static interface TrackDataListener
	{
		/** find out that the primary has changed
		 *
		 * @param primary the primary track
		 */
		public void primaryUpdated(WatchableList primary);

		/** find out that the secondaries have changed
		 *
		 * @param secondaries list of secondary tracks
		 */
		public void secondariesUpdated(WatchableList[] secondaries);
	}

	/** declare that we want to be informed about changes
	 * in selected tracks
	 */
	public void addTrackDataListener(TrackDataListener listener);

	/** find out what the primary track is
	 *
	 */
	public WatchableList getPrimaryTrack();

	/** find out what the secondary track is
	 *
	 */
	public WatchableList[] getSecondaryTracks();

}

/**
 *
 */
package org.mwc.cmap.core.DataTypes.TrackData;

import Debrief.Tools.Tote.WatchableList;

/**
 * @author ian.mayo
 *
 */
public interface TrackDataProvider
{
	public static interface TrackDataListener
	{
		/** find out that the primary has changed
		 *
		 * @param primary the primary track
		 */
		public void primaryUpdated(WatchableList primary);

		/** find out that the secondaries have changed
		 *
		 * @param secondaries list of secondary tracks
		 */
		public void secondariesUpdated(WatchableList[] secondaries);
	}

	/** declare that we want to be informed about changes
	 * in selected tracks
	 */
	public void addTrackDataListener(TrackDataListener listener);

	/** forget that somebody wants to know about track changes
	 *
	 */
	public void removeTrackDataListener(TrackDataListener listener);

	/** find out what the primary track is
	 *
	 */
	public WatchableList getPrimaryTrack();

	/** find out what the secondary track is
	 *
	 */
	public WatchableList[] getSecondaryTracks();

}

Allow removal of track data

Allow removal of track data

git-svn-id: d2601f1668e3cd2de409f5c059006a6eeada0abf@205 cb33b658-6c9e-41a7-9690-cba343611204


/*
 * 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.aries.blueprint.uberbundle;

import org.apache.aries.blueprint.container.BlueprintExtender;
import org.apache.aries.proxy.impl.ProxyManagerActivator;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class UberActivator implements BundleActivator
{
  private BlueprintExtender blueprintActivator = new BlueprintExtender();
  private ProxyManagerActivator proxyActivator = new ProxyManagerActivator();

  public void start(BundleContext context)
  {
    proxyActivator.start(context);
    blueprintActivator.start(context);
  }

  public void stop(BundleContext arg0)
  {
    blueprintActivator.stop(arg0);
    proxyActivator.start(arg0);
  }
}

/*
 * 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.aries.blueprint.uberbundle;

import org.apache.aries.blueprint.container.BlueprintExtender;
import org.apache.aries.proxy.impl.ProxyManagerActivator;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class UberActivator implements BundleActivator
{
  private BlueprintExtender blueprintActivator = new BlueprintExtender();
  private ProxyManagerActivator proxyActivator = new ProxyManagerActivator();

  public void start(BundleContext context)
  {
    proxyActivator.start(context);
    blueprintActivator.start(context);
  }

  public void stop(BundleContext context)
  {
    blueprintActivator.stop(context);
    proxyActivator.stop(context);
  }
}

Fix problem with the proxy activator when using the blueprint bundle

git-svn-id: 212869a37fe990abe2323f86150f3c4d5a6279c2@1033177 13f79535-47bb-0310-9956-ffa450edef68


package protocolsupport.protocol.utils.types;

import java.text.MessageFormat;

import protocolsupport.utils.CollectionsUtils;
import protocolsupport.utils.CollectionsUtils.ArrayMap;

public enum GameMode {

	SURVIVAL(0), CREATIVE(1), ADVENTURE(2), SPECTATOR(3);

	private static final ArrayMap<GameMode> byId = CollectionsUtils.makeEnumMappingArrayMap(GameMode.class, GameMode::getId);

	private final int id;
	GameMode(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public static GameMode getById(int id) {
		GameMode gm = byId.get(id);
		if (gm == null) {
			throw new IllegalArgumentException(MessageFormat.format("Unknown gamemode network id {0}", id));
		}
		return gm;
	}

}

package protocolsupport.protocol.utils.types;

import java.text.MessageFormat;

import protocolsupport.utils.CollectionsUtils;
import protocolsupport.utils.CollectionsUtils.ArrayMap;

public enum GameMode {

	NOT_SET(-1), SURVIVAL(0), CREATIVE(1), ADVENTURE(2), SPECTATOR(3);

	private static final ArrayMap<GameMode> byId = CollectionsUtils.makeEnumMappingArrayMap(GameMode.class, GameMode::getId);

	private final int id;
	GameMode(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public static GameMode getById(int id) {
		GameMode gm = byId.get(id);
		if (gm == null) {
			throw new IllegalArgumentException(MessageFormat.format("Unknown gamemode network id {0}", id));
		}
		return gm;
	}

}

Support -1 gamemode (not set), while it's not valid gamemode and should be only used as starting gamemode for server internals, sometimes custom npc plugins do not set it. All supported versions support this gamemode, and no internal logic depends on it, so allowing it shouldn't bring any problems


package com.leafriend.flix;

import java.io.Console;

public class Flix {

    private Options options;

    public static void main(String[] args) {

        Console console = System.console();

        console.printf("Hello, FLiX\n");
    public Flix(Options options) {
        this.options = options;
    }

    }

}

package com.leafriend.flix;

public class Flix {

    private Options options;

    public static void main(String[] args) {

        Options options = new Options();

        new Flix(options).run();

    }

    public Flix(Options options) {
        this.options = options;
    }

    public void run() {

    }

}

Call run() for new instance

Call run() for new instance


/**
 *
 */
package com.cj.votron;

import java.util.ArrayList;
import java.util.Arrays;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * @author gvamos
 *
 */
public class ElectionsActivity extends Activity {
	  private ListView electionListView ;
	  private ArrayAdapter<String> listAdapter ;

	  @Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    Log.i(this.getClass().getName(),":onCreate");
	    setContentView(R.layout.activity_elections);

	    // Find the ListView resource.
	    electionListView = (ListView) findViewById( R.id.electionsListView );

	    // Create and populate a List of planet names.
	    String[] planets = new String[] { "London", "Paris", "Chatsworth" };
	    ArrayList<String> planetList = new ArrayList<String>();
	    planetList.addAll( Arrays.asList(planets) );

	    // Create ArrayAdapter using the planet list.
	    listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, planetList);

	    // Add more planets. If you passed a String[] instead of a List<String>
	    // into the ArrayAdapter constructor, you must not add more items.
	    // Otherwise an exception will occur.
	    listAdapter.add( "Foo" );
	    listAdapter.add( "Bar" );
	    listAdapter.add( "Baz" );

	    // Set the ArrayAdapter as the ListView's adapter.
	    electionListView.setAdapter( listAdapter );
	  }

}

/**
 *
 */
package com.cj.votron;

import java.util.ArrayList;
import java.util.Arrays;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * @author gvamos
 *
 */
public class ElectionsActivity extends Activity {

	  private ListView electionListView ;
	  private ArrayAdapter<String> listAdapter ;
	  private Config.Elections elections;

	  @Override
	  public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    Log.i(this.getClass().getName(),":onCreate");
	    setContentView(R.layout.activity_elections);

	    elections = Config.getInstance().getElections();
	    elections.updateElections();

	    // Shave the yak.
	    electionListView = (ListView) findViewById( R.id.electionsListView );
	    listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, (elections.getElectionsList()));
	    electionListView.setAdapter( listAdapter );
	  }
}

Refactor to use central config object

Refactor to use central config object


package org.keycloak.admin.client.resource;

import org.keycloak.representations.idm.MappingsRepresentation;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * @author rodrigo.sasaki@icarros.com.br
 */
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface RoleMappingResource {

    @GET
    public MappingsRepresentation getAll();

    @Path("realm")
    public RoleScopeResource realmLevel();

    @Path("applications/{appName}")
    public RoleScopeResource applicationLevel(@PathParam("appName") String appName);

}

package org.keycloak.admin.client.resource;

import org.keycloak.representations.idm.MappingsRepresentation;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * @author rodrigo.sasaki@icarros.com.br
 */
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface RoleMappingResource {

    @GET
    public MappingsRepresentation getAll();

    @Path("realm")
    public RoleScopeResource realmLevel();

    @Path("clients/{clientId}")
    public RoleScopeResource clientLevel(@PathParam("clientId") String clientId);

}

[KEYCLOAK-1206] Change role mapping path in admin client to match API changes


public class View {
	private Player player;
	public View (Player p) {
		player=p;
	}

	public void update() {
		System.out.println("The current player has a health of " + player.getHealth());//TODO

	}

}

public class View {
	private Player player;
	public View (Player p) {
		player=p;
	}

	public void update() {
		System.out.println("The current player has a health of " + player.getHealth());//TODO
		System.out.println("The player has the following items");

		for (Item item : player.getInventory(null)) {
			System.out.println(item.getDescription());
		}

		System.out.println("The player is in room " + player.getCurrentRoom().getLongDescription());

	}

}

Add some text based display

Add some text based display


import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class BinaryTest {

    private String input;
    private int expectedOutput;

    @Parameters
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][]{
                {"1", 1},
                {"10", 2},
                {"11", 3},
                {"100", 4},
                {"1001", 9},
                {"11010", 26},
                {"10001101000", 1128},
                {"2", 0},
                {"5", 0},
                {"9", 0},
                {"134678", 0},
                {"abc10z", 0},
                {"011", 3}
        });
    }

    public BinaryTest(String input, int expectedOutput) {
        this.input = input;
        this.expectedOutput = expectedOutput;
    }

    @Test
    public void test() {
        Binary binary = new Binary(input);

        assertEquals(expectedOutput, binary.getDecimal());
    }
}

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class BinaryTest {

    private String input;
    private int expectedOutput;

    @Parameters
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][]{
                {"1", 1},
                {"10", 2},
                {"11", 3},
                {"100", 4},
                {"1001", 9},
                {"11010", 26},
                {"10001101000", 1128},
                {"2", 0},
                {"5", 0},
                {"9", 0},
                {"134678", 0},
                {"abc10", 0},
                {"10z", 0},
                {"10a10", 0},
                {"011", 3}
        });
    }

    public BinaryTest(String input, int expectedOutput) {
        this.input = input;
        this.expectedOutput = expectedOutput;
    }

    @Test
    public void test() {
        Binary binary = new Binary(input);

        assertEquals(expectedOutput, binary.getDecimal());
    }
}

Add canonical cases to test

Add canonical cases to test


/*
 * 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.logging.log4j.message;

/**
 * A Message that can have a format String attached to it.
 */
public interface FormattedMessage extends Message {
    /**
     * Set the message format.
     * @param format The message format.
     */
    void setFormat(String format);

    /**
     * Return the message format.
     * @return the message format String.
     */
    String getFormat();
}

/*
 * 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.logging.log4j.message;

/**
 * A Message that can have a format String attached to it. The format string is used by the
 * Message implementation as extra information that it may use to help it to determine how
 * to format itself. For example, MapMessage accepts a format of "XML" to tell it to render
 * the Map as XML instead of its default format of {key1="value1" key2="value2"}.
 */
public interface FormattedMessage extends Message {
    /**
     * Set the message format.
     * @param format The message format.
     */
    void setFormat(String format);

    /**
     * Return the message format.
     * @return the message format String.
     */
    String getFormat();
}

Add more details to the javadoc

Add more details to the javadoc

git-svn-id: de5ce936019686f47409c93bcc5e202a9739563b@1364421 13f79535-47bb-0310-9956-ffa450edef68


/*
 * Copyright 2018 the original author or authors.
 *
 * 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 org.gradle.tooling.exceptions;

/**
 * Thrown when the {@link org.gradle.tooling.PhasedBuildActionExecuter.Builder} has been configured
 * with more than one {@link org.gradle.tooling.BuildAction} per phase.
 */
public class MultipleBuildActionsException extends RuntimeException {

    public MultipleBuildActionsException(String message) {
        super(message);
    }
}

/*
 * Copyright 2018 the original author or authors.
 *
 * 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 org.gradle.tooling.exceptions;

import org.gradle.api.Incubating;

/**
 * Thrown when the {@link org.gradle.tooling.PhasedBuildActionExecuter.Builder} has been configured
 * with more than one {@link org.gradle.tooling.BuildAction} per phase.
 *
 * @since 4.7
 */
@Incubating
public class MultipleBuildActionsException extends RuntimeException {

    public MultipleBuildActionsException(String message) {
        super(message);
    }
}

Add @Incubating and @since annotations

Add @Incubating and @since annotations

To MultipleBuildActionsException.

Signed-off-by: Lucas Smaira <ebde68659be3ad482cc698f6db784bb2a410fa24@google.com>


package net.somethingdreadful.MAL;

import android.content.res.Configuration;

import org.holoeverywhere.ThemeManager;
import org.holoeverywhere.app.Application;

import java.util.Locale;

public class Theme extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        PrefManager Prefs = new PrefManager(getApplicationContext());
        Locale locale = Prefs.getLocale();

        // apply it until the app remains cached
        Locale.setDefault(locale);
        Configuration newConfig = new Configuration();
        newConfig.locale = locale;
        getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
    }

    static {
        ThemeManager.setDefaultTheme(ThemeManager.MIXED);
    }
}

package net.somethingdreadful.MAL;

import android.content.res.Configuration;

import org.holoeverywhere.ThemeManager;
import org.holoeverywhere.app.Application;

import java.util.Locale;

public class Theme extends Application {

    Locale locale;

    @Override
    public void onCreate() {
        super.onCreate();
        PrefManager Prefs = new PrefManager(getApplicationContext());
        locale = Prefs.getLocale();

        // apply it until the app remains cached
        Locale.setDefault(locale);
        Configuration newConfig = new Configuration();
        newConfig.locale = locale;
        getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // apply it until the app remains cached
        Locale.setDefault(locale);
        Configuration Config = new Configuration();
        Config.locale = locale;
        getBaseContext().getResources().updateConfiguration(Config, getBaseContext().getResources().getDisplayMetrics());
    }

    static {
        ThemeManager.setDefaultTheme(ThemeManager.MIXED);
    }
}

Fix language when the device has been rotated (Language)


package uk.ac.ebi.quickgo.annotation.service.comm.rest.ontology.model;

import uk.ac.ebi.quickgo.rest.comm.ResponseType;

import java.util.List;

/**
 * Represents part of the model corresponding to the response available from the resource:
 *
 *

 *
/go/terms/{term}

 *

 *
 * This model captures the parts reached by the JSON path expression, "$.results.name".
 *
 * Created 07/04/17
 * @author Edd
 */
public class BasicOntology implements ResponseType {
    private List<Result> results;

    public BasicOntology() {}

    public List<Result> getResults() {
        return results;
    }

    public void setResults(List<Result> results) {
        this.results = results;
    }

    @Override public String toString() {
        return "ResponseType{" +
                "results=" + results +
                '}';
    }

    public static class Result {
        private String id;
        private String name;

        public Result() {}

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override public String toString() {
            return "Result{" +
                    "id='" + id + '\'' +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}

package uk.ac.ebi.quickgo.annotation.service.comm.rest.ontology.model;

import uk.ac.ebi.quickgo.rest.comm.ResponseType;

import java.util.List;

/**
 * Represents part of the model corresponding to the response available from the resource:
 *
 *

 *
/go/terms/{term}

 *

 *
 * or
 *
 *

 *
/eco/terms/{term}

 *

 *
 * This model captures the parts reached by the JSON path expression, "$.results.name".
 *
 * Created 07/04/17
 * @author Edd
 */
public class BasicOntology implements ResponseType {
    private List<Result> results;

    public BasicOntology() {}

    public List<Result> getResults() {
        return results;
    }

    public void setResults(List<Result> results) {
        this.results = results;
    }

    @Override public String toString() {
        return "ResponseType{" +
                "results=" + results +
                '}';
    }

    public static class Result {
        private String id;
        private String name;

        public Result() {}

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        @Override public String toString() {
            return "Result{" +
                    "id='" + id + '\'' +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}

Update the javadoc to show that the basic ontology information can come from go terms OR eco terms


package de.qaware.oss.cloud.service.billing.integration;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.logging.Logger;

@Singleton
@Startup
public class AutostartBean {

    @Inject
    private Logger logger;

    @PersistenceContext
    private EntityManager entityManager;

    @PostConstruct
    void autostart() {
        logger.info("Autostarting Billing service entity manager.");
    }
}

package de.qaware.oss.cloud.service.billing.integration;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.logging.Logger;

@Singleton
@Startup
public class AutostartBean {

    @Inject
    private Logger logger;

    @PersistenceContext
    private EntityManager entityManager;

    @PostConstruct
    void autostart() {
        logger.info("Autostarting Billing service entity manager.");
        entityManager.clear();
    }
}

Use entity manager on startup.

Use entity manager on startup.


/*
 * Copyright (C) 2012 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.stuff.pobj;

import java.util.Set;

import javax.validation.ConstraintViolation;

/**
 * Runtime exception thrown during {@link PersistentObject} operations.
 */
@SuppressWarnings("serial")
public class PersistentObjectValidationException extends PersistentObjectException {

    private final Set<ConstraintViolation<?>> violations;

    /**
     * Constructor.
     *
     * @param violations set of violations
     * @throws IllegalArgumentException if {@code violations} is null
     */
    public PersistentObjectValidationException(Set<ConstraintViolation<?>> violations) {
        this.violations = violations;
    }

    /**
     * Get the set of constraint violations.
     */
    public Set<ConstraintViolation<?>> getViolations() {
        return this.violations;
    }

    private static String generateMessage(Set<ConstraintViolation<?>> violations) {
        if (violations == null)
            throw new IllegalArgumentException("null violations");
        StringBuilder buf = new StringBuilder("object failed to validate with " + violations.size() + " violation(s): ");
        boolean first = true;
        for (ConstraintViolation<?> violation : violations) {
            if (first)
                first = false;
            else
                buf.append("; ");
            buf.append("[" + violation.getPropertyPath() + "]: " + violation.getMessage());
        }
        return buf.toString();
    }
}

/*
 * Copyright (C) 2012 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.stuff.pobj;

import java.util.Set;

import javax.validation.ConstraintViolation;

/**
 * Runtime exception thrown during {@link PersistentObject} operations.
 */
@SuppressWarnings("serial")
public class PersistentObjectValidationException extends PersistentObjectException {

    private final Set<ConstraintViolation<?>> violations;

    /**
     * Constructor.
     *
     * @param violations set of violations
     * @throws IllegalArgumentException if {@code violations} is null
     */
    public PersistentObjectValidationException(Set<ConstraintViolation<?>> violations) {
        super(PersistentObjectValidationException.generateMessage(violations));
        this.violations = violations;
    }

    /**
     * Get the set of constraint violations.
     */
    public Set<ConstraintViolation<?>> getViolations() {
        return this.violations;
    }

    private static String generateMessage(Set<ConstraintViolation<?>> violations) {
        if (violations == null)
            throw new IllegalArgumentException("null violations");
        StringBuilder buf = new StringBuilder("object failed to validate with " + violations.size() + " violation(s): ");
        boolean first = true;
        for (ConstraintViolation<?> violation : violations) {
            if (first)
                first = false;
            else
                buf.append("; ");
            buf.append("[" + violation.getPropertyPath() + "]: " + violation.getMessage());
        }
        return buf.toString();
    }
}

Fix bug in previous comit.

Fix bug in previous comit.


package bj.pranie.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

import javax.sql.DataSource;

/**
 * Created by Sebastian Sokolowski on 13.10.16.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    CustomAuthenticationProvider customAuthenticationProvider;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/",
                        "/week", "/week/*",
                        "/wm/*/*/*/*",
                        "/user/registration", "/user/restore",
                        "/images/*",
                        "/js/*").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/login")
                .defaultSuccessUrl("/week")
                .permitAll()
                .and()
                .logout()
                .permitAll();
    }

    @Autowired
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(customAuthenticationProvider);
    }
}

package bj.pranie.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

import javax.sql.DataSource;

/**
 * Created by Sebastian Sokolowski on 13.10.16.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    CustomAuthenticationProvider customAuthenticationProvider;

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/",
                        "/logout",
                        "/week", "/week/*",
                        "/wm/*/*/*/*",
                        "/user/registration", "/user/restore",
                        "/images/*",
                        "/js/*").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/login")
                .defaultSuccessUrl("/week")
                .permitAll()
                .and()
                .logout()
                .logoutUrl("/logout")
                .logoutSuccessUrl("/")
                .permitAll();
    }

    @Autowired
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(customAuthenticationProvider);
    }
}

Add logout url and regirect to main page after successful login.


/*
 * Copyright 2022 the original author or authors.
 *
 * 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 org.gradle.execution.plan;

import javax.annotation.Nullable;

/**
 * Represents a set of nodes reachable from a particular entry point node (a "requested task")
 */
public class OrdinalGroup extends NodeGroup {
    private final int ordinal;

    public OrdinalGroup(int ordinal) {
        this.ordinal = ordinal;
    }

    @Override
    public String toString() {
        return "task group " + ordinal;
    }

    @Nullable
    @Override
    public OrdinalGroup asOrdinal() {
        return this;
    }

    @Override
    public NodeGroup withOrdinalGroup(OrdinalGroup newOrdinal) {
        return newOrdinal;
    }

    @Override
    public boolean isReachableFromEntryPoint() {
        return true;
    }

    public int getOrdinal() {
        return ordinal;
    }
}

/*
 * Copyright 2022 the original author or authors.
 *
 * 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 org.gradle.execution.plan;

import javax.annotation.Nullable;

/**
 * Represents a set of nodes reachable from a particular entry point node (a "requested task")
 */
public class OrdinalGroup extends NodeGroup {
    private final int ordinal;

    public OrdinalGroup(int ordinal) {
        this.ordinal = ordinal;
    }

    @Override
    public String toString() {
        return "task group " + ordinal;
    }

    @Nullable
    @Override
    public OrdinalGroup asOrdinal() {
        return this;
    }

    @Override
    public NodeGroup withOrdinalGroup(OrdinalGroup newOrdinal) {
        return newOrdinal;
    }

    @Override
    public boolean isReachableFromEntryPoint() {
        return true;
    }

    public int getOrdinal() {
        return ordinal;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        OrdinalGroup that = (OrdinalGroup) o;

        return ordinal == that.ordinal;
    }

    @Override
    public int hashCode() {
        return ordinal;
    }
}

Add equals/hashCode to ordinal Group

Add equals/hashCode to ordinal Group

When loading the execution graph (nodes) from the configuration
cache, then new node groups are created for the ordinals. Since
those didn't have an equals/hashCode implementation, we ended
up having to different OrdinalGroups in OrdinalNodeAccess for
the destroyer tasks, although them having the same ordinal.

This caused clean tasks to run after the producer tasks when
loading from the configuration cache even though the command line
task order was different. See #20897.


package com.speedment.runtime.connector.sqlite.internal;

import com.speedment.runtime.config.Column;
import com.speedment.runtime.core.db.DbmsColumnHandler;

import java.util.function.Predicate;

/**
 * Implementation of {@link DbmsColumnHandler} for SQLite databases.
 *
 * @author Emil Forslund
 * @since  3.1.10
 */
public final class SqliteColumnHandler implements DbmsColumnHandler {
    @Override
    public Predicate<Column> excludedInInsertStatement() {
        return Column::isAutoIncrement;
    }

    @Override
    public Predicate<Column> excludedInUpdateStatement() {
        return col -> false;
    }
}

package com.speedment.runtime.connector.sqlite.internal;

import com.speedment.runtime.config.Column;
import com.speedment.runtime.core.db.DbmsColumnHandler;

import java.util.function.Predicate;

/**
 * Implementation of {@link DbmsColumnHandler} for SQLite databases.
 *
 * @author Emil Forslund
 * @since  3.1.10
 */
public final class SqliteColumnHandler implements DbmsColumnHandler {
    @Override
    public Predicate<Column> excludedInInsertStatement() {
        return col -> false;
    }

    @Override
    public Predicate<Column> excludedInUpdateStatement() {
        return col -> false;
    }
}

sqlite: Remove filter that excludes auto increment columns from persists


import com.github.sormuras.bach.Bach;
import com.github.sormuras.bach.ToolCall;
import com.github.sormuras.bach.ToolFinder;

class format {
  public static void main(String... args) throws Exception {
    var bach = Bach.ofDefaults().with(ToolFinder.ofJavaTools(".bach/external-tools"));
    if (bach.configuration().finder().find("format@1.15.0").isEmpty()) {
      bach.run(
          """
          load-and-verify
            .bach/external-tools/format@1.15.0/google-java-format-1.15.0-all-deps.jar
            https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar\
          #SIZE=3519780\
          &SHA-256=a356bb0236b29c57a3ab678f17a7b027aad603b0960c183a18f1fe322e4f38ea
          """);
    }
    var format = ToolCall.of("format@1.15.0").with("--replace").withFindFiles("**/*.java");
    bach.run("banner", "Format %d .java files".formatted(format.arguments().size() - 1));
    bach.run(format);
  }
}

import com.github.sormuras.bach.Bach;
import com.github.sormuras.bach.ToolCall;

class format {
  public static void main(String... args) throws Exception {
    var bach = Bach.ofDefaults();
    if (bach.configuration().finder().find("format@1.15.0").isEmpty()) {
      bach.run(
          """
          load-and-verify
            .bach/external-tools/format@1.15.0/google-java-format-1.15.0-all-deps.jar
            https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar\
          #SIZE=3519780\
          &SHA-256=a356bb0236b29c57a3ab678f17a7b027aad603b0960c183a18f1fe322e4f38ea
          """);
    }
    var format = ToolCall.of("format@1.15.0").with("--replace").withFindFiles("**/*.java");
    bach.run("banner", "Format %d .java files".formatted(format.arguments().size() - 1));
    bach.run(format);
  }
}

Use default Bach factory with its external tool finder


package com.obidea.semantika.cli2.command;

public class CommandFactory
{
   public static Command create(String command) throws Exception
   {
      if (command.startsWith(Command.SELECT)) {
         return new SelectCommand(command);
      }
      else if (command.startsWith(Command.SET_PREFIX)) {
         return new SetPrefixCommand(command);
      }
      else if (command.startsWith(Command.SHOW_PREFIXES)) {
         return new ShowPrefixesCommand(command);
      }
      throw new Exception("Unknown command"); //$NON-NLS-1$
   }
}

package com.obidea.semantika.cli2.command;

public class CommandFactory
{
   public static Command create(String command) throws Exception
   {
      if (startsWith(command, Command.SELECT)) {
         return new SelectCommand(command);
      }
      else if (startsWith(command, Command.SET_PREFIX)) {
         return new SetPrefixCommand(command);
      }
      else if (startsWith(command, Command.SHOW_PREFIXES)) {
         return new ShowPrefixesCommand(command);
      }
      throw new Exception("Unknown command"); //$NON-NLS-1$
   }

   private static boolean startsWith(String command, String keyword)
   {
      return command.startsWith(keyword) || command.startsWith(keyword.toUpperCase());
   }
}

Set the string comparison to ignore letter cases.


package se.claremont.autotest.common;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * The LogFolder class maintains the test run log folder for logging purposes of test based logs,
 * html based logs, summary log, screen shots and other assets that has to do with test resources
 * being saved along a test execution.
 *
 * Created by jordam on 2016-09-05.
 */
public class LogFolder {
    public static String testRunLogFolder = null;  //Used for test case logging
    @SuppressWarnings("FieldCanBeLocal")
    private static String baseLogFolder = null;     //Read from Settings

    /**
     * Sets the values to run time values.
     *
     * @param testSetName The name of the testSet. Normally used to get test case logs in correct folder
     */
    public static void setLogFolder(String testSetName){
        if(testRunLogFolder == null){
            baseLogFolder = TestRun.settings.getValue(Settings.SettingParameters.BASE_LOG_FOLDER);
            if(!baseLogFolder.endsWith("\\")){ baseLogFolder = baseLogFolder + "\\"; }
            testRunLogFolder = baseLogFolder + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + "_" + testSetName + "\\";
        }
    }
}

package se.claremont.autotest.common;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * The LogFolder class maintains the test run log folder for logging purposes of test based logs,
 * html based logs, summary log, screen shots and other assets that has to do with test resources
 * being saved along a test execution.
 *
 * Created by jordam on 2016-09-05.
 */
public class LogFolder {
    public static String testRunLogFolder = null;  //Used for test case logging
    @SuppressWarnings("FieldCanBeLocal")
    private static String baseLogFolder = null;     //Read from Settings

    /**
     * Sets the values to run time values.
     *
     * @param testSetName The name of the testSet. Normally used to get test case logs in correct folder
     */
    public static void setLogFolder(String testSetName){
        if(testRunLogFolder == null){
            baseLogFolder = TestRun.settings.getValue(Settings.SettingParameters.BASE_LOG_FOLDER);
            if(!baseLogFolder.endsWith("\\") || !baseLogFolder.endsWith("/")){ baseLogFolder = baseLogFolder + "\\"; }
            testRunLogFolder = baseLogFolder.replace("\\", File.separator).replace("/", File.separator) + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + "_" + testSetName + File.separator;
        }
    }
}

Fix for bad file separators for screenshots


/*
 * Copyright 2016-present Facebook, Inc.
 *
 * 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 com.facebook.buck.util.zip;

public enum ZipCompressionLevel {
  NONE(0),
  DEFAULT(6),
  MAX(9),
  ;

  private final int value;

  ZipCompressionLevel(int value) {
    this.value = value;
  }

  public int getValue() {
    return value;
  }
}

/*
 * Copyright 2016-present Facebook, Inc.
 *
 * 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 com.facebook.buck.util.zip;

public enum ZipCompressionLevel {
  NONE(0),
  MIN(1),
  DEFAULT(6),
  MAX(9),
  ;

  private final int value;

  ZipCompressionLevel(int value) {
    this.value = value;
  }

  public int getValue() {
    return value;
  }
}

Revert "[Cleanup] Remove unused MIN enum value."

Summary: This value is may already be used through configuration value.

Reviewed By: bobyangyf

fbshipit-source-id: a1c18fb219


package org.fakekoji;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
import java.nio.file.Path;

public class Utils {

    private static final ClassLoader classLoader = Utils.class.getClassLoader();

    public static String readResource(Path path) throws IOException {
        return readFile(classLoader.getResource(path.toString()));
    }

    public static String readFile(File file) throws IOException {
        final StringBuilder content = new StringBuilder();
        final FileReader fileReader = new FileReader(file);
        final BufferedReader bufferedReader = new BufferedReader(fileReader);
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            content.append(line);
        }
        bufferedReader.close();
        fileReader.close();
        return content.toString();
    }

    public static String readFile(URL url) throws IOException {
        return readFile(new File(url.getFile()));
    }

    public static void writeToFile(Path path, String content) throws IOException {
        writeToFile(path.toFile(), content);
    }

    public static void writeToFile(File file, String content) throws IOException {
        final PrintWriter writer = new PrintWriter(file.getAbsolutePath());
        writer.write(content);
        writer.flush();
        writer.close();
    }
}

package org.fakekoji;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;

import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;

public class Utils {

    private static final ClassLoader classLoader = Utils.class.getClassLoader();

    public static String readResource(Path path) throws IOException {
        return readFile(classLoader.getResource(path.toString()));
    }

    public static String readFile(File file) throws IOException {
        final StringBuilder content = new StringBuilder();
        final FileReader fileReader = new FileReader(file);
        final BufferedReader bufferedReader = new BufferedReader(fileReader);
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            content.append(line);
        }
        bufferedReader.close();
        fileReader.close();
        return content.toString();
    }

    public static String readFile(URL url) throws IOException {
        return readFile(new File(url.getFile()));
    }

    public static void writeToFile(Path path, String content) throws IOException {
        writeToFile(path.toFile(), content);
    }

    public static void writeToFile(File file, String content) throws IOException {
        final PrintWriter writer = new PrintWriter(file.getAbsolutePath());
        writer.write(content);
        writer.flush();
        writer.close();
    }

    public static void moveFile(File source, File target) throws IOException {
        Files.move(source.toPath(), target.toPath(), REPLACE_EXISTING);
    }
}

Create function for moving files

Create function for moving files


// Copyright (C) 2011 jOVAL.org.  All rights reserved.
// This software is licensed under the AGPL 3.0 license available at http://www.joval.org/agpl_v3.txt

package org.joval.os.windows.registry;

import org.joval.intf.windows.registry.IKey;
import org.joval.intf.windows.registry.IMultiStringValue;

/**
 * Representation of a Windows registry multi-string value.
 *
 * @author David A. Solin
 * @version %I% %G%
 */
public class MultiStringValue extends Value implements IMultiStringValue {
    String[] data;

    public MultiStringValue(IKey parent, String name, String[] data) {
	type = Type.REG_MULTI_SZ;
	this.parent = parent;
	this.name = name;
	this.data = data;
    }

    public String[] getData() {
	return data;
    }

    public String toString() {
	StringBuffer sb = new StringBuffer("MultiStringValue [Name=\"").append(name).append("\" Value={");
	for (int i=0; i < data.length; i++) {
	    if (i > 0) {
		sb.append(", ");
	    }
	    sb.append("\"").append(data[i]).append("\"");
	}
	sb.append("}]");
	return sb.toString();
    }
}

// Copyright (C) 2011 jOVAL.org.  All rights reserved.
// This software is licensed under the AGPL 3.0 license available at http://www.joval.org/agpl_v3.txt

package org.joval.os.windows.registry;

import org.joval.intf.windows.registry.IKey;
import org.joval.intf.windows.registry.IMultiStringValue;

/**
 * Representation of a Windows registry multi-string value.
 *
 * @author David A. Solin
 * @version %I% %G%
 */
public class MultiStringValue extends Value implements IMultiStringValue {
    String[] data;

    public MultiStringValue(IKey parent, String name, String[] data) {
	type = Type.REG_MULTI_SZ;
	this.parent = parent;
	this.name = name;
	this.data = data;
    }

    public String[] getData() {
	return data;
    }

    public String toString() {
	StringBuffer sb = new StringBuffer("MultiStringValue [Name=\"").append(name).append("\" Value=");
	if (data == null) {
	    sb.append("null");
	} else {
	    sb.append("{");
	    for (int i=0; i < data.length; i++) {
		if (i > 0) {
		    sb.append(", ");
		}
		sb.append("\"").append(data[i]).append("\"");
	    }
	    sb.append("}");
	}
	sb.append("]");
	return sb.toString();
    }
}

Handle REG_MULTI_SZ.toString when there the value is null (i.e., raw data is a single \0, not a double \0\0).


package se.chalmers.watchme.database;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
/**
 * The table in the database that holds data for Movies.
 *
 * @author lisastenberg
 */
public class MoviesTable {

	public static final String TABLE_MOVIES = "movies";

	public static final String COLUMN_MOVIE_ID = "_id";
	public static final String COLUMN_TITLE = "title";
	public static final String COLUMN_RATING = "rating";
	public static final String COLUMN_NOTE = "note";
	public static final String COLUMN_DATE = "releasedate";

	private static final String CREATE_MOVIES_TABLE = "CREATE TABLE "
			+ TABLE_MOVIES + "(" + COLUMN_MOVIE_ID + " INTEGER PRIMARY KEY,"
			+ COLUMN_TITLE + " TEXT," + COLUMN_RATING + " INTEGER," + COLUMN_NOTE
			+ " TEXT," + COLUMN_DATE + " INTEGER" + ")";

	public static void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_MOVIES_TABLE);
	}

	public static void onUpgrade(SQLiteDatabase db, int oldVersion,
			int newVersion) {
		Log.w(MoviesTable.class.getName(), "Upgrading database from version "
				+ oldVersion + " to " + newVersion
				+ ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_MOVIES);
		onCreate(db);
	}
}

package se.chalmers.watchme.database;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
/**
 * The table in the database that holds data for Movies.
 *
 * @author lisastenberg
 */
public class MoviesTable {

	public static final String TABLE_MOVIES = "movies";

	public static final String COLUMN_MOVIE_ID = "_id";
	public static final String COLUMN_TITLE = "title";
	public static final String COLUMN_RATING = "rating";
	public static final String COLUMN_NOTE = "note";
	public static final String COLUMN_DATE = "releasedate";
	public static final String COLUMN_IMDB_ID = "imdbid";

	private static final String CREATE_MOVIES_TABLE = "CREATE TABLE "
			+ TABLE_MOVIES + "(" + COLUMN_MOVIE_ID + " INTEGER PRIMARY KEY,"
			+ COLUMN_TITLE + " TEXT," + COLUMN_RATING + " INTEGER," + COLUMN_NOTE
			+ " TEXT," + COLUMN_DATE + " INTEGER," + COLUMN_IMDB_ID +" TEXT" + ")";

	public static void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_MOVIES_TABLE);
	}

	public static void onUpgrade(SQLiteDatabase db, int oldVersion,
			int newVersion) {
		Log.w(MoviesTable.class.getName(), "Upgrading database from version "
				+ oldVersion + " to " + newVersion
				+ ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_MOVIES);
		onCreate(db);
	}
}

Add IMDB ID column to Movies table

Add IMDB ID column to Movies table


package cpw.mods.fml.common;

import org.objectweb.asm.tree.ClassNode;

public interface IASMHook {
    /**
     * Inject the {@link Mod} class node into this instance. This allows retrieval from custom
     * attributes or other artifacts in your mod class
     *
     * @param modClassNode The mod class
     * @return optionally a code generated class that will be injected into the classloader
     */
    ClassNode inject(ClassNode modClassNode);
    /**
     * Allow mods to manipulate classes loaded from this {@link Mod}'s jar file. The {@link Mod}
     * class is always guaranteed to be called first
     *
     * @param node The class being loaded
     */
    void modifyClass(String className, ClassNode node);
}

package cpw.mods.fml.common;

import org.objectweb.asm.tree.ClassNode;

public interface IASMHook {
    /**
     * Inject the {@link Mod} class node into this instance. This allows retrieval from custom
     * attributes or other artifacts in your mod class
     *
     * @param modClassNode The mod class
     * @return optionally some code generated classes that will be injected into the classloader
     */
    ClassNode[] inject(ClassNode modClassNode);
    /**
     * Allow mods to manipulate classes loaded from this {@link Mod}'s jar file. The {@link Mod}
     * class is always guaranteed to be called first.
     * The node state should be changed in place.
     *
     * @param node The class being loaded
     */
    void modifyClass(String className, ClassNode node);
}

Tweak IASM hook api. You can return multiple classes now.


package de.innoaccel.wamp.server.converter;

public class MessageParseException extends Exception
{
    private String message;

    public MessageParseException(String message)
    {
        super("Cannot parse message");

        this.message = message;
    }

    public String getRawMessage()
    {
        return this.message;
    }
}

package de.innoaccel.wamp.server.converter;

public class MessageParseException extends Exception
{
}

Remove unnecessary message wrapper of exception


package net.katsuster.strview.media.ts;

import net.katsuster.strview.io.*;
import net.katsuster.strview.media.*;

/**
 * @author katsuhiro
 */
public class TSPacketList extends AbstractLargeList<TSPacket> {
    public LargeBitList buf;

    public TSPacketList() {
        super(LENGTH_UNKNOWN);
    }

    public TSPacketList(LargeBitList l) {
        super(LENGTH_UNKNOWN);

        buf = l;
    }

    @Override
    public void count() {
        setLength(buf.length() / 188 / 8);
    }

    @Override
    protected TSPacket getInner(long index) {
        TSPacket p = new TSPacket();
        FromBitBufferConverter c = new FromBitBufferConverter(BitBuffer.wrap(buf));

        c.doInit();
        c.position(index * 188 * 8);
        p.setNumber(index);
        p.setLevel(0);
        p.read(c);
        c.doFinal();

        return p;
    }

    @Override
    protected void setInner(long index, TSPacket data) {

    }
}

package net.katsuster.strview.media.ts;

import net.katsuster.strview.io.*;
import net.katsuster.strview.media.*;

/**
 * @author katsuhiro
 */
public class TSPacketList extends AbstractLargeList<TSPacket> {
    public LargeBitList buf;

    public TSPacketList() {
        super(LENGTH_UNKNOWN);
    }

    public TSPacketList(LargeBitList l) {
        super(LENGTH_UNKNOWN);

        buf = l;
    }

    @Override
    public void count() {
        setLength(buf.length() / 188 / 8);
    }

    @Override
    protected TSPacket getInner(long index) {
        TSPacket p = new TSPacket();
        FromBitListConverter c = new FromBitListConverter(buf);

        c.doInit();
        c.position(index * 188 * 8);
        p.setNumber(index);
        p.setLevel(0);
        p.read(c);
        c.doFinal();

        return p;
    }

    @Override
    protected void setInner(long index, TSPacket data) {

    }
}

Use LargeBitList instead of BitBuffer.

Use LargeBitList instead of BitBuffer.


/**
 * Copyright 2010 The PlayN Authors
 *
 * 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 playn.java;

import playn.core.LogImpl;

class JavaLog extends LogImpl {

  @Override
  protected void logImpl(Level level, String msg, Throwable e) {
    switch (level) {
    default:
      System.out.println(msg);
      if (e != null)
        e.printStackTrace(System.err);
      break;
    case WARN:
    case ERROR:
      System.err.println(msg);
      if (e != null)
        e.printStackTrace(System.out);
      break;
    }
  }
}

/**
 * Copyright 2010 The PlayN Authors
 *
 * 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 playn.java;

import playn.core.LogImpl;

class JavaLog extends LogImpl {

  @Override
  protected void logImpl(Level level, String msg, Throwable e) {
    switch (level) {
    default:
      System.out.println(msg);
      if (e != null)
        e.printStackTrace(System.out);
      break;
    case WARN:
    case ERROR:
      System.err.println(msg);
      if (e != null)
        e.printStackTrace(System.err);
      break;
    }
  }
}

Use out with out, err with err.

Use out with out, err with err.


package demo.mantle;

public class TestTool implements java.util.spi.ToolProvider {
  @Override
  public String name() {
    return "test(demo.mantle)";
  }

  @Override
  public int run(java.io.PrintWriter out, java.io.PrintWriter err, String... args) {
    try {
      checkMantle();
      return 0;
    } catch (Throwable t) {
      return 1;
    }
  }

  private static void checkMantle() {
    var mantle = new Mantle();
    var type = mantle.core.getClass();
    if (!type.getSimpleName().equals("PublicCore")) {
      throw new AssertionError("Expected PublicCore, but got: " + type);
    }
  }
}

package demo.mantle;

public class TestTool implements java.util.spi.ToolProvider {
  @Override
  public String name() {
    return "test(demo.mantle)";
  }

  @Override
  public int run(java.io.PrintWriter out, java.io.PrintWriter err, String... args) {
    try {
      checkMantle();
      return 0;
    } catch (Throwable throwable) {
      throwable.printStackTrace(err);
      return 1;
    }
  }

  private static void checkMantle() {
    var mantle = new Mantle();
    var type = mantle.core.getClass();
    if (!type.getSimpleName().equals("PublicCore")) {
      throw new AssertionError("Expected PublicCore, but got: " + type);
    }
  }
}

Print stack trace on error

Print stack trace on error


// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * Represents an Athenz Access Token
 *
 * @author bjorncs
 */
public class AthenzAccessToken {

    public static final String HTTP_HEADER_NAME = "Authorization";

    private static final String BEARER_TOKEN_PREFIX = "Bearer ";

    private final String value;

    public AthenzAccessToken(String value) {
        this.value = stripBearerTokenPrefix(value);
    }

    private static String stripBearerTokenPrefix(String rawValue) {
        String stripped = rawValue.strip();
        return stripped.startsWith(BEARER_TOKEN_PREFIX)
                ? stripped.substring(BEARER_TOKEN_PREFIX.length())
                : stripped;
    }

    public String value() { return value; }

    @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzAccessToken that = (AthenzAccessToken) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
}

// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * Represents an Athenz Access Token
 *
 * @author bjorncs
 */
public class AthenzAccessToken {

    public static final String HTTP_HEADER_NAME = "Authorization";

    private static final String BEARER_TOKEN_PREFIX = "Bearer ";

    private final String value;

    public AthenzAccessToken(String value) {
        this.value = stripBearerTokenPrefix(value);
    }

    private static String stripBearerTokenPrefix(String rawValue) {
        String stripped = rawValue.strip();
        String prefixRemoved = stripped.startsWith(BEARER_TOKEN_PREFIX)
                ? stripped.substring(BEARER_TOKEN_PREFIX.length()).strip()
                : stripped;
        if (prefixRemoved.isBlank()) {
            throw new IllegalArgumentException(String.format("Access token is blank: '%s'", prefixRemoved));
        }
        return prefixRemoved;
    }

    public String value() { return value; }

    @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzAccessToken that = (AthenzAccessToken) o;
        return Objects.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(value);
    }
}

Access tokens should not be an empty string