Debian Codegraph @

src/org/tukaani/xz/lzma/State.java

raw symbols SCIP
1 // SPDX-License-Identifier: 0BSD
2 // SPDX-FileCopyrightText: The XZ for Java authors and contributors
3 // SPDX-FileContributor: Lasse Collin <[email protected]>
4 // SPDX-FileContributor: Igor Pavlov <https://7-zip.org/>
5
6 package org.tukaani.xz.lzma;
7
8 final class State {
9 static final int STATES = 12;
10
11 private static final int LIT_STATES = 7;
12
13 private static final int LIT_LIT = 0;
14 private static final int MATCH_LIT_LIT = 1;
15 private static final int REP_LIT_LIT = 2;
16 private static final int SHORTREP_LIT_LIT = 3;
17 private static final int MATCH_LIT = 4;
18 private static final int REP_LIT = 5;
19 private static final int SHORTREP_LIT = 6;
20 private static final int LIT_MATCH = 7;
21 private static final int LIT_LONGREP = 8;
22 private static final int LIT_SHORTREP = 9;
23 private static final int NONLIT_MATCH = 10;
24 private static final int NONLIT_REP = 11;
25
26 private int state;
27
28 State() {}
29
30 State(State other) {
31 state = other.state;
32 }
33
34 void reset() {
35 state = LIT_LIT;
36 }
37
38 int get() {
39 return state;
40 }
41
42 void set(State other) {
43 state = other.state;
44 }
45
46 void updateLiteral() {
47 if (state <= SHORTREP_LIT_LIT)
48 state = LIT_LIT;
49 else if (state <= LIT_SHORTREP)
50 state -= 3;
51 else
52 state -= 6;
53 }
54
55 void updateMatch() {
56 state = state < LIT_STATES ? LIT_MATCH : NONLIT_MATCH;
57 }
58
59 void updateLongRep() {
60 state = state < LIT_STATES ? LIT_LONGREP : NONLIT_REP;
61 }
62
63 void updateShortRep() {
64 state = state < LIT_STATES ? LIT_SHORTREP : NONLIT_REP;
65 }
66
67 boolean isLiteral() {
68 return state < LIT_STATES;
69 }
70 }