KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > obfuscate > MultiMappingProcessor


1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  * of Java bytecode.
4  *
5  * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21 package proguard.obfuscate;
22
23 import proguard.classfile.*;
24 import proguard.classfile.util.ClassUtil;
25
26
27 /**
28  * This MappingKeeper delegates all method calls to each MappingProcessor
29  * in a given list.
30  *
31  * @author Eric Lafortune
32  */

33 public class MultiMappingProcessor implements MappingProcessor
34 {
35     private MappingProcessor[] mappingProcessors;
36
37
38     /**
39      * Creates a new MultiMappingProcessor.
40      * @param mappingProcessors the mapping processors to which method calls
41      * will be delegated.
42      */

43     public MultiMappingProcessor(MappingProcessor[] mappingProcessors)
44     {
45         this.mappingProcessors = mappingProcessors;
46     }
47
48
49     // Implementations for MappingProcessor.
50

51     public boolean processClassMapping(String JavaDoc className,
52                                        String JavaDoc newClassName)
53     {
54         boolean result = false;
55
56         for (int index = 0; index < mappingProcessors.length; index++)
57         {
58             result |= mappingProcessors[index].processClassMapping(className,
59                                                                    newClassName);
60         }
61
62         return result;
63     }
64
65
66     public void processFieldMapping(String JavaDoc className,
67                                     String JavaDoc fieldType,
68                                     String JavaDoc fieldName,
69                                     String JavaDoc newFieldName)
70     {
71         for (int index = 0; index < mappingProcessors.length; index++)
72         {
73             mappingProcessors[index].processFieldMapping(className,
74                                                          fieldType,
75                                                          fieldName,
76                                                          newFieldName);
77         }
78     }
79
80
81     public void processMethodMapping(String JavaDoc className,
82                                      int firstLineNumber,
83                                      int lastLineNumber,
84                                      String JavaDoc methodReturnType,
85                                      String JavaDoc methodNameAndArguments,
86                                      String JavaDoc newMethodName)
87     {
88         for (int index = 0; index < mappingProcessors.length; index++)
89         {
90             mappingProcessors[index].processMethodMapping(className,
91                                                           firstLineNumber,
92                                                           lastLineNumber,
93                                                           methodReturnType,
94                                                           methodNameAndArguments,
95                                                           newMethodName);
96         }
97     }
98 }
99
Popular Tags