LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.peer.xml
Class LyXmlRequestEncoder

java.lang.Object
  extended by leon.peer.LyRequestEncoder
      extended by leon.peer.file.LyFileRequestEncoder
          extended by leon.peer.xml.LyXmlRequestEncoder
Direct Known Subclasses:
LyXmlExportRequestEncoder

public class LyXmlRequestEncoder
extends LyFileRequestEncoder

This class is used for local files as data provider. Methods for creation, deletion and modification are not overriden since they don't have to write anything in the corresponding files. The specific method saveObjects must be called in order to make the objects persistent in a file.

See Also:
LyRequestEncoder

Field Summary
static java.lang.String __VERSION
           
static int TYPE_DEFAULT
          Saving type : only default yet ,but here to keep file save cmpatibility and for further extension.
 
Fields inherited from class leon.peer.file.LyFileRequestEncoder
_environment, _fieldSep, _valueSep, EMPTY_CHARSET, EXPORT_ENCODING, RAW_ENCODING, SPREADSHEET_ENCODING, TEXT_ENCODING, XML_EXPORT_ENCODING
 
Constructor Summary
LyXmlRequestEncoder(LyDataProvider provider, LyDataSource dataSource, java.lang.String fieldSep, java.lang.String valueSep)
          Constructor.
 
Method Summary
 org.xml.sax.helpers.DefaultHandler buildHandler()
          Return the default handler for this provider.
 org.xml.sax.InputSource convertSourceVersion(org.xml.sax.InputSource source)
          Apply any transformation (like XSLT Stylesheets to convert the source version of the XML File to latest version current implementation does nothing : should be overriden in subclasses.
 boolean createObject(java.lang.Object object)
          To create a new object.
 boolean deleteObject(java.lang.Object object)
          To delete an object.
 java.lang.String encodeValue(LyValueSet values, java.util.Vector<LyField> fields, int type)
          Return a line describing the ValueSet.
 java.util.Vector<java.lang.String> encodeValues(java.util.Vector<java.lang.Object> objects, java.util.Vector<LyField> fields, int type)
          Read a set of lines and return a set of objects.
 boolean getObject(LyObjectId objectId, java.util.Vector<LyField> fields)
          Get an object.
 boolean getObjects(java.util.Vector<LyField> fields, LySort sort, LyFilter filter, int n)
          Get a set of objects.
 boolean getSize()
          Return the number of objects from the file.
 boolean getSize(LyFilter filter)
          Return the number of objects from the file .
 void init()
          Initialisation of the data of the instance.
 boolean saveObjects(java.util.Vector<java.lang.Object> objects, java.util.Vector<LyField> fields, int type)
          Method used to saved all the objects contained in the corresponding data source cache.
 boolean setObject(java.lang.Object object)
          To set an object.
 boolean setObjects(java.util.Vector<java.lang.Object> objects)
          To set a set of objects.
 void setResponse(LyResponse response)
          Set the request encoder response.
 boolean writeToConnection(java.util.Vector<java.lang.Object> objects, java.util.Vector<LyField> fields, int type)
          Sends a request to the file connection for writing data.
 boolean writeToConnection(java.util.Vector<java.lang.String> lines)
          Sends a request to the file connection for writing data.
 
Methods inherited from class leon.peer.file.LyFileRequestEncoder
asciiEncode, decodeHeader, decodeValue, decodeValues, decodeValues, encodeHeader, encodeValue, fromString, fromString, getEnvironment, getFieldSeparator, getValueSeparator, readFromConnection, setEnvironment, setHeaderMark
 
Methods inherited from class leon.peer.LyRequestEncoder
deleteObjects, getClassBinding, getDataClass, getProvider, getResponse, isSynchronous, loadObject, setClassBinding, setDataClass, toString, toString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

TYPE_DEFAULT

public static final int TYPE_DEFAULT
Saving type : only default yet ,but here to keep file save cmpatibility and for further extension.

See Also:
Constant Field Values
Constructor Detail

LyXmlRequestEncoder

public LyXmlRequestEncoder(LyDataProvider provider,
                           LyDataSource dataSource,
                           java.lang.String fieldSep,
                           java.lang.String valueSep)
Constructor.

Parameters:
fieldSep - separator used between fields.
valuedSep - separator used between values.
Method Detail

init

public void init()
Initialisation of the data of the instance.

Overrides:
init in class LyFileRequestEncoder

setResponse

public void setResponse(LyResponse response)
Set the request encoder response. Inherited method from LyRequestEncoder to set properties to the response.

Overrides:
setResponse in class LyFileRequestEncoder
Parameters:
the - response

getObject

public boolean getObject(LyObjectId objectId,
                         java.util.Vector<LyField> fields)
Get an object.

Overrides:
getObject in class LyFileRequestEncoder
Parameters:
objectId - object identifier
fields - the fields to load (if null, load all)
Returns:
true if the request was correctly sent to the external data provider.

getObjects

public boolean getObjects(java.util.Vector<LyField> fields,
                          LySort sort,
                          LyFilter filter,
                          int n)
Get a set of objects.

Overrides:
getObjects in class LyFileRequestEncoder
Parameters:
fields - the fields to load (if null, load all)
sort - indicates sorting criterion, or null if default sort is used.
filter - indicates filtering criterion, or null if there is no filter.
n - maximum number of objects to get.
Returns:
true if the request was correctly sent to the external data provider.

getSize

public boolean getSize()
Return the number of objects from the file.

Overrides:
getSize in class LyFileRequestEncoder
Returns:
true if the request was correctly sent to the external data provider.

getSize

public boolean getSize(LyFilter filter)
Return the number of objects from the file .

Overrides:
getSize in class LyFileRequestEncoder
Parameters:
filter - indicates filtering criterion, or null if there is no filter.
Returns:
true if the request was correctly sent to the external data provider.

createObject

public boolean createObject(java.lang.Object object)
To create a new object.

Overrides:
createObject in class LyFileRequestEncoder
Parameters:
object - the new object to create
Returns:
true if the request was correctly sent to the external data provider.

setObject

public boolean setObject(java.lang.Object object)
To set an object.

Overrides:
setObject in class LyFileRequestEncoder
Parameters:
object - the object to set
Returns:
true if the request was correctly sent to the external data provider.

setObjects

public boolean setObjects(java.util.Vector<java.lang.Object> objects)
To set a set of objects.

Overrides:
setObjects in class LyFileRequestEncoder
Parameters:
objects - the objects to set
Returns:
true if the request was correctly sent to the external data provider.

deleteObject

public boolean deleteObject(java.lang.Object object)
To delete an object.

Overrides:
deleteObject in class LyFileRequestEncoder
Parameters:
object - the object to delete
Returns:
true if the request was correctly sent to the external data provider.

convertSourceVersion

public org.xml.sax.InputSource convertSourceVersion(org.xml.sax.InputSource source)
Apply any transformation (like XSLT Stylesheets to convert the source version of the XML File to latest version current implementation does nothing : should be overriden in subclasses.

Parameters:
input - source for parsing (input version)
Returns:
source the new source after parsing (output version)

buildHandler

public org.xml.sax.helpers.DefaultHandler buildHandler()
Return the default handler for this provider.

Returns:
The default handler.

saveObjects

public boolean saveObjects(java.util.Vector<java.lang.Object> objects,
                           java.util.Vector<LyField> fields,
                           int type)
Method used to saved all the objects contained in the corresponding data source cache.

Overrides:
saveObjects in class LyFileRequestEncoder
Parameters:
fields - fields to save (if null save all).
type - indicates the file format
Returns:
true if the request was correctly sent to the external data provider.

encodeValues

public java.util.Vector<java.lang.String> encodeValues(java.util.Vector<java.lang.Object> objects,
                                                       java.util.Vector<LyField> fields,
                                                       int type)
Read a set of lines and return a set of objects.

Overrides:
encodeValues in class LyFileRequestEncoder
Parameters:
objects - the set of objects to encode.
fields - FieldInfos to save (if null save all).
type - indicates the file format.
Returns:
the set of lines describing the set of objects.

encodeValue

public java.lang.String encodeValue(LyValueSet values,
                                    java.util.Vector<LyField> fields,
                                    int type)
Return a line describing the ValueSet.

Parameters:
values - the ValueSet to encode.
fields - the FieldInfos to encode.
type - indicates the file format.
Returns:
the line describing the ValueSet.

writeToConnection

public boolean writeToConnection(java.util.Vector<java.lang.String> lines)
Sends a request to the file connection for writing data.

Overrides:
writeToConnection in class LyFileRequestEncoder
Parameters:
lines - lines to write on the file.
Returns:
lines read from the file.

writeToConnection

public boolean writeToConnection(java.util.Vector<java.lang.Object> objects,
                                 java.util.Vector<LyField> fields,
                                 int type)
Sends a request to the file connection for writing data.

Overrides:
writeToConnection in class LyFileRequestEncoder
Parameters:
objects - the set of objects to encode.
fields - FieldInfos to save (if null save all).
type - indicates the file format.
Returns:
lines read from the file.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com