IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Flat Files > Reference
Custom file splitting
You can implement a custom class containing the splitting logic. The adapter provides a Java™ interface for the class. The version 7.5.0.3 of the adapter provides interfaces for both outbound and inbound processes.
Interface for outbound operations
Use the com.ibm.j2ca.utils.filesplit.SplittingFunctionalityInterface interface for the outbound operations.
Following are the details of the interface:
public interface SplittingFunctionalityInterface extends Iterator{ public int getTotalBOs(String filename) throws SplittingException; public void setBODetails(String filename, int currentPosition, int totalBOs, boolean includeEndBODelimiter) throws SplittingException; public void setSplitCriteria(String splitCriteria); public void setEncoding(String encoding); public void setLogUtils(LogUtils logUtils); public boolean isSplitBySize()}
- public int getTotalBOs(String filename) throws SplittingException
This method returns the total number of business objects present in the event file given by filename.
- public void setSplitCriteria(String splitCriteria)
This method takes the splitCriteria, that is based on the number of business objects in the event file. Each business object is returned during the next() call.
- public void setLogUtils(LogUtils logUtils)
This method is used to set the LogUtils object, which is the class that the user can use to write trace and log messages to the files.
- public void setEncoding(String encoding)
This method is used to set the encoding of the event file content. This encoding is used while reading the file content. This encoding is also used for the SplitCriteria.
- public void setBODetails(String filename, int currentPosition, int totalBOs, boolean includeEndBODelimiter) throws SplittingException
This method is used to set the current business object number so that whenever a next() call is made, the business object number set in the currentPosition is returned. It also takes an includeEndBODelimiter parameter, which when set to true, includes the SplitCriteria at the end of the business object content. This method must be called before every next() call so that the next() method returns the business object content for the business object set in this method.
The iterator has three methods: hasNext(), next, and remove(), that also must be implemented. The next() method returns the business object content (as a byte[]) for the business object position set in setBODetails(). If the business object position is not set, it fails. The hasNext() method indicates whether the business object position set in the setBODetails() exists or not. Before a hasNext() call, the setBODetails() method must be called. The remove() method is called for each of the business object entries being deleted from the Event persistence table. Do not delete the event file in this method, and clean up only the resources that are being used.
- public boolean isSplitBySize()
This method indicates whether the event file is parsed based on size or based on delimiter.
Interface for inbound operations
Use the com.ibm.j2ca.utils.filesplit.InboundSplittingFunctionalityInterface interface for the inbound operations.
The custom splitting class for an inbound operation created in the earlier version of the adapter does not work with the version 7.5.0.3 of the adapter.
Following are the details of the interface:
public interface InboundSplittingFunctionalityInterface{ public Hashtable getBOs(String filename,int quantity, long lastBO,long lastBOPos,boolean withDelim) throws SplittingException,MissingDataException; public void setBODetails(String filename, long currentBO, long startPos, long endPos) throws SplittingException; public Object getBOContent(); public boolean hasMoreBO(); public void remove(); public void setSplitCriteria(String splitCriteria); public void setEncoding(String encoding); public void setLogUtils(LogUtils logUtils); public boolean isSplitBySize();}
- public Hashtable getBOs(String filename, int quantity, long lastBOCount, long lastBOPos, boolean includeEndBODelimiter) throws SplittingException, MissingDataException
This method returns the business objects retrieved from the file specified in the filename to a hashtable. The quantity parameter specifies the number of business objects to be retrieved. The lastBOCount parameter specifies the number of business objects retrieved when the file was previously read. The lastBOPos parameter specifies the end position of the business object when the file was previously read. The includeEndBODelimiter parameter specifies the split criteria to retrieve the business objects. The hashtable that is returned contains the business object count (key) and the start/end positions of that business object (a long array of 2 elements).
- public void setBODetails(String filename, long currentBO, long startPosition, long endPosition)throws SplittingException
This method is used to set the details for the current business object. Therefore, the getBOContent() method retrieves the content of the business object specified in the currentBO. The startPosition and endPosition parameters specify the start and end position for the business object in the file.
- public Object getBOContent()
The getBOContent() method returns the business object content (as a byte[]) for the details set in setBODetails() method.
If the start and end position of the business object is not set in the setBODetails() method, then the getBOContent() method fails.
- public boolean hasMoreBO()
This method returns the value True if there are unread business objects existing in the file after the last call to the getBOs() method.
- public void remove()
The remove() method is called for each of the business object entry being deleted from the Event persistence table. Ensure that you do not delete the event file and clean up only the resources that are being used.
- public void setSplitCriteria(String splitCriteria)
This method returns the splitCriteria set based on the number of business objects in the event file. Each business object is returned during the next() call.
- public void setLogUtils(LogUtils logUtils)
This method is used to set the LogUtils object, which is the class used to write trace and log messages to the files.
- public void setEncoding(String encoding)
This method is used to set the encoding for the content of the event file. This encoding is used while reading the file content and for the SplitCriteria.
- public boolean isSplitBySize()
This method returns the value True when the event file is parsed based on the size, and returns the value False if a delimiter is used.
Related concepts:
Related tasks: