|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcodesimian.Zips
codesimian.Jars
public class Jars
9/07 This class is not finished. Later it will contain
static functions for using, combining, breeding, and evolving JAR files.
Jars.findSelf(boolean) usually works,
but sometimes not when you're not in an applet for example,
and often has problems finding CodeSimian.jar in non-Windows operating-systems (has not been tested much).
Needs to be fixed asap. Finding self is the most reliable
way of getting the bytes of the program's internal files (jar is zip. it has internal files).
For example, find 1 CodeSimian.jar that contains a few different files
from this program (an executing CodeSimian.jar) or find 2 different CodeSimian.jar's,
and combine some of their different files to create a new CodeSimian.jar with different behaviors.
Each software is 1 file (CodeSimian4.jar CodeSimian556.jar etc) and can modify other similar softwares.
NEED TO BUILD: a way to create and execute new JAR files IN MEMORY ONLY
for if a hard-drive is not available like in an APPLET in a webpage.
Nested Class Summary | |
---|---|
static class |
Jars.JarTest
|
static class |
Jars.SaveUpdatedSelf
saves a new CodeSimian.jar somewhere. |
static class |
Jars.ZipEntryAndByteArray
|
Method Summary | |
---|---|
static java.io.ByteArrayInputStream |
breed(java.io.ByteArrayInputStream[] jars)
Breeds 2 or more modified CodeSimian.jar's into a single CodeSimian.jar which is returned |
static java.io.ByteArrayInputStream |
consumeAnotherProgram(java.io.ByteArrayInputStream anyOtherJarProgram)
any JAR file contains classes and maybe other files that CodeSimian might consume by copying it into a new CodeSimian.jar This class should search for a license text file and license at top of source-code files and announce this info to a LicenseListener object (LicenseListener interface not yet created 9/06). |
static java.io.ByteArrayInputStream |
consumeAnyBytes(java.lang.String nameOrDescription,
java.io.InputStream anything)
Creates a new JAR file (a new version of the currently-executing CodeSimian.jar) after consuming some bytes. |
int |
consumeFilesInJar(java.io.ByteArrayInputStream bytesOfJarFile,
java.lang.String putInThisInternalFolder,
CS fileNameJudge,
CS fileBytesJudge,
CS booleanOverwriteP0WithP1)
if putInThisInternalFolder is null, use the files' existing folder plus some prefix. |
int |
consumeFilesInJar(java.io.ByteArrayInputStream bytesOfJarFile,
java.lang.String putInThisInternalFolder,
java.lang.String fileNameEnd)
example: consumeFilesInJar(bytesOfSomeJar, "cs/", ".cs") |
static java.io.ByteArrayInputStream |
consumeSimilar(java.io.ByteArrayInputStream similarToMe,
int minBytesToConsume,
int maxBytesToConsume)
Modifies this program executing now and saves it in a new CodeSimian.jar. |
static java.io.ByteArrayInputStream[] |
findAnythingOnTheInternet(CS byteJudger,
java.net.URL[] startSearchingHere,
int howManyFilesDoYouWant,
long maxMilliseconds,
long minBytesEach,
long maxBytesEach)
|
static java.io.ByteArrayInputStream[] |
findJarsOnTheInternet(CS jarJudger,
java.net.URL[] startSearchingHere,
int howManyJarsDoYouWant,
long maxMilliseconds,
long minBytesEachJar,
long maxBytesEachJar)
Uses jarJudger.setL(ByteArrayInputStream) then executes jarJudger.D() to judge JARs it finds on the internet, and based on how jarJudger judges, tries to find better JARs on the internet next time you call this function with the same (or similar?) jarJudger object. |
static java.lang.String[] |
findLicenses(java.io.ByteArrayInputStream anyJar)
should return strings like "GNU GPL" "GNU LGPL" "public domain" "new BSD" "License of Guile" etc, or whichever licenses the input program allows (can choose any, not required to use all). |
static java.io.ByteArrayInputStream |
findSelf(boolean createApproximateSelfIfCanOnlyFindPartsOfSelf)
returns the CodeSimian.jar that contains this program executing now, or null if could not find it. |
static byte[] |
findSelfBytes(boolean createApproximateSelfIfCanOnlyFindPartsOfSelf)
|
static java.io.ByteArrayInputStream[] |
findSimilarToSelf()
returns Jar files it thinks are most similar to the CodeSimian.jar currently executing. |
static byte[] |
getUpdatedSelfBytes()
|
static java.io.ByteArrayInputStream |
getUpdatedSelfInputStream()
returns the bytes for a new CodeSimian.jar, including all files in the original CodeSimian.jar (returned by findSelf()), except for files deleted by deleteInternalFile and files added or modified by setInternalFile (in InnerFiles.java). |
static float |
GPLcompatible(java.io.ByteArrayInputStream anyJar)
is a JAR file compatible with the GNU GPL license? All LGPL, new BSD, and many other licenses are GPL-compatible. |
static float |
LGPLcompatible(java.io.ByteArrayInputStream anyJar)
is a JAR file compatible with the GNU LGPL license? Unlike GPL, LGPL allows you to keep your code secret while distributing the executable. |
static byte[] |
readBytesForCurrentEntry(java.util.zip.ZipEntry currentEntry,
java.util.zip.ZipInputStream jarIn)
jarIn.getNextJarEntry() must have returned currentEntry the last time it was called, because that positions the ByteArrayInputStream to the beginning of the entry. |
static void |
suicide(Liquid liquidJarSuicide)
This Jar file (like CodeSimian.jar) is the Java program that is running now. |
Methods inherited from class codesimian.Zips |
---|
get1FileFromZip, getFileNames, unzip, zipCsArray, zipFileOrFolder, zipFileOrFolder, zipPathNameSaveToPathName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.io.ByteArrayInputStream findSelf(boolean createApproximateSelfIfCanOnlyFindPartsOfSelf)
createApproximateSelfIfCanOnlyFindPartsOfSelf
- WARNING: approximate self Jars often do not work
because they are made of less than all the files inside CodeSimian.jar and some files are required.
9/06 no code exists to approximate a JAR, but this ability should be added later
in case all the files cant be found, or if a JAR needs to be repaired...public static void suicide(Liquid liquidJarSuicide)
public static byte[] findSelfBytes(boolean createApproximateSelfIfCanOnlyFindPartsOfSelf)
public static java.io.ByteArrayInputStream[] findSimilarToSelf()
public static java.io.ByteArrayInputStream consumeSimilar(java.io.ByteArrayInputStream similarToMe, int minBytesToConsume, int maxBytesToConsume)
public static java.io.ByteArrayInputStream consumeAnotherProgram(java.io.ByteArrayInputStream anyOtherJarProgram)
public static java.io.ByteArrayInputStream[] findJarsOnTheInternet(CS jarJudger, java.net.URL[] startSearchingHere, int howManyJarsDoYouWant, long maxMilliseconds, long minBytesEachJar, long maxBytesEachJar)
public static java.io.ByteArrayInputStream[] findAnythingOnTheInternet(CS byteJudger, java.net.URL[] startSearchingHere, int howManyFilesDoYouWant, long maxMilliseconds, long minBytesEach, long maxBytesEach)
public static java.io.ByteArrayInputStream consumeAnyBytes(java.lang.String nameOrDescription, java.io.InputStream anything)
nameOrDescription
- a filename, for example. Can be null.public static java.io.ByteArrayInputStream breed(java.io.ByteArrayInputStream[] jars)
public static float GPLcompatible(java.io.ByteArrayInputStream anyJar)
public static float LGPLcompatible(java.io.ByteArrayInputStream anyJar)
public static java.lang.String[] findLicenses(java.io.ByteArrayInputStream anyJar)
public static byte[] readBytesForCurrentEntry(java.util.zip.ZipEntry currentEntry, java.util.zip.ZipInputStream jarIn)
public static byte[] getUpdatedSelfBytes() throws java.io.IOException
java.io.IOException
public static java.io.ByteArrayInputStream getUpdatedSelfInputStream()
public int consumeFilesInJar(java.io.ByteArrayInputStream bytesOfJarFile, java.lang.String putInThisInternalFolder, CS fileNameJudge, CS fileBytesJudge, CS booleanOverwriteP0WithP1)
booleanOverwriteP0WithP1
- Its first 2 params are overwritten
by String filenames: P0 old file, P1 new file. Both are codesimian
internal virtual names and paths, like "cs/SelfReplicatingWindow10.cs".public int consumeFilesInJar(java.io.ByteArrayInputStream bytesOfJarFile, java.lang.String putInThisInternalFolder, java.lang.String fileNameEnd)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |