summaryrefslogtreecommitdiff
path: root/java/common/Composite.tpl
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2009-12-26 12:42:57 +0000
committerRafael H. Schloming <rhs@apache.org>2009-12-26 12:42:57 +0000
commit248f1fe188fe2307b9dcf2c87a83b653eaa1920c (patch)
treed5d0959a70218946ff72e107a6c106e32479a398 /java/common/Composite.tpl
parent3c83a0e3ec7cf4dc23e83a340b25f5fc1676f937 (diff)
downloadqpid-python-248f1fe188fe2307b9dcf2c87a83b653eaa1920c.tar.gz
synchronized with trunk except for ruby dir
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid.rnr@893970 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common/Composite.tpl')
-rw-r--r--java/common/Composite.tpl77
1 files changed, 66 insertions, 11 deletions
diff --git a/java/common/Composite.tpl b/java/common/Composite.tpl
index 4aed9b0432..97b7d01f3c 100644
--- a/java/common/Composite.tpl
+++ b/java/common/Composite.tpl
@@ -1,4 +1,25 @@
-package $(pkg);
+package org.apache.qpid.transport;
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -7,17 +28,15 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.qpid.transport.Future;
-import org.apache.qpid.transport.Method;
-import org.apache.qpid.transport.RangeSet;
-import org.apache.qpid.transport.Struct;
-
import org.apache.qpid.transport.codec.Decoder;
import org.apache.qpid.transport.codec.Encodable;
import org.apache.qpid.transport.codec.Encoder;
import org.apache.qpid.transport.network.Frame;
+import org.apache.qpid.util.Strings;
+
+
${
from genutil import *
@@ -73,7 +92,7 @@ public final class $name extends $base {
return $pack;
}
- public final boolean hasPayloadSegment() {
+ public final boolean hasPayload() {
return $payload;
}
@@ -108,7 +127,12 @@ if fields:
${
for f in fields:
if f.option: continue
- out(" $(f.set)($(f.name));\n")
+ if f.ref_type != f.type:
+ out(" $(f.set)($(f.name));\n")
+ else:
+ out(" if($(f.name) != null) {\n")
+ out(" $(f.set)($(f.name));\n")
+ out(" }\n")
if segments:
out(" setHeader(header);\n")
@@ -126,6 +150,7 @@ if options or base == "Method":
if base == "Method":
out(""" case SYNC: this.setSync(true); break;
case BATCH: this.setBatch(true); break;
+ case UNRELIABLE: this.setUnreliable(true); break;
""")
out(""" case NONE: break;
default: throw new IllegalArgumentException("invalid option: " + _options[i]);
@@ -135,9 +160,13 @@ if options or base == "Method":
}
}
- public final <C> void dispatch(C context, MethodDelegate<C> delegate) {
+${
+
+if base == "Method":
+ out(""" public <C> void dispatch(C context, MethodDelegate<C> delegate) {
delegate.$(dromedary(name))(context, this);
- }
+ }""")
+}
${
for f in fields:
@@ -175,7 +204,13 @@ if not f.empty:
}
${
if pack > 0:
- out(" packing_flags |= $(f.flag_mask(pack));")
+ if f.empty:
+ out(" if (value)\\n")
+ out(" packing_flags |= $(f.flag_mask(pack));\\n")
+ out(" else\\n")
+ out(" packing_flags &= ~$(f.flag_mask(pack));")
+ else:
+ out(" packing_flags |= $(f.flag_mask(pack));")
}
this.dirty = true;
return this;
@@ -222,6 +257,26 @@ if segments:
setBody(body);
return this;
}
+
+ public final byte[] getBodyBytes() {
+ ByteBuffer buf = getBody();
+ byte[] bytes = new byte[buf.remaining()];
+ buf.get(bytes);
+ return bytes;
+ }
+
+ public final void setBody(byte[] body)
+ {
+ setBody(ByteBuffer.wrap(body));
+ }
+
+ public final String getBodyString() {
+ return Strings.fromUTF8(getBodyBytes());
+ }
+
+ public final void setBody(String body) {
+ setBody(Strings.toUTF8(body));
+ }
""")
}