1 package SnowMailClient.gnupg.model; 2 3 import java.util.*; 4 import java.io.*; 5 import java.text.*; 6 7 8 13 public final class UIDRecord 14 { 15 private String name; 16 private String mail; 17 18 public UIDRecord() 19 { 20 } 21 22 public final String getName() { return name; } 23 public final String getMail() { return mail; } 24 25 27 public void parseUID_colon_format(String line) throws Exception 28 { 29 Scanner scanner = new Scanner(line); 30 scanner.useDelimiter(":"); 31 32 String r1 = scanner.next(); 33 if(!r1.equalsIgnoreCase("uid")) throw new Exception ("UID reader read only uid records!, not "+r1); 34 35 String ignored = scanner.next(); 36 skip(scanner, 3, "UID0"); ignored = scanner.next(); 38 skip(scanner, 1, "UID1"); 40 String id1 = scanner.next(); 41 42 skip(scanner, 1, "UID2"); 43 String nameAndMail = scanner.next(); 44 47 int posS = nameAndMail.indexOf("<"); 49 int posE = nameAndMail.indexOf(">", posS+1); 50 51 if(posS>=0&&posE>0) 52 { 53 name = nameAndMail.substring(0,posS).trim(); 54 mail = nameAndMail.substring(posS+1, posE).trim(); 55 } 56 else 57 { 58 name = nameAndMail.trim(); 59 } 60 63 64 65 skip(scanner, 0, "UID"); } 67 68 private void skip(Scanner scanner, int n, String prefix) 69 { 70 for(int i=0; i<n; i++) 71 { 72 if(!scanner.hasNext()) 73 { 74 System.out.println(""+prefix+" has no more entries, stopped skip("+n+") after "+i); 75 return; 76 } 77 78 String ent = scanner.next(); 79 if(ent.length()>0) 80 { 81 System.out.println(prefix+" unread rec("+i+")="+ent); 82 } 83 } 84 } 85 86 } | Popular Tags |