How to restrict the size of Buffer data object

Hi everyone.
How do you restrict the size of the Buffer data object. The byte array that you get by calling getData(). I want to restrict the size to be at most X nbr of bytes. I'm 'filling' the buffer like this:
Buffer readBuffer;
PushBufferStream stream;
stream.read(readBuffer);

This is my code:
class DataSourceHandler implements DataSink, BufferTransferHandler {
          private int MAX_DATA_PACKET_SIZE = 2000;
          private DataSource source;
          private PullBufferStream pullStrms[] = null;
          private PushBufferStream pushStrms[] = null;
          // Data sink listeners.
          private Vector listeners = new Vector(1);
          // Stored all the streams that are not yet finished (i.e. EOM
          // has not been received.
          private SourceStream unfinishedStrms[] = null;
          // Loop threads to pull data from a PullBufferDataSource.
          // There is one thread per each PullSourceStream.
          private Loop loops[] = null;
          private Buffer readBuffer;
           * Sets the media source this <code>MediaHandler</code> should use to
           * obtain content.
          public void setSource(DataSource source)
                    throws IncompatibleSourceException {
               // Different types of DataSources need to handled differently.
               if (source instanceof PushBufferDataSource) {
                    System.out.println("source instanceof PushBufferDataSource");
                    pushStrms = ((PushBufferDataSource) source).getStreams();
                    unfinishedStrms = new SourceStream[pushStrms.length];
                    // Set the transfer handler to receive pushed data from
                    // the push DataSource.
                    for (int i = 0; i < pushStrms.length; i++) {
                         pushStrms.setTransferHandler(this);
                         unfinishedStrms[i] = pushStrms[i];
               } else if (source instanceof PullBufferDataSource) {
                    System.out.println("source instanceof PullBufferDataSource");
                    pullStrms = ((PullBufferDataSource) source).getStreams();
                    unfinishedStrms = new SourceStream[pullStrms.length];
                    // For pull data sources, we'll start a thread per
                    // stream to pull data from the source.
                    loops = new Loop[pullStrms.length];
                    for (int i = 0; i < pullStrms.length; i++) {
                         loops[i] = new Loop(this, pullStrms[i]);
                         unfinishedStrms[i] = pullStrms[i];
               } else {
                    // This handler only handles push or pull buffer datasource.
                    throw new IncompatibleSourceException();
               this.source = source;
               readBuffer = new Buffer();
               byte[] data = new byte[MAX_DATA_PACKET_SIZE];
               readBuffer.setData(data);
          * For completeness, DataSink's require this method. But we don't need
          * it.
          public void setOutputLocator(MediaLocator ml) {
          public MediaLocator getOutputLocator() {
               return null;
          public String getContentType() {
               return source.getContentType();
          * Our DataSink does not need to be opened.
          public void open() {
          public void start() {
               try {
                    source.start();
               } catch (IOException e) {
                    System.err.println(e);
               // Start the processing loop if we are dealing with a
               // PullBufferDataSource.
               if (loops != null) {
                    for (int i = 0; i < loops.length; i++)
                         loops[i].restart();
          public void stop() {
               try {
                    source.stop();
               } catch (IOException e) {
                    System.err.println(e);
               // Start the processing loop if we are dealing with a
               // PullBufferDataSource.
               if (loops != null) {
                    for (int i = 0; i < loops.length; i++)
                         loops[i].pause();
          public void close() {
               stop();
               if (loops != null) {
                    for (int i = 0; i < loops.length; i++)
                         loops[i].kill();
          public void addDataSinkListener(DataSinkListener dsl) {
               if (dsl != null)
                    if (!listeners.contains(dsl))
                         listeners.addElement(dsl);
          public void removeDataSinkListener(DataSinkListener dsl) {
               if (dsl != null)
                    listeners.removeElement(dsl);
          protected void sendEvent(DataSinkEvent event) {
               if (!listeners.isEmpty()) {
                    synchronized (listeners) {
                         Enumeration list = listeners.elements();
                         while (list.hasMoreElements()) {
                              DataSinkListener listener = (DataSinkListener) list
                                        .nextElement();
                              listener.dataSinkUpdate(event);

Similar Messages

  • How to restrict the size of folder in KM?

    Hi All,
    How to restrict the size of folder in KM?
    Suppose I allocated 1 personal folder to every SAP KM Folder. Can I restrict the size of folder with do not allowed the uploaded file to be exceeded certain capacity?
    Thanks & Regards,
    zhixuen.

    Hi,
    Refer this [http://help.sap.com/saphelp_nw70/helpdata/en/62/468698a8e611d5993600508b6b8b11/content.htm]
    Also chk.
    https://forums.sdn.sap.com/thread.jspa?threadID=80571
    https://forums.sdn.sap.com/thread.jspa?threadID=80326
    https://forums.sdn.sap.com/thread.jspa?threadID=80145
    http://weblogs.sdn.sap.com/pub/wlg/3219
    Regards
    Baby

  • How to control the size of live data in Coherence?

    How to control the size of live data in Coherence?
    See the following statement:
    Pause times increase as the amount of live data in the heap increases. We recommend not exceeding 70% live data in your heap. This includes primary data, backup data, indexes, and application data.
    --Excerpted from http://coherence.oracle.com/display/COH35UG/Best+Practices                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    In any Java program, it is good practice to make sure your live objects leave some room in the heap for "scratch space." Without this, you will spend too much time in GC, and, in the worst cases, run out of memory. In the general case, you can see how much live data your application requires by looking at the heap used after a full GC's. For Coherence, you should ensure that live data, as you say, is under 70% of the maximum heap size.
    Coherence provides you tools to help enforce this policy. [http://coherence.oracle.com/display/COH35UG/local-scheme] describes how to size limit your cache. By implementing an eviction policy, you can control what happens when a size limit is exceeded.

  • How to change the size of a particular object in the picture?

    How to change the size of a particular object in the picture?

    You need to select it.  Copy that selection to a new layer, and use Free Transform to resize it.
    http://www.youtube.com/watch?v=qWpAGmwhllQ
    http://www.youtube.com/watch?v=Bi4jJnYLkUA

  • How to fix the size of table data in html

    I want to fix the size of table data in html. ie if i want to insert only 50 char in a <td> field then it contain only 50 character, after that it switched to another line and contain the remaining character. Means <td> field wil not get automatically adjust there size according to data.

    you cant specify how many characters a td cell can have but u can specify the pixel width of a td cell
    <td width=50>
    as long as you have wrap text on, then text will not force the box size over the 50 pixels
    this wont limit it to only 50 chars though, you will probably have to use some javascript to cut the string down to size (unless youre using something like php or asp then that will do the trick too)

  • How to restrict the size of a km repository

    Hi all,
        How can i restrict the size of a KM repository/folder ?
    Thanks & Regards
      DD

    Hi,
    Please check these link:-
    1.[https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/3219]
    2.https://www.sdn.sap.com/irj/scn/thread?messageID=601915
    3.https://www.sdn.sap.com/irj/scn/thread?messageID=135202
    Best Regards,
    Atul Bhatia

  • How to show the content of a data object in listbox

    Hello together,
    i have created a service employee_srv for my data object "Employee". How can I show the content of this data object in a listbox in my view, for example DropDownByKey.
    Regards
    Waldemar Schakiel

    Hi,
    An example to create a dynamic context in Webdynpro ABAP:
    data:
    rootnode_info TYPE REF TO if_wd_context_node_info,
    dyn_node TYPE REF TO if_wd_context_node,
    tabname_node TYPE REF TO if_wd_context_node,
    tablename TYPE string.
    rootnode_info = wd_context->get_node_info( ).
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
    parent_info = rootnode_info
    node_name = tablename " Data object Table name
    structure_name = tablename
    is_multiple = abap_true ).
    ***Bind data to Dynamic table:
    DATA: stru_tab TYPE REF TO data.
    FIELD-SYMBOLS:
    <tab> TYPE table.
    create internal table
    CREATE DATA stru_tab TYPE TABLE OF (tablename).
    ASSIGN stru_tab->* TO <tab>.
    dyn_node = wd_context->get_child_node( name = tablename ).
    Bind internal table to context node.
    dyn_node->bind_table( <tab> ).
    Shruthi

  • How to retrieve the BRF+  function result data object of type table in ABAP

    Hi,
    I am calling a BRF+ function from Abap....If the result data object of the function is element then i am able to get the value back in ABAP...Suppose the result data object of the function is of table type,I couldnt retrieve the value....Can you please help me how to retrieve the table data object value of the function from abap....
    Regards,
    Dheepak.

    Hi,
    Thanks carsten and Tiwari for your reply...
    Tiwari,
    I understand that if i know the data type of the result data object which i am going to get i can declare it my ABAP program and get the values....But i am developing a generic program which calls the various BRF+ functions based on the function id...So i am not aware what is the data type of the result data object....so is there a any way to handle this situation...Please advice...
    Carsten,
    I used the GET_DATA_OBJECT_STRUCTURE method of class CL_FDT_FUNCTION_PROCESS to get the data object structure...i am able to get whether it is an element or structure or internal table...
    But is there any way to get the data type of the object...For example if it is going to be an element of type BELNR_D,is it possible to get the BELNR_D value in my program...Please advice...
    Thanks,
    Dheepak.

  • ADF-BC/JSF How to restrict the size of an ordImage

    Hi all
    I have a table containing two columns with type ordsys.OdImage. One is a small resolution icon and the other the image itself.
    Using Steve Muench s example mo 69, I was able to create a ADF-BC/JSF application that loads images to the database.
    Now my next step is to reject images whose size in pixels is other than the one defined for thumbnails, which is 100x100, I thought that I could do this by tampering with the getter methods of the ViewRowImpl Java class but it didn't work. It appears to me that the framework creates an empty image first and then loads the contents from a file.
    Can anybody give me a clue about how to accomplish this ?
    Thanks in advance
    Thanassis

    Just finished testing the validateEntity() approach and it failed.
    I think that I must be doing something wrong here.
    I use the OrdImageDomain.getHeight() and getWidth() functions and they both return 0 wheither invoked during attribute setter method or during the validateEntity().
    Anybody out there with a clue ....
    Thanassis

  • How to fix the size of a window object?

    Is there any way that I could use to stop the user from resizing a window interface, and also remove the MINIMIZE and MAXIMIZE buttons up the right coner of the window ?

    I don;t know about removing the min and max buttons, but you can use yourFrame.setResizable(false);

  • How to restrict the upload file size in me21n/me22n/me23n?

    Hi Guru's,
    I have a requirement to restrict the user from attaching a local file more than 20MB in Purchase Order.
    In standard SAP system, the user can attach a file of any size in PO. How to restrict the size of the file?
    I have no clue how to achieve this? Any kind of help would be great...
    Thanks in Advance...
    Regards,
    Satyam

    Hi Guru's,
    The file size is now restricted in function GUI_UPLOAD. But this function module is used at many places. I want to restrict it only for Tcode: ME22n and ME23n.
    I thought of restricting it by sy-tcode field but sy-tcode value  is not passed to this function module in the run time.
    Could anyone help me on this how to restrict it for the above mentioned tcodes??
    Regards,
    Satyam

  • How to limit the size of the connection method parameter

    I connected an FMS server like var nc = new NetConnection ();
                                                      nc.connect ("rtmfp :/ / localhost: 61018/zy/1", a);
    But how to restrict the size of the parameter a, assuming that this a set to a 10GB object, or a very large byte, I found that the server received. This allows the hacker attacks, Is there any way to limit the size of this a, I hope that does not exceed 100KB.

    RTMFP encodes low-level messages in a manner compatible with RTMP messages. RTMP messages are length-field limited to 16MB (24 bits), and there is an artificial software limit somewhat less than that (approximately 10MB if i recall correctly).
    it should not be possible to send a connect message to an RTMFP or RTMP server exceeding about 10MB.
    ByteArray is limited to 4GB, and can't be serialized to AMF beyond 512MB (29 bits).
    also keep in mind that for an RTMFP or RTMP server to receive such a large message, that many bytes must be sent to it from somewhere (you).

  • How to restrict the Number of attachments

    Hi All,
    I would like to restrict the Number of Attachments,
    I found many threads on how to restrict the size on the attachments.
    Is there any standard way(profile or setup) to restrict the number of attachments
    Other Option is
    When the user try to add attachments, I need to get the Entity, PRIMARY key and
    query FND_ATTACHED_DOCUMENTS count and through an error message.
    Not sure how easy it is.
    If anybody tried this requirement please share the logic to achieve the same.
    Thanks,
    With Regards,
    Kali.

    Hi All,
    I have achieved using the below logic, in the ProcessFormRequest,
    String eventParam = pageContext.getParameter(EVENT_PARAM);
    if("oaAddAttachment".equals(eventParam))
    String pkValue = pageContext.getParameter("PKEYID");
    String attachmentCountQry = "SELECT count(*) FROM fnd_attached_documents WHERE entity_name = <EONAME> AND pk1_value = "+pkValue ;
    //Execute the query and get the count,
    int attachmentsCountInt = executeQuery(attachmentCountQry );
    if(attachmentsCountInt >=2)
    throw new OAException("Add only 2 attachments");
    With Regards,
    Kali.

  • How to restrict the fields in a std screen i.e addtional data b of va01

    how to restrict the fields in a std screen i.e addtional data b of va01
    certain document type
    as i already added some fields in it
    can u help me with the setp
    With regards
    rohan Shetty

    Hi Rohan,
    Can you please let us know the solution that you had, i have similar requirement?
    Thanks,
    Manohar.

  • How to know the size of data in some columns of a table?

    Hi,
    How can the size of of data for some specified column be determined?
    For example : TableA has 20 columns and the size of table is 20 GB. I want to know the size of data kept in last four columns.
    Thanks in Advance,
    Vishu

    You could use vsize to determine the size of a column element and sum them upselect sum(vsize(column_of_interest)) from whatever_table;

Maybe you are looking for

  • Sharepoint Designer 2010 and Visio 2013

    I am testing out Visio Professional 2013. I can import a VWI file from Sharepoint Designer 2010 and I can export a VWI file from Visio. But when I try to import the VWI file created in Visio 2013 into sharpoint Designer 2010 it appears to work, as I

  • Adobe Media Encoder - Premiere Pro SLOW Rendering

    Hi, there I've been using my laptop which has the specs: 2.8ghz intel core 2 extreme, 4gb DDR2 800mhz RAM, 8800m GTS 512mb. Now, I've been able to export my videos from Premiere Pro on that machine roughly with a 1:5 time ratio, a 1 minute video migh

  • Regarding Bakcground jobs

    Hello Experts, I want to know about the 'sequential background job'.  how it works and what are the main parameters we need to pass to the function module called JOB_CLOSE through ABAP code in programming. Please help me in this regard, Thank you. Re

  • Firefox will not run for mulitple instances of the SAME user account on Windows Multipoint Server 2011

    We have an HP MS6200 MulitSeat PC It is running Microsoft Windows MultiPoint Server 2011 (which appears to be a tweaked version of Windows 7) It is set up in a computer lab, and students log in using their shared room account - ie multiple instances

  • Siebel Operation - Query

    Hi All, I am using Siebel Query operaion in one of the workflow steps, where I want to query on BC for multiple field value. For eg: I have Field values for Row_Id is 333-X and 334-Y , I want to Query on BC and want to return records with Row_id 333-