[bug-62435] Rename getAllEmbedds method to getAllEmbeddedParts (getAllEmbedds is retained but deprecated)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1833059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-06-06 16:51:13 +00:00
parent 9f5d0a9c97
commit 3d756a7bd3
13 changed files with 34 additions and 18 deletions

View File

@ -94,7 +94,7 @@ public class LoadEmbedded {
}
public static void loadEmbedded(XSSFWorkbook workbook) throws IOException, InvalidFormatException, OpenXML4JException, XmlException {
for (PackagePart pPart : workbook.getAllEmbedds()) {
for (PackagePart pPart : workbook.getAllEmbeddedParts()) {
String contentType = pPart.getContentType();
if (contentType.equals("application/vnd.ms-excel")) {
// Excel Workbook - either binary or OpenXML

View File

@ -47,7 +47,7 @@ public final class DataExtraction {
is.close();
// Get the document's embedded files.
for (PackagePart p : ppt.getAllEmbedds()) {
for (PackagePart p : ppt.getAllEmbeddedParts()) {
String type = p.getContentType();
// typically file name
String name = p.getPartName().getName();

View File

@ -33,7 +33,7 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class EmbeddedObjects {
public static void main(String[] args) throws Exception {
try (XSSFWorkbook workbook = new XSSFWorkbook(args[0])) {
for (PackagePart pPart : workbook.getAllEmbedds()) {
for (PackagePart pPart : workbook.getAllEmbeddedParts()) {
String contentType = pPart.getContentType();
try (InputStream is = pPart.getInputStream()) {
Closeable document;

View File

@ -99,7 +99,7 @@ public class UpdateEmbeddedDoc {
* file system.
*/
public void updateEmbeddedDoc() throws OpenXML4JException, IOException {
List<PackagePart> embeddedDocs = this.doc.getAllEmbedds();
List<PackagePart> embeddedDocs = this.doc.getAllEmbeddedParts();
for (PackagePart pPart : embeddedDocs) {
String ext = pPart.getPartName().getExtension();
if (BINARY_EXTENSION.equals(ext) || OPENXML_EXTENSION.equals(ext)) {
@ -153,7 +153,7 @@ public class UpdateEmbeddedDoc {
* file system.
*/
public void checkUpdatedDoc() throws OpenXML4JException, IOException {
for (PackagePart pPart : this.doc.getAllEmbedds()) {
for (PackagePart pPart : this.doc.getAllEmbeddedParts()) {
String ext = pPart.getPartName().getExtension();
if (BINARY_EXTENSION.equals(ext) || OPENXML_EXTENSION.equals(ext)) {
try (InputStream is = pPart.getInputStream();

View File

@ -28,7 +28,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public final class POIXMLDocumentHandler {
protected void handlePOIXMLDocument(POIXMLDocument doc) throws Exception {
assertNotNull(doc.getAllEmbedds());
assertNotNull(doc.getAllEmbeds());
assertNotNull(doc.getPackage());
assertNotNull(doc.getPackagePart());
assertNotNull(doc.getProperties());

View File

@ -34,6 +34,7 @@ import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.util.Removal;
import org.apache.xmlbeans.impl.common.SystemCache;
/**
@ -153,10 +154,25 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close
* Get the document's embedded files.
*
* @return the document's embedded files
*
*
* @throws OpenXML4JException if the embedded parts can't be determined
* @deprecated use <code>getAllEmbeddedParts</code> instead
*/
public abstract List<PackagePart> getAllEmbedds() throws OpenXML4JException;
@Deprecated
@Removal(version = "4.2")
public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
return getAllEmbeddedParts();
}
/**
* Get the document's embedded files.
*
* @return the document's embedded files
*
* @throws OpenXML4JException if the embedded parts can't be determined
* @since POI 4.0.0
*/
public abstract List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException;
protected final void load(POIXMLFactory factory) throws IOException {
Map<PackagePart, POIXMLDocumentPart> context = new HashMap<>();

View File

@ -109,7 +109,7 @@ public class XmlVisioDocument extends POIXMLDocument {
* Not currently implemented
*/
@Override
public List<PackagePart> getAllEmbedds() {
public List<PackagePart> getAllEmbeddedParts() {
return new ArrayList<>();
}

View File

@ -192,7 +192,7 @@ public class XMLSlideShow extends POIXMLDocument
* Get the document's embedded files.
*/
@Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
return Collections.unmodifiableList(
getPackage().getPartsByName(Pattern.compile("/ppt/embeddings/.*?"))
);

View File

@ -256,7 +256,7 @@ public class XSLFSlideShow extends POIXMLDocument {
* Get the document's embedded files.
*/
@Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
return embedds;
}

View File

@ -1864,7 +1864,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
* Get the document's embedded files.
*/
@Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
List<PackagePart> embedds = new LinkedList<>();
for(XSSFSheet sheet : sheets){

View File

@ -558,7 +558,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
* Get the document's embedded files.
*/
@Override
public List<PackagePart> getAllEmbedds() throws OpenXML4JException {
public List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException {
List<PackagePart> embedds = new LinkedList<>();
// Get the embeddings for the workbook

View File

@ -57,11 +57,11 @@ public class TestEmbedded extends TestCase
}
private void test(POIXMLDocument doc, int expectedCount) throws Exception {
assertNotNull(doc.getAllEmbedds());
assertEquals(expectedCount, doc.getAllEmbedds().size());
assertNotNull(doc.getAllEmbeddedParts());
assertEquals(expectedCount, doc.getAllEmbeddedParts().size());
for(int i=0; i<doc.getAllEmbedds().size(); i++) {
PackagePart pp = doc.getAllEmbedds().get(i);
for(int i=0; i<doc.getAllEmbeddedParts().size(); i++) {
PackagePart pp = doc.getAllEmbeddedParts().get(i);
assertNotNull(pp);
byte[] b = IOUtils.toByteArray(pp.getInputStream());

View File

@ -67,7 +67,7 @@ public final class TestPOIXMLDocument {
}
@Override
public List<PackagePart> getAllEmbedds() {
public List<PackagePart> getAllEmbeddedParts() {
throw new RuntimeException("not supported");
}