scpsolver.lpsolver
Class SolverFactory

java.lang.Object
  extended by scpsolver.lpsolver.SolverFactory

public class SolverFactory
extends java.lang.Object

Basic service provider for the LinearProgramSolver interface. Loads all found classes and returns the first found class, if required. Implementation mainly inspired by

Author:
michael

Method Summary
static LinearProgramSolver getSolver(java.lang.String name)
          Tries to get a specific solver by its name.
static void main(java.lang.String[] args)
           
static LinearProgramSolver newDefault()
          Searches for service provider of the LinearProgramSolver service and returns the first instance it found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newDefault

public static LinearProgramSolver newDefault()
Searches for service provider of the LinearProgramSolver service and returns the first instance it found. If no service was found, it prints the stack trace to stderr and returns null. When this method is first invoked, it initializes the ServiceLoader, which locates available services from the classpath. Subsequent calls use the result of this first initialization. Therefore, if there are no available services at the moment of the first call, there will be no available services for the rest of the program run. Future implementations might ignore this problem.

Returns:
the first LinearProgramSolver Service Provider found

getSolver

public static LinearProgramSolver getSolver(java.lang.String name)
Tries to get a specific solver by its name. Like the newDefault method, the getSolver method searches through the list of service providers and compares the name parameter to the result of the method call getName of every service provider, until either the matching service provider is found and returned or there are no further service providers available. In this case, the method returns the same result as the newDefault method.

Parameters:
name - the name of the requested linear program solver
Returns:
an instance of the requested solver, if it was found or the result of the newDefault method call

main

public static void main(java.lang.String[] args)