@Test public void testFixHrefs_simple_correct() { String packageHref = "OEBPS/content.opf"; String resourceHref = "OEBPS/foo/bar.html"; Resources resources = mock(Resources.class); Resource resource = mock(Resource.class); when(resources.getAll()).thenReturn(Arrays.asList(resource)); when(resource.getHref()).thenReturn(resourceHref); PackageDocumentReader.fixHrefs(packageHref, resources); Mockito.verify(resource).setHref("foo/bar.html"); }
static Resources fixHrefs(String packageHref, Resources resourcesByHref) { int lastSlashPos = packageHref.lastIndexOf('/'); if(lastSlashPos < 0) { return resourcesByHref; } Resources result = new Resources(); for(Resource resource: resourcesByHref.getAll()) { if(StringUtil.isNotBlank(resource.getHref()) && resource.getHref().length() > lastSlashPos) { resource.setHref(resource.getHref().substring(lastSlashPos + 1)); } result.add(resource); } return result; }
PackageDocumentReader extends PackageDocumentBase { static Resources fixHrefs(String packageHref, Resources resourcesByHref) { int lastSlashPos = packageHref.lastIndexOf('/'); if(lastSlashPos < 0) { return resourcesByHref; } Resources result = new Resources(); for(Resource resource: resourcesByHref.getAll()) { if(StringUtil.isNotBlank(resource.getHref()) && resource.getHref().length() > lastSlashPos) { resource.setHref(resource.getHref().substring(lastSlashPos + 1)); } result.add(resource); } return result; } }
PackageDocumentReader extends PackageDocumentBase { static Resources fixHrefs(String packageHref, Resources resourcesByHref) { int lastSlashPos = packageHref.lastIndexOf('/'); if(lastSlashPos < 0) { return resourcesByHref; } Resources result = new Resources(); for(Resource resource: resourcesByHref.getAll()) { if(StringUtil.isNotBlank(resource.getHref()) && resource.getHref().length() > lastSlashPos) { resource.setHref(resource.getHref().substring(lastSlashPos + 1)); } result.add(resource); } return result; }  }
PackageDocumentReader extends PackageDocumentBase { static Resources fixHrefs(String packageHref, Resources resourcesByHref) { int lastSlashPos = packageHref.lastIndexOf('/'); if(lastSlashPos < 0) { return resourcesByHref; } Resources result = new Resources(); for(Resource resource: resourcesByHref.getAll()) { if(StringUtil.isNotBlank(resource.getHref()) && resource.getHref().length() > lastSlashPos) { resource.setHref(resource.getHref().substring(lastSlashPos + 1)); } result.add(resource); } return result; }  static void read(Resource packageResource, EpubReader epubReader, Book book, Resources resources); }
PackageDocumentReader extends PackageDocumentBase { static Resources fixHrefs(String packageHref, Resources resourcesByHref) { int lastSlashPos = packageHref.lastIndexOf('/'); if(lastSlashPos < 0) { return resourcesByHref; } Resources result = new Resources(); for(Resource resource: resourcesByHref.getAll()) { if(StringUtil.isNotBlank(resource.getHref()) && resource.getHref().length() > lastSlashPos) { resource.setHref(resource.getHref().substring(lastSlashPos + 1)); } result.add(resource); } return result; }  static void read(Resource packageResource, EpubReader epubReader, Book book, Resources resources);  }