1 2 17 18 19 package org.apache.poi.poifs.property; 20 21 import java.io.IOException ; 22 23 import java.util.*; 24 25 import org.apache.poi.poifs.common.POIFSConstants; 26 import org.apache.poi.poifs.storage.ListManagedBlock; 27 28 39 40 class PropertyFactory 41 { 42 43 private PropertyFactory() 45 { 46 } 47 48 58 59 static List convertToProperties(ListManagedBlock [] blocks) 60 throws IOException 61 { 62 List properties = new ArrayList(); 63 64 for (int j = 0; j < blocks.length; j++) 65 { 66 byte[] data = blocks[ j ].getData(); 67 int property_count = data.length 68 / POIFSConstants.PROPERTY_SIZE; 69 int offset = 0; 70 71 for (int k = 0; k < property_count; k++) 72 { 73 switch (data[ offset + PropertyConstants.PROPERTY_TYPE_OFFSET ]) 74 { 75 76 case PropertyConstants.DIRECTORY_TYPE : 77 properties 78 .add(new DirectoryProperty(properties.size(), 79 data, offset)); 80 break; 81 82 case PropertyConstants.DOCUMENT_TYPE : 83 properties.add(new DocumentProperty(properties.size(), 84 data, offset)); 85 break; 86 87 case PropertyConstants.ROOT_TYPE : 88 properties.add(new RootProperty(properties.size(), 89 data, offset)); 90 break; 91 92 default : 93 properties.add(null); 94 break; 95 } 96 offset += POIFSConstants.PROPERTY_SIZE; 97 } 98 } 99 return properties; 100 } 101 } 103 | Popular Tags |