001    package plugins;
002    import sharpster.common.*;
003    import java.util.*;
004    import plugins.JavaRolePluginModule.*;
005    
006    public class JavaRolePlugin {
007        //  extends PartOfFilePlugin
008        
009        /**
010         *  Returns the name of the plug-in which has created this data.
011         */
012        public String getPluginName() { 
013            return new String("JavaRolePlugin");
014        }
015        
016        /**
017         *  Retrns a description of this plug-in.
018         */
019        public String getPluginDescription(){
020                return new String("JavaRolePlugin: A plugin for extracting parts of files depending on tags");
021        }
022        
023        /**
024         * Parse a commandline argument and convert it to a specific plugin data.
025         */
026        public PluginData parseArguments(LinkedList args) { 
027            return new JavaRolePluginData();
028        }
029        
030        
031        
032        /**
033         *  Extract the shared parts from a file collection.
034         */
035        public ResponseCollection extractParts(SharedFile originalFile, String role) {
036            if (role.equals("doc")) {
037                return Extractor.extractPartsForDoc(originalFile);
038            }
039            else {
040                return Extractor.extractPartsForRole(originalFile,role);
041            }
042        }
043        
044        /**
045         *  Merge the shared parts with the entire files.
046         */
047        public ResponseCollection mergeParts(SharedFile originalFile, SharedFile partsFile, String role) {
048            if (role.equals("doc")) {
049                return Merger.mergePartsWithRoleDoc(originalFile,partsFile);
050            }
051            else {
052                return Merger.mergePartsWithRole(originalFile,partsFile,role);
053            }
054        }
055        
056        
057        
058        /**
059         * Extract the shared parts from a file collection.
060         */
061      /*public String extractParts(String originalFile, String role) {
062        ParseTree tree=new ParseTree(originalFile);
063        if(role.equals("doc")) {
064          Extractor.cleanseMethodBodies(tree);
065          return tree.toString();
066        }else{
067          Extractor.extractPartsForRole(tree,role);
068          return tree.toString();
069        }
070        }*/
071        
072        /**
073         * Merge the shared parts with the entire files.
074         */
075      /*public String mergeParts(String originalFile, String partsOfFile, String role) {
076        // @todo släng in felmeddelanden om inte parseträden kan skapas
077        ParseTree originalTree = new ParseTree(originalFile);
078        ParseTree partsTree = new ParseTree(partsOfFile);
079        if(role.equals("doc")) {
080          // @todo felmeddelande om ihopslagningen misslyckas av någon anledning
081          Merger.mergePartsWithRoleDoc(originalTree,partsTree);
082          return originalTree.toString();
083        }else{
084          // @todo felmeddelande om ihopslagningen misslyckas av någon anledning
085          Merger.mergePartsWithRole(originalTree,partsTree,role);
086          return originalTree.toString();
087        }
088        }*/
089    }
090    
091    
092    
093