else
{
// Only zip up zips.
writer = new FilteredDataEntryWriter(new DataEntryParentFilter(
new DataEntryNameFilter(
new ExtensionMatcher(".zip"))),
zipWriter,
writer);
}
// Zip up any ears, if necessary.
DataEntryWriter earWriter = new JarWriter(writer);
if (outputIsEar)
{
// Always zip.
writer = earWriter;
}
else
{
// Only zip up ears.
writer = new FilteredDataEntryWriter(new DataEntryParentFilter(
new DataEntryNameFilter(
new ExtensionMatcher(".ear"))),
earWriter,
writer);
}
// Zip up any wars, if necessary.
DataEntryWriter warWriter = new JarWriter(writer);
if (outputIsWar)
{
// Always zip.
writer = warWriter;
}
else
{
// Only zip up wars.
writer = new FilteredDataEntryWriter(new DataEntryParentFilter(
new DataEntryNameFilter(
new ExtensionMatcher(".war"))),
warWriter,
writer);
}
// Zip up any aars, if necessary.
DataEntryWriter aarWriter = new JarWriter(writer);
if (outputIsAar)
{
// Always zip.
writer = aarWriter;
}
else
{
// Only zip up aars.
writer = new FilteredDataEntryWriter(new DataEntryParentFilter(
new DataEntryNameFilter(
new ExtensionMatcher(".aar"))),
aarWriter,
writer);
}
// Zip up any jars, if necessary.
DataEntryWriter jarWriter = new JarWriter(writer);
if (outputIsJar)
{
// Always zip.
writer = jarWriter;
}
else
{
// Only zip up jars.
writer = new FilteredDataEntryWriter(new DataEntryParentFilter(
new DataEntryNameFilter(
new ExtensionMatcher(".jar"))),
jarWriter,
writer);
}
// Zip up any apks, if necessary.
DataEntryWriter apkWriter = new JarWriter(writer);
if (outputIsApk)
{
// Always zip.
writer = apkWriter;
}
else
{
// Only zip up apks.
writer = new FilteredDataEntryWriter(new DataEntryParentFilter(
new DataEntryNameFilter(
new ExtensionMatcher(".apk"))),
apkWriter,
writer);
}
// Create the copying DataEntryReader.
DataEntryReader reader = new DataEntryCopier(writer);
boolean inputIsApk = input.endsWith(".apk") ||
input.endsWith(".ap_");
boolean inputIsJar = input.endsWith(".jar");
boolean inputIsAar = input.endsWith(".aar");
boolean inputIsWar = input.endsWith(".war");
boolean inputIsEar = input.endsWith(".ear");
boolean inputIsZip = input.endsWith(".zip");
// Unzip any apks, if necessary.
DataEntryReader apkReader = new JarReader(reader);
if (inputIsApk)
{
// Always unzip.
reader = apkReader;
}
else
{
// Only unzip apk entries.
reader = new FilteredDataEntryReader(new DataEntryNameFilter(
new ExtensionMatcher(".apk")),
apkReader,
reader);
// Unzip any jars, if necessary.
DataEntryReader jarReader = new JarReader(reader);
if (inputIsJar)
{
// Always unzip.
reader = jarReader;
}
else
{
// Only unzip jar entries.
reader = new FilteredDataEntryReader(new DataEntryNameFilter(
new ExtensionMatcher(".jar")),
jarReader,
reader);
// Unzip any aars, if necessary.
DataEntryReader aarReader = new JarReader(reader);
if (inputIsAar)
{
// Always unzip.
reader = aarReader;
}
else
{
// Only unzip aar entries.
reader = new FilteredDataEntryReader(new DataEntryNameFilter(
new ExtensionMatcher(".aar")),
aarReader,
reader);
// Unzip any wars, if necessary.
DataEntryReader warReader = new JarReader(reader);
if (inputIsWar)
{
// Always unzip.
reader = warReader;
}
else
{
// Only unzip war entries.
reader = new FilteredDataEntryReader(new DataEntryNameFilter(
new ExtensionMatcher(".war")),
warReader,
reader);
// Unzip any ears, if necessary.
DataEntryReader earReader = new JarReader(reader);
if (inputIsEar)
{
// Always unzip.
reader = earReader;
}
else
{
// Only unzip ear entries.
reader = new FilteredDataEntryReader(new DataEntryNameFilter(
new ExtensionMatcher(".ear")),
earReader,
reader);
// Unzip any zips, if necessary.
DataEntryReader zipReader = new JarReader(reader);
if (inputIsZip)
{
// Always unzip.
reader = zipReader;
}
else
{
// Only unzip zip entries.
reader = new FilteredDataEntryReader(new DataEntryNameFilter(
new ExtensionMatcher(".zip")),
zipReader,
reader);
}
}
}