Package org.utplsql.api.reporter
Class ReporterFactory
- java.lang.Object
-
- org.utplsql.api.reporter.ReporterFactory
-
- All Implemented Interfaces:
oracle.jdbc.internal.ObjectDataFactory,oracle.sql.ORADataFactory
public final class ReporterFactory extends Object implements oracle.sql.ORADataFactory
This class manages the instantiation of reporters. One can register a supplier method for a specific name which will then be callable via createReporter(name)Use the static createEmpty or createDefault methods to get a new instance. We don't allow direct instantiation because we want
- Register default ReporterFactoryMethods for Core-Reporters
- Be able to add more than one ReporterFactory implementation due to backwards-compatibility in future
- Author:
- pesse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReporterFactory.ReporterFactoryMethodInfo
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description oracle.sql.ORADatacreate(oracle.sql.Datum d, int sqlType)static ReporterFactorycreateDefault(CompatibilityProxy proxy)Returns a new instance of a ReporterFactory with the default ReporterFactoryMethods registered.static ReporterFactorycreateEmpty()Returns a new instance of an empty ReporterFactory with no registered ReporterFactoryMethods Normally, you should be using createDefault-method instead.ReportercreateReporter(String reporterName)Returns a new reporter of the given name (or should do so).ReportercreateReporter(String reporterName, Object[] attributes)Returns a new reporter of the given name.Map<String,String>getRegisteredReporterInfo()Returns a set of all registered reporter's namesbooleanhasRegisteredFactoryMethodFor(String reporterName)Checks whether a given reporter has a registered FactoryMethod or notReporterFactory.ReporterFactoryMethodInforegisterReporterFactoryMethod(String reporterName, BiFunction<String,Object[],? extends Reporter> factoryMethod, String description)Registers a creation method for a specified reporter name.ReporterFactory.ReporterFactoryMethodInfounregisterReporterFactoryMethod(String reporterName)Unregisters a specified reporter name.
-
-
-
Method Detail
-
createEmpty
public static ReporterFactory createEmpty()
Returns a new instance of an empty ReporterFactory with no registered ReporterFactoryMethods Normally, you should be using createDefault-method instead.- Returns:
- a new ReporterFactory instance
-
createDefault
public static ReporterFactory createDefault(CompatibilityProxy proxy)
Returns a new instance of a ReporterFactory with the default ReporterFactoryMethods registered. This can depend on the version of utPLSQL, therefore you have to provide a CompatibilityProxy- Parameters:
proxy- Compatibility proxy- Returns:
- a new ReporterFactory instance with all default ReporterFactoryMethods registered
-
registerReporterFactoryMethod
public ReporterFactory.ReporterFactoryMethodInfo registerReporterFactoryMethod(String reporterName, BiFunction<String,Object[],? extends Reporter> factoryMethod, String description)
Registers a creation method for a specified reporter name. Overrides eventually existing creation method- Parameters:
reporterName- the reporter's name to registerfactoryMethod- the method which will return the reporterdescription- the description of the reporter- Returns:
- Object with information about the registered reporter
-
unregisterReporterFactoryMethod
public ReporterFactory.ReporterFactoryMethodInfo unregisterReporterFactoryMethod(String reporterName)
Unregisters a specified reporter name.- Parameters:
reporterName- the reporter's name to unregister- Returns:
- information about the reporter which was previously registered or null
-
hasRegisteredFactoryMethodFor
public boolean hasRegisteredFactoryMethodFor(String reporterName)
Checks whether a given reporter has a registered FactoryMethod or not- Parameters:
reporterName- the reporter's name- Returns:
- true or false
-
createReporter
public Reporter createReporter(String reporterName, @Nullable Object[] attributes)
Returns a new reporter of the given name. If no specific ReporterFactoryMethod is registered, returns a default {Reporter}- Parameters:
reporterName- the reporter's name to create a new instance ofattributes- attributes from STRUCT- Returns:
- A reporter
-
createReporter
public Reporter createReporter(String reporterName)
Returns a new reporter of the given name (or should do so). If no specific ReporterFactoryMethod is registered, returns a default {Reporter}- Parameters:
reporterName- Name of the reporter- Returns:
- Reporter
-
getRegisteredReporterInfo
public Map<String,String> getRegisteredReporterInfo()
Returns a set of all registered reporter's names- Returns:
- Map of reporter names
-
create
public oracle.sql.ORAData create(oracle.sql.Datum d, int sqlType) throws SQLException- Specified by:
createin interfaceoracle.sql.ORADataFactory- Throws:
SQLException
-
-