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 registered ProCAKEReadera and ProCAKEWriters of 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);
 ProCAKEReader reader = (ProCAKEReader) 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 Details

    • bind

      public static boolean bind(IO implementation)
    • getContentHandlerNamesFor

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

      public static List<String> getContentHandlerNamesFor(Object value)
      Returns a list of names of the content handlers that are capable to read the given object.
      Parameters:
      value - The content handler must be capable to read this object.
      Returns:
      Returns a list of names of the content handlers 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 ProCAKEReaders that are capable to read the given class.
      Parameters:
      value - The ProCAKEReader must be capable to read this class.
      Returns:
      Returns a list of names of the ProCAKEReaders that are capable to read the given class.
    • getReaderNamesFor

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

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

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

      public static List<String> getFamiliarWriter(String familyName)
      Returns a list of names of ProCAKEWriters, 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 ProCAKEWriters, 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 content handlers, 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:
    • 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: