MCPcopy Create free account
hub / github.com/GateNLP/gate-core / createResource

Method createResource

src/main/java/gate/creole/BootStrap.java:525–653  ·  view source on GitHub ↗

Creates the resource and dumps out a project structure using the structure from gate/resource/creole/bootstrap/Template and the information provided by the user @param resourceName is the name of the resource @param packageName is the name of the new resource @param typeResource is the type of the

( String resourceName,String packageName,
                              String typeResource,String className,
                              Set<String> interfacesList,String pathNewProject)

Source from the content-addressed store, hash-verified

523 * @param pathNewProject is the path where it will be the new resource
524 */
525 public void createResource( String resourceName,String packageName,
526 String typeResource,String className,
527 Set<String> interfacesList,String pathNewProject)
528 throws
529 IOException,ClassNotFoundException,
530 GateException,InterruptedException {
531 // the current file created by the system
532 File newFile = null;
533
534 // define for reading from a file.properties
535 Properties properties = new Properties();
536
537 // the new path of the current file
538 String newPathFile = null;
539
540 // the path of file from template project
541 String oldPathFile = null;
542
543 // verify the input
544 verifyInput(className,pathNewProject);
545
546 // determine the interfaces that the resource implements and the class
547 // that it extends
548 String interfacesAndClass = getInterfacesAndClass (typeResource,
549 interfacesList);
550
551 //determine the list with packages
552 listPackages = determinePath(packageName);
553
554 //add "/" at the end of the path of project
555 if (!pathNewProject.endsWith("/")) pathNewProject = pathNewProject + "/";
556
557 // determine the path of the main class
558 String stringPackages = listPackages.get(0);
559 for (int i=1;i<listPackages.size();i++) {
560 stringPackages = stringPackages + "/"+listPackages.get(i);
561 }
562
563 // create the map with the names
564 createNames(packageName,resourceName,className,
565 stringPackages,interfacesAndClass);
566
567 // take the content of the file with the structure of the template project
568 InputStream inputStream = Files.getGateResourceAsStream(oldResource +
569 "file-list.properties");
570
571 // put all the files and directories
572 properties.load(inputStream);
573
574 // close the input stream
575 inputStream.close();
576
577 // firstly create the directories
578 String oldDirectories = properties.getProperty("directories");
579 StringTokenizer token = new StringTokenizer(oldDirectories,",");
580 while (token.hasMoreTokens()) {
581 String propPathDirectory = token.nextToken();
582 if (propPathDirectory.endsWith("___ALLPACKAGES___")) {

Callers 2

mainMethod · 0.95
runMethod · 0.45

Calls 15

verifyInputMethod · 0.95
getInterfacesAndClassMethod · 0.95
determinePathMethod · 0.95
createNamesMethod · 0.95
closeMethod · 0.95
changeKeyValueMethod · 0.95
executableFileMethod · 0.95
loadMethod · 0.80
getMethod · 0.65
sizeMethod · 0.65
getPropertyMethod · 0.65

Tested by

no test coverage detected