mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00:00
Format with google-java-format
This commit is contained in:
parent
355484ebfb
commit
8a6f4a91e9
2 changed files with 19 additions and 9 deletions
|
|
@ -16,7 +16,6 @@
|
|||
package androidx.media3.exoplayer.dash.manifest;
|
||||
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
@ -63,7 +62,10 @@ public final class UrlTemplate {
|
|||
|
||||
/** Internal constructor. Use {@link #compile(String)} to build instances of this class. */
|
||||
private UrlTemplate(
|
||||
ArrayList<String> urlPieces, ArrayList<Integer> identifiers, ArrayList<String> identifierFormatTags, int identifierCount) {
|
||||
ArrayList<String> urlPieces,
|
||||
ArrayList<Integer> identifiers,
|
||||
ArrayList<String> identifierFormatTags,
|
||||
int identifierCount) {
|
||||
this.urlPieces = urlPieces;
|
||||
this.identifiers = identifiers;
|
||||
this.identifierFormatTags = identifierFormatTags;
|
||||
|
|
@ -115,17 +117,23 @@ public final class UrlTemplate {
|
|||
* @throws IllegalArgumentException If the template string is malformed.
|
||||
*/
|
||||
private static int parseTemplate(
|
||||
String template, ArrayList<String> urlPieces, ArrayList<Integer> identifiers, ArrayList<String> identifierFormatTags) {
|
||||
String template,
|
||||
ArrayList<String> urlPieces,
|
||||
ArrayList<Integer> identifiers,
|
||||
ArrayList<String> identifierFormatTags) {
|
||||
urlPieces.add("");
|
||||
int templateIndex = 0;
|
||||
int identifierCount = 0;
|
||||
while (templateIndex < template.length()) {
|
||||
int dollarIndex = template.indexOf("$", templateIndex);
|
||||
if (dollarIndex == -1) {
|
||||
urlPieces.set(identifierCount, urlPieces.get(identifierCount) + template.substring(templateIndex));
|
||||
urlPieces.set(
|
||||
identifierCount, urlPieces.get(identifierCount) + template.substring(templateIndex));
|
||||
templateIndex = template.length();
|
||||
} else if (dollarIndex != templateIndex) {
|
||||
urlPieces.set(identifierCount, urlPieces.get(identifierCount) + template.substring(templateIndex, dollarIndex));
|
||||
urlPieces.set(
|
||||
identifierCount,
|
||||
urlPieces.get(identifierCount) + template.substring(templateIndex, dollarIndex));
|
||||
templateIndex = dollarIndex;
|
||||
} else if (template.startsWith(ESCAPED_DOLLAR, templateIndex)) {
|
||||
urlPieces.set(identifierCount, urlPieces.get(identifierCount) + "$");
|
||||
|
|
|
|||
|
|
@ -72,16 +72,18 @@ public class UrlTemplateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fullWithMultipleOccurrences(){
|
||||
String template = "$Bandwidth$_a1_$RepresentationID$_b1_$Time$_c1_$Number$_$Bandwidth$_a2_$RepresentationID$_b2_$Time$_c2_$Number$";
|
||||
public void fullWithMultipleOccurrences() {
|
||||
String template =
|
||||
"$Bandwidth$_a1_$RepresentationID$_b1_$Time$_c1_$Number$_$Bandwidth$_a2_$RepresentationID$_b2_$Time$_c2_$Number$";
|
||||
UrlTemplate urlTemplate = UrlTemplate.compile(template);
|
||||
String url = urlTemplate.buildUri("abc1", 10, 650000, 5000);
|
||||
assertThat(url).isEqualTo("650000_a1_abc1_b1_5000_c1_10_650000_a2_abc1_b2_5000_c2_10");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fullWithMultipleOccurrencesAndDollarEscaping(){
|
||||
String template = "$$$Bandwidth$$$_a1$$_$RepresentationID$_b1_$Time$_c1_$Number$$$_$$$Bandwidth$$$_a2$$_$RepresentationID$_b2_$Time$_c2_$Number$$$";
|
||||
public void fullWithMultipleOccurrencesAndDollarEscaping() {
|
||||
String template =
|
||||
"$$$Bandwidth$$$_a1$$_$RepresentationID$_b1_$Time$_c1_$Number$$$_$$$Bandwidth$$$_a2$$_$RepresentationID$_b2_$Time$_c2_$Number$$$";
|
||||
UrlTemplate urlTemplate = UrlTemplate.compile(template);
|
||||
String url = urlTemplate.buildUri("abc1", 10, 650000, 5000);
|
||||
assertThat(url).isEqualTo("$650000$_a1$_abc1_b1_5000_c1_10$_$650000$_a2$_abc1_b2_5000_c2_10$");
|
||||
|
|
|
|||
Loading…
Reference in a new issue