Class IOFactory

  • All Implemented Interfaces:
    Factory

    public class IOFactory
    extends Object
    implements Factory
    This factory contains all registered Reader, Writer, and ContentHandler of the ProCAKE.

    To way how to get a io component is always the same:

    1. request the io names that are able to handle a given class
    2. request the io component with one of the names

    For example, to get an parser for a Model the 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 Detail

      • bind

        public static boolean bind​(IO implementation)
      • getContentHandlerNamesFor

        public static List<String> getContentHandlerNamesFor​(Class value)
        Returns a list of names of the ContentHandlers that are capable to read the given class.
        Parameters:
        value - The ContentHandler must 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 the ContentHandlers that are capable to read the given object.
        Parameters:
        value - The ContentHandler must 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 the Readers that are capable to read the given class.
        Parameters:
        value - The Reader must be capable to read this class.
        Returns:
        Returns a list of names of the Readers that are capable to read the given class.
      • getReaderNamesFor

        public static List<String> getReaderNamesFor​(Object value)
        Returns a list of names of the Readers that are capable to read the given object.
        Parameters:
        value - The Reader must be capable to read this object.
        Returns:
        Returns a list of names of the Readers that are capable to read the given object.
      • getWriterNamesFor

        public static List<String> getWriterNamesFor​(Class value)
        Returns a list of names of the Writers that are capable to read the given class.
        Parameters:
        value - The Writer must be capable to read this class.
        Returns:
        Returns a list of names of the Writers that are capable to read the given class.
      • getWriterNamesFor

        public static List<String> getWriterNamesFor​(Object value)
        Returns a list of names of the Writers that are capable to read the given object.
        Parameters:
        value - The Writer must be capable to read this object.
        Returns:
        Returns a list of names of the Writers that are capable to read the given object.
      • getFamiliarWriter

        public static List<String> getFamiliarWriter​(String familyName)
        Returns a list of names of Writers, 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 of Writers, 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 of ContentHandlers, 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)
      • getParameter

        public static String getParameter​(String key)
      • reset

        public void reset()
        Description copied from interface: Factory
        This 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.
        Specified by:
        reset in interface Factory
      • addParameter

        public void addParameter​(AbstractParameter param)
        Description copied from interface: Factory
        Adds a parameter to this factory.
        Specified by:
        addParameter in interface Factory
        Parameters:
        param - the parameter to add
      • bind

        public boolean bind​(Object implementation)
        Description copied from interface: Factory
        Bind an implementation to the factory.
        Specified by:
        bind in interface Factory
        Parameters:
        implementation - The object to bind.
        Returns:
        true if the factory accept the implementation, otherwise false .
        See Also:
        Factory.bind(java.lang.Object)
      • unbind

        public boolean unbind​(Object implementation)
        Description copied from interface: Factory
        Unbinds an implementation from the factory.
        Specified by:
        unbind in interface Factory
        Parameters:
        implementation - The object to unbind.
        Returns:
        true if the factory accept the implementation, otherwise false .
        See Also:
        Factory.unbind(java.lang.Object)