private void startTag(String aPrefix, String aName, XmlPullParser aParser) throws Exception {
   if ("entry".equals(aName)) {
     tweets.addTweet(currentTweet = new Tweet());
   } else if ("published".equals(aName)) {
     aParser.next();
     currentTweet.setPublished(dateFormat.parse(aParser.getText()));
   } else if (("title".equals(aName)) && (currentTweet != null)) {
     aParser.next();
     currentTweet.setTitle(aParser.getText());
   } else if ("content".equals(aName)) {
     Content _c = new Content();
     _c.setType(aParser.getAttributeValue(null, "type"));
     aParser.next();
     _c.setValue(aParser.getText());
     currentTweet.setContent(_c);
   } else if ("lang".equals(aName)) {
     aParser.next();
     currentTweet.setLanguage(aParser.getText());
   } else if ("author".equals(aName)) {
     currentTweet.setAuthor(currentAuthor = new Author());
   } else if ("name".equals(aName)) {
     aParser.next();
     currentAuthor.setName(aParser.getText());
   } else if ("uri".equals(aName)) {
     aParser.next();
     currentAuthor.setUri(aParser.getText());
   }
 }
Esempio n. 2
0
  public void writeIndex(String location) {

    System.out.println("Writing index at: " + location);

    ObjectOutputStream objectOutputStream = null;

    try {

      File outputFile = new File(location);
      if (!outputFile.exists()) {
        outputFile.getParentFile().mkdirs();
        outputFile.createNewFile();
      }

      OutputStream file = new FileOutputStream(outputFile);
      BufferedOutputStream buffer = new BufferedOutputStream(file);
      objectOutputStream = new ObjectOutputStream(buffer);
      objectOutputStream.writeObject(tokenCountMap);
      objectOutputStream.writeObject(references);
    } catch (IOException ex) {
      System.out.println(
          "\nError writing index for " + author.getName() + " at location " + location);
    } finally {
      if (objectOutputStream != null)
        try {
          objectOutputStream.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
    }
  }
Esempio n. 3
0
 public void testSearchWithId() throws Exception {
   // Create test setup
   removeAll(Author.class);
   // Create
   Author author = new Author("Stephenson", "Neal");
   getStore().save(author);
   long id = author.getPersistenceId();
   // Select
   List result = null;
   result = getStore().find("find author where persistenceid = " + id);
   Assert.assertEquals(result.size(), 1);
   result = getStore().find("find author where persistenceid = ?", new Object[] {new Long(id)});
   Assert.assertEquals(result.size(), 1);
   result = getStore().find("find author where author.persistenceid = " + id);
   Assert.assertEquals(result.size(), 1);
   result =
       getStore().find("find author where author.persistenceid = ?", new Object[] {new Long(id)});
   Assert.assertEquals(result.size(), 1);
 }
Esempio n. 4
0
 public String getAuthorName() {
   return author.getName();
 }