use of org.apache.poi.poifs.property.DirectoryProperty in project poi by apache.
the class DirectoryNode method createDirectory.
/**
* create a new DirectoryEntry
*
* @param name the name of the new DirectoryEntry
*
* @return the new DirectoryEntry
*
* @exception IOException
*/
public DirectoryEntry createDirectory(final String name) throws IOException {
DirectoryNode rval;
DirectoryProperty property = new DirectoryProperty(name);
if (_ofilesystem != null) {
rval = new DirectoryNode(property, _ofilesystem, this);
_ofilesystem.addDirectory(property);
} else {
rval = new DirectoryNode(property, _nfilesystem, this);
_nfilesystem.addDirectory(property);
}
((DirectoryProperty) getProperty()).addChild(property);
_entries.add(rval);
_byname.put(name, rval);
return rval;
}
use of org.apache.poi.poifs.property.DirectoryProperty in project poi by apache.
the class POIFSReader method processProperties.
private void processProperties(final BlockList small_blocks, final BlockList big_blocks, final Iterator<Property> properties, final POIFSDocumentPath path) throws IOException {
if (!properties.hasNext() && notifyEmptyDirectories) {
Iterator<POIFSReaderListener> listeners = registry.getListeners(path, ".");
while (listeners.hasNext()) {
POIFSReaderListener pl = listeners.next();
POIFSReaderEvent pe = new POIFSReaderEvent(null, path, null);
pl.processPOIFSReaderEvent(pe);
}
return;
}
while (properties.hasNext()) {
Property property = properties.next();
String name = property.getName();
if (property.isDirectory()) {
POIFSDocumentPath new_path = new POIFSDocumentPath(path, new String[] { name });
DirectoryProperty dp = (DirectoryProperty) property;
processProperties(small_blocks, big_blocks, dp.getChildren(), new_path);
} else {
int startBlock = property.getStartBlock();
Iterator<POIFSReaderListener> listeners = registry.getListeners(path, name);
if (listeners.hasNext()) {
int size = property.getSize();
OPOIFSDocument document = null;
if (property.shouldUseSmallBlocks()) {
document = new OPOIFSDocument(name, small_blocks.fetchBlocks(startBlock, -1), size);
} else {
document = new OPOIFSDocument(name, big_blocks.fetchBlocks(startBlock, -1), size);
}
while (listeners.hasNext()) {
POIFSReaderListener listener = listeners.next();
listener.processPOIFSReaderEvent(new POIFSReaderEvent(new DocumentInputStream(document), path, name));
}
} else {
// consume the document's data and discard it
if (property.shouldUseSmallBlocks()) {
small_blocks.fetchBlocks(startBlock, -1);
} else {
big_blocks.fetchBlocks(startBlock, -1);
}
}
}
}
}
use of org.apache.poi.poifs.property.DirectoryProperty in project poi by apache.
the class DirectoryNode method createDocument.
/**
* create a new DocumentEntry
*
* @param document the new document
*
* @return the new DocumentEntry
*
* @exception IOException
*/
DocumentEntry createDocument(final NPOIFSDocument document) throws IOException {
DocumentProperty property = document.getDocumentProperty();
DocumentNode rval = new DocumentNode(property, this);
((DirectoryProperty) getProperty()).addChild(property);
_nfilesystem.addDocument(document);
_entries.add(rval);
_byname.put(property.getName(), rval);
return rval;
}
use of org.apache.poi.poifs.property.DirectoryProperty in project poi by apache.
the class DirectoryNode method createDocument.
/**
* create a new DocumentEntry
*
* @param document the new document
*
* @return the new DocumentEntry
*
* @exception IOException
*/
DocumentEntry createDocument(final OPOIFSDocument document) throws IOException {
DocumentProperty property = document.getDocumentProperty();
DocumentNode rval = new DocumentNode(property, this);
((DirectoryProperty) getProperty()).addChild(property);
_ofilesystem.addDocument(document);
_entries.add(rval);
_byname.put(property.getName(), rval);
return rval;
}
use of org.apache.poi.poifs.property.DirectoryProperty in project poi by apache.
the class OPOIFSFileSystem method processProperties.
private void processProperties(final BlockList small_blocks, final BlockList big_blocks, final Iterator<Property> properties, final DirectoryNode dir, final int headerPropertiesStartAt) throws IOException {
while (properties.hasNext()) {
Property property = properties.next();
String name = property.getName();
DirectoryNode parent = (dir == null) ? ((DirectoryNode) getRoot()) : dir;
if (property.isDirectory()) {
DirectoryNode new_dir = (DirectoryNode) parent.createDirectory(name);
new_dir.setStorageClsid(property.getStorageClsid());
processProperties(small_blocks, big_blocks, ((DirectoryProperty) property).getChildren(), new_dir, headerPropertiesStartAt);
} else {
int startBlock = property.getStartBlock();
int size = property.getSize();
OPOIFSDocument document = null;
if (property.shouldUseSmallBlocks()) {
document = new OPOIFSDocument(name, small_blocks.fetchBlocks(startBlock, headerPropertiesStartAt), size);
} else {
document = new OPOIFSDocument(name, big_blocks.fetchBlocks(startBlock, headerPropertiesStartAt), size);
}
parent.createDocument(document);
}
}
}
Aggregations