private List<StorageSerialization> findAllStorageSerializations() throws UnableToCompleteException{ logger.branch(TreeLogger.Type.DEBUG, "Find StorageSerialization XML"); List<StorageSerialization> storageSerializations = new ArrayList<>(); for(String pathName : resourceOracle.getPathNames()){ if(pathName.endsWith(SERIALIZATION_CONFIG)){ StorageSerialization storageSerialization = parseXmlResource(resourceOracle.getResource(pathName)); if(storageSerialization != null){ storageSerializations.add(storageSerialization); } } } return storageSerializations; }
/** * Get all related resources of the auto resource bundler. * */ private HashSet<Resource> getResources(GeneratorContext context, JClassType userType, FileFilter filter) { Map<String, Resource> map = context.getResourcesOracle().getResourceMap(); final String pack = userType.getPackage().getName().replace('.', '/'); HashSet<Resource> resourceList = new HashSet<Resource>(); for (Entry<String, Resource> entry : map.entrySet()) { String path = entry.getKey(); if (!path.startsWith(pack)) continue; String ext = getExtension(path); if (EXTENSION_MAP.containsKey(ext)) resourceList.add(entry.getValue()); } return resourceList; }
private Resource getTemplateResource(MortalLogger logger, String templatePath, ResourceOracle resourceOracle) throws UnableToCompleteException { Resource resource = resourceOracle.getResource(templatePath); if (null == resource) { logger.die("Unable to find resource: " + templatePath); } return resource; }
private Resource getTemplateResource(GeneratorContext context) { String packageResourcePath = this.targetType.getPackage().getName().replace('.', '/') + "/"; ResourceOracle resourceOracle = context.getResourcesOracle(); Map<String, Resource> reourceMap = new HashMap<>(); for (Resource resource : resourceOracle.getResources()) { reourceMap.put(resource.getPath(), resource); } String templatePath = packageResourcePath + this.templateName + "_" + this.locale + UiBinderLocalizedCreator.TEMPLATE_SUFFIX; Resource templateResource = reourceMap.get(templatePath); if (templateResource == null) { this.locale = null; templatePath = packageResourcePath + this.templateName + UiBinderLocalizedCreator.TEMPLATE_SUFFIX; templateResource = reourceMap.get(templatePath); } if (templateResource != null) { this.templateName = templatePath.replace(packageResourcePath, ""); } return templateResource; }
private Resource getTemplateResource(MortalLogger logger, String templatePath, ResourceOracle resourceOracle) throws UnableToCompleteException { Resource resource = resourceOracle.getResource(templatePath); if (null == resource) { logger.die("Unable to find resource: " + templatePath); } return resource; }
private Resource getTemplateResource(GeneratorContext context) { String packageResourcePath = this.targetType.getPackage().getName().replace('.', '/') + "/"; ResourceOracle resourceOracle = context.getResourcesOracle(); Map<String, Resource> reourceMap = new HashMap<>(); for (Resource resource : resourceOracle.getResources()) { reourceMap.put(resource.getPath(), resource); } String templatePath = packageResourcePath + this.templateName + "_" + this.locale + UiBinderLocalizedCreator.TEMPLATE_SUFFIX; Resource templateResource = reourceMap.get(templatePath); if (templateResource == null) { this.locale = null; templatePath = packageResourcePath + this.templateName + UiBinderLocalizedCreator.TEMPLATE_SUFFIX; templateResource = reourceMap.get(templatePath); } if (templateResource != null) { this.templateName = templatePath.replace(packageResourcePath, ""); } return templateResource; }
/** * Get all related resources of the auto resource bundler. */ private HashSet<Resource> getResources(GeneratorContext context, JClassType userType, FileFilter filter) { final String pack = userType.getPackage().getName().replace('.', '/'); HashSet<Resource> resourceList = new HashSet<Resource>(); for (String path : context.getResourcesOracle().getPathNames()) { if (!path.startsWith(pack)) continue; String ext = getExtension(path); if (EXTENSION_MAP.containsKey(ext)) resourceList.add(context.getResourcesOracle().getResource(path)); } return resourceList; }
@Override public InputSource resolveEntity(String publicId, String systemId) { String matchingPrefix = findMatchingPrefix(systemId); Resource resource = null; if (matchingPrefix != null) { resource = resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length())); } if (resource == null) { resource = resourceOracle.getResource(pathBase + systemId); } if (resource != null) { String content; try { InputStream resourceStream = resource.openContents(); content = Util.readStreamAsString(resourceStream); } catch (IOException ex) { logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation()); throw new RuntimeException(ex); } InputSource inputSource = new InputSource(new StringReader(content)); inputSource.setPublicId(publicId); inputSource.setSystemId(resource.getPath()); return inputSource; } /* * Let Sax find it on the interweb. */ return null; }
private Document getW3cDoc(MortalLogger logger, DesignTimeUtils designTime, ResourceOracle resourceOracle, String templatePath) throws UnableToCompleteException { Resource resource = resourceOracle.getResourceMap().get(templatePath); if (null == resource) { logger.die("Unable to find resource: " + templatePath); } Document doc = null; try { String content = designTime.getTemplateContent(templatePath); if (content == null) { content = Util.readStreamAsString(resource.openContents()); } doc = new W3cDomHelper(logger.getTreeLogger(), resourceOracle).documentFor( content, resource.getPath()); } catch (SAXParseException e) { logger.die( "Error parsing XML (line " + e.getLineNumber() + "): " + e.getMessage(), e); } return doc; }
/** * Get all related resources of the auto resource bundler. */ private HashSet<Resource> getResources(GeneratorContext context, JClassType userType, FileFilter filter) { final String pack = userType.getPackage().getName().replace('.', '/'); HashSet<Resource> resourceList = new HashSet<Resource>(); for (String path : context.getResourcesOracle().getPathNames()) { if (!path.startsWith(pack)) continue; String ext = getExtension(path); if (EXTENSION_MAP.containsKey(ext)) resourceList.add(context.getResourcesOracle().getResource(path)); } return resourceList; }
@Override public InputSource resolveEntity(String publicId, String systemId) { String matchingPrefix = findMatchingPrefix(systemId); Resource resource = null; if (matchingPrefix != null) { resource = resourceOracle.getResource(RESOURCES + systemId.substring(matchingPrefix.length())); } if (resource == null) { resource = resourceOracle.getResource(pathBase + systemId); } if (resource != null) { String content; try { InputStream resourceStream = resource.openContents(); content = Util.readStreamAsString(resourceStream); } catch (IOException ex) { logger.log(TreeLogger.ERROR, "Error reading resource: " + resource.getLocation()); throw new RuntimeException(ex); } InputSource inputSource = new InputSource(new StringReader(content)); inputSource.setPublicId(publicId); inputSource.setSystemId(resource.getPath()); return inputSource; } /* * Let Sax find it on the interweb. */ return null; }
String ext = "." + element.getExt(); String path = partialPath + ext; Resource resource = resourceOracle.getResource(path); if (resource == null && partialPath.contains("$")) { resource = resourceOracle.getResource(path);
String ext = "." + element.getExt(); String path = partialPath + ext; Resource resource = resourceOracle.getResource(path); if (resource == null && partialPath.contains("$")) { resource = resourceOracle.getResource(path);