01: /*
02: * ====================================================================
03: * Copyright (c) 2004 Marc Strapetz, marc.strapetz@smartsvn.com.
04: * All rights reserved.
05: *
06: * This software is licensed as described in the file COPYING, which
07: * you should have received as part of this distribution. Use is
08: * subject to license terms.
09: * ====================================================================
10: */
11:
12: package de.regnis.q.sequence.media;
13:
14: import de.regnis.q.sequence.core.*;
15:
16: /**
17: * @author Marc Strapetz
18: */
19: public class QSequenceCachingMedia extends QSequenceIntMedia {
20:
21: // Fields =================================================================
22:
23: private final QSequenceCachingMediaSymbolMap symbolMap;
24: private final int[] leftSymbols;
25: private final int[] rightSymbols;
26:
27: // Setup ==================================================================
28:
29: public QSequenceCachingMedia(QSequenceCachableMedia media,
30: QSequenceCanceller canceller) throws QSequenceException {
31: super (canceller);
32:
33: this .symbolMap = new QSequenceCachingMediaSymbolMap(media
34: .getLeftLength()
35: + media.getRightLength());
36: this .leftSymbols = symbolMap.createSymbols(media,
37: new QSequenceCachableMediaLeftGetter());
38: this .rightSymbols = symbolMap.createSymbols(media,
39: new QSequenceCachableMediaRightGetter());
40: }
41:
42: // Implemented ============================================================
43:
44: public int getLeftLength() {
45: return leftSymbols.length;
46: }
47:
48: public int getRightLength() {
49: return rightSymbols.length;
50: }
51:
52: public boolean equals(int leftIndex, int rightIndex)
53: throws QSequenceCancelledException {
54: checkCancelled();
55: return leftSymbols[leftIndex] == rightSymbols[rightIndex];
56: }
57:
58: // Accessing ==============================================================
59:
60: public int getSymbolCount() {
61: return symbolMap.getSymbolCount();
62: }
63:
64: public int[] getLeftSymbols() {
65: return leftSymbols;
66: }
67:
68: public int[] getRightSymbols() {
69: return rightSymbols;
70: }
71: }
|