/** * @return import instance. This is preferred way to include the AE into * pipeline, especially when a pipeline descriptor is expected to be * serialized into XML. * @see PipelineDescriptorUtils#createAggregateDescription(java.util.List, * java.util.List) */ public static Import getAEImport() { Import result = new Import_impl(); result.setName(AE_SENTENCE_SPLITTER); return result; }
public WarmUpDataProvider(String inputFileName) throws IOException { this.inputFileName = inputFileName; Import_impl theImport = new Import_impl(); theImport.setSuffix(".zip"); if ( !inputFileName.endsWith(".zip")) { theImport.setName(inputFileName); this.inputFileName = resolveToAbsolutePath(theImport); // strip 'file:' from the begining this.inputFileName = this.inputFileName.substring(this.inputFileName.indexOf(':')+1); } fis = new FileInputStream(new File(this.inputFileName)); zis = new ZipInputStream(new BufferedInputStream(fis, 1024 * 100)); docSeq = 0; }
/** * Overridden to provide custom XML representation. * * @see org.apache.uima.util.XMLizable#buildFromXMLElement(org.w3c.dom.Element, * org.apache.uima.util.XMLParser) */ public void buildFromXMLElement(Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) throws InvalidXMLException { String name = aElement.getAttribute("name"); setName(name.length() == 0 ? null : name); String location = aElement.getAttribute("location"); setLocation(location.length() == 0 ? null : location); // validate that at exactly one of name or location is specified if (!((getName() == null) ^ (getLocation() == null))) { throw new InvalidXMLException(InvalidXMLException.IMPORT_MUST_HAVE_NAME_XOR_LOCATION, new Object[0]); } }
private void addImportIfValid(List<Import> importList, Import_impl import_impl) { if (import_impl.getName() != null && import_impl.getLocation() != null) { throw new IllegalArgumentException("Trying to use name and location for import: " + import_impl.getName() + " <->" + import_impl.getLocation()); } if (import_impl.getName() != null || import_impl.getLocation() != null) { importList.add(import_impl); } }
public AnalysisEngineDescription createAnalysisEngineDescription(RutaDescriptorInformation desc, TypeSystemDescription typeSystemDescription, String typeSystemOutput, String engineOutput, RutaBuildOptions options, String[] scriptPaths, String[] enginePaths, String[] resourcePaths) throws InvalidXMLException, IOException { TypeSystemDescription aets = uimaFactory.createTypeSystemDescription(); Import_impl import_impl = null; boolean needToIncludeTypeSystemDescriptor = true; if (options.isImportByName()) { if (typeSystemDescription != null) { import_impl = new Import_impl(); import_impl.setName(typeSystemDescription.getName()); needToIncludeTypeSystemDescriptor = false; } } else { if (typeSystemOutput != null) { String relativeLocation = getRelativeLocation(new File(typeSystemOutput).toURI(), engineOutput); import_impl = new Import_impl(); import_impl.setLocation(relativeLocation); needToIncludeTypeSystemDescriptor = false; } } AnalysisEngineDescription analysisEngineDescription = configureEngine(desc, engineOutput, options, scriptPaths, enginePaths, resourcePaths, import_impl, aets); if(needToIncludeTypeSystemDescriptor) { analysisEngineDescription.getAnalysisEngineMetaData().setTypeSystem(typeSystemDescription); } return analysisEngineDescription; }
Import_impl imprt = new Import_impl(); imprt.setName(descriptorName); URL url; try { url = imprt.findAbsoluteUrl(ResourceManagerFactory.newResourceManager());
/** * Creates the location import. * * @param location the location * @return a location import * @throws MalformedURLException - */ public Import createLocationImport(String location) throws MalformedURLException { String sDescriptorRelativePath = editor.getDescriptorRelativePath(location); // If relative path is not "relative", on Windows might get back // an absolute path starting with C: or something like it. // If a path starts with "C:", it must be preceeded by // file:/ so the C: is not interpreted as a "scheme". if (sDescriptorRelativePath.indexOf("file:/") == -1 //$NON-NLS-1$ && sDescriptorRelativePath.indexOf(":/") > -1) { //$NON-NLS-1$ sDescriptorRelativePath = "file:/" + sDescriptorRelativePath; //$NON-NLS-1$ } Import imp = new Import_impl(); // fails on unix? URL url = new URL("file:/" + getDescriptorDirectory()); // Set relative Path Base // a version that might work on all platforms URL url = new File(editor.getDescriptorDirectory()).toURL(); ((Import_impl) imp).setSourceUrl(url); imp.setLocation(sDescriptorRelativePath); return imp; }
public URL findAbsoluteUrl(ResourceManager aResourceManager) throws InvalidXMLException { String location, name; if ((location=getLocation()) != null) { try { URL url = new URL(this.getRelativePathBase(), location); UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(), "findAbsoluteUrl", LOG_RESOURCE_BUNDLE, "UIMA_import_by__CONFIG", } catch (MalformedURLException e) { throw new InvalidXMLException(InvalidXMLException.MALFORMED_IMPORT_URL, new Object[] { location, getSourceUrlString() }, e); } else if ((name=getName()) != null) { String filename = name.replace('.', '/') + byNameSuffix; URL url; } catch (MalformedURLException e) { throw new InvalidXMLException(InvalidXMLException.IMPORT_BY_NAME_TARGET_NOT_FOUND, new Object[] { filename, getSourceUrlString() }, e); new Object[] { filename, getSourceUrlString() }); new Object[] { getSourceUrlString() });
private void toXMLinner(boolean aWriteDefaultNamespaceAttribute) throws SAXException { SerialContext sc = serialContext.get(); Serializer serializer = sc.serializer; String namespace = getXmlizationInfo().namespace; AttributesImpl attrs = new AttributesImpl(); String name = getName(); if (name != null) { attrs.addAttribute("", "name", "name", "", name); } String location = getLocation(); if (location != null) { attrs.addAttribute("", "location", "location", "", location); } Node node = serializer.findMatchingSubElement("import"); serializer.outputStartElement(node, namespace, "import", "import", attrs); // aContentHandler.startElement(getXmlizationInfo().namespace, "import", "import", attrs); serializer.outputEndElement(node, namespace, "import", "import"); // aContentHandler.endElement(getXmlizationInfo().namespace, "import", "import"); }
List<TypeSystemDescription> toInclude = new ArrayList<TypeSystemDescription>(); List<Import> importList = new ArrayList<Import>(); Import_impl import_impl = new Import_impl(); if (options.isImportByName()) { String name = initialTypeSystem.getName(); import_impl.setName(name); } else if (options.isResolveImports()) { String absoluteLocation = initialTypeSystem.getSourceUrlString(); import_impl.setLocation(absoluteLocation); } else { URI uri = null; String relativeLocation = getRelativeLocation(uri, typeSystemOutput); if (relativeLocation != null) { import_impl.setLocation(relativeLocation); } else { import_impl.setName(initialTypeSystem.getName()); toInclude.add(each); } else { import_impl = new Import_impl(); if (options.isImportByName()) { import_impl.setName(eachName); } else if (options.isResolveImports()) { String absoluteLocation = each.getSourceUrlString(); import_impl.setLocation(absoluteLocation); } else { String relativeLocation = getRelativeLocation(url.toURI(), typeSystemOutput); if (relativeLocation == null) {
.parseAnalysisEngineDescription(new XMLInputSource(defaultAnalysisEngine)); if (import_impl != null && (import_impl.getName() != null || import_impl.getLocation() != null)) { aets.setImports(new Import[] { import_impl });
/** * @return import instance. This is preferred way to include the AE into * pipeline, especially when a pipeline descriptor is expected to be * serialized into XML. * @see PipelineDescriptorUtils#createAggregateDescription(java.util.List, * java.util.List) */ public static Import getAEImport() { Import result = new Import_impl(); result.setName(AE_TOKENIZER); return result; }
/** * Creates a {@link FsIndexCollection} from descriptor names. * * @param descriptorNames * The fully qualified, Java-style, dotted descriptor names. * @return a {@link FsIndexCollection} that includes the indexes from all of the specified files. */ public static FsIndexCollection createFsIndexCollection(String... descriptorNames) { List<Import> imports = new ArrayList<Import>(); for (String descriptorName : descriptorNames) { Import imp = new Import_impl(); imp.setName(descriptorName); imports.add(imp); } Import[] importArray = new Import[imports.size()]; FsIndexCollection fsIndexCollection = new FsIndexCollection_impl(); fsIndexCollection.setImports(imports.toArray(importArray)); return fsIndexCollection; }
/** * Creates a {@link FsIndexCollection} from a descriptor file * * @param descriptorURIs * The descriptor file paths. * @return A {@link FsIndexCollection} that includes the indexes from all of the specified files. */ public static FsIndexCollection createTypeSystemDescriptionFromPath(String... descriptorURIs) { List<Import> imports = new ArrayList<Import>(); for (String descriptorURI : descriptorURIs) { Import imp = new Import_impl(); imp.setLocation(descriptorURI); imports.add(imp); } Import[] importArray = new Import[imports.size()]; FsIndexCollection fsIndexCollection = new FsIndexCollection_impl(); fsIndexCollection.setImports(imports.toArray(importArray)); return fsIndexCollection; }
/** * Creates a TypeSystemDescription from descriptor names. * * @param descriptorNames * The fully qualified, Java-style, dotted descriptor names. * @return A TypeSystemDescription that includes the types from all of the specified files. */ public static TypeSystemDescription createTypeSystemDescription(String... descriptorNames) { TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); List<Import> imports = new ArrayList<Import>(); for (String descriptorName : descriptorNames) { Import imp = new Import_impl(); imp.setName(descriptorName); imports.add(imp); } Import[] importArray = new Import[imports.size()]; typeSystem.setImports(imports.toArray(importArray)); return typeSystem; }
/** * Creates a TypeSystemDescription from a descriptor file * * @param descriptorURIs * The descriptor file paths. * @return A TypeSystemDescription that includes the types from all of the specified files. */ public static TypeSystemDescription createTypeSystemDescriptionFromPath(String... descriptorURIs) { TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); List<Import> imports = new ArrayList<Import>(); for (String descriptorURI : descriptorURIs) { Import imp = new Import_impl(); imp.setLocation(descriptorURI); imports.add(imp); } Import[] importArray = new Import[imports.size()]; typeSystem.setImports(imports.toArray(importArray)); return typeSystem; }
private static XMLInputSource resolveImportByName(String aFileResource, ResourceManager aResourceManager) throws InvalidXMLException, ResourceInitializationException, IOException { XMLInputSource input; if (aFileResource.startsWith(IMPORT_BY_NAME_PREFIX)) { Import theImport = new Import_impl(); theImport.setName(aFileResource.substring(IMPORT_BY_NAME_PREFIX.length())); input = new XMLInputSource(theImport.findAbsoluteUrl(aResourceManager)); } else { input = new XMLInputSource(aFileResource); } return input; }
public static String resolveByName(String input) { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); Import theImport = new Import_impl(); theImport.setName(input); try { return theImport.findAbsoluteUrl(resourceManager).toExternalForm(); } catch (InvalidXMLException e) { if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.SEVERE)) { UIMAFramework.getLogger(CLASS_NAME).logrb(Level.SEVERE, XsltImportByName.class.getName(), "resolveByName", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__SEVERE", e.toString()); } return null; } }
File descriptorFile = new File(ds.getBasedir(), descriptorLocation); this.getLog().info("JCasGen: Found descriptor '" + descriptorFile.getAbsolutePath() + "'"); Import imp = new Import_impl();
Import descriptorImport = new Import_impl(); FlowControllerDeclaration fcd = new FlowControllerDeclaration_impl(); desc.setFlowControllerDeclaration(fcd); fcd.setImport(new Import_impl()); fcd.setKey(FlowControllerKey); fcd.getImport().setName(fcsn);