コード例 #1
0
ファイル: PVItem.java プロジェクト: profcalculus/cs-studio
  /**
   * Create PVItem from XML document
   *
   * @param model Model to which this item will belong (but doesn't, yet)
   * @param node XML node with item configuration
   * @return PVItem
   * @throws Exception on error
   */
  public static PVItem fromDocument(final Model model, final Element node) throws Exception {
    final String name = DOMHelper.getSubelementString(node, Model.TAG_NAME);
    final double period = DOMHelper.getSubelementDouble(node, Model.TAG_SCAN_PERIOD, 0.0);

    final PVItem item = new PVItem(name, period);
    final int buffer_size =
        DOMHelper.getSubelementInt(
            node, Model.TAG_LIVE_SAMPLE_BUFFER_SIZE, Preferences.getLiveSampleBufferSize());
    item.setLiveCapacity(buffer_size);

    final String req_txt =
        DOMHelper.getSubelementString(node, Model.TAG_REQUEST, RequestType.OPTIMIZED.name());
    try {
      final RequestType request = RequestType.valueOf(req_txt);
      item.setRequestType(request);
    } catch (Throwable ex) {
      // Ignore
    }

    item.configureFromDocument(model, node);

    // Load archives from saved configuration
    boolean have_imported_data = false;
    Element archive = DOMHelper.findFirstElementNode(node.getFirstChild(), Model.TAG_ARCHIVE);
    while (archive != null) {
      final String url = DOMHelper.getSubelementString(archive, Model.TAG_URL);
      final int key = DOMHelper.getSubelementInt(archive, Model.TAG_KEY);
      final String arch = DOMHelper.getSubelementString(archive, Model.TAG_NAME);

      if (url.startsWith(ImportArchiveReaderFactory.PREFIX)) have_imported_data = true;

      item.addArchiveDataSource(new ArchiveDataSource(url, key, arch));
      archive = DOMHelper.findNextElementNode(archive, Model.TAG_ARCHIVE);
    }

    // When requested, use default archive sources for 'real' archives (RDB, ...)
    // Do not clobber an imported archive data source, a specific file which was
    // probably not meant to be replaced by a default.
    if (Preferences.useDefaultArchives() && !have_imported_data)
      item.useDefaultArchiveDataSources();

    return item;
  }
コード例 #2
0
ファイル: AppPage.java プロジェクト: gautric/keycloak
 public RequestType getRequestType() {
   return RequestType.valueOf(driver.getTitle());
 }
コード例 #3
0
 public RequestType findValueByNumber(int number) {
   return RequestType.valueOf(number);
 }