001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata masks may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: SerializedByteArray.java,v $
031: * Revision 1.5 2005/10/02 14:06:32 colinmacleod
032: * Added/improved log4j logging.
033: *
034: * Revision 1.4 2005/09/14 12:52:22 colinmacleod
035: * Added serialVersionUID.
036: * Changed XPath expression for choice.
037: *
038: * Revision 1.3 2005/04/09 18:04:17 colinmacleod
039: * Changed copyright text to GPL v2 explicitly.
040: *
041: * Revision 1.2 2005/01/06 22:21:45 colinmacleod
042: * Moved up a version number.
043: * Changed copyright notices to 2005.
044: * Updated the documentation:
045: * - started working on multiproject:site docu.
046: * - changed the logo.
047: * Added checkstyle and fixed LOADS of style issues.
048: * Added separate thirdparty subproject.
049: * Added struts (in web), util and webgui (in webtheme) from ivata op.
050: *
051: * Revision 1.4 2004/03/21 21:16:36 colinmacleod
052: * Shortened name to ivata op.
053: *
054: * Revision 1.3 2004/02/10 19:57:25 colinmacleod
055: * Changed email address.
056: *
057: * Revision 1.2 2004/02/01 22:07:32 colinmacleod
058: * Added full names to author tags
059: *
060: * Revision 1.1.1.1 2004/01/27 20:59:46 colinmacleod
061: * Moved ivata op to SourceForge.
062: *
063: * Revision 1.2 2003/10/15 14:13:53 colin
064: * fixing for XDoclet
065: *
066: * Revision 1.4 2003/02/24 19:27:31 colin
067: * restructured file paths
068: *
069: * Revision 1.3 2003/02/04 17:43:52 colin
070: * copyright notice
071: *
072: * Revision 1.2 2002/09/09 12:58:47 peter
073: * changes on SerializedByteArray
074: *
075: * Revision 1.1 2002/08/16 11:38:44 peter
076: * created with rose, does not do anything so far...
077: * -----------------------------------------------------------------------------
078: */
079: package com.ivata.mask.util;
080:
081: import org.apache.log4j.Logger;
082:
083: import java.io.ByteArrayInputStream;
084: import java.io.InputStream;
085: import java.io.Serializable;
086:
087: /**
088: * <p>
089: * This is a utility class which serializes an array of bytes.
090: * </p>
091: *
092: * @since ivata masks 0.4 (2001-04-20)
093: * @author Peter Illes
094: * @version $Revision: 1.5 $
095: */
096: public class SerializedByteArray implements Serializable {
097: /**
098: * Logger for this class.
099: */
100: private static final Logger logger = Logger
101: .getLogger(SerializedByteArray.class);
102:
103: /**
104: * Serialization version (for <code>Serializable</code> interface).
105: */
106: private static final long serialVersionUID = 1L;
107: /**
108: * <p>
109: * The array of bytes to store in this instance.
110: * </p>
111: */
112: private byte[] bytes;
113:
114: /**
115: * <p>
116: * Default constructor. Creates an instance holding the values of an array
117: * of bytes.
118: * </p>
119: *
120: * @param byteArray
121: * byte array to hold the values of
122: */
123: public SerializedByteArray(final byte[] byteArray) {
124: this .bytes = byteArray;
125: }
126:
127: /**
128: * <p>
129: * Get an inputStream containing the array contents.
130: * </p>
131: *
132: * @return <code>InputStream</code> containing the array contents.
133: */
134: public final InputStream getInputStream() {
135: if (logger.isDebugEnabled()) {
136: logger.debug("getInputStream() - start");
137: }
138:
139: InputStream inputStream = new ByteArrayInputStream(bytes);
140:
141: if (logger.isDebugEnabled()) {
142: logger.debug("getInputStream() - end - return value = "
143: + inputStream);
144: }
145: return inputStream;
146: }
147: }
|