Example #1
0
  public Vector _clone_sort(Vector dati, Vector dati_cr) {
    Vector result = new Vector();
    Vector index = new Vector();
    for (int i = 0; i < dati_cr.size(); i++) index.add(new Integer(i));
    try {

      Object a[] = dati_cr.toArray();
      Object a_index[] = index.toArray();
      Object src_index[] = (Object[]) a_index.clone();
      Object src[] = (Object[]) a.clone();
      _clone_mergeSort(src, a, 0, a.length, src_index, a_index);
      ListIterator li = dati_cr.listIterator();
      ListIterator l_index = index.listIterator();
      for (int j = 0; j < a.length; j++) {
        li.next();
        li.set(a[j]);
        l_index.next();
        l_index.set(a_index[j]);
      }
    } catch (Exception e) {
      e.toString();
    }

    for (int i = 0; i < index.size(); i++)
      result.add(dati.elementAt(((Integer) index.elementAt(i)).intValue()));
    return result;
  }
 public static LogotypeReference getInstance(ASN1Sequence seq) {
   ASN1Sequence refStructHashSeq = null;
   ASN1Sequence refStructURISeq = null;
   if (seq.size() != 2) {
     throw new IllegalArgumentException("size of sequence must be 2 not " + seq.size());
   }
   refStructHashSeq = ASN1Sequence.getInstance(seq.getObjectAt(0));
   refStructURISeq = ASN1Sequence.getInstance(seq.getObjectAt(1));
   DigestInfo[] refStructHash = null;
   DERIA5String[] refStructURI = null;
   {
     Vector<DigestInfo> v = new Vector<DigestInfo>();
     for (int i = 0; i < refStructHashSeq.size(); i++) {
       DigestInfo di = DigestInfo.getInstance(refStructHashSeq.getObjectAt(i));
       v.add(di);
     }
     refStructHash = v.toArray(new DigestInfo[refStructHashSeq.size()]);
   }
   {
     Vector<DERIA5String> v = new Vector<DERIA5String>();
     for (int i = 0; i < refStructURISeq.size(); i++) {
       DERIA5String di = DERIA5String.getInstance(refStructURISeq.getObjectAt(i));
       v.add(di);
     }
     refStructHash = v.toArray(new DigestInfo[refStructURISeq.size()]);
   }
   return new LogotypeReference(refStructHash, refStructURI);
 }
Example #3
0
 public static String[] Split(String as_Value, String as_SubStr) throws Exception {
   String[] ls_Out = (String[]) null;
   StringTokenizer lo_ST = null;
   Vector lo_Out = new Vector();
   boolean lb_Return = false;
   int li_Count = 0;
   int li_Start = 0;
   int i = 0;
   try {
     if ((as_Value != null)
         && (!as_Value.equals(""))
         && (as_SubStr != null)
         && (!as_SubStr.equals(""))) lb_Return = true;
     while (lb_Return) {
       li_Count = as_Value.indexOf(as_SubStr, li_Start);
       if (li_Count == -1) {
         li_Count = as_Value.length();
         lb_Return = false;
       }
       lo_Out.add(as_Value.substring(li_Start, li_Count));
       li_Start = li_Count + as_SubStr.length();
     }
   } catch (Exception e) {
     e.printStackTrace();
     throw new Exception("CommonUtil:Split Error!\n" + e.getMessage());
   }
   if (lo_Out.toArray().length > 0) {
     Object[] lo_Temp = lo_Out.toArray();
     ls_Out = new String[lo_Temp.length];
     for (i = 0; i < lo_Temp.length; i++) {
       ls_Out[i] = ((String) lo_Temp[i]);
     }
   }
   return ls_Out;
 }
Example #4
0
  @Override
  public void valueChanged(TreeSelectionEvent e) {
    if (e.getSource() == colors && !locked) {
      TreeSelectionModel tsm = colors.getSelectionModel();
      TreePath tp[] = tsm.getSelectionPaths();
      if (tp == null) return;
      Vector<ClassedItem> tmp = new Vector<ClassedItem>();
      for (TreePath element : tp) {
        try {
          Object[] path = element.getPath();
          ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString());
          tmp.add(ci);
        } catch (Exception exp) {
          // User did not select a leafnode
        }
      }

      if (sceneElement instanceof NenyaImageSceneElement) {
        ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaTileSceneElement) {
        ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0]));
      }
      if (sceneElement instanceof NenyaComponentSceneElement) {
        ((NenyaComponentSceneElement) sceneElement)
            .getComponents()[itemList.getSelectedIndex()].setColorList(
                tmp.toArray(new ClassedItem[0]));
      }

      submitElement(sceneElement, null);
    } else {
      super.valueChanged(e);
    }
  }
 private void tableRowDropDown(
     String s, String s1, java.util.Vector vector, java.util.Vector vector1, int i) {
   String as[] = new String[vector.size()];
   String as1[] = new String[vector1.size()];
   vector.toArray(as);
   vector1.toArray(as1);
   tableRowDropDown(s, s1, as, as1, i);
 }
  /**
   * This function returns a map whose entries hold the coordinates of the sequence as keys and the
   * coordinates of the target sequences as values.</br> If a coordinate in sequence corresponds to
   * a gap in another sequence, then -1 is assigned to that position.</br> For example suppose we
   * have the sequences:</br> seq1: AAT-GCT-TCG</br> seq2: G--C-CTCT-C</br> seq3: A-T--GT-AG-</br>
   * Then, if we wish to find the mapping of seq1's coordinates to seq2's coordinates, this will
   * give us: 0 -> 0, 1 -> -1, 2 -> -1, 3 -> -1, 4 -> 2, 5 -> 3, 6 -> 5, 7 -> -1, 8 -> 6.</br> Also,
   * if we wish to find the mapping of seq1's coordinates to seq2's and seq3's coordinates, this
   * will give us: 0 -> {0, 0}, 1 -> {-1, -1}, 2 -> {-1, 1}, 3 -> {-1, -1}, 4 -> {2, 2}, 5 -> {3,
   * 3}, 6 -> {5, 4}, 7 -> {-1, 5}, 8 -> {6, -1}.
   *
   * @param <T> This could be either the serial number of the sequence (valid range: [0,
   *     sequences.length-1]) or the sequence names
   * @param <E>
   * @param seqID The sequence ID (either serial number or name) which we wish to map</br> Note that
   *     the valid range of serial numbers is [0, sequences.length-1]
   * @param targetSeqIDs The (target) sequences IDs (either serial numbers or names)
   * @return A map whose keys are the sequence coordinates and values the corresponding coordinates
   *     of the target sequences
   * @throws IllegalArgumentException
   * @see GappedAlignmentString
   */
  public <T extends Object> Map mapSeqCoords2SeqsCoords(
      T generic_seqID, Vector<T> generic_targetSeqIDs)
      throws IllegalArgumentException, IndexOutOfBoundsException {
    GappedAlignmentString gas_seq;
    GappedAlignmentString[] gas_targetSeqs;

    String[] speciesNames = species();

    // Check if generic_seqID is mistakenly included in the generic_targetSeqIDs set
    if (generic_targetSeqIDs.contains(generic_seqID)) generic_targetSeqIDs.remove(generic_seqID);

    if (generic_targetSeqIDs.size() + 1 > speciesNames.length)
      throw new IndexOutOfBoundsException("You entered more sequences than are in the file.");

    Map map = new HashMap();
    // Check whether sequence IDs are inputed as serial numbers or as names
    String seqsClassName = generic_seqID.getClass().getSimpleName();

    // if( generic_seqID.getClass() instanceof java.lang.Integer )
    // System.out.println("XAXA");

    if (seqsClassName.equals("Integer")) {
      Integer seqID = (Integer) generic_seqID;
      Integer[] seqIDs = generic_targetSeqIDs.toArray(new Integer[generic_targetSeqIDs.size()]);

      if ((StatUtil.findMax(seqIDs).getFirst() > speciesNames.length - 1)
          || (StatUtil.findMin(seqIDs).getFirst() < 0))
        throw new IndexOutOfBoundsException(
            "The sequence IDs (aka, serial numbers have to lie inside"
                + " the range 0 to speciesNames.length -1");

      gas_seq = getGappedAlignment(speciesNames[seqID]);
      gas_targetSeqs = new GappedAlignmentString[seqIDs.length];
      for (int i = 0; i < seqIDs.length; i++)
        gas_targetSeqs[i] = getGappedAlignment(speciesNames[seqIDs[i]]);
    } else if (seqsClassName.equals("String")) {
      String seqID = (String) generic_seqID;
      String[] seqIDs = generic_targetSeqIDs.toArray(new String[generic_targetSeqIDs.size()]);

      gas_seq = getGappedAlignment(seqID);
      gas_targetSeqs = new GappedAlignmentString[seqIDs.length];
      for (int i = 0; i < seqIDs.length; i++) gas_targetSeqs[i] = getGappedAlignment(seqIDs[i]);
    } else {
      throw new IllegalArgumentException("Sequence IDs should be either of type Integer or String");
    }

    // Pairwise Alignment
    if (gas_targetSeqs.length == 1) {
      map = doMapSeq2Seq(gas_seq, gas_targetSeqs);
    }
    // Multiple Alignment
    else {
      map = doMapSeq2Seqs(gas_seq, gas_targetSeqs);
    }

    return map;
  } // end of mapSeqCoords2SeqsCoords method
Example #7
0
  private Vector vector_ElementSet(InformationObject[] io, AppService proc) {
    // output Vector
    Vector output = new Vector();

    // temporary
    short[] tmp1 = null;
    Vector tmp2 = new Vector();

    // controls
    boolean newlist = true;

    // calculation of overhead
    int overhead = this.szCaa + this.szCot + 2;

    // reduced dataset for packaging
    int max_data_length = this.max_asdu_length - overhead;

    // modification and packaging
    for (int ii = 0; ii < io.length; ii++) {
      if (newlist) {
        newlist = false;
        // neue liste aufbauen -> erhalten der asduinfos

        if (io[ii] != null) {
          tmp1 = scalar_ElementSet(io[ii], proc);
          for (int jj = 0; jj < tmp1.length; jj++) {
            tmp2.add(tmp1[jj]);
          }
        }
      } else {

        // prüfung, ob das neue element die asdulänge überschreiten würde
        if (io[ii] != null) {
          tmp1 = scalar_ElementSet(io[ii], proc);
          if ((tmp2.size() + tmp1.length - overhead) > max_data_length) {
            output.add(this.Obj2shortArray(tmp2.toArray()));
            tmp2.clear();
            ii--;
            newlist = true;
          } else {
            // deleting overhead (zero index based means after overhead)
            for (int jj = overhead; jj < tmp1.length; jj++) {
              tmp2.add(tmp1[jj]);
            }
            // define object length
            short tmp3 = (Short) tmp2.get(1);
            tmp2.set(1, (short) (tmp3 + 1));
          }
        }
      }
    }
    // fertig mit bearbeitung und add in den ausgabevektor
    output.add(this.Obj2shortArray(tmp2.toArray()));
    return output;
  }
 @Override
 public final void importData(final ImportSelector infilt) {
   final File srcFile = new File(source);
   if ((true == srcFile.exists()) && (true == srcFile.canRead())) {
     FileReader fr = null;
     try {
       fr = new FileReader(srcFile);
       int r;
       char c;
       StringBuffer sb = new StringBuffer();
       do {
         r = fr.read();
         if (r != -1) {
           c = (char) r;
           if ('\n' != c) {
             sb.append(c);
           } else {
             final String line = sb.toString();
             sb = new StringBuffer(); // Delete all characters
             if (false == partImport(line, infilt)) {
               setTheData(resultCollect.toArray(new DataSet[0]));
               return;
             }
           }
         } else {
           // last line
           if (0 < sb.length()) {
             final String line = sb.toString();
             if (false == partImport(line, infilt)) {
               setTheData(resultCollect.toArray(new DataSet[0]));
               return;
             }
           }
         }
       } while (r != -1);
       setTheData(resultCollect.toArray(new DataSet[0]));
     } catch (final FileNotFoundException e) {
       e.printStackTrace();
     } catch (final IOException e) {
       e.printStackTrace();
     } finally {
       if (null != fr) {
         try {
           fr.close();
         } catch (final IOException e) {
           e.printStackTrace();
         }
       }
     }
   }
 }
Example #9
0
  /**
   * Constructs an instance of TRECQuery that reads and stores all the queries from files with the
   * specified filename.
   *
   * @param queryfilenames String[] the name of the files containing all the queries.
   */
  public TRECQuery(String[] queryfilenames) {
    Vector<String> vecStringQueries = new Vector<String>();
    Vector<String> vecStringQueryIDs = new Vector<String>();
    if (this.extractQuery(queryfilenames, vecStringQueries, vecStringQueryIDs))
      this.topicFiles = queryfilenames;
    if (topicFiles == null)
      logger.error(
          "Topic files were specified, but non could be parsed correctly to obtain any topics."
              + " Check you have the correct topic files specified, and that TrecQueryTags properties are correct.");

    this.queries = vecStringQueries.toArray(new String[0]);
    this.query_ids = vecStringQueryIDs.toArray(new String[0]);
    this.index = 0;
  }
  /**
   * Gets the current settings of FuzzyRoughSubsetEval
   *
   * @return an array of strings suitable for passing to setOptions()
   */
  public String[] getOptions() {
    Vector<String> result;

    result = new Vector<String>();

    result.add("-Z");
    result.add(
        (m_FuzzyMeasure.getClass().getName() + " " + Utils.joinOptions(m_FuzzyMeasure.getOptions()))
            .trim());

    result.add("-I");
    result.add(
        (m_Implicator.getClass().getName() + " " + Utils.joinOptions(m_Implicator.getOptions()))
            .trim());

    result.add("-T");
    result.add(
        (m_TNorm.getClass().getName() + " " + Utils.joinOptions(m_TNorm.getOptions())).trim());

    result.add("-R");
    result.add(
        (m_Similarity.getClass().getName() + " " + Utils.joinOptions(m_Similarity.getOptions()))
            .trim());

    return result.toArray(new String[result.size()]);
  }
Example #11
0
 /**
  * Aborts the connection in response to an error.
  *
  * @param e The error that caused the connection to be aborted. Never null.
  */
 @java.lang.SuppressWarnings("ToArrayCallWithZeroLengthArrayArgument")
 @SuppressWarnings(
     "ITA_INEFFICIENT_TO_ARRAY") // intentionally; race condition on listeners otherwise
 protected void terminate(IOException e) {
   try {
     synchronized (this) {
       if (e == null) throw new IllegalArgumentException();
       outClosed = inClosed = e;
       try {
         transport.closeRead();
       } catch (IOException x) {
         logger.log(Level.WARNING, "Failed to close down the reader side of the transport", x);
       }
       try {
         synchronized (pendingCalls) {
           for (Request<?, ?> req : pendingCalls.values()) req.abort(e);
           pendingCalls.clear();
         }
         synchronized (executingCalls) {
           for (Request<?, ?> r : executingCalls.values()) {
             java.util.concurrent.Future<?> f = r.future;
             if (f != null) f.cancel(true);
           }
           executingCalls.clear();
         }
       } finally {
         notifyAll();
       }
     } // JENKINS-14909: leave synch block
   } finally {
     if (e instanceof OrderlyShutdown) e = null;
     for (Listener l : listeners.toArray(new Listener[0])) l.onClosed(this, e);
   }
 }
Example #12
0
  public void assignTracks(final String primaryTrack, final Vector<String> secondaryTracks) {
    // ok - find the matching tracks/
    final Object theP = _theLayers.findLayer(primaryTrack);
    if (theP != null) {
      if (theP instanceof WatchableList) {
        _thePrimary = (WatchableList) theP;
      }
    }

    // do we have secondaries?
    if (secondaryTracks != null) {
      // and now the secs
      final Vector<Layer> secs = new Vector<Layer>(0, 1);
      final Iterator<String> iter = secondaryTracks.iterator();
      while (iter.hasNext()) {
        final String thisS = iter.next();
        final Layer theS = _theLayers.findLayer(thisS);
        if (theS != null)
          if (theS instanceof WatchableList) {
            secs.add(theS);
          }
      }

      if (secs.size() > 0) {
        _theSecondaries = new WatchableList[] {};
        _theSecondaries = secs.toArray(_theSecondaries);
      }
    }
  }
  public java.lang.Object[] getListofActivities1() {

    java.lang.Object[] listofActivities1 = null;

    java.util.Vector listActVector1 = new java.util.Vector(1, 1);

    try {

      //    java.sql.Connection connDB =
      // java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/sako","postgres","pilsiner");

      java.sql.Statement stmt1 = connectDB.createStatement();

      java.sql.ResultSet rSet1 =
          stmt1.executeQuery(
              "SELECT distinct patient_no from hp_patient_card where date BETWEEN '"
                  + beginDate
                  + "' AND '"
                  + endDate
                  + "' and invoice_no NOT iLike 'O%' OR invoice_no NOT iLike 'I%'");

      while (rSet1.next()) {

        listActVector1.addElement(rSet1.getObject(1).toString());
      }

    } catch (java.sql.SQLException sqlExec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), sqlExec.getMessage());
    }

    listofActivities1 = listActVector1.toArray();
    System.out.println("Done list of activities ...");
    return listofActivities1;
  }
  @Override
  protected Void doInBackground(Long... params) {
    long movieId = params[0];

    WebService webService = new WebService();
    List<Trailer> trailers = webService.getMovieTrailers(movieId);

    Vector<ContentValues> cVVector = new Vector<ContentValues>(trailers.size());
    for (int i = 0; i < trailers.size(); i++) {
      Trailer trailer = trailers.get(i);
      ContentValues values = trailer.asContentValues();
      values.put(MovieContract.TrailerEntry.COLUMN_MOVIE_ID, movieId);
      cVVector.add(values);
    }

    // add to database
    int inserted = 0;
    if (cVVector.size() > 0) {
      ContentValues[] contentValues = new ContentValues[cVVector.size()];
      cVVector.toArray(contentValues);
      inserted =
          mContext
              .getContentResolver()
              .bulkInsert(MovieContract.TrailerEntry.CONTENT_URI, contentValues);
    }
    Log.d(TAG, "FetchTrailersTask Complete. " + inserted + " Inserted");

    return null;
  }
  /**
   * Gets the current settings of the Classifier.
   *
   * @return an array of strings suitable for passing to setOptions
   */
  @Override
  public String[] getOptions() {
    Vector<String> result;
    String[] clustererOptions;

    result = new Vector<String>();

    clustererOptions = new String[0];
    if ((m_clusterer != null) && (m_clusterer instanceof OptionHandler)) {
      clustererOptions = ((OptionHandler) m_clusterer).getOptions();
    }

    if (getClusterer() != null) {
      result.add("-W");
      result.add(getClusterer().getClass().getName());
    }

    if (getNoSizeDetermination()) {
      result.add("-no-size");
    }

    result.add("--");
    result.addAll(Arrays.asList(clustererOptions));

    return result.toArray(new String[result.size()]);
  }
Example #16
0
File: AR.java Project: zhaog/cdt
  public String[] extractFiles(String outdir, String[] names) throws IOException {
    Vector<String> names_used = new Vector<String>();
    String object_name;
    int count;

    loadHeaders();

    count = 0;
    for (MemberHeader memberHeader : memberHeaders) {
      object_name = memberHeader.getObjectName();
      if (names != null && !stringInStrings(object_name, names)) continue;

      object_name = "" + count + "_" + object_name; // $NON-NLS-1$ //$NON-NLS-2$
      count++;

      byte[] data = memberHeader.getObjectData();
      File output = new File(outdir, object_name);
      names_used.add(object_name);

      RandomAccessFile rfile = new RandomAccessFile(output, "rw"); // $NON-NLS-1$
      rfile.write(data);
      rfile.close();
    }

    return names_used.toArray(new String[0]);
  }
Example #17
0
  public String[] getStringLines(String text, int w, int[] out_para) {
    try {
      AttributedString atext = new AttributedString(text);
      atext.addAttribute(TextAttribute.FONT, m_graphics2d.getFont(), 0, text.length());
      atext.addAttribute(TextAttribute.SIZE, m_graphics2d.getFont(), 0, text.length());

      Vector<String> lines = new Vector<String>();
      LineBreakMeasurer textMeasurer =
          new LineBreakMeasurer(atext.getIterator(), m_graphics2d.getFontRenderContext());

      while (textMeasurer.getPosition() >= 0 && textMeasurer.getPosition() < text.length()) {
        int curr_pos = textMeasurer.getPosition();
        int next_pos = curr_pos;
        int limit = text.indexOf('\n', curr_pos);
        if (limit >= curr_pos) {
          next_pos = textMeasurer.nextOffset(w, limit + 1, false);
        } else {
          next_pos = textMeasurer.nextOffset(w);
        }
        lines.addElement(text.substring(curr_pos, next_pos));
        textMeasurer.setPosition(next_pos);
      }

      return lines.toArray(new String[lines.size()]);
    } catch (Throwable err) {
      err.printStackTrace();
      return new String[] {"(Error !)"};
    }
  }
Example #18
0
  public java.lang.Object[] getDates() {

    java.lang.Object[] listofDates = null;

    java.util.Vector listofDatesVector = new java.util.Vector(1, 1);

    try {

      //    java.sql.Connection connDB =
      // java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/sako","postgres","pilsiner");

      java.sql.Statement stmt1 = connectDB.createStatement();

      java.sql.ResultSet rSet1 =
          stmt1.executeQuery(
              "SELECT DISTINCT category FROM st_stock_prices where department ilike '"
                  + CashPoint
                  + "' ORDER BY category");

      while (rSet1.next()) {

        listofDatesVector.addElement(rSet1.getObject(1).toString());
      }

    } catch (java.sql.SQLException sqlExec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), sqlExec.getMessage());
    }

    listofDates = listofDatesVector.toArray();
    System.out.println("Done list of Staff Nos ...");
    return listofDates;
  }
  /**
   * Creates a new PathTokenizer using the given path and separator character(s).
   *
   * @param path the path to break into tokens
   * @param separators the character(s) that separate tokens
   * @param reverseOrder if true, the path will be tokenized in reverse order, from right to left
   */
  public PathTokenizer(String path, String separators, boolean reverseOrder) {
    this.separators = separators;
    this.reverseOrder = reverseOrder;

    // Split the path into tokens
    StringTokenizer st = new StringTokenizer(path, separators, true);
    Vector<String> tokensV = new Vector<>();
    while (st.hasMoreTokens()) {
      tokensV.add(st.nextToken());
    }

    // Convert Vector into array
    tokens = new String[tokensV.size()];
    int nbTokens = tokens.length;

    if (reverseOrder) {
      for (int i = 0; i < nbTokens; i++) tokens[i] = tokensV.elementAt(nbTokens - i - 1);
    } else {
      tokensV.toArray(tokens);
    }

    // Initialize current path
    if (reverseOrder) currentPath = new StringBuffer(path);
    else currentPath = new StringBuffer(path.length());

    // Skip leading separator
    skipSeparators();
  }
 public void setProgress(int progress, int total) {
   CalculationListener[] listenersLocal;
   synchronized (this) {
     listenersLocal = listeners.toArray(new CalculationListener[listeners.size()]);
   }
   for (CalculationListener listener : listenersLocal) listener.setProgress(progress, total);
 }
 public void setCalculating(boolean calculating) {
   CalculationListener[] listenersLocal;
   synchronized (this) {
     listenersLocal = listeners.toArray(new CalculationListener[listeners.size()]);
   }
   for (CalculationListener listener : listenersLocal) listener.setCalculating(calculating);
 }
Example #22
0
 public String[] getUserList() throws RemoteException {
   Vector<String> res = new Vector<String>();
   for (ChatUser CU : userstable.values()) {
     res.add(CU.getName());
   }
   return res.toArray(new String[] {});
 }
  public java.lang.Object[] getListofActivities() {

    java.lang.Object[] listofActivities = null;

    java.util.Vector listActVector = new java.util.Vector(1, 1);

    try {

      java.sql.Statement stmt1 = connectDB.createStatement();

      java.sql.ResultSet rSet1 =
          stmt1.executeQuery(
              "SELECT DISTINCT order_no FROM st_orders WHERE date BETWEEN '"
                  + beginDate
                  + "' AND '"
                  + endDate
                  + "' ORDER BY order_no");

      while (rSet1.next()) {

        listActVector.addElement(rSet1.getObject(1).toString().toUpperCase());
      }

    } catch (java.sql.SQLException sqlExec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), sqlExec.getMessage());
    }

    listofActivities = listActVector.toArray();
    System.out.println("Done list of activities ...");
    return listofActivities;
  }
Example #24
0
  public static int addReviewsRelatedToMovie(
      Context mContext, long movieRowId, ArrayList<Review> reviews) {
    Vector<ContentValues> contentValuesVector = new Vector<>(reviews.size());

    for (int i = 0; i < reviews.size(); i++) {
      ContentValues reviewsValue = new ContentValues();
      String revTmdbId = reviews.get(i).getId();
      long revMovieId = movieRowId;
      String revAuthor = reviews.get(i).getAuthor();
      String revContent = reviews.get(i).getContent();
      String revLink = reviews.get(i).getUrl();

      reviewsValue.put(FavoriteMoviesContract.ReviewEntry.COLUMN_TMDB_REVIEW_ID, revTmdbId);
      reviewsValue.put(FavoriteMoviesContract.ReviewEntry.COLUMN_MOVIE_ID, revMovieId);
      reviewsValue.put(FavoriteMoviesContract.ReviewEntry.COLUMN_AUTHOR, revAuthor);
      reviewsValue.put(FavoriteMoviesContract.ReviewEntry.COLUMN_CONTENT, revContent);
      reviewsValue.put(FavoriteMoviesContract.ReviewEntry.COLUMN_REVIEW_LINK, revLink);
      contentValuesVector.add(reviewsValue);
    }
    int reviewsInserted = 0;
    if (contentValuesVector.size() > 0) {
      ContentValues[] cvArray = new ContentValues[contentValuesVector.size()];
      contentValuesVector.toArray(cvArray);
      reviewsInserted =
          mContext
              .getContentResolver()
              .bulkInsert(FavoriteMoviesContract.ReviewEntry.CONTENT_URI, cvArray);
    }
    return reviewsInserted;
  }
Example #25
0
 public User[] getAllUser() {
   Vector<User> v = new Vector<User>();
   Cursor cursor = null;
   try {
     cursor = db.find("select * from " + TABLENAME, null);
     while (cursor.moveToNext()) {
       User temp = new User();
       temp.setId_DB(cursor.getInt(cursor.getColumnIndex("id_DB")));
       temp.setAddress(cursor.getString(cursor.getColumnIndex(User.ADDRESS)));
       temp.setQq(cursor.getString(cursor.getColumnIndex(User.QQ)));
       temp.setDanwei(cursor.getString(cursor.getColumnIndex(User.DANWEI)));
       temp.setName(cursor.getString(cursor.getColumnIndex(User.NAME)));
       temp.setMobile(cursor.getString(cursor.getColumnIndex(User.MOBILE)));
       v.add(temp);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     if (cursor != null) cursor.close();
     db.closeConnection();
   }
   if (v.size() > 0) {
     return v.toArray(new User[] {});
   } else {
     User[] users = new User[1];
     User user = new User();
     user.setName("无结果111");
     users[0] = user;
     return users;
   }
 }
  public java.lang.Object[] getListofStaffNos() {

    java.lang.Object[] listofStaffNos = null;

    java.util.Vector listStaffNoVector = new java.util.Vector(1, 1);

    try {

      //    java.sql.Connection connDB =
      // java.sql.DriverManager.getConnection("jdbc:postgresql://localhost:5432/sako","postgres","pilsiner");

      java.sql.Statement stmt1 = connectDB.createStatement();

      java.sql.ResultSet rSet1 =
          stmt1.executeQuery(
              "SELECT DISTINCT patient_no FROM hp_patient_card WHERE date::date = current_date AND payment_mode = 'Scheme' order by patient_no");

      while (rSet1.next()) {

        listStaffNoVector.addElement(rSet1.getObject(1).toString());
      }

    } catch (java.sql.SQLException sqlExec) {

      javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), sqlExec.getMessage());
    }

    listofStaffNos = listStaffNoVector.toArray();
    System.out.println("Done list of Staff Nos ...");
    return listofStaffNos;
  }
Example #27
0
  public java.lang.Object[] getSystemMenuItems2Enable(java.lang.String[] menus2enable) {

    java.lang.Object[] menuList2enable = null;

    java.util.Vector menuListVector = new java.util.Vector(1, 1);

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

      try {

        java.sql.Statement stmtDB = connDB.createStatement();

        java.sql.ResultSet rSet =
            stmtDB.executeQuery(
                "SELECT menu_item FROM menu_item_list WHERE item_desc='"
                    + menus2enable[i]
                    + "' AND app_name = 'hospital_hr'");

        while (rSet.next()) {

          menuListVector.addElement(rSet.getString(1));
        }

      } catch (java.sql.SQLException sqlExec) {

        javax.swing.JOptionPane.showMessageDialog(this, sqlExec.getLocalizedMessage());
      }
    }

    return menuList2enable = menuListVector.toArray();
  }
Example #28
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.city_listview);

    // Receive the data passed from MainActivity
    Bundle params = getIntent().getExtras();

    this.setTitle("Choose a city to load from:");

    // Construct the cities list
    Vector<String> items = new Vector<String>();
    items.add("<Delete City>");

    List<Profile> allCities = db.getAllProfiles();
    for (int i = 0; i < allCities.size(); i++) {
      items.add((allCities.get(i)).cityName);
    }

    cityList = (ListView) findViewById(R.id.list);
    cityList.setOnItemClickListener(this);
    cityList.setOnItemLongClickListener(this);
    cities =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, items.toArray(new String[0]));
    cityList.setAdapter(cities);

    // get the mainProfile from MainActivity
    newProfile = (Profile) params.getParcelableArrayList("profile").get(0);
  }
Example #29
0
  /**
   * Gets the current settings of the filter.
   *
   * @return an array of strings suitable for passing to setOptions
   */
  public String[] getOptions() {
    Vector<String> result;

    result = new Vector<String>();

    if (m_AttributeType != Attribute.NUMERIC) {
      result.add("-T");
      result.add("" + getAttributeType());
    }

    result.add("-N");
    result.add(Utils.backQuoteChars(getAttributeName()));

    if (m_AttributeType == Attribute.NOMINAL) {
      result.add("-L");
      result.add(getNominalLabels());
    } else if (m_AttributeType == Attribute.NOMINAL) {
      result.add("-F");
      result.add(getDateFormat());
    }

    result.add("-C");
    result.add("" + getAttributeIndex());

    return result.toArray(new String[result.size()]);
  }
Example #30
0
  /**
   * If this object has changed, as indicated by the <code>hasChanged</code> method, then notify all
   * of its observers and then call the <code>clearChanged</code> method to indicate that this
   * object has no longer changed.
   *
   * <p>Each observer has its <code>update</code> method called with two arguments: this observable
   * object and the <code>arg</code> argument.
   *
   * @param arg any object.
   * @see java.util.Observable#clearChanged()
   * @see java.util.Observable#hasChanged()
   * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
   */
  public void notifyObservers(Object arg) {
    /*
     * a temporary array buffer, used as a snapshot of the state of
     * current Observers.
     */
    Object[] arrLocal;

    synchronized (this) {
      /* We don't want the Observer doing callbacks into
       * arbitrary code while holding its own Monitor.
       * The code where we extract each Observable from
       * the Vector and store the state of the Observer
       * needs synchronization, but notifying observers
       * does not (should not).  The worst result of any
       * potential race-condition here is that:
       * 1) a newly-added Observer will miss a
       *   notification in progress
       * 2) a recently unregistered Observer will be
       *   wrongly notified when it doesn't care
       */
      if (!changed) return;
      arrLocal = obs.toArray();
      clearChanged();
    }

    for (int i = arrLocal.length - 1; i >= 0; i--) ((Observer) arrLocal[i]).update(this, arg);
  }