Package org.rcsb.cif.model.builder
Class CifBuilder
- java.lang.Object
-
- org.rcsb.cif.model.builder.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:enteris 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 likeCategoryBuilder.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 Summary
Constructors Constructor Description CifBuilder()Create a new builder instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CifBuilderaddBlock(Block block)Add an arbitrary block and make this builder aware of it.CifFilebuild()Process all stored information and release aCifFileinstance.BlockBuilderenterBlock(String blockName)Dive into a block captured by this builder.CifFileleaveFile()Process all stored information and release aCifFileinstance.
-
-
-
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 aCifFileinstance. Equal tobuild()for this builder class.- Returns:
- the created CifFile
-
build
public CifFile build()
Process all stored information and release aCifFileinstance. Equal toleaveFile()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
-
-