@Platform(include="<nix/File.hpp>") @Platform(value="linux",link="nix@.1",preload="hdf5@.7") @Platform(value="windows",link="nix",preload={"hdf5","msvcp120","msvcr120","szip","zlib"}) @Namespace(value="nix") public class File extends ImplContainer implements Comparable<File>
Constructor and Description |
---|
File()
Constructor that creates an uninitialized File.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the file.
|
int |
compareTo(File file) |
Block |
createBlock(String name,
String type)
Create an new block, that is immediately persisted in the file.
|
Section |
createSection(String name,
String type)
Creates a new Section with a given name and type.
|
boolean |
deleteBlock(Block block)
Deletes a block from the file.
|
boolean |
deleteBlock(String nameOrId)
Deletes a block from the file.
|
boolean |
deleteSection(Section section)
Deletes the Section.
|
boolean |
deleteSection(String nameOrId)
Deletes the Section that is specified with the id.
|
List<Section> |
findSections(int maxDepth)
Get all sections in this file recursively.
|
List<Section> |
findSections(java.util.function.Predicate<Section> filter,
int maxDepth)
Get all sections in this file recursively.
|
void |
forceCreatedAt(Date date)
Sets the creation date to the provided value even if the attribute is set.
|
void |
forceUpdatedAt()
Sets the time of the last update to the current time.
|
Block |
getBlock(long index)
Read an existing with block from the file, addressed by index.
|
Block |
getBlock(String nameOrId)
Read an existing block from the file.
|
long |
getBlockCount()
Get the number of blocks in in the file.
|
List<Block> |
getBlocks()
Get all blocks within this file.
|
List<Block> |
getBlocks(java.util.function.Predicate<Block> filter)
Get all blocks within this file.
|
Date |
getCreatedAt()
Get the creation date of the file.
|
String |
getFormat()
Read the format hint from the file.
|
String |
getLocation()
Return the location / uri.
|
Section |
getSection(long index)
Get root section with a given index/position.
|
Section |
getSection(String nameOrId)
Get a root section with the given name/id.
|
long |
getSectionCount()
Returns the number of root sections stored in the File.
|
List<Section> |
getSections()
Get all root sections within this file.
|
List<Section> |
getSections(java.util.function.Predicate<Section> filter)
Get all root sections within this file.
|
Date |
getUpdatedAt()
Get the date of the last update.
|
int[] |
getVersion()
Read the NIX format version from the file.
|
boolean |
hasBlock(Block block)
Check if a block exists in the file.
|
boolean |
hasBlock(String nameOrId)
Check if a block exists in the file.
|
boolean |
hasSection(Section section)
Check if a specific root section exists in the file.
|
boolean |
hasSection(String nameOrId)
Check if a specific root section exists in the file.
|
boolean |
isNone()
Check if entity is null
|
boolean |
isOpen()
Check if the file is currently open.
|
static File |
open(String name)
Opens a file in ReadWrite mode and with back-end implementation in hdf5.
|
static File |
open(String name,
int mode)
Opens a file with back-end implementation in hdf5.
|
static File |
open(String name,
int mode,
String impl)
Opens a file.
|
void |
setCreatedAt()
Sets the creation time to the current time if the field is not set.
|
void |
setUpdatedAt()
Sets the time of the last update to the current time if the field is not set.
|
Result |
validate()
Validator.
|
isInitialized
address, asBuffer, asByteBuffer, capacity, capacity, deallocate, deallocate, deallocateReferences, equals, fill, hashCode, isNull, limit, limit, memchr, memcmp, memcpy, memmove, memset, offsetof, position, position, put, setNull, sizeof, toString, zero
public File()
Calling any method on an uninitialized file will throw a RuntimeException
.
@Cast(value="bool") public boolean isNone()
ImplContainer
isNone
in class ImplContainer
@ByVal public static File open(@StdString String name, @Cast(value="nix::FileMode") int mode, @StdString String impl)
public static File open(@StdString String name, int mode)
@ByVal public static File open(@StdString String name)
name
- The name/path of the file.@Name(value="blockCount") public long getBlockCount()
Block
@Cast(value="bool") public boolean hasBlock(@StdString String nameOrId)
nameOrId
- Name or ID of the block.Block
@Cast(value="bool") public boolean hasBlock(@Const @ByRef Block block)
block
- The block to check.Block
@ByVal public Block getBlock(@StdString String nameOrId)
nameOrId
- Name or ID of the block.Block
@ByVal public Block getBlock(@Cast(value="size_t") long index)
index
- The index of the block to read.Block
@ByVal public Block createBlock(@StdString String name, @StdString String type)
name
- The name of the block.type
- The type of the block.Block
@Cast(value="bool") public boolean deleteBlock(@StdString String nameOrId)
nameOrId
- Name or id of the block to delete.Block
@Cast(value="bool") public boolean deleteBlock(@Const @ByRef Block block)
block
- The block to delete.Block
public List<Block> getBlocks()
Block
public List<Block> getBlocks(java.util.function.Predicate<Block> filter)
The parameter filter can be used to filter block by various criteria.
filter
- A filter function.Block
@Cast(value="bool") public boolean hasSection(@StdString String nameOrId)
nameOrId
- Name or ID of the section.Section
@Cast(value="bool") public boolean hasSection(@Const @ByRef Section section)
section
- The section to check.Section
public Section getSection(String nameOrId)
nameOrId
- Name or id of the section.Section
public Section getSection(long index)
index
- The index of the section.Section
@Name(value="sectionCount") public long getSectionCount()
Section
public List<Section> getSections()
The parameter filter can be used to filter sections by various criteria. By default a filter is used that accepts all sections.
Section
public List<Section> getSections(java.util.function.Predicate<Section> filter)
The parameter filter can be used to filter sections by various criteria.
filter
- A filter function.Section
public List<Section> findSections(java.util.function.Predicate<Section> filter, int maxDepth)
This method traverses the trees of all section in the file. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list.
filter
- A filter function.maxDepth
- The maximum depth of traversal.Section
public List<Section> findSections(int maxDepth)
This method traverses the trees of all section in the file. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
maxDepth
- The maximum depth of traversal.Section
public Section createSection(String name, String type)
name
- The name of the section.type
- The type of the section.Section
@Cast(value="bool") public boolean deleteSection(@StdString String nameOrId)
nameOrId
- Name or id of the section to delete.Section
@Cast(value="bool") public boolean deleteSection(@Const @ByRef Section section)
section
- The section to delete.Section
public int[] getVersion()
The version consist of three integers standing for the major, minor and patch version of the nix format.
@Name(value="format") @StdString public String getFormat()
@Name(value="location") @StdString public String getLocation()
public Date getCreatedAt()
public Date getUpdatedAt()
public void setUpdatedAt()
public void forceUpdatedAt()
public void setCreatedAt()
public void forceCreatedAt(Date date)
date
- The creation date to set.public void close()
@Cast(value="bool") public boolean isOpen()
public int compareTo(File file)
compareTo
in interface Comparable<File>
Copyright © 2016. All rights reserved.