本文整理汇总了Java中proguard.classfile.io.ProgramClassWriter类的典型用法代码示例。如果您正苦于以下问题:Java ProgramClassWriter类的具体用法?Java ProgramClassWriter怎么用?Java ProgramClassWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProgramClassWriter类属于proguard.classfile.io包,在下文中一共展示了ProgramClassWriter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import proguard.classfile.io.ProgramClassWriter; //导入依赖的package包/类
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();
}
}
}
示例2: visitProgramClass
import proguard.classfile.io.ProgramClassWriter; //导入依赖的package包/类
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);
}
}