org.apache.uima.util.InvalidXMLException Java Examples
The following examples show how to use
org.apache.uima.util.InvalidXMLException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnalysisEngine_implTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testParameterGroups() throws Exception { // Check that both groups parameters and non-group parameters are validated XMLInputSource in = new XMLInputSource( JUnitExtension.getFile("TextAnalysisEngineImplTest/AnnotatorWithGroupParameterError.xml")); AnalysisEngineDescription desc = null; InvalidXMLException ex = null; //try { desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); //} catch (InvalidXMLException e) { //ex = e; //} in.close(); // For now parse should always work ... in a later release will fail unless special environment variable set boolean support240bug = true; // System.getenv("UIMA_Jira3123") != null; if (support240bug) { assertNotNull(desc); } else { fail(); } }
Example #2
Source File: InstallationTester.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Checks if a given analysis engine specifier file can be used to produce an instance of analysis * engine. Returns <code>true</code>, if an analysis engine can be instantiated, * <code>false</code> otherwise. * * @param specifier the resource specifier * @param resource_manager a new resource_manager * @param status the place where to put the results * * @throws IOException * If an I/O exception occurred while creating <code>XMLInputSource</code>. * @throws InvalidXMLException * If the XML parser failed to parse the given input file. * @throws ResourceInitializationException * If the specified AE cannot be instantiated. */ private void testAnalysisEngine(ResourceSpecifier specifier, ResourceManager resource_manager, TestStatus status) throws IOException, InvalidXMLException, ResourceInitializationException { AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier, resource_manager, null); //create CAS from the analysis engine CAS cas = null; if (ae != null) { cas = ae.newCAS(); } //check test result if (ae != null && cas != null) { status.setRetCode(TestStatus.TEST_SUCCESSFUL); } else { status.setRetCode(TestStatus.TEST_NOT_SUCCESSFUL); status.setMessage(I18nUtil.localizeMessage(PEAR_MESSAGE_RESOURCE_BUNDLE, "installation_verification_ae_not_created", new Object[] { this.pkgBrowser .getInstallationDescriptor().getMainComponentId() }, null)); } }
Example #3
Source File: CasProcessorConfigurationJAXBImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Returns parsed filter expressions as List. * */ public LinkedList getFilter() throws ResourceConfigurationException { String filterExpression = null; try { filterExpression = getFilterString(); if (filterExpression != null) { if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_show_cp_filter__FINEST", new Object[] { Thread.currentThread().getName(), name, filterExpression }); } Filter filter = new Filter(); return filter.parse(filterExpression); } } catch (Exception e) { throw new ResourceConfigurationException(InvalidXMLException.INVALID_ELEMENT_TEXT, new Object[] { "filter" }, new Exception(CpmLocalizedMessage.getLocalizedMessage( CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] { Thread.currentThread().getName(), name, "filer" }))); } return null; }
Example #4
Source File: InstallationTester.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Checks if a given CC specifier file can be used to produce an instance of CC. Returns * <code>true</code>, if a CC can be instantiated, <code>false</code> otherwise. * * @param specifier the resource specifier * @param resource_manager a new resource_manager * @param status the place where to put the results * * @throws IOException * If an I/O exception occurred while creating <code>XMLInputSource</code>. * @throws InvalidXMLException * If the XML parser failed to parse the given input file. * @throws ResourceInitializationException * If the specified CC cannot be instantiated. */ private void testCasConsumer(ResourceSpecifier specifier, ResourceManager resource_manager, TestStatus status) throws IOException, InvalidXMLException, ResourceInitializationException { CasConsumer cc = UIMAFramework.produceCasConsumer(specifier, resource_manager, null); if (cc != null) { status.setRetCode(TestStatus.TEST_SUCCESSFUL); } else { status.setRetCode(TestStatus.TEST_NOT_SUCCESSFUL); status.setMessage(I18nUtil.localizeMessage(PEAR_MESSAGE_RESOURCE_BUNDLE, "installation_verification_cc_not_created", new Object[] { this.pkgBrowser .getInstallationDescriptor().getMainComponentId() }, null)); } }
Example #5
Source File: JCasCoverClassFactoryTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Test public void testCreateJCasCoverClass() throws InvalidXMLException, IOException, ResourceInitializationException { File file = JUnitExtension.getFile("JCasGen/typeSystemAllKinds.xml"); TypeSystemDescription tsDesc = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(file)); CAS cas = CasCreationUtils.createCas(tsDesc, null, null); JCasCoverClassFactory jcf = new JCasCoverClassFactory(); byte[] r = jcf.createJCasCoverClass((TypeImpl) cas.getTypeSystem().getType("pkg.sample.name.All")); Path root = Paths.get("."); // should resolve to the project path Path dir = root.resolve("temp/test/JCasGen"); dir.toFile().mkdirs(); Files.write(dir.resolve("testOutputAllKinds.class"), r); System.out.println("debug: generated byte array"); }
Example #6
Source File: CasProcessorDeploymentParamsImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Overridden to read "name" and "value" attributes. * * @param aElement the a element * @param aParser the a parser * @param aOptions the a options * @throws InvalidXMLException the invalid XML exception * @see org.apache.uima.resource.metadata.impl.MetaDataObject_impl#buildFromXMLElement(org.w3c.dom.Element, * org.apache.uima.util.XMLParser, org.apache.uima.util.XMLParser.ParsingOptions) */ @Override public void buildFromXMLElement(Element aElement, XMLParser aParser, ParsingOptions aOptions) throws InvalidXMLException { NodeList nodes = aElement.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node instanceof Element) { // assumes all children are parameter elements NamedNodeMap nodeMap = node.getAttributes(); String paramName = nodeMap.getNamedItem("name").getNodeValue(); String paramValue = nodeMap.getNamedItem("value").getNodeValue(); String paramType = "string"; // default if (nodeMap.getNamedItem("type") != null) { paramType = nodeMap.getNamedItem("type").getNodeValue(); } // nodeMap.getNamedItem("type").getNodeValue(); CasProcessorDeploymentParam p = new CasProcessorDeploymentParamImpl(paramName, paramValue, paramType); params.add(p); } } }
Example #7
Source File: ExternalResourceFactory.java From uima-uimafit with Apache License 2.0 | 6 votes |
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * a compatible type is found, the given resource is bound to it. * * @param aDesc * a description. * @param aResDesc * the resource description. */ private static void scanRecursivelyForDependenciesByInterfaceAndBind( AnalysisEngineDescription aDesc, ExternalResourceDescription aResDesc) throws InvalidXMLException, ClassNotFoundException { // Recursively address delegates if (!aDesc.isPrimitive()) { for (ResourceSpecifier delegate : aDesc.getDelegateAnalysisEngineSpecifiers().values()) { bindResource(delegate, aResDesc); } } // Bind if necessary Class<?> resClass = Class.forName(getImplementationName(aResDesc)); for (ExternalResourceDependency dep : aDesc.getExternalResourceDependencies()) { Class<?> apiClass = Class.forName(dep.getInterfaceName()); // Never bind fields of type Object. See also ExternalResourceInitializer#getApi() if (apiClass.equals(Object.class)) { continue; } if (apiClass.isAssignableFrom(resClass)) { bindResourceOnce(aDesc, dep.getKey(), aResDesc); } } }
Example #8
Source File: ImportResBindSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override protected boolean isValidImport(String title, String message) { ResourceManagerConfiguration savedRmc = editor.getResolvedExternalResourcesAndBindings(); if (null != savedRmc) savedRmc = (ResourceManagerConfiguration) ((ResourceManagerConfiguration_impl) savedRmc) .clone(); try { editor.setResolvedExternalResourcesAndBindings(); } catch (InvalidXMLException e) { Utility.popMessage(title, message + editor.getMessagesToRootCause(e), MessageDialog.ERROR); revert(savedRmc); return false; } if (!isValidAe()) { revert(savedRmc); return false; } return true; }
Example #9
Source File: InstallationTester.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Checks if a given CR specifier file can be used to produce an instance of CR. Returns * <code>true</code>, if a CR can be instantiated, <code>false</code> otherwise. * * @param specifier the resource specifier * @param resource_manager a new resource_manager * @param status the place where to put the results * * @throws IOException * If an I/O exception occurred while creating <code>XMLInputSource</code>. * @throws InvalidXMLException * If the XML parser failed to parse the given input file. * @throws ResourceInitializationException * If the specified CR cannot be instantiated. */ private void testCollectionReader(ResourceSpecifier specifier, ResourceManager resource_manager, TestStatus status) throws IOException, InvalidXMLException, ResourceInitializationException { CollectionReader cr = UIMAFramework.produceCollectionReader(specifier, resource_manager, null); if (cr != null) { status.setRetCode(TestStatus.TEST_SUCCESSFUL); } else { status.setRetCode(TestStatus.TEST_NOT_SUCCESSFUL); status.setMessage(I18nUtil.localizeMessage(PEAR_MESSAGE_RESOURCE_BUNDLE, "installation_verification_cr_not_created", new Object[] { this.pkgBrowser .getInstallationDescriptor().getMainComponentId() }, null)); } }
Example #10
Source File: XMLParser_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Builds an object from its XML DOM representation. * * @param aElement * a DOM Element * * @return an <code>XMLizable</code> object constructed from the DOM element * * @throws InvalidXMLException * if the XML element does not specify a valid object */ public XMLizable buildObject(Element aElement, ParsingOptions aOptions) throws InvalidXMLException { // attempt to locate a Class that can be built from the element Class<? extends XMLizable> cls = mElementToClassMap.get(aElement.getTagName()); if (cls == null) { throw new InvalidXMLException(InvalidXMLException.UNKNOWN_ELEMENT, new Object[] { aElement .getTagName() }); } // resolve the class name and instantiate the class XMLizable object; try { object = cls.newInstance(); } catch (Exception e) { throw new UIMA_IllegalStateException( UIMA_IllegalStateException.COULD_NOT_INSTANTIATE_XMLIZABLE, new Object[] { cls .getName() }, e); } callBuildFromXMLElement(aElement, object, aOptions); return object; }
Example #11
Source File: AnalysisEngineMetaData_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException { if (getTypeSystem() != null) { getTypeSystem().resolveImports(aResourceManager); } if (getTypePriorities() != null) { getTypePriorities().resolveImports(aResourceManager); } if (getFsIndexCollection() != null) { getFsIndexCollection().resolveImports(aResourceManager); } }
Example #12
Source File: AnalysisEnginePanel.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Refresh from file. * * @throws InvalidXMLException the invalid XML exception * @throws IOException Signals that an I/O exception has occurred. */ public void refreshFromFile() throws InvalidXMLException, IOException { clearAll(); this.aeSpecifier = UIMAFramework.getXMLParser().parseResourceSpecifier( new XMLInputSource(this.specifierFile)); if (aeSpecifier instanceof AnalysisEngineDescription) { AnalysisEngineDescription aeDescription = (AnalysisEngineDescription) aeSpecifier; populate(aeDescription.getMetaData(), null); } else { this.removeAll(); } this.lastFileSyncTimestamp = this.specifierFile.lastModified(); }
Example #13
Source File: AbstractSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Creates the by name import. * * @param fileName the file name * @return the import */ public Import createByNameImport(String fileName) { if (fileName.endsWith(".xml")) fileName = fileName.substring(0, fileName.length() - 4); fileName = fileName.replace('\\', '/'); fileName = fileName.replace('/', '.'); int i = fileName.indexOf(":"); if (i >= 0) fileName = fileName.substring(i + 1); if (fileName.charAt(0) == '.') fileName = fileName.substring(1); int partStart = 0; Import imp = UIMAFramework.getResourceSpecifierFactory().createImport(); ResourceManager rm = editor.createResourceManager(); for (;;) { imp.setName(fileName.substring(partStart)); try { imp.findAbsoluteUrl(rm); } catch (InvalidXMLException e) { partStart = fileName.indexOf('.', partStart) + 1; if (0 == partStart) return imp; // not found -outer code will catch error later continue; } return imp; } }
Example #14
Source File: EntitySalienceProcessorAnalysisEngineSpark.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
@Override public void initialize() throws ResourceInitializationException{ try { logger.debug("Setting analysis engine to AIDA."); this.setAnalysisEngine(PipelinesHolder.getAnalyisEngine(PipelineType.DISAMBIGUATION)); } catch (InvalidXMLException | IOException | ClassNotFoundException | EntityLinkingDataAccessException | MissingSettingException | NoSuchMethodException e) { e.printStackTrace(); System.out.println(e.getMessage()); throw new ResourceInitializationException(e); } }
Example #15
Source File: CasConsumerDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Overridden to set default operational properties if they are not specified in descriptor. */ public void buildFromXMLElement(Element aElement, XMLParser aParser, ParsingOptions aOptions) throws InvalidXMLException { super.buildFromXMLElement(aElement, aParser, aOptions); if (getCasConsumerMetaData().getOperationalProperties() == null) { OperationalProperties opProps = UIMAFramework.getResourceSpecifierFactory() .createOperationalProperties(); opProps.setModifiesCas(false); opProps.setMultipleDeploymentAllowed(false); opProps.setOutputsNewCASes(false); getCasConsumerMetaData().setOperationalProperties(opProps); } }
Example #16
Source File: ResourceMetaData_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Overridden to validate configuration parameter data types immediately after parsing is * complete. * * @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 { super.buildFromXMLElement(aElement, aParser, aOptions); try { validateConfigurationParameterSettings(); } catch (ResourceConfigurationException e) { throw new InvalidXMLException(e); } }
Example #17
Source File: XMLParser_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public CollectionReaderDescription parseCollectionReaderDescription(XMLInputSource aInput, ParsingOptions aOptions) throws InvalidXMLException { // attempt to locate resource specifier schema XMLizable object = parse(aInput, RESOURCE_SPECIFIER_NAMESPACE, SCHEMA_URL, aOptions); if (object instanceof CollectionReaderDescription) { return (CollectionReaderDescription) object; } else { throw new InvalidXMLException(InvalidXMLException.INVALID_CLASS, new Object[] { CollectionReaderDescription.class.getName(), object.getClass().getName() }); } }
Example #18
Source File: Attribute_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Overridden to read the name and value properties from XML attributes. * * @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 { setName(aElement.getAttribute("name")); setValue(aElement.getAttribute("value")); // call superclass method for good measure super.buildFromXMLElement(aElement, aParser, aOptions); }
Example #19
Source File: AnalysisEngineFactoryExternalResourceTest.java From uima-uimafit with Apache License 2.0 | 5 votes |
AnalysisEngineDescription saveLoad(AnalysisEngineDescription aDesc) throws InvalidXMLException, SAXException, IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); aDesc.toXML(bos); return UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(new ByteArrayInputStream(bos.toByteArray()), null)); }
Example #20
Source File: PipelinesHolder.java From ambiverse-nlu with Apache License 2.0 | 5 votes |
private AnalysisEngineDescription createAnalysisEngineDescription(Component component) throws ResourceInitializationException, IOException, InvalidXMLException, NoSuchMethodException, MissingSettingException, ClassNotFoundException { AnalysisEngineDescription aed = createEngineDescription(component.component, component.params); aed.getAnalysisEngineMetaData().setName(component.name()); return aed; }
Example #21
Source File: CPEFactory.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Instantiates a local (managed) Cas Processor. * * @param aCasProcessorCfg - * Cas Processor configuration * @return - Local CasProcessor * @throws ResourceConfigurationException - */ private CasProcessor produceLocalCasProcessor(CpeCasProcessor aCasProcessorCfg) throws ResourceConfigurationException { if (aCasProcessorCfg == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "casProcessor", "casProcessors" }, new Exception(CpmLocalizedMessage.getLocalizedMessage( CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread.currentThread().getName() }))); } CasProcessor casProcessor = new NetworkCasProcessorImpl(aCasProcessorCfg); return casProcessor; }
Example #22
Source File: ResourceManagerConfiguration_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public synchronized void resolveImports() throws InvalidXMLException { if (getImports().length == 0) { resolveImports(null, null); } else { resolveImports(new TreeSet<>(), UIMAFramework.newDefaultResourceManager()); } }
Example #23
Source File: DeployFactory.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Returns a * {@link org.apache.uima.collection.impl.base_cpm.container.deployer.CasProcessorDeployer} object * that specializes in deploying components as either local, remote, or integrated. * * @param aCpeFactory cpe factory * @param aCasProcessorConfig cpe configuration reference * @param aPca mode of deployment. * @return appropriate deployer object for the mode of depolyment * @throws ResourceConfigurationException missing protocol or other deployment error */ public static CasProcessorDeployer getDeployer(CPEFactory aCpeFactory, CpeCasProcessor aCasProcessorConfig, ProcessControllerAdapter aPca) throws ResourceConfigurationException { String deployMode = aCasProcessorConfig.getDeployment(); if (Constants.DEPLOYMENT_LOCAL.equals(deployMode)) { return new VinciCasProcessorDeployer(aCpeFactory); } else if (Constants.DEPLOYMENT_REMOTE.equals(deployMode)) { String protocol = getProtocol(aCasProcessorConfig, aCpeFactory.getResourceManager()); if (protocol == null || protocol.trim().length() == 0) { throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_service_descriptor__SEVERE", new Object[] { Thread.currentThread().getName(), "<uriSpecifier>", "<protocol>" }, new Exception(CpmLocalizedMessage.getLocalizedMessage( CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_invalid_service_descriptor__WARNING", new Object[] { Thread.currentThread().getName(), aCasProcessorConfig.getName() }))); } else if (Constants.SOCKET_PROTOCOL.equalsIgnoreCase(protocol)) { if (aPca == null) { throw new ResourceConfigurationException( ResourceInitializationException.CONFIG_SETTING_ABSENT, new Object[] { "ProcessControllerAdapter" }); } return new SocketCasProcessorDeployer(aPca, aCpeFactory); } else { // Default is still Vinci return new VinciCasProcessorDeployer(aCpeFactory); } } else if (Constants.DEPLOYMENT_INTEGRATED.equals(deployMode)) { return new CPEDeployerDefaultImpl(aCpeFactory); } throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] { "deployment", "casProcessor" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_Exception_invalid_deployment__WARNING", new Object[] { Thread.currentThread().getName(), aCasProcessorConfig.getName(), deployMode }))); }
Example #24
Source File: XMLParser_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
private void callBuildFromXMLElement(Element aElement, XMLizable object, ParsingOptions aOptions) throws InvalidXMLException { if (aOptions.preserveComments && (object instanceof MetaDataObject_impl)) { ((MetaDataObject_impl)object).setInfoset(aElement); } object.buildFromXMLElement(aElement, this, aOptions); }
Example #25
Source File: ResourceMetaData_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Validates configuration parameter settings within a group. * * @param aNVPs * the parameter settings * @param aGroupName * the group * @param aParamDecls * Configuration Parameter Declarations * * @throws ResourceConfigurationException * if the configuration parameter settings are invalid */ protected void validateConfigurationParameterSettings(NameValuePair[] aNVPs, String aGroupName, ConfigurationParameterDeclarations aParamDecls) throws ResourceConfigurationException { for (int i = 0; i < aNVPs.length; i++) { // look up the parameter info String name = aNVPs[i].getName(); if (name == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "name", "nameValuePair" }); } ConfigurationParameter param = aParamDecls.getConfigurationParameter(aGroupName, name); if (param == null) { if (aGroupName == null) { throw new ResourceConfigurationException( ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { name, getName() }); } else { throw new ResourceConfigurationException( ResourceConfigurationException.NONEXISTENT_PARAMETER_IN_GROUP, new Object[] { name, aGroupName, getName() }); } } else { // check datatype validateConfigurationParameterDataTypeMatch(param, aNVPs[i]); } } }
Example #26
Source File: XMLParser_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public TypeSystemDescription parseTypeSystemDescription(XMLInputSource aInput, ParsingOptions aOptions) throws InvalidXMLException { // attempt to locate resource specifier schema XMLizable object = parse(aInput, RESOURCE_SPECIFIER_NAMESPACE, SCHEMA_URL, aOptions); if (object instanceof TypeSystemDescription) { return (TypeSystemDescription) object; } else { throw new InvalidXMLException(InvalidXMLException.INVALID_CLASS, new Object[] { TypeSystemDescription.class.getName(), object.getClass().getName() }); } }
Example #27
Source File: Import_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * 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]); } }
Example #28
Source File: XMLParser_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public ResourceManagerConfiguration parseResourceManagerConfiguration(XMLInputSource aInput, ParsingOptions aOptions) throws InvalidXMLException { // attempt to locate resource specifier schema XMLizable object = parse(aInput, RESOURCE_SPECIFIER_NAMESPACE, SCHEMA_URL, aOptions); if (object instanceof ResourceManagerConfiguration) { return (ResourceManagerConfiguration) object; } else { throw new InvalidXMLException(InvalidXMLException.INVALID_CLASS, new Object[] { ResourceManagerConfiguration.class.getName(), object.getClass().getName() }); } }
Example #29
Source File: CasProcessorExecutableImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Overridden to read "name" and "value" attributes. * * @param aElement the a element * @param aParser the a parser * @param aOptions the a options * @throws InvalidXMLException the invalid XML exception * @see org.apache.uima.resource.metadata.impl.MetaDataObject_impl#buildFromXMLElement(org.w3c.dom.Element, * org.apache.uima.util.XMLParser, org.apache.uima.util.XMLParser.ParsingOptions) */ @Override public void buildFromXMLElement(Element aElement, XMLParser aParser, ParsingOptions aOptions) throws InvalidXMLException { // TODO Auto-generated method stub setExecutable(aElement.getAttribute("executable")); setDir(aElement.getAttribute("dir")); NodeList nodes = aElement.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node instanceof Element) { if ("arg".equals(node.getNodeName())) { // assumes all children are CasProcessor elements CasProcessorExecArg arg = (CasProcessorExecArg) aParser.buildObject((Element) node, aOptions); args.add(arg); } else if ("env".equals(node.getNodeName())) { // assumes all children are CasProcessor elements CasProcessorRuntimeEnvParam env = (CasProcessorRuntimeEnvParam) aParser.buildObject( (Element) node, aOptions); envs.add(env); } } } }
Example #30
Source File: FsIndexKeyDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Overridden to handle XML import of the <code>typePriority</code> and <code>comparator</code> * properties. * * @see MetaDataObject_impl#readPropertyValueFromXMLElement(PropertyXmlInfo, Element, XMLParser, org.apache.uima.util.XMLParser.ParsingOptions) */ protected void readPropertyValueFromXMLElement(PropertyXmlInfo aPropXmlInfo, Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) throws InvalidXMLException { if ("typePriority".equals(aPropXmlInfo.propertyName)) { // The mere presence of a <typePriority/> element in the XML indicates // that this property is true mTypePriority = true; } else if ("comparator".equals(aPropXmlInfo.propertyName)) { // This property has an interger-encoded value which is written to XML as // a more user-friendly string. boolean success = false; String comparatorStr = XMLUtils.getText(aElement); for (int i = 0; i < COMPARATOR_STRINGS.length; i++) { if (COMPARATOR_STRINGS[i].equals(comparatorStr)) { setComparator(i); success = true; break; } } if (!success) { throw new InvalidXMLException(InvalidXMLException.INVALID_ELEMENT_TEXT, new Object[] { comparatorStr, "comparator" }); } } else { // for all other attributes, use the default superclass behavior super.readPropertyValueFromXMLElement(aPropXmlInfo, aElement, aParser, aOptions); } }