예제 #1
1
  private Vector generateOcts() {
    int start = 0;
    int end = 0;
    Vector vec = new Vector();

    while ((end + 1) < string.length) {
      if (string[end] == 0 && string[end + 1] == 0) {
        byte[] nStr = new byte[end - start + 1];

        System.arraycopy(string, start, nStr, 0, nStr.length);

        vec.addElement(new DEROctetString(nStr));
        start = end + 1;
      }
      end++;
    }

    byte[] nStr = new byte[string.length - start];

    System.arraycopy(string, start, nStr, 0, nStr.length);

    vec.addElement(new DEROctetString(nStr));

    return vec;
  }
  /**
   * Returns an enumeration describing the available options.
   *
   * @return an enumeration of all the available options.
   */
  public Enumeration listOptions() {

    Vector newVector = new Vector(2);

    newVector.addElement(
        new Option(
            "\tNumber of folds used for cross validation (default 10).",
            "X",
            1,
            "-X <number of folds>"));
    newVector.addElement(
        new Option(
            "\tClassifier parameter options.\n"
                + "\teg: \"N 1 5 10\" Sets an optimisation parameter for the\n"
                + "\tclassifier with name -N, with lower bound 1, upper bound\n"
                + "\t5, and 10 optimisation steps. The upper bound may be the\n"
                + "\tcharacter 'A' or 'I' to substitute the number of\n"
                + "\tattributes or instances in the training data,\n"
                + "\trespectively. This parameter may be supplied more than\n"
                + "\tonce to optimise over several classifier options\n"
                + "\tsimultaneously.",
            "P",
            1,
            "-P <classifier parameter>"));

    Enumeration enu = super.listOptions();
    while (enu.hasMoreElements()) {
      newVector.addElement(enu.nextElement());
    }
    return newVector.elements();
  }
예제 #3
1
  /** Creates new form SessionLog */
  public SessionLog() {
    initComponents();

    try {
      Connection con = DBConnection.getConnection();
      String query = "select * from user_session where user_id=?";
      PreparedStatement psmt = con.prepareStatement(query);
      psmt.setString(1, "ababab");
      ResultSet rs = psmt.executeQuery();
      ResultSetMetaData rsmd;
      rsmd = rs.getMetaData();
      Vector column = new Vector();
      int count = rsmd.getColumnCount();
      DefaultTableModel dtm = new DefaultTableModel();
      for (int i = 1; i <= count; i++) {
        column.addElement(rsmd.getColumnName(i));
      }
      dtm.setColumnIdentifiers(column);
      while (rs.next()) {
        Vector row = new Vector();
        for (int i = 1; i <= count; i++) {
          row.addElement(rs.getString(i));
        }
        dtm.addRow(row);
      }
      jTable1.setModel(dtm);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
예제 #4
1
  @SuppressWarnings({"rawtypes", "unchecked"})
  public static Vector createFTPParameter(ManageableThread thread) {
    Vector vtReturn = new Vector();

    vtReturn.add(
        createTextParameter(
            "ftpUse", 400, "The billing runing ftp mode, that must put cdr file in remote server"));
    vtReturn.add(createTextParameter("ftpAddress", 400, ""));
    vtReturn.add(createIntegerParameter("ftpPort", ""));
    vtReturn.add(createTextParameter("ftpUser", 400, ""));
    vtReturn.add(createTextParameter("ftpPass", 400, ""));
    vtReturn.add(createComboParameter("ftpMode", "upload,download,manual", ""));
    vtReturn.add(createTextParameter("ftpRemoteDir", 400, ""));
    vtReturn.add(createTextParameter("ftpBackupDir", 400, ""));
    vtReturn.add(createTextParameter("ftpTempDir", 400, ""));

    vtReturn.addElement(createTextParameter("importDir", 300, ""));
    vtReturn.addElement(createTextParameter("exportDir", 300, ""));
    vtReturn.addElement(createTextParameter("tempDir", 300, ""));
    vtReturn.addElement(createTextParameter("errorDir", 300, ""));
    vtReturn.addElement(createTextParameter("rejectDir", 300, ""));
    vtReturn.addElement(createTextParameter("backupDir", 300, ""));

    vtReturn.addElement(createTextParameter("wildcard", 300, ""));

    return vtReturn;
  }
예제 #5
1
 private String getInfo(ResultSet rs) throws SQLException {
   // position to first record
   boolean moreRecords = rs.next();
   // If there are no records, display a message
   if (!moreRecords) {
     return null;
   }
   Vector columnHeads = new Vector();
   Vector rows = new Vector();
   try {
     // get column heads
     ResultSetMetaData rsmd = rs.getMetaData();
     for (int i = 1; i <= rsmd.getColumnCount(); ++i)
       columnHeads.addElement(rsmd.getColumnName(i));
     // get row data
     do {
       rows.addElement(getNextRow(rs, rsmd));
     } while (rs.next());
     String info;
     String aux = rows.get(0).toString();
     info = aux.substring(1, aux.length() - 1);
     return info;
   } catch (SQLException sqlex) {
     sqlex.printStackTrace();
     return null;
   }
 }
예제 #6
1
        public void handle(PeerMessage event) {
          PeerAddress oldFriend;
          PeerAddress sender = event.getMSPeerSource();
          PeerAddress newFriend = event.getNewFriend();

          // add the sender address to the list of friends
          if (!friends.contains(sender)) {
            if (friends.size() == viewSize) {
              oldFriend = friends.get(rand.nextInt(viewSize));
              friends.remove(oldFriend);
              fdUnregister(oldFriend);
              Snapshot.removeFriend(serverPeerAddress, oldFriend);
            }

            friends.addElement(sender);
            fdRegister(sender);
            Snapshot.addFriend(serverPeerAddress, sender);
          }

          // add the received new friend from the sender to the list of friends
          if (!friends.contains(newFriend) && !serverPeerAddress.equals(newFriend)) {
            if (friends.size() == viewSize) {
              oldFriend = friends.get(rand.nextInt(viewSize));
              friends.remove(oldFriend);
              fdUnregister(oldFriend);
              Snapshot.removeFriend(serverPeerAddress, oldFriend);
            }

            friends.addElement(newFriend);
            fdRegister(newFriend);
            Snapshot.addFriend(serverPeerAddress, newFriend);
          }
        }
예제 #7
1
  public Vector obterLinhas(String nome, String status) {
    Vector linhas = new Vector();
    try {
      if (status.equals("Ativo")) {
        usuariosAtivos = usuarioDao.obterUsuarios(nome, status);
        for (int i = 0; i < usuariosAtivos.size(); i++) {
          Usuario usuario = usuariosAtivos.get(i);
          linhas.addElement(this.criarLinhaUsuario(usuario));
        }
      } else {
        usuariosInativos = usuarioDao.obterUsuarios(nome, status);
        for (int i = 0; i < usuariosInativos.size(); i++) {
          Usuario usuario = usuariosInativos.get(i);
          linhas.addElement(this.criarLinhaUsuario(usuario));
        }
      }
    } catch (SQLException ex) {
      ex.printStackTrace();
      JOptionPane.showMessageDialog(
          null,
          "Erro ao acesso o banco de dados,\n" + "por favor contate o Suporte",
          "Erro",
          JOptionPane.ERROR_MESSAGE);
    }

    return linhas;
  }
  protected Object getControlObject() {
    Vector responsibilities = new Vector();

    Calendar cal1 = Calendar.getInstance();
    cal1.clear();
    cal1.set(Calendar.MONTH, Calendar.JANUARY);
    cal1.set(Calendar.DAY_OF_MONTH, 1);
    cal1.set(Calendar.YEAR, 2001);

    Calendar cal2 = Calendar.getInstance();
    cal2.clear();
    cal2.set(Calendar.MONTH, Calendar.DECEMBER);
    cal2.set(Calendar.DAY_OF_MONTH, 27);
    cal2.set(Calendar.YEAR, 2004);

    Calendar cal3 = Calendar.getInstance();
    cal3.clear();
    cal3.set(Calendar.MONTH, Calendar.MAY);
    cal3.set(Calendar.DAY_OF_MONTH, 6);
    cal3.set(Calendar.YEAR, 2002);

    responsibilities.addElement(cal1);
    responsibilities.addElement(cal2);
    responsibilities.addElement(cal3);

    Employee employee = new Employee();
    employee.setID(CONTROL_ID);
    employee.setResponsibilities(responsibilities);
    return employee;
  }
  private void rellenaBeneficios() {
    Beneficios beneficio1 =
        new Beneficios(
            1, "Tienes garantizados tus derechos humanos por parte " + "de las autoridades", 1);
    Beneficios beneficio2 = new Beneficios(2, "No existe la esclavitud", 1);
    Beneficios beneficio3 = new Beneficios(3, "No puedes ser discriminado", 1);
    Beneficios beneficio4 = new Beneficios(4, "Educacion de calidad garantizada por el estado", 2);
    Beneficios beneficio5 = new Beneficios(5, "Educacion gratuita", 2);
    Beneficios beneficio6 =
        new Beneficios(6, "Nadie puede impedir a alguien ejercer su profesion", 3);
    Beneficios beneficio7 = new Beneficios(7, "Tienen que pagar y retribuir de manera justa", 3);
    Beneficios beneficio8 =
        new Beneficios(
            8,
            "Tienen que repestar el paso peatonal los conductores " + "de caulquier vehiculo",
            4);

    beneficios.addElement(beneficio1);
    beneficios.addElement(beneficio2);
    beneficios.addElement(beneficio3);
    beneficios.addElement(beneficio4);
    beneficios.addElement(beneficio5);
    beneficios.addElement(beneficio6);
    beneficios.addElement(beneficio7);
    beneficios.addElement(beneficio8);
  }
예제 #10
0
 public void init(FigCanvas c) {
   this.urlName = "";
   this.urlRegionX = 20;
   this.urlRegionY = 12;
   this.paths = new Vector();
   SensorBoxWithLabel sb1 = new SensorBoxWithLabel("current", c);
   sb1.setAttribute("current");
   sb1.setCheckState(true);
   sb1.setFont(new Font("Dialog", Font.BOLD, 8));
   sb1.setColor(Color.red);
   SensorBoxWithLabel sb2 = new SensorBoxWithLabel("common", c);
   sb2.setAttribute(this.getCommonDirPath());
   sb2.setCheckState(false);
   sb2.setFont(new Font("Dialog", Font.BOLD, 8));
   sb2.setColor(Color.green);
   SensorBoxWithLabel sb3 = new SensorBoxWithLabel("user", c);
   sb3.setAttribute(this.getUserDirPath());
   sb3.setCheckState(false);
   sb3.setFont(new Font("Dialog", Font.BOLD, 8));
   sb3.setColor(Color.blue);
   SensorBoxWithLabel sb4 = new SensorBoxWithLabel("net", c);
   sb4.setAttribute("");
   sb4.setCheckState(false);
   sb4.setFont(new Font("Dialog", Font.BOLD, 8));
   sb4.setColor(Color.red);
   paths.addElement(sb1);
   paths.addElement(sb2);
   paths.addElement(sb3);
   paths.addElement(sb4);
   this.selectedBasePathBox = 0;
 }
  /** Creates a new instance of AccountPicker */
  public AccountSelect(Display display, boolean enableQuit) {
    super();
    // this.display=display;

    setTitleItem(new Title(SR.MS_ACCOUNTS));

    accountList = new Vector();
    Account a;

    int index = 0;
    activeAccount = Config.getInstance().accountIndex;
    do {
      a = Account.createFromStorage(index);
      if (a != null) {
        accountList.addElement(a);
        a.active = (activeAccount == index);
        index++;
      }
    } while (a != null);
    if (accountList.isEmpty()) {
      a = Account.createFromJad();
      if (a != null) {
        // a.updateJidCache();
        accountList.addElement(a);
        rmsUpdate();
      }
    }
    attachDisplay(display);
    addCommand(cmdAdd);

    if (enableQuit) addCommand(cmdQuit);

    commandState();
    setCommandListener(this);
  }
예제 #12
0
  /**
   * Read a list of space-separated "flag_extension" sequences and return the list as a array of
   * Strings. An empty list is returned as null. This is an IMAP-ism, and perhaps this method should
   * moved into the IMAP layer.
   */
  public String[] readSimpleList() {
    skipSpaces();

    if (buffer[index] != '(') // not what we expected
    return null;
    index++; // skip '('

    Vector v = new Vector();
    int start;
    for (start = index; buffer[index] != ')'; index++) {
      if (buffer[index] == ' ') { // got one item
        v.addElement(ASCIIUtility.toString(buffer, start, index));
        start = index + 1; // index gets incremented at the top
      }
    }
    if (index > start) // get the last item
    v.addElement(ASCIIUtility.toString(buffer, start, index));
    index++; // skip ')'

    int size = v.size();
    if (size > 0) {
      String[] s = new String[size];
      v.copyInto(s);
      return s;
    } else // empty list
    return null;
  }
예제 #13
0
  /**
   * Makes a button panel with combinations of OK, Save, Save As, Cancel, Apply, and Delete
   *
   * @param opt Bitwise combination of USE_OK, USE_CANCEL, USE_APPLY, USE_DELETE
   * @param actionListener Action listener for button clicks
   * @param spacing The spacing between labels.
   */
  public static ButtonPanel closeOutPanel(int opt, ActionListener actionListener, int spacing) {

    Vector<String> vl = new Vector<String>(7);

    if (checkBit(opt, USE_OK)) {
      vl.addElement(OK_LABEL);
    }

    if (checkBit(opt, USE_CANCEL)) {
      vl.addElement(CANCEL_LABEL);
    }

    if (checkBit(opt, USE_APPLY)) {
      vl.addElement(APPLY_LABEL);
    }

    if (checkBit(opt, USE_DELETE)) {
      vl.addElement(DELETE_LABEL);
    }

    int num = vl.size();

    if (num < 1) {
      return null;
    }

    String[] labels = new String[num];

    for (int i = 0; i < num; i++) {
      labels[i] = (vl.elementAt(i));
    }

    return new ButtonPanel(labels, actionListener, spacing);
  }
예제 #14
0
파일: J48.java 프로젝트: huangwen87/mdrill
 /**
  * Returns an enumeration of the additional measure names
  *
  * @return an enumeration of the measure names
  */
 public Enumeration enumerateMeasures() {
   Vector newVector = new Vector(3);
   newVector.addElement("measureTreeSize");
   newVector.addElement("measureNumLeaves");
   newVector.addElement("measureNumRules");
   return newVector.elements();
 }
예제 #15
0
  /**
   * Creates a new HTMLText and sets its default formatting properties.
   *
   * @param inCol Color of the bounding box background.
   * @param outCol Color of the bounding box border.
   * @param textCol Default text color.
   * @param fontSiz Default font size.
   * @param fontStl Default font style.
   * @param fontNam Default font name.
   * @param flags Default text alignment flags.
   * @param margin Default margins size.
   */
  public HTMLText(
      Color inCol,
      Color outCol,
      int textCol,
      int fontSiz,
      int fontStl,
      String fontNam,
      int blur,
      int rounded,
      int flags,
      Insets margin) {
    m_body = new FormatToken();
    m_body.m_flags = flags;
    m_body.m_margin = margin;

    m_inCol = inCol;
    m_outCol = outCol;
    m_color = textCol;
    m_bkCol = -1;
    m_style = fontStl;
    m_size = fontSiz;
    m_name = fontNam;
    m_blur = blur;
    m_rounded = rounded;
    m_wCur = 0;
    m_tokens = new Vector();
    m_heap = new Vector();
    m_heap.addElement("c=#" + Integer.toHexString(textCol));
    m_heap.addElement("s=" + fontSiz);
    m_heap.addElement("f=" + fontNam);

    if ((fontStl & Font.BOLD) != 0) m_heap.addElement("b");
    if ((fontStl & Font.ITALIC) != 0) m_heap.addElement("i");
  }
예제 #16
0
  /**
   * Add a Condition to the form's Collection.
   *
   * @param condition the condition to be set
   */
  public Triggerable addTriggerable(Triggerable t) {
    int existingIx = triggerables.indexOf(t);
    if (existingIx >= 0) {
      // one node may control access to many nodes; this means many nodes effectively have the same
      // condition
      // let's identify when conditions are the same, and store and calculate it only once

      // note, if the contextRef is unnecessarily deep, the condition will be evaluated more times
      // than needed
      // perhaps detect when 'identical' condition has a shorter contextRef, and use that one
      // instead?
      return (Triggerable) triggerables.elementAt(existingIx);
    } else {
      triggerables.addElement(t);
      triggerablesInOrder = false;

      Vector triggers = t.getTriggers();
      for (int i = 0; i < triggers.size(); i++) {
        TreeReference trigger = (TreeReference) triggers.elementAt(i);
        if (!triggerIndex.containsKey(trigger)) {
          triggerIndex.put(trigger, new Vector());
        }
        Vector triggered = (Vector) triggerIndex.get(trigger);
        if (!triggered.contains(t)) {
          triggered.addElement(t);
        }
      }

      return t;
    }
  }
 protected Vector buildToNClobVec() {
   Vector vec = new Vector();
   vec.addElement(String.class);
   vec.addElement(Character[].class);
   vec.addElement(char[].class);
   return vec;
 }
  /**
   * List of games containing this member.
   *
   * @param c Connection
   * @param firstGameName Game name that should be first element of list (if <tt>newConn</tt> is a
   *     member of it), or null.
   * @return The games, in no particular order (past firstGameName), or a 0-length Vector, if member
   *     isn't in any game.
   * @see #replaceMemberAllGames(StringConnection, StringConnection)
   * @since 1.1.08
   */
  public Vector memberGames(StringConnection c, final String firstGameName) {
    Vector cGames = new Vector();

    synchronized (gameData) {
      SOCGame firstGame = null;
      if (firstGameName != null) {
        firstGame = getGameData(firstGameName);
        if (firstGame != null) {
          Vector members = getMembers(firstGameName);
          if ((members != null) && members.contains(c)) cGames.addElement(firstGame);
        }
      }

      Enumeration gdEnum = getGamesData();
      while (gdEnum.hasMoreElements()) {
        SOCGame ga = (SOCGame) gdEnum.nextElement();
        if (ga == firstGame) continue;
        Vector members = getMembers(ga.getName());
        if ((members == null) || !members.contains(c)) continue;

        cGames.addElement(ga);
      }
    }

    return cGames;
  }
예제 #19
0
 protected void load(Element root) throws Exception {
   NodeList list;
   int i;
   list = WSHelper.getElementChildren(root, "Messages");
   if (list != null) {
     for (i = 0; i < list.getLength(); i++) {
       Element nc = (Element) list.item(i);
       _Messages.addElement(JanusMessageInfo.loadFrom(nc));
     }
   }
   list = WSHelper.getElementChildren(root, "Rating");
   if (list != null) {
     for (i = 0; i < list.getLength(); i++) {
       Element nc = (Element) list.item(i);
       _Rating.addElement(JanusRatingInfo.loadFrom(nc));
     }
   }
   list = WSHelper.getElementChildren(root, "Moderate");
   if (list != null) {
     for (i = 0; i < list.getLength(); i++) {
       Element nc = (Element) list.item(i);
       _Moderate.addElement(JanusModerateInfo.loadFrom(nc));
     }
   }
 }
예제 #20
0
    public ErrorEntry(String path, String messageProp, Object[] args) {
      this.path = path;

      String message = jEdit.getProperty(messageProp, args);
      if (message == null) message = "Undefined property: " + messageProp;

      Log.log(Log.ERROR, this, path + ":");
      Log.log(Log.ERROR, this, message);

      Vector tokenizedMessage = new Vector();
      int lastIndex = -1;
      for (int i = 0; i < message.length(); i++) {
        if (message.charAt(i) == '\n') {
          tokenizedMessage.addElement(message.substring(lastIndex + 1, i));
          lastIndex = i;
        }
      }

      if (lastIndex != message.length()) {
        tokenizedMessage.addElement(message.substring(lastIndex + 1));
      }

      messages = new String[tokenizedMessage.size()];
      tokenizedMessage.copyInto(messages);
    }
  /**
   * Returns an enumeration describing the available options.
   *
   * @return an enumeration of all the available options.
   */
  public Enumeration listOptions() {
    Vector result;
    Enumeration en;

    result = new Vector();

    // ancestor
    en = super.listOptions();
    while (en.hasMoreElements()) result.addElement(en.nextElement());

    result.addElement(
        new Option(
            "\tUses a sorted list (ordered according to distance) instead of the\n"
                + "\tKDTree for finding the neighbors.\n"
                + "\t(default is KDTree)",
            "naive",
            0,
            "-naive"));

    // IBk
    en = m_Classifier.listOptions();
    while (en.hasMoreElements()) {
      Option o = (Option) en.nextElement();
      // remove -X, -W and -E
      if (!o.name().equals("X") && !o.name().equals("W") && !o.name().equals("E"))
        result.addElement(o);
    }

    return result.elements();
  }
예제 #22
0
  /**
   * Returns an enumeration describing the available options.
   *
   * @return an enumeration of all the available options.
   */
  public Enumeration listOptions() {
    Vector newVector = new Vector(4);

    newVector.addElement(
        new Option(
            "\tSpecify a starting set of attributes." + "\n\tEg. 1,3,5-7.",
            "P",
            1,
            "-P <start set>"));
    newVector.addElement(
        new Option(
            "\tDirection of search. (default = 1).",
            "D",
            1,
            "-D <0 = backward | 1 = forward " + "| 2 = bi-directional>"));
    newVector.addElement(
        new Option(
            "\tNumber of non-improving nodes to" + "\n\tconsider before terminating search.",
            "N",
            1,
            "-N <num>"));
    newVector.addElement(
        new Option(
            "\tSize of lookup cache for evaluated subsets."
                + "\n\tExpressed as a multiple of the number of"
                + "\n\tattributes in the data set. (default = 1)",
            "S",
            1,
            "-S <num>"));

    return newVector.elements();
  }
예제 #23
0
  /**
   * Adds the given FieldInfo to this ClassInfo
   *
   * @param fieldInfo the FieldInfo to add
   */
  public void addFieldInfo(final FieldInfo fieldInfo) {
    if (fieldInfo == null) {
      return;
    }

    fieldInfo.setDeclaringClassInfo(this);

    switch (fieldInfo.getNodeType()) {
      case XMLInfo.ATTRIBUTE_TYPE:
        if (_atts == null) {
          _atts = new Vector(3);
        }
        if (!_atts.contains(fieldInfo)) {
          _atts.addElement(fieldInfo);
        }
        break;
      case XMLInfo.TEXT_TYPE:
        _textField = fieldInfo;
        break;
      default:
        if (_elements == null) {
          _elements = new Vector(5);
        }
        if (!_elements.contains(fieldInfo)) {
          _elements.addElement(fieldInfo);
        }
        break;
    }
  } // -- addFieldInfo
예제 #24
0
  /*
   * In text: a string seperate by comma (,) Out a collection of elements
   * without (between) comma
   */
  static Collection parseIPaddresses(String text) {
    Vector prefixes = new Vector();
    if (text == null || "".equals(text)) {
      return prefixes;
    }

    String tempStr = text.toUpperCase();
    String currentLabel = null;

    int index = tempStr.indexOf(",");
    while (index != -1) {
      currentLabel = tempStr.substring(0, index).trim();
      if (!"".equals(currentLabel)) {
        prefixes.addElement(currentLabel);
      }
      tempStr = tempStr.substring(index + 1);
      index = tempStr.indexOf(",");
    }
    // Last label
    currentLabel = tempStr.trim();
    if (!"".equals(currentLabel)) {
      prefixes.addElement(currentLabel);
    }
    return prefixes;
  }
예제 #25
0
  public static String[] parseString(String text, String seperator) {
    Vector vResult = new Vector();
    if (text == null || "".equals(text)) {
      return null;
    }
    String tempStr = text.trim();
    String currentLabel = null;
    int index = tempStr.indexOf(seperator);
    while (index != -1) {
      currentLabel = tempStr.substring(0, index).trim();

      if (!"".equals(currentLabel)) {
        vResult.addElement(currentLabel);
      }
      tempStr = tempStr.substring(index + 1);
      index = tempStr.indexOf(seperator);
    } // Last label
    currentLabel = tempStr.trim();
    if (!"".equals(currentLabel)) {
      vResult.addElement(currentLabel);
    }
    String[] re = new String[vResult.size()];
    Iterator it = vResult.iterator();
    index = 0;
    while (it.hasNext()) {
      re[index] = (String) it.next();
      index++;
    }
    return re;
  }
예제 #26
0
  /** Add nodes from under "dir" into curTop. Highly recursive. */
  DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) {

    String curPath = dir.getPath();
    DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath);
    if (curTop != null) { // should only be null at root
      curTop.add(curDir);
    }
    Vector<String> ol = new Vector<String>();
    String[] tmp = dir.list();

    for (String aTmp : tmp) ol.addElement(aTmp);

    Collections.sort(ol, String.CASE_INSENSITIVE_ORDER);
    File f;
    Vector<String> files = new Vector<String>();
    // Make two passes, one for Dirs and one for Files. This is #1.
    for (int i = 0; i < ol.size(); i++) {
      String thisObject = ol.elementAt(i);
      String newPath;
      if (curPath.equals(".")) newPath = thisObject;
      else newPath = curPath + File.separator + thisObject;
      if ((f = new File(newPath)).isDirectory()) addNodes(curDir, f);
      else files.addElement(thisObject);
    }
    // Pass two: for files.
    for (int fnum = 0; fnum < files.size(); fnum++)
      curDir.add(new DefaultMutableTreeNode(files.elementAt(fnum)));
    return curDir;
  }
    public void startElement(String uri, String localName, String qName, Attributes atts) {

      logger.log(
          LogService.LOG_DEBUG,
          "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$
              + qName);
      if (!_isParsedDataValid) return;

      String name = getName(localName, qName);
      if (name.equalsIgnoreCase(OPTION)) {
        OptionHandler optionHandler = new OptionHandler(this);
        optionHandler.init(name, atts);
        if (optionHandler._isParsedDataValid) {
          // Only add valid Option
          _optionLabel_vector.addElement(optionHandler._label_val);
          _optionValue_vector.addElement(optionHandler._value_val);
        }
      } else {
        logger.log(
            LogService.LOG_WARNING,
            NLS.bind(
                MetaTypeMsg.UNEXPECTED_ELEMENT,
                new Object[] {
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
      }
    }
예제 #28
0
  public FormIndex buildIndex(Vector indexes, Vector multiplicities, Vector elements) {
    FormIndex cur = null;
    Vector curMultiplicities = new Vector();
    for (int j = 0; j < multiplicities.size(); ++j) {
      curMultiplicities.addElement(multiplicities.elementAt(j));
    }

    Vector curElements = new Vector();
    for (int j = 0; j < elements.size(); ++j) {
      curElements.addElement(elements.elementAt(j));
    }

    for (int i = indexes.size() - 1; i >= 0; i--) {
      int ix = ((Integer) indexes.elementAt(i)).intValue();
      int mult = ((Integer) multiplicities.elementAt(i)).intValue();

      // TODO: ... No words. Just fix it.

      TreeReference ref =
          (TreeReference)
              ((XPathReference) ((IFormElement) elements.elementAt(i)).getBind()).getReference();
      if (!(elements.elementAt(i) instanceof GroupDef
          && ((GroupDef) elements.elementAt(i)).getRepeat())) {
        mult = -1;
      }

      cur = new FormIndex(cur, ix, mult, getChildInstanceRef(curElements, curMultiplicities));
      curMultiplicities.removeElementAt(curMultiplicities.size() - 1);
      curElements.removeElementAt(curElements.size() - 1);
    }
    return cur;
  }
예제 #29
0
  // Read from file
  public void readFile(String fileName) {
    // TODO Auto-generated method stub

    try {
      FileReader frStream = new FileReader(fileName);
      BufferedReader brStream = new BufferedReader(frStream);
      String inputLine;
      int i = 0;
      Vector<Object> currentRow = new Vector<Object>();
      while ((inputLine = brStream.readLine()) != null) {
        // Ignore the file comment
        if (inputLine.startsWith("#")) continue;

        // Extract the column name
        if (inputLine.startsWith("$")) {
          StringTokenizer st1 = new StringTokenizer(inputLine.substring(1), " ");

          while (st1.hasMoreTokens()) colName.addElement(st1.nextToken());
        } else
        // Extract data and put into the row records
        {
          StringTokenizer st1 = new StringTokenizer(inputLine, " ");
          currentRow = new Vector<Object>();
          while (st1.hasMoreTokens()) currentRow.addElement(st1.nextToken());
          data.addElement(currentRow);
        }
      }

      brStream.close();
    } catch (IOException ex) {
      System.out.println("Error in readFile method! " + ex);
    }
  }
예제 #30
0
  /**
   * Set an attribute. This replaces an attribute of the same name. To set the zeroth attribute (the
   * tag name), use setTagName().
   *
   * @param attribute The attribute to set.
   */
  public void setAttribute(Attribute attribute) {
    boolean replaced;
    Vector attributes;
    int length;
    String name;
    Attribute test;
    String test_name;

    replaced = false;
    attributes = getAttributesEx();
    length = attributes.size();
    if (0 < length) {
      name = attribute.getName();
      for (int i = 1; i < attributes.size(); i++) {
        test = (Attribute) attributes.elementAt(i);
        test_name = test.getName();
        if (null != test_name)
          if (test_name.equalsIgnoreCase(name)) {
            attributes.setElementAt(attribute, i);
            replaced = true;
          }
      }
    }
    if (!replaced) {
      // add whitespace between attributes
      if ((0 != length) && !((Attribute) attributes.elementAt(length - 1)).isWhitespace())
        attributes.addElement(new Attribute(" "));
      attributes.addElement(attribute);
    }
  }