チェンジセット 160 : BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/endpointMetadata/MetadataManager.java
- 更新日時:
- 2014/09/25 15:42:35 (10 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/endpointMetadata/MetadataManager.java
r158 r160 2 2 3 3 import java.io.File; 4 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.Set; 5 6 6 7 public class MetadataManager { 7 8 9 HashMap<String,MetadataFile> metadataTable = null; 10 11 12 public static void main(String[] args) throws Exception{ 13 String dirStr = "c:\\temp\\crawl"; 14 MetadataManager manager = new MetadataManager(dirStr); 15 String[] uris = manager.getURIList(); 16 for(String uri: uris){ 17 System.out.println(uri); 18 MetadataFile mFile = manager.getMetadataFile(uri); 19 System.out.println(mFile.getStartDateTime().getTime().toString()); 20 System.out.println(mFile.getEndDateTime().getTime().toString()); 21 } 22 } 8 23 9 MetadataFile[] metadataFiles = null; 24 public MetadataFile getMetadataFile(String uri){ 25 return metadataTable.get(uri); 26 } 27 28 public String[] getURIList(){ 29 Set<String> keySet = metadataTable.keySet(); 30 return keySet.toArray(new String[0]); 31 } 32 10 33 11 34 public MetadataManager(String metadataDirStr) throws Exception { … … 15 38 16 39 public void init(String metadataDirStr) throws Exception{ 40 metadataTable = new HashMap<String,MetadataFile>(); 17 41 File metadataDir = new File(metadataDirStr); 18 42 File[] files = null; … … 30 54 throw new Exception("File/Directory not found: " + metadataDirStr); 31 55 } 32 ArrayList<MetadataFile> aList = new ArrayList<MetadataFile>();33 56 for(File file: files){ 34 57 MetadataFile metadataFile = null; 35 58 try{ 36 59 metadataFile = new MetadataFile(file); 37 aList.add(metadataFile); 60 String uri = metadataFile.getEndpointURI(); 61 if( uri != null ){ 62 metadataTable.put(uri, metadataFile); 63 } 38 64 }catch(Exception ex){ 39 65 // WARNING 40 66 System.out.println("Invalid metadata file: " + file.getAbsolutePath()); 67 ex.printStackTrace(); 41 68 } 42 69 } 43 metadataFiles = aList.toArray(new MetadataFile[0]);44 70 } 45 71