Package gate.creole

Examples of gate.creole.ResourceInstantiationException


      String fileName = "JapeExtended_" + grammarfile.getName().replaceAll("\\.jape$","") + Gate.genSym() + ".jape";
      //System.out.println("Generated file name: "+fileName);
      try {
        generatedFileURL = new File(tmpDir,fileName).toURI().toURL();
      } catch (MalformedURLException ex) {
        throw new ResourceInstantiationException("Cannot create generated file URL for "+tmpDir+" / "+fileName);
      }
    }
    String jape = "";
    try {
      jape = readURL2String(originalURL,encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not read grammar file "+originalURL,ex);
    }
    //System.out.println("Got jape file: \n"+jape);
    ST template = new ST(jape,'$','$');
    //System.out.println("Created template");
    //System.out.println("regenerating: variables="+variables);
    //System.out.println("regenerating: parameters="+parameters);
    //System.out.println("regenerating: vs="+vs);
    for(Object key : vs.keySet()) {
      if(key instanceof String) {
        //System.out.println("Setting key/val: "+key+"/"+vs.get(key));
        template.add((String)key, vs.get(key));
      } else {
        System.err.println("Ignored parameter for template (not a String): "+
          key+"="+vs.get(key).toString());
      }
    }
    String result = template.render();
    //System.out.println("Rendered template: \n"+result);
    File generatedFile = Files.fileFromURL(generatedFileURL);
    System.out.println("Generated grammar file: "+generatedFile);
    try {
      FileUtils.writeStringToFile(generatedFile, result, encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not write to file "+generatedFile,ex);
    }
    return generatedFileURL;
  }
View Full Code Here


      //if couldn't find it that way, try with current thread class loader
      try {
        clazz = Class.forName(opName, true,
          Thread.currentThread().getContextClassLoader()).asSubclass(ConstraintPredicate.class);
      } catch (ClassNotFoundException e1) {
        throw new ResourceInstantiationException("Cannot load class for operator: " + opName, e1);
      }
    } catch (ClassCastException cce) {
      throw new ResourceInstantiationException("Operator class '" + opName + "' must implement ConstraintPredicate");
    }
    //instantiate an instance of the class so can get the operator string
    try {
      ConstraintPredicate predicate = clazz.newInstance();
      String opSymbol = predicate.getOperator();
      //now store it in ConstraintFactory
      Factory.getConstraintFactory().addOperator(opSymbol, clazz);
    } catch (Exception e) {
      throw new ResourceInstantiationException("Cannot instantiate class for operator: " + opName, e);
    }
  }
View Full Code Here

      String fileName = "JapePlusExtended_" + grammarfile.getName().replaceAll("\\.jape$","") + Gate.genSym() + ".jape";
      //System.out.println("Generated file name: "+fileName);
      try {
        generatedFileURL = new File(tmpDir,fileName).toURI().toURL();
      } catch (MalformedURLException ex) {
        throw new ResourceInstantiationException("Cannot create generated file URL for "+tmpDir+" / "+fileName);
      }
    }
    String jape = "";
    try {
      jape = readURL2String(originalURL,encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not read grammar file "+originalURL,ex);
    }
    //System.out.println("Got jape file: \n"+jape);
    ST template = new ST(jape,'$','$');
    //System.out.println("Created template");
    //System.out.println("regenerating: variables="+variables);
    //System.out.println("regenerating: parameters="+parameters);
    //System.out.println("regenerating: vs="+vs);
    for(Object key : vs.keySet()) {
      if(key instanceof String) {
        //System.out.println("Setting key/val: "+key+"/"+vs.get(key));
        template.add((String)key, vs.get(key));
      } else {
        System.err.println("Ignored parameter for template (not a String): "+
          key+"="+vs.get(key).toString());
      }
    }
    String result = template.render();
    //System.out.println("Rendered template: \n"+result);
    File generatedFile = Files.fileFromURL(generatedFileURL);
    System.out.println("Generated grammar file: "+generatedFile);
    try {
      FileUtils.writeStringToFile(generatedFile, result, encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not write to file "+generatedFile,ex);
    }
    return generatedFileURL;
  }
View Full Code Here

      //if couldn't find it that way, try with current thread class loader
      try {
        clazz = Class.forName(opName, true,
          Thread.currentThread().getContextClassLoader()).asSubclass(ConstraintPredicate.class);
      } catch (ClassNotFoundException e1) {
        throw new ResourceInstantiationException("Cannot load class for operator: " + opName, e1);
      }
    } catch (ClassCastException cce) {
      throw new ResourceInstantiationException("Operator class '" + opName + "' must implement ConstraintPredicate");
    }
    //instantiate an instance of the class so can get the operator string
    try {
      ConstraintPredicate predicate = clazz.newInstance();
      String opSymbol = predicate.getOperator();
      //now store it in ConstraintFactory
      Factory.getConstraintFactory().addOperator(opSymbol, clazz);
    } catch (Exception e) {
      throw new ResourceInstantiationException("Cannot instantiate class for operator: " + opName, e);
    }
  }
View Full Code Here

      String fileName = grammarfile.getName().replaceAll("\\.jape$","") + Gate.genSym() + ".jape";
      //System.out.println("Generated file name: "+fileName);
      try {
        generatedFileURL = new File(tmpDir,fileName).toURI().toURL();
      } catch (MalformedURLException ex) {
        throw new ResourceInstantiationException("Cannot create generated file URL for "+tmpDir+" / "+fileName);
      }
    }
    String jape = "";
    try {
      jape = readURL2String(originalURL,encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not read grammar file "+originalURL,ex);
    }
    //System.out.println("Got jape file: \n"+jape);
    ST template = new ST(jape,'$','$');
    //System.out.println("Created template");
    //System.out.println("regenerating: variables="+variables);
    //System.out.println("regenerating: parameters="+parameters);
    //System.out.println("regenerating: vs="+vs);
    for(Object key : vs.keySet()) {
      if(key instanceof String) {
        //System.out.println("Setting key/val: "+key+"/"+vs.get(key));
        template.add((String)key, vs.get(key));
      } else {
        System.err.println("Ignored parameter for template (not a String): "+
          key+"="+vs.get(key).toString());
      }
    }
    String result = template.render();
    //System.out.println("Rendered template: \n"+result);
    File generatedFile = Files.fileFromURL(generatedFileURL);
    System.out.println("Generated grammar file: "+generatedFile);
    try {
      FileUtils.writeStringToFile(generatedFile, result, encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not write to file "+generatedFile,ex);
    }
    return generatedFileURL;
  }
View Full Code Here

      //if couldn't find it that way, try with current thread class loader
      try {
        clazz = Class.forName(opName, true,
          Thread.currentThread().getContextClassLoader()).asSubclass(ConstraintPredicate.class);
      } catch (ClassNotFoundException e1) {
        throw new ResourceInstantiationException("Cannot load class for operator: " + opName, e1);
      }
    } catch (ClassCastException cce) {
      throw new ResourceInstantiationException("Operator class '" + opName + "' must implement ConstraintPredicate");
    }
    //instantiate an instance of the class so can get the operator string
    try {
      ConstraintPredicate predicate = clazz.newInstance();
      String opSymbol = predicate.getOperator();
      //now store it in ConstraintFactory
      Factory.getConstraintFactory().addOperator(opSymbol, clazz);
    } catch (Exception e) {
      throw new ResourceInstantiationException("Cannot instantiate class for operator: " + opName, e);
    }
  }
View Full Code Here

      String fileName = grammarfile.getName().replaceAll("\\.jape$","") + Gate.genSym() + ".jape";
      //System.out.println("Generated file name: "+fileName);
      try {
        generatedFileURL = new File(tmpDir,fileName).toURI().toURL();
      } catch (MalformedURLException ex) {
        throw new ResourceInstantiationException("Cannot create generated file URL for "+tmpDir+" / "+fileName);
      }
    }
    String jape = "";
    try {
      jape = readURL2String(originalURL,encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not read grammar file "+originalURL,ex);
    }
    //System.out.println("Got jape file: \n"+jape);
    ST template = new ST(jape,'$','$');
    //System.out.println("Created template");
    //System.out.println("regenerating: variables="+variables);
    //System.out.println("regenerating: parameters="+parameters);
    //System.out.println("regenerating: vs="+vs);
    for(Object key : vs.keySet()) {
      if(key instanceof String) {
        //System.out.println("Setting key/val: "+key+"/"+vs.get(key));
        template.add((String)key, vs.get(key));
      } else {
        System.err.println("Ignored parameter for template (not a String): "+
          key+"="+vs.get(key).toString());
      }
    }
    String result = template.render();
    //System.out.println("Rendered template: \n"+result);
    File generatedFile = Files.fileFromURL(generatedFileURL);
    System.out.println("Generated grammar file: "+generatedFile);
    try {
      FileUtils.writeStringToFile(generatedFile, result, encoding);
    } catch (IOException ex) {
      throw new ResourceInstantiationException("Could not write to file "+generatedFile,ex);
    }
    return generatedFileURL;
  }
View Full Code Here

      //if couldn't find it that way, try with current thread class loader
      try {
        clazz = Class.forName(opName, true,
          Thread.currentThread().getContextClassLoader()).asSubclass(ConstraintPredicate.class);
      } catch (ClassNotFoundException e1) {
        throw new ResourceInstantiationException("Cannot load class for operator: " + opName, e1);
      }
    } catch (ClassCastException cce) {
      throw new ResourceInstantiationException("Operator class '" + opName + "' must implement ConstraintPredicate");
    }
    //instantiate an instance of the class so can get the operator string
    try {
      ConstraintPredicate predicate = clazz.newInstance();
      String opSymbol = predicate.getOperator();
      //now store it in ConstraintFactory
      Factory.getConstraintFactory().addOperator(opSymbol, clazz);
    } catch (Exception e) {
      throw new ResourceInstantiationException("Cannot instantiate class for operator: " + opName, e);
    }
  }
View Full Code Here

  public Resource init() throws ResourceInstantiationException {
    super.init();
    logger = Logger.getLogger(this.getClass());

    if(getContainedAnnotationTypeName() == null || getContainedAnnotationTypeName().equals("")) {
      throw new ResourceInstantiationException("Contained Annotation Type Name must be specified");
    }
    try {
      directoryFile = new File(directoryUrl.toURI());
    } catch (URISyntaxException ex) {
      throw new ResourceInstantiationException(ex);
    }
    return this;
  }
View Full Code Here

    } else {
      try {
        loadData();
        gazStore.compact();
      } catch (Exception ex) {
        throw new ResourceInstantiationException("Could not load gazetteer", ex);
      }
      gazStore.refcount++;
      loadedGazStores.put(uniqueGazStoreKey, gazStore);
      logger.info("New GazStore loaded for "+uniqueGazStoreKey);
    }      
View Full Code Here

TOP

Related Classes of gate.creole.ResourceInstantiationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.