-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
broke circular dependency AbstractExpandedDecoder
- Loading branch information
Showing
4 changed files
with
72 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 9 additions & 59 deletions
68
src/core/oned/rss/expanded/decoders/AbstractExpandedDecoder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,25 @@ | ||
import FormatException from '../../../../FormatException'; | ||
import NotFoundException from '../../../../NotFoundException'; | ||
import IllegalStateException from '../../../../IllegalStateException'; | ||
import BitArray from '../../../../common/BitArray'; | ||
import GeneralAppIdDecoder from './GeneralAppIdDecoder'; | ||
import AI01AndOtherAIs from './AI01AndOtherAIs'; | ||
import AnyAIDecoder from './AnyAIDecoder'; | ||
import AI013103decoder from './AI013103decoder'; | ||
import AI01320xDecoder from './AI01320xDecoder'; | ||
import AI01392xDecoder from './AI01392xDecoder'; | ||
import AI01393xDecoder from './AI01393xDecoder'; | ||
import AI013x0x1xDecoder from './AI013x0x1xDecoder'; | ||
|
||
export default abstract class AbstractExpandedDecoder{ | ||
export default abstract class AbstractExpandedDecoder { | ||
|
||
private readonly information: BitArray; | ||
private readonly generalDecoder: GeneralAppIdDecoder; | ||
|
||
constructor(information:BitArray) { | ||
constructor(information: BitArray) { | ||
this.information = information; | ||
this.generalDecoder = new GeneralAppIdDecoder(information) | ||
this.generalDecoder = new GeneralAppIdDecoder(information); | ||
} | ||
|
||
protected getInformation():BitArray{ | ||
protected getInformation(): BitArray { | ||
return this.information; | ||
} | ||
|
||
protected getGeneralDecoder():GeneralAppIdDecoder { | ||
protected getGeneralDecoder(): GeneralAppIdDecoder { | ||
return this.generalDecoder; | ||
} | ||
|
||
public abstract parseInformation(): string | ||
|
||
public static createDecoder(information: BitArray): AbstractExpandedDecoder { | ||
try { | ||
if (information.get(1)) { | ||
return new AI01AndOtherAIs(information); | ||
|
||
} | ||
if (!information.get(2)) { | ||
return new AnyAIDecoder(information); | ||
} | ||
|
||
let fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4); | ||
|
||
switch (fourBitEncodationMethod) { | ||
case 4: return new AI013103decoder(information); | ||
case 5: return new AI01320xDecoder(information); | ||
} | ||
|
||
let fiveBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 5); | ||
switch (fiveBitEncodationMethod) { | ||
case 12: return new AI01392xDecoder(information); | ||
case 13: return new AI01393xDecoder(information); | ||
} | ||
|
||
let sevenBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 7); | ||
switch (sevenBitEncodationMethod) { | ||
case 56: return new AI013x0x1xDecoder(information, "310", "11"); | ||
case 57: return new AI013x0x1xDecoder(information, "320", "11"); | ||
case 58: return new AI013x0x1xDecoder(information, "310", "13"); | ||
case 59: return new AI013x0x1xDecoder(information, "320", "13"); | ||
case 60: return new AI013x0x1xDecoder(information, "310", "15"); | ||
case 61: return new AI013x0x1xDecoder(information, "320", "15"); | ||
case 62: return new AI013x0x1xDecoder(information, "310", "17"); | ||
case 63: return new AI013x0x1xDecoder(information, "320", "17"); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
throw new IllegalStateException("unknown decoder: " + information); | ||
} | ||
|
||
|
||
} | ||
public abstract parseInformation(): string; | ||
|
||
} | ||
// createDecoder moved to own file due to circular dependency | ||
} |
54 changes: 54 additions & 0 deletions
54
src/core/oned/rss/expanded/decoders/AbstractExpandedDecoderComplement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import IllegalStateException from '../../../../IllegalStateException'; | ||
import BitArray from '../../../../common/BitArray'; | ||
import GeneralAppIdDecoder from './GeneralAppIdDecoder'; | ||
import AI01AndOtherAIs from './AI01AndOtherAIs'; | ||
import AnyAIDecoder from './AnyAIDecoder'; | ||
import AI013103decoder from './AI013103decoder'; | ||
import AI01320xDecoder from './AI01320xDecoder'; | ||
import AI01392xDecoder from './AI01392xDecoder'; | ||
import AI01393xDecoder from './AI01393xDecoder'; | ||
import AI013x0x1xDecoder from './AI013x0x1xDecoder'; | ||
import AbstractExpandedDecoder from './AbstractExpandedDecoder'; | ||
|
||
|
||
export function createDecoder(information: BitArray): AbstractExpandedDecoder { | ||
try { | ||
if (information.get(1)) { | ||
return new AI01AndOtherAIs(information); | ||
|
||
} | ||
if (!information.get(2)) { | ||
return new AnyAIDecoder(information); | ||
} | ||
|
||
let fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4); | ||
|
||
switch (fourBitEncodationMethod) { | ||
case 4: return new AI013103decoder(information); | ||
case 5: return new AI01320xDecoder(information); | ||
} | ||
|
||
let fiveBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 5); | ||
switch (fiveBitEncodationMethod) { | ||
case 12: return new AI01392xDecoder(information); | ||
case 13: return new AI01393xDecoder(information); | ||
} | ||
|
||
let sevenBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 7); | ||
switch (sevenBitEncodationMethod) { | ||
case 56: return new AI013x0x1xDecoder(information, '310', '11'); | ||
case 57: return new AI013x0x1xDecoder(information, '320', '11'); | ||
case 58: return new AI013x0x1xDecoder(information, '310', '13'); | ||
case 59: return new AI013x0x1xDecoder(information, '320', '13'); | ||
case 60: return new AI013x0x1xDecoder(information, '310', '15'); | ||
case 61: return new AI013x0x1xDecoder(information, '320', '15'); | ||
case 62: return new AI013x0x1xDecoder(information, '310', '17'); | ||
case 63: return new AI013x0x1xDecoder(information, '320', '17'); | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
throw new IllegalStateException('unknown decoder: ' + information); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import BitArray from '../../../../common/BitArray'; | ||
import StringBuilder from '../../../../util/StringBuilder'; | ||
import AbstractExpandedDecoder from './AbstractExpandedDecoder'; | ||
|
||
|
||
export default class AnyAIDecoder extends AbstractExpandedDecoder { | ||
|
||
private static readonly HEADER_SIZE:number = 2 + 1 + 2; | ||
constructor(information:BitArray) { | ||
private static readonly HEADER_SIZE: number = 2 + 1 + 2; | ||
|
||
constructor(information: BitArray) { | ||
super(information); | ||
} | ||
|
||
public parseInformation():string { | ||
public parseInformation(): string { | ||
let buf = new StringBuilder(); | ||
return this.getGeneralDecoder().decodeAllCodes(buf, AnyAIDecoder.HEADER_SIZE); | ||
} | ||
} | ||
} |