View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006 Imola Informatica.
3    *  All rights reserved. This program and the accompanying materials
4    *  are made available under the terms of the LGPL License v2.1
5    *  which accompanies this distribution, and is available at
6    *  http://www.gnu.org/licenses/lgpl.html
7    *******************************************************************************/
8   /**
9    * 
10   */
11  package it.imolinfo.jbi4cics.connection.jca;
12  
13  import it.imolinfo.jbi4cics.jbi.Messages;
14  import java.io.IOException;
15  import java.io.InputStream;
16  import java.io.OutputStream;
17  
18  import javax.resource.cci.Record;
19  import javax.resource.cci.Streamable;
20  
21  /**
22   * @author raffaele
23   *
24   */
25  public class CommareaRecord implements Streamable, Record {
26  
27    /**
28     * 
29     */
30    private static final long serialVersionUID = -4083607545259706340L;
31    
32    /**
33     * The responsible to translate localized messages.
34     */
35    private static final Messages MESSAGES
36            = Messages.getMessages(CommareaRecord.class);
37    
38    /**
39     * 
40     */
41    private String recordName;
42    private String recordShortDescription;
43    private byte[] commarea;
44  
45    /**
46     * 
47     */
48    public CommareaRecord() {
49      super();
50      // TODO Auto-generated constructor stub
51    }
52    
53    /**
54     * @return Returns the commareaLength.
55     */
56    public int getCommareaLength() {
57      return commarea.length;
58    }
59  
60    /**
61     * @param commareaLength The commareaLength to set.
62     */
63    public void setCommareaLength(int commareaLength) {
64      commarea=new byte[commareaLength];
65    }
66  
67    
68  
69    /* (non-Javadoc)
70     * @see javax.resource.cci.Streamable#read(java.io.InputStream)
71     */
72    public void read(InputStream is) throws IOException {
73      int byteRead=is.read(commarea);
74      if (byteRead!=commarea.length){
75        throw new IOException(MESSAGES.getString("CIC000301_IO_exception", new Object[] {byteRead, commarea.length})); 
76      }    
77    }
78  
79    /* (non-Javadoc)
80     * @see javax.resource.cci.Streamable#write(java.io.OutputStream)
81     */
82    public void write(OutputStream os) throws IOException {
83      os.write(commarea);
84    }
85  
86    /* (non-Javadoc)
87     * @see javax.resource.cci.Record#getRecordName()
88     */
89    public String getRecordName() {
90      return recordName;
91    }
92  
93    /* (non-Javadoc)
94     * @see javax.resource.cci.Record#setRecordName(java.lang.String)
95     */
96    public void setRecordName(String arg0) {
97      recordName=arg0;
98    }
99  
100   /* (non-Javadoc)
101    * @see javax.resource.cci.Record#setRecordShortDescription(java.lang.String)
102    */
103   public void setRecordShortDescription(String arg0) {
104     recordShortDescription=arg0;
105   }
106 
107   /* (non-Javadoc)
108    * @see javax.resource.cci.Record#getRecordShortDescription()
109    */
110   public String getRecordShortDescription() {
111     return recordShortDescription;
112   }
113 
114   /**
115    * @return Returns the commarea.
116    */
117   public byte[] getCommarea() {
118     return commarea;
119   }
120 
121   /**
122    * @param commarea The commarea to set.
123    */
124   public void setCommarea(byte[] commarea) {
125     this.commarea = commarea;
126   }
127   
128   public Object clone(){
129     CommareaRecord cloned=new CommareaRecord();
130     cloned.setRecordName(recordName);
131     cloned.setRecordShortDescription(recordShortDescription);
132     byte[] buffer=new byte[commarea.length];
133     System.arraycopy(commarea,0,buffer,0,commarea.length);
134     cloned.setCommarea(buffer);
135     return cloned;
136   }
137 
138 }
139 
140 /**
141  * la stessa classe in spring, può dare qualche suggerimento...
142  */
143