@VisibleForTesting
  void populate(
      Function<Optional<String>, Path> cellRoots,
      ProjectFilesystem filesystem,
      BuildRuleFactoryParams params,
      Object dto,
      final ImmutableSet.Builder<BuildTarget> declaredDeps,
      Map<String, ?> instance,
      boolean onlyOptional)
      throws ConstructorArgMarshalException {
    Set<ParamInfo<?>> allInfo = getAllParamInfo(dto);

    for (ParamInfo<?> info : allInfo) {
      if (onlyOptional && !info.isOptional()) {
        continue;
      }
      try {
        info.setFromParams(cellRoots, filesystem, params, dto, instance);
      } catch (ParamInfoException e) {
        throw new ConstructorArgMarshalException(e.getMessage(), e);
      }
      if (info.getName().equals("deps")) {
        populateDeclaredDeps(info, declaredDeps, dto);
      }
    }
  }
  /**
   * Create a parameter object for an update, delete or insert statement.
   *
   * @param pos the substitution position of the parameter marker in the SQL
   * @param info the ColInfo column descriptor
   * @param value the column data item
   * @return The new parameter as a <code>ParamInfo</code> object.
   */
  protected ParamInfo buildParameter(int pos, ColInfo info, Object value) throws SQLException {

    int length = 0;
    if (value instanceof String) {
      length = ((String) value).length();
    } else if (value instanceof byte[]) {
      length = ((byte[]) value).length;
    } else if (value instanceof BlobImpl) {
      BlobImpl blob = (BlobImpl) value;
      value = blob.getBinaryStream();
      length = (int) blob.length();
    } else if (value instanceof ClobImpl) {
      ClobImpl clob = (ClobImpl) value;
      value = clob.getCharacterStream();
      length = (int) clob.length();
    }
    ParamInfo param = new ParamInfo(info, null, value, length);
    param.isUnicode =
        info.sqlType.equals("nvarchar")
            || info.sqlType.equals("nchar")
            || info.sqlType.equals("ntext");
    param.markerPos = pos;

    return param;
  }
 /**
  * Retrieve the value of an output parameter.
  *
  * @param parameterIndex the ordinal position of the parameter
  * @return the parameter value as an <code>Object</code>
  * @throws SQLException if the parameter has not been set
  */
 protected Object getOutputValue(int parameterIndex) throws SQLException {
   ParamInfo parameter = getParameter(parameterIndex);
   if (!parameter.isOutput) {
     throw new SQLException(
         Messages.get("error.callable.notoutput", new Integer(parameterIndex)), "07000");
   }
   Object value = parameter.getOutValue();
   paramWasNull = (value == null);
   return value;
 }
Esempio n. 4
0
 /**
  * Find the ParamInfo from the name
  *
  * @param name name
  * @return param info
  */
 public ParamInfo findByName(String name) {
   name = name.trim();
   for (int i = 0; i < myParamInfos.size(); i++) {
     ParamInfo paramInfo = (ParamInfo) myParamInfos.get(i);
     if (paramInfo.getName().equals(name)) {
       return paramInfo;
     }
   }
   return null;
 }
Esempio n. 5
0
 public void addExpressionParam(String paramName) {
   ParamInfo paramInfo = null;
   if (exprParams == null) {
     exprParams = new HashMap();
   } else {
     paramInfo = (ParamInfo) exprParams.get(paramName);
   }
   if (paramInfo == null) {
     paramInfo = new ParamInfo(paramName, exprParamType);
     exprParams.put(paramName, paramInfo);
   }
   paramInfo.addParamIndex(paramIndexGenerator.getNewIndex());
 }
Esempio n. 6
0
 /**
  * Get the list of resources
  *
  * @return the list of resources
  */
 public List getResources() {
   List infos = new ArrayList();
   for (int i = 0; i < myTables.size(); i++) {
     ParamDefaultsTable paramDefaultsTable = (ParamDefaultsTable) myTables.get(i);
     for (ParamInfo paramInfo : (List<ParamInfo>) paramDefaultsTable.getParamInfoList()) {
       infos.add(
           new ResourceViewer.ResourceWrapper(
               paramInfo,
               paramInfo.toString(),
               paramDefaultsTable.label,
               paramDefaultsTable.isEditable));
     }
   }
   return infos;
 }
Esempio n. 7
0
 public void collectExpressionParams() throws QueryParsingException {
   if (exprParams != null) {
     for (Iterator it = exprParams.keySet().iterator(); it.hasNext(); ) {
       String paramName = (String) it.next();
       ParamInfo paramInfo = (ParamInfo) exprParams.get(paramName);
       ParamInfo info = (ParamInfo) params.get(paramName);
       if (info == null) {
         params.put(paramName, paramInfo);
       } else {
         info.copy(paramInfo);
       }
     }
     exprParams = null;
   }
   exprParamType = ExtendedSQLTypes.UNKNOWN;
 }
Esempio n. 8
0
 public void setEditMode(boolean s) {
   if (!s) pane.setEditMode(s);
   else {
     int edits = ParamInfo.getEditItems();
     if ((edits & ParamInfo.TOOLPANELS) > 0) pane.setEditMode(true);
     else pane.setEditMode(false);
   }
 }
  @SuppressWarnings("unchecked")
  private <T> void populateDeclaredDeps(
      ParamInfo<T> paramInfo, final ImmutableSet.Builder<BuildTarget> declaredDeps, Object dto) {

    if (paramInfo.isDep()) {
      paramInfo.traverse(
          new ParamInfo.Traversal() {
            @Override
            public void traverse(Object object) {
              if (!(object instanceof BuildTarget)) {
                return;
              }
              declaredDeps.add((BuildTarget) object);
            }
          },
          (T) dto);
    }
  }
Esempio n. 10
0
 public void addExpressionParams(Map paramMap) throws QueryParsingException {
   for (Iterator it = paramMap.entrySet().iterator(); it.hasNext(); ) {
     Map.Entry entry = (Map.Entry) it.next();
     String paramName = (String) entry.getKey();
     ParamInfo paramInfo = (ParamInfo) entry.getValue();
     ParamInfo info = null;
     if (exprParams == null) {
       exprParams = new HashMap();
     } else {
       info = (ParamInfo) exprParams.get(paramName);
     }
     if (info == null) {
       exprParams.put(paramName, paramInfo);
     } else {
       info.copy(paramInfo);
     }
   }
 }
Esempio n. 11
0
  @Override
  protected Value apply(ParseSession session, ParamInfo params) {

    // Evaluate items
    Object items = params.getItems().evaluate(session).checkNotNull(session, "foreach()");

    // Iterate over items and evaluate expression
    if (items instanceof Map) items = ((Map<?, ?>) items).entrySet();
    if (!(items instanceof Iterable))
      throw new EvalException(
          "invalid foreach() operation over non-Iterable object of type "
              + items.getClass().getName());
    for (Object item : ((Iterable<?>) items))
      this.evaluate(session, params.getVariable(), new ConstValue(item), params.getExpr());

    // Done
    return Value.NO_VALUE;
  }
Esempio n. 12
0
  /**
   * Generates a new set-ICBM-parameter-information command from the given incoming SNAC packet.
   *
   * @param packet an incoming set-ICBM-parameters packet
   */
  protected SetParamInfoCmd(SnacPacket packet) {
    super(CMD_SET_PARAM_INFO);

    DefensiveTools.checkNull(packet, "packet");

    ByteBlock snacData = packet.getData();

    paramInfo = ParamInfo.readParamInfo(snacData);
  }
Esempio n. 13
0
  public VTabbedToolPanel(SessionShare sshare, AppIF appIF) {
    // super( new BorderLayout() );
    this.sshare = sshare;
    this.appIF = appIF;
    this.tabbedToolPanel = new JPanel();
    this.pinPanel = this;
    this.selectedTabName = null;
    setPinObj(this.tabbedToolPanel);
    this.tabbedToolPanel.setLayout(new BorderLayout());
    this.tabbedPane = new JTabbedPane();
    panelName = "Tab Panel";
    setTitle(panelName);
    setName(panelName);

    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            tabChanged();
            /**
             * ** the following was moved to tabChanged() if(tabbedPane.getTabCount() > 1 &&
             * Util.getRQPanel() != null) { int ind = tabbedPane.getSelectedIndex(); if(ind >= 0 &&
             * ind < tabbedPane.getTabCount())
             * Util.getRQPanel().updatePopup(tabbedPane.getTitleAt(ind)); } *********
             */
          }
        });

    // Add Mouse Listener for CSH
    MouseAdapter ml = new CSHMouseAdapter();
    tabbedPane.addMouseListener(ml);

    Object obj = sshare.userInfo().get("canvasnum");
    if (obj != null) {
      Dimension dim = (Dimension) obj;
      nviews = (dim.height) * (dim.width);
    } else nviews = 1;

    for (int i = 0; i < nviews; i++) tp_paneInfo[i] = new Hashtable();

    /*
    obj = sshare.userInfo().get("activeWin");
    if(obj != null) {
               vpId = ((Integer)obj).intValue();
    } else vpId = 0;
            */

    // System.out.println("VToolPanel nviews vpId "+nviews+" "+vpId);

    fillHashtable();
    Util.setVTabbedToolPanel(this);
    ParamInfo.addEditListener(this);
  }
Esempio n. 14
0
 /**
  * Get the color table, range, etc, from the given display control and save them as the param
  * defaults for its data choice
  *
  * @param displayControl the display control to get state from
  */
 public void saveDefaults(DisplayControlImpl displayControl) {
   try {
     List choices = displayControl.getMyDataChoices();
     if (choices.size() != 1) {
       return;
     }
     DataChoice dc = (DataChoice) choices.get(0);
     String name = dc.getName();
     String ctName =
         ((displayControl.getColorTable() != null)
             ? displayControl.getColorTable().getName()
             : null);
     ParamInfo newParamInfo =
         new ParamInfo(
             name,
             ctName,
             displayControl.getRange(),
             displayControl.getContourInfo(),
             displayControl.getDisplayUnit());
     ParamDefaultsTable firstTable = getFirstTable();
     if (!firstTable.editRow(newParamInfo, false)) {
       return;
     }
     ParamInfo origParamInfo = firstTable.findByName(dc.getName());
     if (origParamInfo == null) {
       firstTable.addBeginning(newParamInfo);
       firstTable.getSelectionModel().setSelectionInterval(0, 0);
     } else {
       origParamInfo.initWith(newParamInfo);
       firstTable.tableChanged();
       firstTable.selectParamInfo(origParamInfo);
     }
     saveData();
     show();
     GuiUtils.showComponentInTabs(firstTable);
   } catch (Exception exc) {
     LogUtil.printException(log_, "copying defaults", exc);
   }
 }
Esempio n. 15
0
  public void copyExpressionParams(int count) {
    if (exprParams != null && count > 0) {
      int paramCount = 0;
      // calculate param count first
      for (Iterator it = exprParams.values().iterator(); it.hasNext(); ) {
        ParamInfo info = (ParamInfo) it.next();
        paramCount += info.getIndexList().size();
      }

      for (Iterator it = exprParams.values().iterator(); it.hasNext(); ) {
        ParamInfo info = (ParamInfo) it.next();
        List l = (List) ((ArrayList) info.getIndexList()).clone();
        for (int i = 0, n = l.size(); i < n; i++) {
          int index = ((Integer) l.get(i)).intValue();
          for (int j = 1; j <= count; j++) {
            info.addParamIndex(index + j * paramCount);
          }
        }
      }
      paramIndexGenerator.increase(paramCount * count);
    }
  }
Esempio n. 16
0
  /**
   * Create the param infos from the given xml root
   *
   * @param root The xml root
   * @param overwriteOk Ok to overwrite an existing one
   */
  private void loadParamDefaults(Element root, boolean overwriteOk) {
    List listOfInfos = createParamInfoList(root);
    for (int i = 0; i < listOfInfos.size(); i++) {
      ParamInfo newParamInfo = (ParamInfo) listOfInfos.get(i);
      String paramName = newParamInfo.getName();
      if (!overwriteOk && (paramToInfo.get(paramName) != null)) {
        continue;
      }

      ParamInfo oldParamInfo = (ParamInfo) paramToInfo.get(paramName);
      if (oldParamInfo == null) {
        paramToInfo.put(paramName, newParamInfo);
        paramInfos.add(newParamInfo);
      } else {
        if (!oldParamInfo.hasColorTableName()) {
          oldParamInfo.setColorTableName(newParamInfo.getColorTableName());
        }
        if (!oldParamInfo.hasRange()) {
          oldParamInfo.setRange(newParamInfo.getRange());
        }
      }
    }
  }
  public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
    ParamInfo pi = getParameter(parameterIndex);

    pi.isOutput = true;

    if (Support.getJdbcTypeName(sqlType).equals("ERROR")) {
      throw new SQLException(
          Messages.get("error.generic.badtype", Integer.toString(sqlType)), "HY092");
    }

    if (sqlType == java.sql.Types.CLOB) {
      pi.jdbcType = java.sql.Types.LONGVARCHAR;
    } else if (sqlType == java.sql.Types.BLOB) {
      pi.jdbcType = java.sql.Types.LONGVARBINARY;
    } else {
      pi.jdbcType = sqlType;
    }

    pi.scale = scale;
  }
Esempio n. 18
0
 /**
  * Returns a ContourInfo based on the parameter name (e.g., rh, t, etc.)
  *
  * @param paramName Name to look for
  * @return The {@link ucar.unidata.util.ContourInfo} found or null
  */
 public ContourInfo getParamContourInfo(String paramName) {
   ParamInfo paramInfo = getParamInfo(paramName);
   return ((paramInfo != null) ? paramInfo.getContourInfo() : null);
 }
Esempio n. 19
0
 /**
  * Returns a Range based on the parameter name (e.g., rh, t, etc.)
  *
  * @param paramName Name to look for
  * @return The {@link ucar.unidata.util.Range} found or null
  */
 public Range getParamRange(String paramName) {
   ParamInfo paramInfo = getParamInfo(paramName);
   return ((paramInfo != null) ? paramInfo.getRange() : null);
 }
Esempio n. 20
0
    /**
     * Edit row
     *
     * @param paramInfo param info
     * @param removeOnCancel Should remove param info if user presses cancel_
     * @return ok
     */
    public boolean editRow(ParamInfo paramInfo, boolean removeOnCancel) {

      List comps = new ArrayList();
      ParamField nameFld = new ParamField(null, true);
      nameFld.setText(paramInfo.getName());
      JPanel topPanel = GuiUtils.hbox(GuiUtils.lLabel("Parameter:  "), nameFld);
      topPanel = GuiUtils.inset(topPanel, 5);

      comps.add(GuiUtils.inset(new JLabel("Defined"), new Insets(5, 0, 0, 0)));
      comps.add(GuiUtils.filler());
      comps.add(GuiUtils.filler());

      final JLabel ctPreviewLbl = new JLabel("");
      final JLabel ctLbl = new JLabel("");
      if (paramInfo.hasColorTableName()) {
        ctLbl.setText(paramInfo.getColorTableName());
        ColorTable ct =
            getIdv().getColorTableManager().getColorTable(paramInfo.getColorTableName());
        if (ct != null) {
          ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
        } else {
          ctPreviewLbl.setIcon(null);
        }
      }
      String cbxLabel = "";
      final ArrayList menus = new ArrayList();
      getIdv()
          .getColorTableManager()
          .makeColorTableMenu(
              new ObjectListener(null) {
                public void actionPerformed(ActionEvent ae, Object data) {
                  ctLbl.setText(data.toString());
                  ColorTable ct = getIdv().getColorTableManager().getColorTable(ctLbl.getText());
                  if (ct != null) {
                    ctPreviewLbl.setIcon(ColorTableCanvas.getIcon(ct));
                  } else {
                    ctPreviewLbl.setIcon(null);
                  }
                }
              },
              menus);

      JCheckBox ctUseCbx = new JCheckBox(cbxLabel, paramInfo.hasColorTableName());
      final JButton ctPopup = new JButton("Change");
      ctPopup.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              GuiUtils.showPopupMenu(menus, ctPopup);
            }
          });
      addEditComponents(
          comps,
          "Color Table:",
          ctUseCbx,
          GuiUtils.hbox(ctPopup, GuiUtils.vbox(ctLbl, ctPreviewLbl), 5));

      JCheckBox rangeUseCbx = new JCheckBox(cbxLabel, paramInfo.hasRange());
      JTextField minFld = new JTextField("" + paramInfo.getMin(), 4);
      JTextField maxFld = new JTextField("" + paramInfo.getMax(), 4);
      JPanel rangePanel = GuiUtils.hbox(minFld, maxFld, 5);
      addEditComponents(comps, "Range:", rangeUseCbx, rangePanel);

      JCheckBox unitUseCbx = new JCheckBox(cbxLabel, paramInfo.hasDisplayUnit());
      String unitLabel = "";
      Unit unit = null;
      if (paramInfo.hasDisplayUnit()) {
        unit = paramInfo.getDisplayUnit();
      }

      JComboBox unitFld = getIdv().getDisplayConventions().makeUnitBox(unit, null);
      //            JTextField unitFld = new JTextField(unitLabel, 15);
      addEditComponents(comps, "Unit:", unitUseCbx, unitFld);

      ContourInfo ci = paramInfo.getContourInfo();
      JCheckBox contourUseCbx = new JCheckBox(cbxLabel, ci != null);
      if (ci == null) {
        ci = new ContourInfo();
      }
      ContourInfoDialog contDialog =
          new ContourInfoDialog("Edit Contour Defaults", false, null, false);
      contDialog.setState(ci);
      addEditComponents(comps, "Contour:", contourUseCbx, contDialog.getContents());

      GuiUtils.tmpInsets = new Insets(5, 5, 5, 5);
      JComponent contents = GuiUtils.doLayout(comps, 3, GuiUtils.WT_NNY, GuiUtils.WT_N);

      contents = GuiUtils.topCenter(topPanel, contents);
      contents = GuiUtils.inset(contents, 5);
      while (true) {
        if (!GuiUtils.showOkCancelDialog(null, "Parameter Defaults", contents, null)) {
          if (removeOnCancel) {
            myParamInfos.remove(paramInfo);
            tableChanged();
          }
          return false;
        }
        String what = "";
        try {
          if (contourUseCbx.isSelected()) {
            what = "setting contour defaults";
            contDialog.doApply();
            ci.set(contDialog.getInfo());
            paramInfo.setContourInfo(ci);
          } else {
            paramInfo.clearContourInfo();
          }
          if (unitUseCbx.isSelected()) {
            what = "setting display unit";
            Object selected = unitFld.getSelectedItem();
            String unitName = TwoFacedObject.getIdString(selected);
            if ((unitName == null) || unitName.trim().equals("")) {
              paramInfo.setDisplayUnit(null);
            } else {
              paramInfo.setDisplayUnit(ucar.visad.Util.parseUnit(unitName));
            }
          } else {
            paramInfo.setDisplayUnit(null);
          }

          if (ctUseCbx.isSelected()) {
            paramInfo.setColorTableName(ctLbl.getText());
          } else {
            paramInfo.clearColorTableName();
          }

          if (rangeUseCbx.isSelected()) {
            what = "setting range";
            paramInfo.setRange(
                new Range(Misc.parseNumber(minFld.getText()), Misc.parseNumber(maxFld.getText())));
          } else {
            paramInfo.clearRange();
          }

          paramInfo.setName(nameFld.getText().trim());
          break;
        } catch (Exception exc) {
          errorMsg("An error occurred " + what + "\n " + exc.getMessage());
          //              exc.printStackTrace();
        }
      }
      repaint();
      saveData();
      return true;
    }
Esempio n. 21
0
 /**
  * Returns a Unit based on the parameter name (e.g., rh, t, etc.)
  *
  * @param paramName Name to look for
  * @return The Unit found or null
  */
 public Unit getParamDisplayUnit(String paramName) {
   ParamInfo paramInfo = getParamInfo(paramName);
   return ((paramInfo != null) ? paramInfo.getDisplayUnit() : null);
 }
Esempio n. 22
0
 /**
  * パラメータの削除
  *
  * @param tag タグ名
  * @param paramName パラメータ名
  * @see org.bbreak.excella.reports.model.ParamInfo#removeParam(java.lang.String, java.lang.String)
  */
 public void removeParam(String tag, String paramName) {
   paramInfo.removeParam(tag, paramName);
 }
Esempio n. 23
0
  protected void handleSnacResponse(SnacResponseEvent e) {
    super.handleSnacResponse(e);

    Log.debug("OSCAR bos snac response received: " + e);

    SnacCommand cmd = e.getSnacCommand();

    if (cmd instanceof LocRightsCmd) {
      request(new SetInfoCmd(new InfoData("oscargateway", null, MY_CAPS, null)));
      request(new MyInfoRequest());
    } else if (cmd instanceof ParamInfoCmd) {
      ParamInfoCmd pic = (ParamInfoCmd) cmd;

      ParamInfo info = pic.getParamInfo();

      request(
          new SetParamInfoCmd(
              new ParamInfo(
                  0,
                  info.getFlags() | ParamInfo.FLAG_TYPING_NOTIFICATION,
                  8000,
                  info.getMaxSenderWarning(),
                  info.getMaxReceiverWarning(),
                  0)));
    } else if (cmd instanceof ServiceRedirect) {
      ServiceRedirect sr = (ServiceRedirect) cmd;

      oscarSession.connectToService(sr.getSnacFamily(), sr.getRedirectHost(), sr.getCookie());

    } else if (cmd instanceof SsiDataCmd) {
      SsiDataCmd sdc = (SsiDataCmd) cmd;

      List<SsiItem> items = sdc.getItems();
      for (SsiItem item : items) {
        SsiItemObj obj = itemFactory.getItemObj(item);
        if (obj instanceof BuddyItem) {
          Log.debug("AIM got buddy item " + obj);
          oscarSession.gotBuddy((BuddyItem) obj);
        } else if (obj instanceof GroupItem) {
          Log.debug("AIM got group item " + obj);
          oscarSession.gotGroup((GroupItem) obj);
        }
      }

      if (sdc.getLastModDate() != 0) {
        request(new ActivateSsiCmd());
        clientReady();

        Presence p = new Presence();
        p.setTo(oscarSession.getJID());
        p.setFrom(oscarSession.getTransport().getJID());
        oscarSession.getTransport().sendPacket(p);

        oscarSession.setLoginStatus(TransportLoginStatus.LOGGED_IN);
        oscarSession.gotCompleteSSI();
      }
    } else if (cmd instanceof OfflineMsgIcqCmd) {
      OfflineMsgIcqCmd omic = (OfflineMsgIcqCmd) cmd;

      String sn = String.valueOf(omic.getFromUIN());
      // String msg = "Offline message sent at "+new
      // Date(omic.getDate().getTime()).toString()+"\n"+OscarTools.stripHtml(omic.getContents()).trim();
      String msg =
          "Offline message received:\n"
              + StringUtils.unescapeFromXML(OscarTools.stripHtml(omic.getContents()).trim());
      EncodedStringInfo encmsg = MinimalEncoder.encodeMinimally(msg);
      InstantMessage imsg =
          new InstantMessage(
              encmsg.getImEncoding().getCharsetCode(), ByteBlock.wrap(encmsg.getData()));

      oscarSession
          .getTransport()
          .sendMessage(
              oscarSession.getJIDWithHighestPriority(),
              oscarSession.getTransport().convertIDToJID(sn),
              imsg.getMessage());
    } else if (cmd instanceof OfflineMsgDoneCmd) {
      request(new OfflineMsgIcqAckCmd(oscarSession.getUIN(), (int) oscarSession.nextIcqId()));
    } else if (cmd instanceof MetaShortInfoCmd) {
      //            MetaShortInfoCmd msic = (MetaShortInfoCmd)cmd;
      //            Log.debug("RECEIVED META SHORT INFO: "+msic);
      //            oscarSession.updateRosterNickname(String.valueOf(msic.getUIN()),
      // msic.getNickname());
    } else if (cmd instanceof BuddyAddedYouCmd) {
      BuddyAddedYouCmd bay = (BuddyAddedYouCmd) cmd;

      Presence p = new Presence();
      p.setType(Presence.Type.subscribe);
      p.setTo(oscarSession.getJID());
      p.setFrom(oscarSession.getTransport().convertIDToJID(bay.getUin()));
      oscarSession.getTransport().sendPacket(p);
    } else if (cmd instanceof BuddyAuthRequest) {
      BuddyAuthRequest bar = (BuddyAuthRequest) cmd;

      Presence p = new Presence();
      p.setType(Presence.Type.subscribe);
      p.setTo(oscarSession.getJID());
      p.setFrom(oscarSession.getTransport().convertIDToJID(bar.getScreenname()));
      oscarSession.getTransport().sendPacket(p);
    } else if (cmd instanceof AuthReplyCmd) {
      AuthReplyCmd ar = (AuthReplyCmd) cmd;

      if (ar.isAccepted()) {
        Presence p = new Presence();
        p.setType(Presence.Type.subscribed);
        p.setTo(oscarSession.getJID());
        p.setFrom(oscarSession.getTransport().convertIDToJID(ar.getSender()));
        oscarSession.getTransport().sendPacket(p);
      } else {
        Presence p = new Presence();
        p.setType(Presence.Type.unsubscribed);
        p.setTo(oscarSession.getJID());
        p.setFrom(oscarSession.getTransport().convertIDToJID(ar.getSender()));
        oscarSession.getTransport().sendPacket(p);
      }
    } else if (cmd instanceof AuthFutureCmd) {
      AuthFutureCmd af = (AuthFutureCmd) cmd;

      Presence p = new Presence();
      p.setType(Presence.Type.subscribe);
      p.setTo(oscarSession.getJID());
      p.setFrom(oscarSession.getTransport().convertIDToJID(af.getUin()));
      oscarSession.getTransport().sendPacket(p);
    }
  }
Esempio n. 24
0
 /**
  * パラメータのクリア
  *
  * @param tag タグ名
  * @see org.bbreak.excella.reports.model.ParamInfo#clearParam(java.lang.String)
  */
 public void clearParam(String tag) {
   paramInfo.clearParam(tag);
 }
Esempio n. 25
0
 /**
  * パラメータのデータ取得
  *
  * @param tag タグ名
  * @param paramName パラメータ名
  * @return パラメータ名に対応するデータ。存在しない場合はnull
  * @see org.bbreak.excella.reports.model.ParamInfo#getParam(java.lang.String, java.lang.String)
  */
 public Object getParam(String tag, String paramName) {
   return paramInfo.getParam(tag, paramName);
 }
Esempio n. 26
0
 /**
  * パラメータのクリア
  *
  * @see org.bbreak.excella.reports.model.ParamInfo#clearParam()
  */
 public void clearParam() {
   paramInfo.clearParam();
 }
Esempio n. 27
0
 /**
  * パラメータの追加
  *
  * @param tag タグ名
  * @param params 追加パラメータ
  * @see org.bbreak.excella.reports.model.ParamInfo#addParams(java.lang.String, java.util.Map)
  */
 public void addParams(String tag, Map<String, Object> params) {
   paramInfo.addParams(tag, params);
 }
Esempio n. 28
0
 /**
  * パラメータの追加
  *
  * @param tag タグ名
  * @param paramName パラメータ名
  * @param data データ
  * @see org.bbreak.excella.reports.model.ParamInfo#addParam(java.lang.String, java.lang.String,
  *     java.lang.Object)
  */
 public void addParam(String tag, String paramName, Object data) {
   paramInfo.addParam(tag, paramName, data);
 }
Esempio n. 29
0
  public ObjectDescription generateObjectDescription(Object o, Integer objID, boolean addObject) {

    ObjectDescription result = null;

    // Object annotations
    ObjectInfo objectInfo = null;

    Annotation[] objectAnnotations = o.getClass().getAnnotations();

    for (Annotation a : objectAnnotations) {
      if (a.annotationType().equals(ObjectInfo.class)) {
        objectInfo = (ObjectInfo) a;
        break;
      }
    }

    if (addObject) {
      ObjectEntry oEntry = new ObjectEntry(o);
      if (objID != null) {
        objects.addWithID(oEntry, objID);
      } else {
        objects.add(oEntry);
        objID = oEntry.getID();
      }
    }

    boolean hasCustomReferenceMethod = false;

    // we need special treatment for proxy objects
    if (o instanceof ProxyObject) {
      ProxyObject proxy = (ProxyObject) o;

      result = proxy.getObjectDescription();

      result.setName(o.getClass().getName());

      result.setID(objID);

      // update objID of methods
      for (MethodDescription mDesc : result.getMethods()) {
        mDesc.setObjectID(objID);
      }

    } else {
      result = new ObjectDescription();
      result.setInfo(objectInfo);

      result.setName(o.getClass().getName());

      result.setID(objID);

      Class<?> c = o.getClass();

      Method[] theMethods = null;

      if (objectInfo != null && objectInfo.showInheritedMethods()) {
        theMethods = c.getMethods();
      } else {
        ArrayList<Method> methods = new ArrayList<Method>();

        // methods declared by class c
        for (Method m : c.getDeclaredMethods()) {
          methods.add(m);
        }

        // methods declared in superclasses of c
        for (Method m : c.getMethods()) {
          MethodInfo info = m.getAnnotation(MethodInfo.class);
          // if m is marked as inheritGUI this method will
          // be visualized even if it is a method declared
          // in a superclass of c
          if (info != null && info.inheritGUI()) {
            if (!methods.contains(m)) {
              methods.add(m);
            }
          }
        }

        Method[] tmpArray = new Method[methods.size()];

        theMethods = methods.toArray(tmpArray);
      }

      for (int i = 0; i < theMethods.length; i++) {

        // filter groovy object specific methods
        String method = theMethods[i].getName();
        boolean isGroovyObject = o instanceof GroovyObject;
        boolean isGroovyMethod =
            method.equals("setProperty")
                || method.equals("getProperty")
                || method.equals("invokeMethod")
                || method.equals("getMetaClass")
                || method.equals("setMetaClass"); // ||
        //                            // the following methods are only present
        //                            // for Groovy >= 1.6
        //                            method.equals("super$1$wait") ||
        //                            method.equals("super$1$toString") ||
        //                            method.equals("super$1$notify") ||
        //                            method.equals("super$1$notifyAll") ||
        //                            method.equals("super$1$getClass") ||
        //                            method.equals("super$1$equals") ||
        //                            method.equals("super$1$clone") ||
        //                            method.equals("super$1$hashCode") ||
        //                            method.equals("super$1$finalize");

        // For Groovy >= 1.6 private methods have $ sign in their
        // name, e.g.,
        //   private doSomething()
        // will be changed to
        //   this$2$doSomething()
        // which is unfortunately accessible and thus will be
        // visualized by vrl.
        // To prevent groovys strange behavior
        // methods with $ sign are ignored and treated as private.
        boolean isPrivateGroovyMethod = method.contains("$");

        // TODO improve that code!
        if ((isGroovyObject && isGroovyMethod) || isPrivateGroovyMethod) {
          continue;
        }

        Class[] parameterTypes = theMethods[i].getParameterTypes();

        Annotation[][] allParameterAnnotations = theMethods[i].getParameterAnnotations();

        ArrayList<String> paramNames = new ArrayList<String>();

        ArrayList<ParamInfo> paramAnnotations = new ArrayList<ParamInfo>();
        ArrayList<ParamGroupInfo> paramGroupAnnotations = new ArrayList<ParamGroupInfo>();

        // retrieving annotation information for each parameter
        for (int j = 0; j < allParameterAnnotations.length; j++) {

          Annotation[] annotations = allParameterAnnotations[j];

          // add name element and set it to null
          // because we don't know if parameter j is annotated
          paramNames.add(null);
          paramAnnotations.add(null);
          paramGroupAnnotations.add(null);

          // check all annotations of parameter j
          // if we have a ParamInfo annotation retrieve data
          // and store it as element of paramName
          for (Annotation a : annotations) {
            if (a.annotationType().equals(ParamInfo.class)) {
              ParamInfo n = (ParamInfo) a;
              if (!n.name().equals("")) {
                paramNames.set(j, n.name());
              }
              paramAnnotations.set(j, n);
            } else {
              if (a.annotationType().equals(ParamGroupInfo.class)) {
                ParamGroupInfo n = (ParamGroupInfo) a;
                paramGroupAnnotations.set(j, n);
              }
            }
          } // end for a
        } // end for j

        // convert list to array
        String[] parameterNames = paramNames.toArray(new String[paramNames.size()]);

        ParamInfo[] parameterAnnotations =
            paramAnnotations.toArray(new ParamInfo[paramAnnotations.size()]);

        ParamGroupInfo[] parameterGroupAnnotations =
            paramGroupAnnotations.toArray(new ParamGroupInfo[paramGroupAnnotations.size()]);

        Class returnType = theMethods[i].getReturnType();

        String methodString = theMethods[i].getName();
        String methodTitle = "";
        String returnValueName = null;

        int modifiers = theMethods[i].getModifiers();

        String modifierString = Modifier.toString(modifiers);

        // Method Annotations
        Annotation[] annotations = theMethods[i].getAnnotations();
        MethodInfo methodInfo = null;

        OutputInfo outputInfo = null;

        boolean interactive = true;
        boolean hide = false;

        for (Annotation a : annotations) {
          if (a.annotationType().equals(MethodInfo.class)) {
            MethodInfo n = (MethodInfo) a;

            methodTitle = n.name();
            interactive = n.interactive();
            hide = n.hide();
            returnValueName = n.valueName();

            methodInfo = n;
          }

          if (a.annotationType().equals(OutputInfo.class)) {
            outputInfo = (OutputInfo) a;
          }
        }

        if (theMethods[i].getAnnotation(ReferenceMethodInfo.class) != null) {
          hasCustomReferenceMethod = true;
          MethodDescription customReferenceMethod =
              new MethodDescription(
                  objID,
                  0,
                  methodString,
                  methodTitle,
                  null,
                  parameterTypes,
                  parameterNames,
                  parameterAnnotations,
                  parameterGroupAnnotations,
                  returnType,
                  returnValueName,
                  interactive,
                  methodInfo,
                  outputInfo);

          if (customReferenceMethod.getParameterTypes() == null
              || customReferenceMethod.getParameterTypes().length != 1) {
            throw new IllegalArgumentException(
                " Cannot to use "
                    + "\""
                    + methodString
                    + "\" as reference method"
                    + " because the number of parameters does not"
                    + " match. Exactly one parameter must be"
                    + " provided.");
          }

          if (customReferenceMethod.getReturnType() == void.class
              || customReferenceMethod.getReturnType().isPrimitive()) {
            throw new IllegalArgumentException(
                " Cannot to use "
                    + "\""
                    + methodString
                    + "\" as reference method"
                    + " because it does not return an object."
                    + " Returning primitives or void is not"
                    + " allowed.");
          }

          customReferenceMethod.setMethodType(MethodType.CUSTOM_REFERENCE);

          result.addMethod(customReferenceMethod);
        } //
        // TODO: at the moment method id is always 0 and will only be
        //      set from corresponding method representations
        //
        //      is it necessary to change that?
        else if (modifierString.contains("public")
            && (methodInfo == null || !methodInfo.ignore())) {
          result.addMethod(
              new MethodDescription(
                  objID,
                  0,
                  methodString,
                  methodTitle,
                  null,
                  parameterTypes,
                  parameterNames,
                  parameterAnnotations,
                  parameterGroupAnnotations,
                  returnType,
                  returnValueName,
                  interactive,
                  methodInfo,
                  outputInfo));
        }
      } // end for i

      // Object name
      if (objectInfo != null && !objectInfo.name().equals("")) {
        result.setName(objectInfo.name());
      }
    } // end else if (o instanceof ProxyObject)

    if (!hasCustomReferenceMethod) {
      result.addMethod(MethodDescription.createReferenceMethod(objID, o.getClass()));
    }

    return result;
  }
Esempio n. 30
0
 /**
  * Get the color table for a particular parameter from ParamInfo
  *
  * @param info parameter information
  * @return the associated color table.
  */
 private ColorTable getColorTable(ParamInfo info) {
   if (info.getColorTableName() != null) {
     return getIdv().getColorTableManager().getColorTable(info.getColorTableName());
   }
   return null;
 }