com.funambol.syncml.client
Class FileObject

java.lang.Object
  extended by com.funambol.syncml.client.FileObject

public class FileObject
extends java.lang.Object

This class represents a FileObject which is a file with its meta information as defined by OMA (see OMA File Data Object Specification for more details). This class actually stores the meta information, while the actual content is not part of it. The reason is that in general the content of a file cannot be kept in memory, so the class could just store a URL or a stream, but at the moment this is not even supported as this need is not forseen. Beside storing the file object meta information, this class has also the ability to parse/format an item (at least its meta info). For this purpose there are two sets of methods:
parsePrologue, parseEpilogue and parse
formatPrologue and formatEpilogue Parsing is split between the prologue (everything up to the body content [escluded]) and the epilogue (everything after the body content). If the item is known to be small, then it can be parsed in one shot via the parse method. Formatting is als split between the prologue and the epilogue


Constructor Summary
FileObject()
           
 
Method Summary
 java.lang.String formatEpilogue()
          Formats the epilogue of this file object.
 java.lang.String formatEpilogue(boolean formatBody)
          Formats the epilogue of this file object.
 java.lang.String formatPrologue()
          Formats the prologue of this file object.
 java.lang.String formatPrologue(boolean formatBody)
          Formats the prologue of this file object.
 java.util.Date getAccessed()
          Gets the last accessed time
 boolean getArchived()
          Gets the archived attribute
 java.util.Date getCreated()
          Gets the creation time
 boolean getDeleted()
          Gets the deleted attribute
 boolean getExecutable()
          Gets the executable attribute
 boolean getHidden()
          Gets the hidden attribute
 java.util.Date getModified()
          Gets the modification time
 java.lang.String getName()
          Gets the file name
 boolean getReadable()
          Gets the readable attribute
 int getSize()
          Gets the file size.
 boolean getSystem()
          Gets the system attribute
 boolean getWritable()
          Gets the writable attribute
 boolean isBodyBase64()
          Returns true if the body is encoded in base64 (if not it is assumed to be plain text)
 java.lang.String parse(java.io.InputStream is)
          This method parses a file object which is readable entirely from the input stream.
 void parseEpilogue(java.lang.String epilogue)
          Parses the epilogue of a file object.
 java.lang.String parsePrologue(java.io.InputStream is)
          Parses the prologue of a file object.
 void setAccessed(java.util.Date accessed)
          Sets the last accessed time
 void setArchived(boolean a)
          Sets the archived attribute
 void setCreated(java.util.Date created)
          Sets the creation time
 void setDeleted(boolean d)
          Sets the deleted attribute
 void setExecutable(boolean e)
          Sets the executable attribute
 void setHidden(boolean h)
          Sets the hidden attribute
 void setModified(java.util.Date modified)
          Sets the modification time
 void setName(java.lang.String name)
          Sets the file name
 void setReadable(boolean r)
          Sets the readable attribute
 void setSize(int size)
          Sets the file size
 void setSystem(boolean s)
          Sets the system attribute
 void setWritable(boolean w)
          Sets the writable attribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileObject

public FileObject()
Method Detail

setName

public void setName(java.lang.String name)
Sets the file name

Parameters:
name - the name

getName

public java.lang.String getName()
Gets the file name


getModified

public java.util.Date getModified()
Gets the modification time


setModified

public void setModified(java.util.Date modified)
Sets the modification time


setCreated

public void setCreated(java.util.Date created)
Sets the creation time


getCreated

public java.util.Date getCreated()
Gets the creation time


setAccessed

public void setAccessed(java.util.Date accessed)
Sets the last accessed time


getAccessed

public java.util.Date getAccessed()
Gets the last accessed time


setHidden

public void setHidden(boolean h)
Sets the hidden attribute


getHidden

public boolean getHidden()
Gets the hidden attribute


setSystem

public void setSystem(boolean s)
Sets the system attribute


getSystem

public boolean getSystem()
Gets the system attribute


setArchived

public void setArchived(boolean a)
Sets the archived attribute


getArchived

public boolean getArchived()
Gets the archived attribute


setDeleted

public void setDeleted(boolean d)
Sets the deleted attribute


getDeleted

public boolean getDeleted()
Gets the deleted attribute


setWritable

public void setWritable(boolean w)
Sets the writable attribute


getWritable

public boolean getWritable()
Gets the writable attribute


setReadable

public void setReadable(boolean r)
Sets the readable attribute


getReadable

public boolean getReadable()
Gets the readable attribute


setExecutable

public void setExecutable(boolean e)
Sets the executable attribute


getExecutable

public boolean getExecutable()
Gets the executable attribute


setSize

public void setSize(int size)
Sets the file size


getSize

public int getSize()
Gets the file size. This attribute is not mandatory and if the information is not available, -1 is returned.


isBodyBase64

public boolean isBodyBase64()
Returns true if the body is encoded in base64 (if not it is assumed to be plain text)


formatPrologue

public java.lang.String formatPrologue()
Formats the prologue of this file object. The prologue is everything from the File tag up to the body content (excluded)

Returns:
the formatted prologue

formatPrologue

public java.lang.String formatPrologue(boolean formatBody)
Formats the prologue of this file object. The prologue is everything from the File tag up to the body content (excluded)

Parameters:
formatBody - specifies if the body tag must be formatted
Returns:
the formatted prologue

formatEpilogue

public java.lang.String formatEpilogue()
Formats the epilogue of this file object. The epilogue is everything after the body content (excluded)

Returns:
the formatted epilogue

formatEpilogue

public java.lang.String formatEpilogue(boolean formatBody)
Formats the epilogue of this file object. The epilogue is everything after the body content (excluded)

Parameters:
formatBody - specifies if the body tag must be formatted
Returns:
the formatted epilogue

parsePrologue

public java.lang.String parsePrologue(java.io.InputStream is)
                               throws FileObjectException
Parses the prologue of a file object. This method checks the syntax of the item and it stops its analysis once it finds the body tag. During the analysis it sets the memebers of this file object accordingly to the file object properties. If the item contains more than then body (at least the body closure tag) then the method returns null, as the user shall use the parse method to parse the entire item in one shot.

Parameters:
is - the input stream representing the input
Returns:
the body content contained in the input stream. In other words the analysis scans all the input stream and returns everything comes after the body tag. The method may return null if the body is not found or the there is no body content.
Throws:
FileObjectException - if the parsing fail for any reason

parseEpilogue

public void parseEpilogue(java.lang.String epilogue)
                   throws FileObjectException
Parses the epilogue of a file object. The epilogue is everything after the body content (starting with the body closure tag)

Throws:
FileObjectException

parse

public java.lang.String parse(java.io.InputStream is)
                       throws FileObjectException
This method parses a file object which is readable entirely from the input stream. This method loads in the memory the entire item's body, so it must be used only when it is known that the item body is small enough.

Parameters:
is - the stream from which data is read
Returns:
the item body content
Throws:
FileObjectException - if any error occurs during the parsing


Copyright © 2001-2009 Funambol.