-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02f53c4
commit 8bac901
Showing
37 changed files
with
188 additions
and
135 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
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
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
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
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
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
52 changes: 52 additions & 0 deletions
52
iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/SlicedCharSequence.java
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,52 @@ | ||
package com.iab.gpp.encoder.section; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class SlicedCharSequence implements CharSequence { | ||
|
||
private final CharSequence base; | ||
private final int start; | ||
private final int end; | ||
|
||
private SlicedCharSequence(CharSequence base, int start, int end) { | ||
this.base = base; | ||
this.start = start; | ||
this.end = end; | ||
} | ||
|
||
public static List<CharSequence> split(CharSequence charSequence, char splitter) { | ||
List<CharSequence> out = new ArrayList<>(1); | ||
int length = charSequence.length(); | ||
int start = 0; | ||
for (int i = 0; i < length; i++) { | ||
if (charSequence.charAt(i) == splitter) { | ||
out.add(new SlicedCharSequence(charSequence, start, i)); | ||
start = i + 1; | ||
} | ||
} | ||
out.add(new SlicedCharSequence(charSequence, start, length)); | ||
return out; | ||
} | ||
|
||
@Override | ||
public int length() { | ||
return end - start; | ||
} | ||
|
||
@Override | ||
public char charAt(int index) { | ||
return base.charAt(start + index); | ||
} | ||
|
||
@Override | ||
public CharSequence subSequence(int newStart, int newEnd) { | ||
return base.subSequence(start + newStart, start + newEnd); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return base.subSequence(start, end).toString(); | ||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.