Exemplo n.º 1
0
 public void startElement(String uri, String localName, String qName, Attributes attributes)
     throws SAXException {
   if (localName.equals("mailboxes") || qName.equals("mailboxes")) {
     String version = attributes.getValue("version");
     if (!version.equals(MailboxProperties.getVersion()))
       throw new SAXException("Unknown mailbox history format");
   } else if (localName.equals("mailbox") || qName.equals("mailbox")) {
     // Start a new entry.
     String mailboxName = attributes.getValue("name");
     currentEntry = new Entry(mailboxName);
     try {
       currentEntry.when = Long.parseLong(attributes.getValue("when"));
     } catch (NumberFormatException e) {
       Log.error(e);
     }
   } else if (localName.equals("property") || qName.equals("property")) {
     Debug.assertTrue(currentEntry != null);
     String key = attributes.getValue("name");
     if (key != null) {
       String value = attributes.getValue("value");
       if (value != null) {
         Property property = Property.findProperty(key);
         if (property != null) currentEntry.properties.setPropertyFromString(property, value);
       }
     }
   }
 }
 private Line findLineForOccurrence(File sourceFile, Line sourceLine) {
   if (sourceFile == null) return null;
   if (sourceLine == null) return null;
   final String cp = sourceFile.canonicalPath();
   Line line;
   for (line = getFirstLine(); line != null; line = line.next()) {
     if (line instanceof FileLine) {
       if (((FileLine) line).getCanonicalPath().equals(cp)) break;
     }
   }
   if (line == null) return null;
   Debug.assertTrue(line instanceof FileLine);
   Debug.assertTrue(((FileLine) line).getCanonicalPath().equals(cp));
   int target = sourceLine.lineNumber() + 1;
   Line best = null;
   for (line = line.next(); line instanceof OccurrenceLine; line = line.next()) {
     int candidate = ((OccurrenceLine) line).getSourceLineNumber();
     if (candidate == target) return line;
     if (best != null && candidate > target) return best;
     best = line;
   }
   return best;
 }