Java Code Examples for proguard.classfile.io.ProgramClassWriter

The following examples show how to use proguard.classfile.io.ProgramClassWriter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: java-n-IDE-for-Android   Source File: ClassRewriter.java    License: Apache License 2.0 5 votes vote down vote up
public void read(DataEntry dataEntry) throws IOException
{
    String inputName = dataEntry.getName();
    String className = inputName.substring(0, inputName.length() - ClassConstants.CLASS_FILE_EXTENSION.length());

    // Find the modified class corrsponding to the input entry.
    ProgramClass programClass = (ProgramClass)classPool.getClass(className);
    if (programClass != null)
    {
        // Rename the data entry if necessary.
        String newClassName = programClass.getName();
        if (!className.equals(newClassName))
        {
            dataEntry = new RenamedDataEntry(dataEntry, newClassName + ClassConstants.CLASS_FILE_EXTENSION);
        }

        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(dataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
}
 
Example 2
Source Project: proguard   Source File: ClassRewriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void read(DataEntry dataEntry) throws IOException
{
    String inputName = dataEntry.getName();
    String className = inputName.substring(0, inputName.length() - ClassConstants.CLASS_FILE_EXTENSION.length());

    // Find the modified class corrsponding to the input entry.
    ProgramClass programClass = (ProgramClass)classPool.getClass(className);
    if (programClass != null)
    {
        // Rename the data entry if necessary.
        String newClassName = programClass.getName();
        if (!className.equals(newClassName))
        {
            dataEntry = new RenamedDataEntry(dataEntry, newClassName + ClassConstants.CLASS_FILE_EXTENSION);
        }

        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(dataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
}
 
Example 3
public void visitProgramClass(ProgramClass programClass)
{
    // Rename the data entry if necessary.
    String    actualClassName = programClass.getName();
    DataEntry actualDataEntry =
        new RenamedDataEntry(templateDataEntry,
                             actualClassName + ClassConstants.CLASS_FILE_EXTENSION);

    try
    {
        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(actualDataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
    catch (IOException e)
    {
        throw new RuntimeException("Can't write program class ["+actualClassName+"] to ["+actualDataEntry+"] ("+e.getMessage()+")", e);
    }
}
 
Example 4
Source Project: bazel   Source File: ClassRewriter.java    License: Apache License 2.0 5 votes vote down vote up
public void read(DataEntry dataEntry) throws IOException
{
    String inputName = dataEntry.getName();
    String className = inputName.substring(0, inputName.length() - ClassConstants.CLASS_FILE_EXTENSION.length());

    // Find the modified class corrsponding to the input entry.
    ProgramClass programClass = (ProgramClass)classPool.getClass(className);
    if (programClass != null)
    {
        // Rename the data entry if necessary.
        String newClassName = programClass.getName();
        if (!className.equals(newClassName))
        {
            dataEntry = new RenamedDataEntry(dataEntry, newClassName + ClassConstants.CLASS_FILE_EXTENSION);
        }

        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(dataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
}
 
Example 5
Source Project: bazel   Source File: DataEntryClassWriter.java    License: Apache License 2.0 5 votes vote down vote up
public void visitProgramClass(ProgramClass programClass)
{
    // Rename the data entry if necessary.
    String    actualClassName = programClass.getName();
    DataEntry actualDataEntry =
        new RenamedDataEntry(templateDataEntry,
                             actualClassName + ClassConstants.CLASS_FILE_EXTENSION);

    try
    {
        // Get the output entry corresponding to this input entry.
        OutputStream outputStream = dataEntryWriter.getOutputStream(actualDataEntry);
        if (outputStream != null)
        {
            // Write the class to the output entry.
            DataOutputStream classOutputStream = new DataOutputStream(outputStream);

            new ProgramClassWriter(classOutputStream).visitProgramClass(programClass);

            classOutputStream.flush();
        }
    }
    catch (IOException e)
    {
        throw new RuntimeException("Can't write program class ["+actualClassName+"] to ["+actualDataEntry+"] ("+e.getMessage()+")", e);
    }
}