Data Request Broker
2-3-release

fr.gael.drb.impl.zip
Class ZipFileNode

java.lang.Object
  extended by fr.gael.drb.DrbDefaultNodesChangeProducer
      extended by fr.gael.drb.DrbAbstractNode
          extended by fr.gael.drb.impl.DrbNodeImpl
              extended by fr.gael.drb.impl.zip.ZipFileNode
All Implemented Interfaces:
DrbMutableNode, DrbNode, DrbNodesChangeListener, DrbNodesChangeProducer, EventListener

public class ZipFileNode
extends DrbNodeImpl

Zip File implementation


Field Summary
protected  ZipFile zipFile
          the ZipFile
 
Fields inherited from interface fr.gael.drb.DrbItem
ATTRIBUTE_ITEM, NODE_ITEM, UNDEFINED_ITEM, VALUE_ITEM
 
Constructor Summary
protected ZipFileNode(File file, DrbNode basenode)
          Builds a new ZipFileNode from a file.
protected ZipFileNode(InputStream in, DrbNode basenode)
          Builds a new ZipFileNode from an inputStream
protected ZipFileNode(ZipFile zip_file, DrbNode basenode)
          Builds a new ZipFileNode from a file.
 
Method Summary
protected  ZipNode createNode(ZipEntry currententry, DrbNode parent, ZipEntry[] children)
          This method create a zip node with a zip entry
 DrbAttributeList getAttributes()
          The attributes of the nodes.
 DrbNodeList getChildren()
          The children of the current node.
 ZipEntry[] getEntries()
          This method get entries from the zipFile or from the inputStream
 Object getImpl(Class api)
          Returns a specific implementation.
 int getIndex()
          The index of the node in the parent children list.
protected  InputStream getInputstream(ZipEntry zip_entry)
          Get the ZipInputStream
 String getName()
          Name of the node.
 DrbNode getParent()
          The parent of the current node.
 String getPath()
          The full path of the node.
 boolean hasImpl(Class api)
          Tests if a specific interface can be provided.
 
Methods inherited from class fr.gael.drb.impl.DrbNodeImpl
close, createAttribute, createNode, flush, getProvider
 
Methods inherited from class fr.gael.drb.DrbAbstractNode
allowsMultiOccurrence, appendChild, appendReference, equals, getAttribute, getChildAt, getChildrenCount, getContent, getFirstChild, getItemType, getLastChild, getNamedChild, getNamespaceBindings, getNamespaceURI, getNextSibling, getOccurrence, getPreviousSibling, getRoot, getValue, getValueType, getXPathName, getXPathName, hasChild, insertChild, removeChild, rename, replaceChild, setAttributes, setNamespaceBindings, setNamespaceURI, setValue, toString
 
Methods inherited from class fr.gael.drb.DrbDefaultNodesChangeProducer
addNodesChangeListener, getListenerList, nodesChanged, nodesInserted, nodesRemoved, removeNodesChangeListener, setListenerList, structureChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

zipFile

protected ZipFile zipFile
the ZipFile

Constructor Detail

ZipFileNode

protected ZipFileNode(InputStream in,
                      DrbNode basenode)
Builds a new ZipFileNode from an inputStream

Parameters:
in - The inputStream that contains the zip.
basenode - A reference to a the base node of an external implementation.

ZipFileNode

protected ZipFileNode(File file,
                      DrbNode basenode)
               throws IOException
Builds a new ZipFileNode from a file.

Parameters:
file - The file that contains the zip. This parameter shall never be null.
basenode - A reference to a the base node of an external implementation.
Throws:
IOException - This exception is raised when ZipFile can't be created

ZipFileNode

protected ZipFileNode(ZipFile zip_file,
                      DrbNode basenode)
               throws IOException
Builds a new ZipFileNode from a file.

Parameters:
zip_file - The file that contains the zip. This parameter shall never be null.
basenode - A reference to a the base node of an external implementation.
Throws:
IOException - This exception is raised when ZipFile can't be created
Method Detail

getPath

public String getPath()
The full path of the node. The full path is the full path of the parent node to witch is appended the name of the current node.

Warning: Because the occurence number of the current node is not known in the parent, the occurence qualifier is not support by the current implementation.A possible algorithm shall be to search a reference to the current node in the list of children of the parent.

If no parent have already been set no absolute path is considered. A path considering the current node has a root node is not valid for the factory and is therefore not significant in the current implementation.

Overrides:
getPath in class DrbAbstractNode
Returns:
The absolute path of the current node.

getEntries

public ZipEntry[] getEntries()
This method get entries from the zipFile or from the inputStream

Returns:
ZipEntry[] the list if the zip entry

getName

public String getName()
Name of the node. Returns the name of the node. This name is the canonical name of the node. It does not contains any prefix, path and location part. This name clearly identifies the node in its parent depending only from its occurence number and its index. All nodes provided by an implementation is named. Therefore this operation never returns null value. An empty string is however allowed if the node is unique (e.g. non named root node).

Overrides:
getName in class DrbAbstractNode
Returns:
The name of the node.

getIndex

public int getIndex()
The index of the node in the parent children list. This operation counts the previous sibling to retreive the index of the current node.

Overrides:
getIndex in class DrbAbstractNode
Returns:
The index of the current node.

getParent

public DrbNode getParent()
The parent of the current node. The base node (the one of the underlying implementation) is always returned.

Specified by:
getParent in class DrbAbstractNode
Returns:
A reference to the parent node if any or null otherwise.

createNode

protected ZipNode createNode(ZipEntry currententry,
                             DrbNode parent,
                             ZipEntry[] children)
This method create a zip node with a zip entry

Parameters:
currententry - The ZipEntry
parent - The parent of this node
children - the list of children
Returns:
ZipNode The new node created

getChildren

public DrbNodeList getChildren()
The children of the current node. This operation returns all entries in the ZIP archive.

Specified by:
getChildren in class DrbAbstractNode
Returns:
The list of children if any or null otherwise.

getAttributes

public final DrbAttributeList getAttributes()
The attributes of the nodes. This operation returns a list of attribute previously set (if any).

Overrides:
getAttributes in class DrbAbstractNode
Returns:
The list attributes of the current node or null if none.

getInputstream

protected InputStream getInputstream(ZipEntry zip_entry)
Get the ZipInputStream

Parameters:
zip_entry - the zip entry
Returns:
inputStream

hasImpl

public boolean hasImpl(Class api)
Tests if a specific interface can be provided. This operations tests with a minimum of time and memory consumption if the current implementation can provide a specific interface. It important to consider that hasImpl() provides information about the ability to provide such interface in general cases but not focused on the current instance. It may therefore be impossible to get a specific implementation from a node whereas hasImpl() operation returns true.

Overrides:
hasImpl in class DrbNodeImpl
Parameters:
api - The class type to test.
Returns:
true if an implementation of the interface can be provided and false otherwise.

getImpl

public Object getImpl(Class api)
Returns a specific implementation. This operation returns a reference to an object implementing a specific interface. This mean is useful to benefit by a specific and direct API instead of using the DrbNode interface. The provided object shall represent the current node such as it is possible after a call to this operation, to dismiss the reference to the node. For instance, a file is usually wrapped as a drb.impl.file.File class and thanks to this operation can be seen as a InputStream enabling direct access to the handled file.

Overrides:
getImpl in class DrbNodeImpl
Parameters:
api - The interface (or class) to be provided.
Returns:
A reference to the object implementing the interface or a null reference otherwise.

Data Request Broker - DRB API®
2-3-release

Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .