KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jca > cci > core > support > CommAreaRecord


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20 import java.io.InputStream JavaDoc;
21 import java.io.OutputStream JavaDoc;
22
23 import javax.resource.cci.Record JavaDoc;
24 import javax.resource.cci.Streamable JavaDoc;
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 JavaDoc, Streamable JavaDoc {
37
38     private byte[] bytes;
39
40     private String JavaDoc recordName;
41
42     private String JavaDoc recordShortDescription;
43
44
45     /**
46      * Create a new CommAreaRecord.
47      * @see #read(java.io.InputStream)
48      */

49     public CommAreaRecord() {
50     }
51
52     /**
53      * Create a new CommAreaRecord.
54      * @param bytes the bytes to fill the record with
55      */

56     public CommAreaRecord(byte[] bytes) {
57         this.bytes = bytes;
58     }
59
60
61     public void setRecordName(String JavaDoc recordName) {
62         this.recordName=recordName;
63     }
64
65     public String JavaDoc getRecordName() {
66         return recordName;
67     }
68
69     public void setRecordShortDescription(String JavaDoc recordShortDescription) {
70         this.recordShortDescription=recordShortDescription;
71     }
72
73     public String JavaDoc getRecordShortDescription() {
74         return recordShortDescription;
75     }
76
77
78     public void read(InputStream JavaDoc in) throws IOException JavaDoc {
79         this.bytes = FileCopyUtils.copyToByteArray(in);
80     }
81
82     public void write(OutputStream JavaDoc out) throws IOException JavaDoc {
83         out.write(this.bytes);
84         out.flush();
85     }
86
87     public byte[] toByteArray() {
88         return this.bytes;
89     }
90
91
92     public Object JavaDoc clone() {
93         return new CommAreaRecord(this.bytes);
94     }
95
96 }
97
Popular Tags