01 package org.apache.qpid.framing;
02
03 import org.apache.mina.common.ByteBuffer;
04
05 /*
06 *
07 * Licensed to the Apache Software Foundation (ASF) under one
08 * or more contributor license agreements. See the NOTICE file
09 * distributed with this work for additional information
10 * regarding copyright ownership. The ASF licenses this file
11 * to you under the Apache License, Version 2.0 (the
12 * "License"); you may not use this file except in compliance
13 * with the License. You may obtain a copy of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing,
18 * software distributed under the License is distributed on an
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 * KIND, either express or implied. See the License for the
21 * specific language governing permissions and limitations
22 * under the License.
23 *
24 */
25 public abstract class DeferredDataBlock extends AMQDataBlock
26 {
27 private AMQDataBlock _underlyingDataBlock;
28
29
30 public long getSize()
31 {
32 if(_underlyingDataBlock == null)
33 {
34 _underlyingDataBlock = createAMQDataBlock();
35 }
36 return _underlyingDataBlock.getSize();
37 }
38
39 public void writePayload(ByteBuffer buffer)
40 {
41 if(_underlyingDataBlock == null)
42 {
43 _underlyingDataBlock = createAMQDataBlock();
44 }
45 _underlyingDataBlock.writePayload(buffer);
46 }
47
48 abstract protected AMQDataBlock createAMQDataBlock();
49
50 }
|