01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jca.cci.core.support;
18:
19: import java.io.IOException;
20: import java.io.InputStream;
21: import java.io.OutputStream;
22:
23: import javax.resource.cci.Record;
24: import javax.resource.cci.Streamable;
25:
26: import org.springframework.util.FileCopyUtils;
27:
28: /**
29: * CCI Record implementation for a COMMAREA, holding a byte array.
30: *
31: * @author Thierry Templier
32: * @author Juergen Hoeller
33: * @since 1.2
34: * @see org.springframework.jca.cci.object.MappingCommAreaOperation
35: */
36: public class CommAreaRecord implements Record, Streamable {
37:
38: private byte[] bytes;
39:
40: private String recordName;
41:
42: private String recordShortDescription;
43:
44: /**
45: * Create a new CommAreaRecord.
46: * @see #read(java.io.InputStream)
47: */
48: public CommAreaRecord() {
49: }
50:
51: /**
52: * Create a new CommAreaRecord.
53: * @param bytes the bytes to fill the record with
54: */
55: public CommAreaRecord(byte[] bytes) {
56: this .bytes = bytes;
57: }
58:
59: public void setRecordName(String recordName) {
60: this .recordName = recordName;
61: }
62:
63: public String getRecordName() {
64: return recordName;
65: }
66:
67: public void setRecordShortDescription(String recordShortDescription) {
68: this .recordShortDescription = recordShortDescription;
69: }
70:
71: public String getRecordShortDescription() {
72: return recordShortDescription;
73: }
74:
75: public void read(InputStream in) throws IOException {
76: this .bytes = FileCopyUtils.copyToByteArray(in);
77: }
78:
79: public void write(OutputStream out) throws IOException {
80: out.write(this .bytes);
81: out.flush();
82: }
83:
84: public byte[] toByteArray() {
85: return this .bytes;
86: }
87:
88: public Object clone() {
89: return new CommAreaRecord(this.bytes);
90: }
91:
92: }
|