Class CifBuilder


  • public class CifBuilder
    extends Object
    Allows the creation of CifFile instances which were not read from some InputStream. The builder follows a stepwise approach (i.e. the builder does not always return itself, but rather several subclasses provide builder-functions relevant in a specific context). The implementation represents the hierarchy of a CifFile (file - block - category - column - data) by a D3-like approach: enter is used to move to a more fine-grained level of information (e.g. file to block), while leave does the opposite. By following this approach, all elements are aware of their parent and all parents can process information from their children appropriately. It is also possible to create builder instances for categories or columns directly, however they need to be added explicitly by functions like CategoryBuilder.addColumn(Column). As for many parts of this library, absolutely no checks are performed - e.g. the number of rows in columns connected by a category can be different which will cause all sorts of issues. However, it is up to the user to ensure data integrity.
    • Constructor Detail

      • CifBuilder

        public CifBuilder()
        Create a new builder instance.
    • Method Detail

      • enterBlock

        public BlockBuilder enterBlock​(String blockName)
        Dive into a block captured by this builder.
        Parameters:
        blockName - the name of this block - usually the pdbId for protein structures
        Returns:
        the BlockBuilder instance
      • leaveFile

        public CifFile leaveFile()
        Process all stored information and release a CifFile instance. Equal to build() for this builder class.
        Returns:
        the created CifFile
      • build

        public CifFile build()
        Process all stored information and release a CifFile instance. Equal to leaveFile() for this builder class.
        Returns:
        the created CifFile
      • addBlock

        public CifBuilder addBlock​(Block block)
        Add an arbitrary block and make this builder aware of it.
        Parameters:
        block - the block to add
        Returns:
        this CifBuilder instance