01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the License). You may not use this file except in
05: * compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * Header Notice in each file and include the License file
14: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * If applicable, add the following below the CDDL Header,
16: * with the fields enclosed by brackets [] replaced by
17: * you own identifying information:
18: * "Portions Copyrighted [year] [name of copyright owner]"
19: *
20: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
21: */
22:
23: /*
24: * ByteArray.java
25: *
26: * Created on September 19, 2010, 8:19 AM
27: *
28: * To change this template, choose Tools | Options and locate the template under
29: * the Source Creation and Management node. Right-click the template and choose
30: * Open. You can then make changes to the template in the Source Editor.
31: */
32:
33: package com.sun.xml.wss.impl.misc;
34:
35: /**
36: *
37: * @author K.Venugopal@sun.com
38: */
39: public class ByteArray {
40: byte[] iv = null;
41: byte[] ed = null;
42: int length = 0;
43:
44: /** Creates a new instance of ByteArray */
45: public ByteArray(byte[] iv, byte[] ed) {
46: this .iv = iv;
47: this .ed = ed;
48: if (this .iv != null) {
49: length = iv.length;
50: }
51: if (this .ed != null) {
52: length = length + ed.length;
53: }
54: }
55:
56: public int getLength() {
57: return length;
58: }
59:
60: public byte byteAt(int i) {
61: if (i < 0 || i > length) {
62: throw new ArrayIndexOutOfBoundsException("Index " + i
63: + " is out of range");
64: }
65: if (iv != null && i < iv.length) {
66: return iv[i];
67: } else if (iv == null || iv.length == 0) {
68: return ed[i];
69: } else {
70: int index = i - iv.length;
71: return ed[index];
72: }
73: }
74: }
|