Class IOFactory
- java.lang.Object
-
- de.uni_trier.wi2.procake.utils.io.IOFactory
-
- All Implemented Interfaces:
Factory
public class IOFactory extends Object implements Factory
This factory contains all registeredReader,Writer, andContentHandlerof the ProCAKE.To way how to get a io component is always the same:
- request the io names that are able to handle a given class
- request the io component with one of the names
For example, to get an parser for a
Modelthe Java code would be:String names[] = IOFactory.getReaderNamesFor(Model.class); if (names.length == 0) throw new CakeIOException(IO.COMPONENT, IO.LOG_READER_NOT_FOUND, this, Model.class); Reader reader = (Reader) IOFactory.newIO(names[0]); reader.setFilename("..."); Model model = (Model) reader.read();It is guaranteed that you can cast the result of an reader or content handler to the class for that you have requested the reader.
- Author:
- Rainer Maximini, Maximilian Hoffmann
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddParameter(AbstractParameter param)Adds a parameter to this factory.static booleanbind(IO implementation)booleanbind(Object implementation)Bind an implementation to the factory.static List<String>getContentHandlerNamesFor(Class value)Returns a list of names of theContentHandlers that are capable to read the given class.static List<String>getContentHandlerNamesFor(Object value)Returns a list of names of theContentHandlers that are capable to read the given object.static List<String>getFamiliarContentHandler(String familyName)Returns a list of names ofContentHandlers, which are capable of handling files for the given familyName.static List<String>getFamiliarWriter(String familyName)Returns a list of names ofWriters, which are of the same family as the given familyName.static List<String>getFamiliarWriter(String familyName, Class forClass)Returns a list of names ofWriters, which are of the same family as the given familyName AND are capable of writing the given object-class.static List<String>getIONames()static StringgetParameter(String key)static List<String>getReaderNamesFor(Class value)Returns a list of names of theReaders that are capable to read the given class.static List<String>getReaderNamesFor(Object value)Returns a list of names of theReaders that are capable to read the given object.static List<String>getWriterNamesFor(Class value)Returns a list of names of theWriters that are capable to read the given class.static List<String>getWriterNamesFor(Object value)Returns a list of names of theWriters that are capable to read the given object.static IOnewIO(String name)Creates a new instance of the io component with the given name.voidreset()This method has to be implemented by every factory in order to allow a proper restart of ProCAKE.static booleanunbind(IO implementation)booleanunbind(Object implementation)Unbinds an implementation from the factory.
-
-
-
Method Detail
-
bind
public static boolean bind(IO implementation)
-
getContentHandlerNamesFor
public static List<String> getContentHandlerNamesFor(Class value)
Returns a list of names of theContentHandlers that are capable to read the given class.- Parameters:
value- TheContentHandlermust be capable to read this class.- Returns:
- Returns a list of names of the
ContentHandlers that are capable to read the given class.
-
getContentHandlerNamesFor
public static List<String> getContentHandlerNamesFor(Object value)
Returns a list of names of theContentHandlers that are capable to read the given object.- Parameters:
value- TheContentHandlermust be capable to read this object.- Returns:
- Returns a list of names of the
ContentHandlers that are capable to read the given object.
-
getIONames
public static List<String> getIONames()
- Returns:
- Returns a list of names of all io components that are registered.
-
getReaderNamesFor
public static List<String> getReaderNamesFor(Class value)
Returns a list of names of theReaders that are capable to read the given class.
-
getReaderNamesFor
public static List<String> getReaderNamesFor(Object value)
Returns a list of names of theReaders that are capable to read the given object.
-
getWriterNamesFor
public static List<String> getWriterNamesFor(Class value)
Returns a list of names of theWriters that are capable to read the given class.
-
getWriterNamesFor
public static List<String> getWriterNamesFor(Object value)
Returns a list of names of theWriters that are capable to read the given object.
-
getFamiliarWriter
public static List<String> getFamiliarWriter(String familyName)
Returns a list of names ofWriters, which are of the same family as the given familyName.- Parameters:
familyName-- Returns:
-
getFamiliarWriter
public static List<String> getFamiliarWriter(String familyName, Class forClass)
Returns a list of names ofWriters, which are of the same family as the given familyName AND are capable of writing the given object-class.- Returns:
-
getFamiliarContentHandler
public static List<String> getFamiliarContentHandler(String familyName)
Returns a list of names ofContentHandlers, which are capable of handling files for the given familyName.- Parameters:
familyName-- Returns:
-
newIO
public static IO newIO(String name)
Creates a new instance of the io component with the given name.- Parameters:
name- The name of the IO object.- Returns:
- A new IO object.
-
unbind
public static boolean unbind(IO implementation)
-
reset
public void reset()
Description copied from interface:FactoryThis method has to be implemented by every factory in order to allow a proper restart of ProCAKE. For example, this method might reset the default factory object or other stateful variables.
-
addParameter
public void addParameter(AbstractParameter param)
Description copied from interface:FactoryAdds a parameter to this factory.- Specified by:
addParameterin interfaceFactory- Parameters:
param- the parameter to add
-
bind
public boolean bind(Object implementation)
Description copied from interface:FactoryBind an implementation to the factory.- Specified by:
bindin interfaceFactory- Parameters:
implementation- The object to bind.- Returns:
trueif the factory accept the implementation, otherwisefalse.- See Also:
Factory.bind(java.lang.Object)
-
unbind
public boolean unbind(Object implementation)
Description copied from interface:FactoryUnbinds an implementation from the factory.- Specified by:
unbindin interfaceFactory- Parameters:
implementation- The object to unbind.- Returns:
trueif the factory accept the implementation, otherwisefalse.- See Also:
Factory.unbind(java.lang.Object)
-
-