コード例 #1
0
 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());
   }
 }
コード例 #2
0
ファイル: AuthorIndex.java プロジェクト: 0mpurdy/MSE-FilePrep
  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();
        }
    }
  }
コード例 #3
0
ファイル: SelectTests.java プロジェクト: nile/beankeeper
 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);
 }
コード例 #4
0
ファイル: AuthorIndex.java プロジェクト: 0mpurdy/MSE-FilePrep
 public String getAuthorName() {
   return author.getName();
 }