/**
   * Sets the application attribute using the name passed to the constructor.
   *
   * @param e
   */
  private void addApplicationAttribute(IEntry iEntry) {
    if (!(iEntry instanceof BaseEntry)) {
      throw new IllegalArgumentException("Unexpected entry type: " + iEntry.getClass());
    }
    BaseEntry<?> e = (BaseEntry<?>) iEntry;

    GoogleBaseAttributesExtension attrs = e.getExtension(GoogleBaseAttributesExtension.class);
    if (attrs == null) {
      return;
    }
    attrs.setApplication(application);
  }
 @Override
 public void declareExtensions(ExtensionProfile extProfile) {
   if (extProfile.isDeclared(CombinationEntry.class)) {
     return;
   }
   super.declareExtensions(extProfile);
   extProfile.declare(CombinationEntry.class, GwoComboActive.class);
   extProfile.declare(CombinationEntry.class, GwoComboId.class);
   extProfile.declare(CombinationEntry.class, GwoComboString.class);
   extProfile.declare(CombinationEntry.class, GwoExperimentId.class);
 }
 @Override
 public void declareExtensions(ExtensionProfile extProfile) {
   if (extProfile.isDeclared(IssueCommentsEntry.class)) {
     return;
   }
   super.declareExtensions(extProfile);
   extProfile.declare(IssueCommentsEntry.class, IssuesLink.getDefaultDescription(false, true));
   extProfile.declare(IssueCommentsEntry.class, SendEmail.class);
   extProfile.declare(IssueCommentsEntry.class, Updates.class);
   new Updates().declareExtensions(extProfile);
 }
Esempio n. 4
0
 /**
  * Displays the given list of entries and prompts the user to select the index of one of the
  * entries. NOTE: The displayed index is 1-based and is converted to 0-based before being
  * returned.
  *
  * @param reader to read input from the keyboard
  * @param entries the list of entries to display
  * @param type describes the type of things the list contains
  * @return the 0-based index of the user's selection
  * @throws IOException if an I/O error occurs while getting input from user
  */
 private int getIndexFromUser(BufferedReader reader, List entries, String type)
     throws IOException {
   for (int i = 0; i < entries.size(); i++) {
     BaseEntry entry = (BaseEntry) entries.get(i);
     System.out.println("\t(" + (i + 1) + ") " + entry.getTitle().getPlainText());
   }
   int index = -1;
   while (true) {
     out.print("Enter the number of the spreadsheet to load: ");
     String userInput = reader.readLine();
     try {
       index = Integer.parseInt(userInput);
       if (index < 1 || index > entries.size()) {
         throw new NumberFormatException();
       }
       break;
     } catch (NumberFormatException e) {
       System.out.println("Please enter a valid number for your selection.");
     }
   }
   return index - 1;
 }
 /**
  * Prints detailed information regarding a Generic Entry
  *
  * @param entry The entry of interest
  */
 private static void printBasicEntryDetails(BaseEntry entry) {
   System.out.println("\tTitle: " + entry.getTitle().getPlainText());
   System.out.println("\tAtom ID: " + entry.getId());
   System.out.println("\tLast updated: " + entry.getUpdated());
   System.out.println("\tEntry Categories:");
   Iterator it = entry.getCategories().iterator();
   while (it.hasNext()) {
     System.out.println("\t\t" + it.next().toString());
   }
   System.out.println("\tLinks:");
   if (entry.getLinks().size() == 0) {
     System.out.println("\t\t<No links, sorry!>");
   }
   for (int i = 0; i < entry.getLinks().size(); i++) {
     System.out.println("\t\t" + ((Link) (entry.getLinks().get(i))).getHref());
   }
 }
 /**
  * Convenience method for getting a batchId from an entry if it's there.
  *
  * @param entry
  * @return the id or null if it's not defined
  */
 public static String getIdFrom(BaseEntry<?> entry) {
   BatchId tag = entry.getExtension(BatchId.class);
   return tag == null ? null : tag.getId();
 }