samples/preventcyclicdependencies/src-acyclic1/org/apidesign/cycles/array/MutableArray.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:58:11 +0200
changeset 154 0fd5e9c500b9
parent 153 b5cbb797ec0a
permissions -rw-r--r--
Merge: Geertjan's changs up to 2000
jtulach@87
     1
package org.apidesign.cycles.array;
jtulach@87
     2
jtulach@87
     3
import java.io.IOException;
jtulach@87
     4
import java.io.OutputStream;
jtulach@87
     5
import org.openide.util.Lookup;
jtulach@87
     6
// BEGIN: nocycles.ma2
jtulach@87
     7
public class MutableArray {
jtulach@87
     8
    private byte[] arr;
jtulach@87
     9
jtulach@87
    10
    public MutableArray(byte[] arr) {
jtulach@87
    11
        this.arr = arr;
jtulach@87
    12
    }
jtulach@87
    13
jtulach@87
    14
    public void xor(byte b) {
jtulach@87
    15
        for (int i = 0; i < arr.length; i++) { arr[i] ^= b; }
jtulach@87
    16
    }
jtulach@87
    17
jtulach@87
    18
    public void encrypt(OutputStream os) throws IOException {
jtulach@87
    19
        DoEncode en = Lookup.getDefault().lookup(DoEncode.class);
jtulach@154
    20
        assert en != null : "org.netbeans.example.crypt missing!";
jtulach@87
    21
        byte[] clone = (byte[]) arr.clone();
jtulach@87
    22
        en.encode(clone);
jtulach@87
    23
        os.write(clone);
jtulach@88
    24
    }    
jtulach@87
    25
}
jtulach@87
    26
// END: nocycles.ma2