/** * used when hovering. * * @param source the source * @return the description from import * @throws InvalidXMLException the invalid XML exception * @throws IOException Signals that an I/O exception has occurred. */ @Override protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException { TypePriorities parsedImportItem = UIMAFramework.getXMLParser().parseTypePriorities( new XMLInputSource(source)); return parsedImportItem.getDescription(); }
private void resolveImport(URL aURL, Collection<String> aAlreadyImportedTypePrioritiesURLs, Collection<TypePriorityList> aResults, ResourceManager aResourceManager) throws InvalidXMLException, IOException { //check the import cache TypePriorities desc; String urlString = aURL.toString(); Map<String, XMLizable> importCache = ((ResourceManager_impl)aResourceManager).getImportCache(); Map<String, Set<String>> importUrlsCache = ((ResourceManager_impl)aResourceManager).getImportUrlsCache(); synchronized(importCache) { XMLizable cachedObject = importCache.get(urlString); if (cachedObject instanceof TypePriorities) { desc = (TypePriorities)cachedObject; // Add the URLs parsed for this cached object to the list already-parsed (UIMA-5058) aAlreadyImportedTypePrioritiesURLs.addAll(importUrlsCache.get(urlString)); } else { XMLInputSource input; input = new XMLInputSource(aURL); desc = UIMAFramework.getXMLParser().parseTypePriorities(input); TreeSet<String> previouslyImported = new TreeSet<String>(aAlreadyImportedTypePrioritiesURLs); desc.resolveImports(aAlreadyImportedTypePrioritiesURLs, aResourceManager); importCache.put(urlString, desc); // Save the URLS parsed by this import TreeSet<String> locallyImported = new TreeSet<String>(aAlreadyImportedTypePrioritiesURLs); locallyImported.removeAll(previouslyImported); importUrlsCache.put(urlString, locallyImported); } } aResults.addAll(Arrays.asList(desc.getPriorityLists())); }
try { XMLInputSource xmlInput = new XMLInputSource(location); TypePriorities typePriorities = getXMLParser().parseTypePriorities(xmlInput); typePriorities.resolveImports(); typePrioritiesList.add(typePriorities);