@Test(expected = IllegalArgumentException.class) public void testBadClassPath() throws IOException { ExampleAnnotator annotator = new ExampleAnnotator(); annotator.getResourceAsInputStream("classpath:a/b/c/JUNK-DOESNT-EXIST.txt"); }
public InputStream getResourceAsInputStream(String resourcePath) throws IOException { InputStream stream = null; if (resourcePath == null) { throw new IllegalArgumentException("Resource path cannot be null."); } if (resourcePath.startsWith("classpath:")) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); stream = cl.getResourceAsStream(resourcePath.substring(10)); if (stream == null) { throw new IllegalArgumentException("Resource: " + resourcePath + " not found in classpath."); } return stream; } else { String file; if (resourcePath.startsWith("file:")) { file = resourcePath.substring(5); } else { file = resourcePath; } File f = new File(file); if (!f.exists()) { throw new IllegalArgumentException( "Resource: " + resourcePath + " not found using file path resolution. Current directory is " + new File(".").getCanonicalPath()); } return new FileInputStream(f); } }
LeoBaseAnnotator extends JCasAnnotator_ImplBase implements LeoAnnotator { public InputStream getResourceAsInputStream(String resourcePath) throws IOException { InputStream stream = null; if (resourcePath == null) { throw new IllegalArgumentException("Resource path cannot be null."); } if (resourcePath.startsWith("classpath:")) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); stream = cl.getResourceAsStream(resourcePath.substring(10)); if (stream == null) { throw new IllegalArgumentException("Resource: " + resourcePath + " not found in classpath."); } return stream; } else { String file; if (resourcePath.startsWith("file:")) { file = resourcePath.substring(5); } else { file = resourcePath; } File f = new File(file); if (!f.exists()) { throw new IllegalArgumentException( "Resource: " + resourcePath + " not found using file path resolution. Current directory is " + new File(".").getCanonicalPath()); } return new FileInputStream(f); } } }
LeoBaseAnnotator extends JCasAnnotator_ImplBase implements LeoAnnotator { public InputStream getResourceAsInputStream(String resourcePath) throws IOException { InputStream stream = null; if (resourcePath == null) { throw new IllegalArgumentException("Resource path cannot be null."); } if (resourcePath.startsWith("classpath:")) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); stream = cl.getResourceAsStream(resourcePath.substring(10)); if (stream == null) { throw new IllegalArgumentException("Resource: " + resourcePath + " not found in classpath."); } return stream; } else { String file; if (resourcePath.startsWith("file:")) { file = resourcePath.substring(5); } else { file = resourcePath; } File f = new File(file); if (!f.exists()) { throw new IllegalArgumentException( "Resource: " + resourcePath + " not found using file path resolution. Current directory is " + new File(".").getCanonicalPath()); } return new FileInputStream(f); } } LeoBaseAnnotator();  LeoBaseAnnotator(String outputType, String...inputTypes); }
LeoBaseAnnotator extends JCasAnnotator_ImplBase implements LeoAnnotator { public InputStream getResourceAsInputStream(String resourcePath) throws IOException { InputStream stream = null; if (resourcePath == null) { throw new IllegalArgumentException("Resource path cannot be null."); } if (resourcePath.startsWith("classpath:")) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); stream = cl.getResourceAsStream(resourcePath.substring(10)); if (stream == null) { throw new IllegalArgumentException("Resource: " + resourcePath + " not found in classpath."); } return stream; } else { String file; if (resourcePath.startsWith("file:")) { file = resourcePath.substring(5); } else { file = resourcePath; } File f = new File(file); if (!f.exists()) { throw new IllegalArgumentException( "Resource: " + resourcePath + " not found using file path resolution. Current directory is " + new File(".").getCanonicalPath()); } return new FileInputStream(f); } } LeoBaseAnnotator();  LeoBaseAnnotator(String outputType, String...inputTypes); String[] getInputTypes(); T setInputTypes(String...inputTypes); String getOutputType(); T setOutputType(String outputType); int getNumInstances(); T setNumInstances(int numInstances); String getName(); T setName(String name); String[] getIncludeTypesFilter(); T setIncludeTypesFilter(String...includeTypesFilterNames); String[] getExcludeTypesFilter(); T setExcludeTypesFilter(String...excludeTypesFilterNames); @Override void initialize(UimaContext aContext); InputStream getResourceAsInputStream(String resourcePath); String getResourceFileAsString(String resourcePath); long getNumberOfCASesProcessed(); T resetNumberOfCASesProcessed(); long getNumberOfFilteredCASesProcessed(); T resetNumberOfFilteredCASesProcessed(); @Override final void process(JCas aJCas); abstract void annotate(JCas aJCas); @Override void collectionProcessComplete(); LeoDelegate getDescriptor(); LeoAEDescriptor getLeoAEDescriptor(); LeoTypeSystemDescription getLeoTypeSystemDescription(); T addLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription); T setLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription); }
LeoBaseAnnotator extends JCasAnnotator_ImplBase implements LeoAnnotator { public InputStream getResourceAsInputStream(String resourcePath) throws IOException { InputStream stream = null; if (resourcePath == null) { throw new IllegalArgumentException("Resource path cannot be null."); } if (resourcePath.startsWith("classpath:")) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); stream = cl.getResourceAsStream(resourcePath.substring(10)); if (stream == null) { throw new IllegalArgumentException("Resource: " + resourcePath + " not found in classpath."); } return stream; } else { String file; if (resourcePath.startsWith("file:")) { file = resourcePath.substring(5); } else { file = resourcePath; } File f = new File(file); if (!f.exists()) { throw new IllegalArgumentException( "Resource: " + resourcePath + " not found using file path resolution. Current directory is " + new File(".").getCanonicalPath()); } return new FileInputStream(f); } } LeoBaseAnnotator();  LeoBaseAnnotator(String outputType, String...inputTypes); String[] getInputTypes(); T setInputTypes(String...inputTypes); String getOutputType(); T setOutputType(String outputType); int getNumInstances(); T setNumInstances(int numInstances); String getName(); T setName(String name); String[] getIncludeTypesFilter(); T setIncludeTypesFilter(String...includeTypesFilterNames); String[] getExcludeTypesFilter(); T setExcludeTypesFilter(String...excludeTypesFilterNames); @Override void initialize(UimaContext aContext); InputStream getResourceAsInputStream(String resourcePath); String getResourceFileAsString(String resourcePath); long getNumberOfCASesProcessed(); T resetNumberOfCASesProcessed(); long getNumberOfFilteredCASesProcessed(); T resetNumberOfFilteredCASesProcessed(); @Override final void process(JCas aJCas); abstract void annotate(JCas aJCas); @Override void collectionProcessComplete(); LeoDelegate getDescriptor(); LeoAEDescriptor getLeoAEDescriptor(); LeoTypeSystemDescription getLeoTypeSystemDescription(); T addLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription); T setLeoTypeSystemDescription(LeoTypeSystemDescription typeSystemDescription);  }