Esempio n. 1
2
  // Takes and image_id, pulls in the image from cache, and goes about
  // encoding it to put it into the database in a transaction.  The last
  // query in the transaction records the image having been stored.
  protected void storeImage(int image_id) throws Exception {
    PhotoImage p = new PhotoImage(image_id);
    SpyDB pdb = getDB();
    Connection db = null;
    Statement st = null;
    Vector v = p.getImage();
    System.err.println(
        "Storer: Got image for " + image_id + " " + v.size() + " lines of data to store.");
    try {
      int i = 0, n = 0;
      db = pdb.getConn();
      db.setAutoCommit(false);
      st = db.createStatement();
      BASE64Encoder base64 = new BASE64Encoder();
      String data = "";

      for (; i < v.size(); i++) {
        String tmp = base64.encodeBuffer((byte[]) v.elementAt(i));
        tmp = tmp.trim();

        if (data.length() < 2048) {
          data += tmp + "\n";
        } else {
          storeQuery(image_id, n, st, data);
          data = tmp;
          n++;
        }
      }
      // OK, this is sick, but another one right now for the spare.
      if (data.length() > 0) {
        System.err.println("Storer:  Storing spare.");
        storeQuery(image_id, n, st, data);
        n++;
      }
      System.err.println("Storer:  Stored " + n + " lines of data for " + image_id + ".");
      st.executeUpdate(
          "update upload_log set stored=datetime(now())\n" + "\twhere photo_id = " + image_id);
      db.commit();
      // Go ahead and generate a thumbnail.
      p.getThumbnail();
    } catch (Exception e) {
      // If anything happens, roll it back.
      if (st != null) {
        try {
          db.rollback();
        } catch (Exception e3) {
          // Nothing
        }
      }
    } finally {
      if (db != null) {
        try {
          db.setAutoCommit(true);
        } catch (Exception e) {
          System.err.println("Error:  " + e);
        }
      }
      pdb.freeDBConn();
    }
  }
Esempio n. 2
1
 /**
  * Event.detail line start offset (input) Event.text line text (input) LineStyleEvent.styles
  * Enumeration of StyleRanges, need to be in order. (output) LineStyleEvent.background line
  * background color (output)
  */
 public void lineGetStyle(LineStyleEvent event) {
   Vector styles = new Vector();
   int token;
   StyleRange lastStyle;
   // If the line is part of a block comment, create one style for the entire line.
   if (inBlockComment(event.lineOffset, event.lineOffset + event.lineText.length())) {
     styles.addElement(
         new StyleRange(event.lineOffset, event.lineText.length(), getColor(COMMENT), null));
     event.styles = new StyleRange[styles.size()];
     styles.copyInto(event.styles);
     return;
   }
   Color defaultFgColor = ((Control) event.widget).getForeground();
   scanner.setRange(event.lineText);
   token = scanner.nextToken();
   while (token != EOF) {
     if (token == OTHER) {
       // do nothing for non-colored tokens
     } else if (token != WHITE) {
       Color color = getColor(token);
       // Only create a style if the token color is different than the
       // widget's default foreground color and the token's style is not
       // bold.  Keywords are bolded.
       if ((!color.equals(defaultFgColor)) || (token == KEY)) {
         StyleRange style =
             new StyleRange(
                 scanner.getStartOffset() + event.lineOffset, scanner.getLength(), color, null);
         if (token == KEY) {
           style.fontStyle = SWT.BOLD;
         }
         if (styles.isEmpty()) {
           styles.addElement(style);
         } else {
           // Merge similar styles.  Doing so will improve performance.
           lastStyle = (StyleRange) styles.lastElement();
           if (lastStyle.similarTo(style) && (lastStyle.start + lastStyle.length == style.start)) {
             lastStyle.length += style.length;
           } else {
             styles.addElement(style);
           }
         }
       }
     } else if ((!styles.isEmpty())
         && ((lastStyle = (StyleRange) styles.lastElement()).fontStyle == SWT.BOLD)) {
       int start = scanner.getStartOffset() + event.lineOffset;
       lastStyle = (StyleRange) styles.lastElement();
       // A font style of SWT.BOLD implies that the last style
       // represents a java keyword.
       if (lastStyle.start + lastStyle.length == start) {
         // Have the white space take on the style before it to
         // minimize the number of style ranges created and the
         // number of font style changes during rendering.
         lastStyle.length += scanner.getLength();
       }
     }
     token = scanner.nextToken();
   }
   event.styles = new StyleRange[styles.size()];
   styles.copyInto(event.styles);
 }
Esempio n. 3
1
  public ViewComponentInfo projectAbsoluteCoordinateRecursively(Integer ix, Integer iy) {
    // Miss
    if (!checkHit(ix, iy)) return null;

    if (this.viewType.endsWith("Spinner")) {
      this.isSpinner = true;
      return this;
    }

    // I'm hit and has child.
    if (this.children != null) {
      // Assumption : children never intersect

      ViewComponentInfo projected_child;

      if (this.isContainer || this.viewType.equals("android.widget.TabWidget")) {
        Vector<ViewComponentInfo> views = new Vector<ViewComponentInfo>();
        for (ViewComponentInfo child : children) {
          if (child.checkHit(ix, iy)) {
            child.isCollectionMember = true;
            views.add(child);
          }
        }
        if (views.size() == 1) {
          return views.firstElement();
        }
      }
      if (this.viewType.endsWith(("FrameLayout"))) {
        LinkedList<ViewComponentInfo> chlist = new LinkedList<ViewComponentInfo>(children);
        ViewComponentInfo child = getFrameContent(children);
        projected_child = child.projectAbsoluteCoordinateRecursively(ix, iy);
        if (projected_child != null) return projected_child;
      } else {
        Vector<ViewComponentInfo> views = new Vector<ViewComponentInfo>();
        for (ViewComponentInfo child : children) {
          projected_child = child.projectAbsoluteCoordinateRecursively(ix, iy);
          if (projected_child != null) views.add(projected_child);
        }
        if (views.size() == 1) {
          return views.firstElement();
        }
      }
    }

    // The point hit no child.
    // Thus return my self.
    if (this.viewType.endsWith("Layout")
        || this.viewType.endsWith("TextView")
        || this.viewType.endsWith("ScrollView")
        || this.viewType.endsWith("ViewStub")
        || this.viewType.endsWith("DialogTitle")
        || this.viewType.endsWith("ImageView")) {
      if (this.hasOnClickListener()) return this;
      else return null;
    }
    return this;
  }
Esempio n. 4
0
  /**
   * Constructs a <code>VariabilityRecordTable</code> with a list of variability records.
   *
   * @param record_list the list of variability records.
   * @param desktop the parent desktop.
   */
  public VariabilityRecordTable(Vector record_list, net.aerith.misao.gui.Desktop desktop) {
    this.record_list = record_list;
    this.desktop = desktop;

    index = new ArrayIndex(record_list.size());

    model = new DefaultTableModel(column_names, 0);
    Object[] objects = new Object[column_names.length];
    objects[0] = new Boolean(true);
    for (int i = 1; i < column_names.length; i++) objects[i] = "";
    for (int i = 0; i < record_list.size(); i++) model.addRow(objects);
    setModel(model);

    column_model = (DefaultTableColumnModel) getColumnModel();
    for (int i = 1; i < column_names.length; i++)
      column_model
          .getColumn(i)
          .setCellRenderer(
              new StringRenderer(column_names[i], LabelTableCellRenderer.MODE_MULTIPLE_SELECTION));

    initializeCheckColumn();

    setTableHeader(new TableHeader(column_model));

    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    initializeColumnWidth();

    pane = this;

    initPopupMenu();
  }
 /** Get row count (part of table model interface) */
 public int getRowCount() {
   int count = data.size();
   if (filter_data != null) {
     count = filter_data.size();
   }
   return count;
 }
 public boolean checkEvents(BundleEvent[] expevents) {
   boolean res = true;
   for (int i = 0; i < 20; i++) {
     try {
       Thread.sleep(100);
     } catch (InterruptedException ignore) {
     }
     if (events.size() == expevents.length) {
       break;
     }
   }
   if (events.size() == expevents.length) {
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       if (!(be.getBundle().equals(expevents[i].getBundle())
           && be.getType() == expevents[i].getType())) {
         res = false;
       }
     }
   } else {
     res = false;
   }
   if (!res) {
     out.println("Real events");
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       out.println("Event " + be.getBundle() + ", Type " + be.getType());
     }
     out.println("Expected events");
     for (int i = 0; i < expevents.length; i++) {
       out.println("Event " + expevents[i].getBundle() + ", Type " + expevents[i].getType());
     }
   }
   return res;
 }
  public Matrix matrix(boolean centered) {
    String[] genes = genes();
    Matrix matrix = new Matrix(genes.length, coefs.size());

    for (int j = 0; j < coefs.size(); j++) {
      Map<String, Double> values = coefs.get(j).geneValues(args.compare);
      double sum = 0.0;

      for (int i = 0; i < genes.length; i++) {
        Double value = values.get(genes[i]);
        if (value != null) {
          matrix.set(i, j, value);
          sum += value;
        } else {
          matrix.set(i, j, 0.0);
        }
      }

      if (centered) {
        sum /= (double) genes.length;
        for (int i = 0; i < genes.length; i++) {
          matrix.set(i, j, matrix.get(i, j) - sum);
        }
      }
    }

    return matrix;
  }
Esempio n. 8
0
  public void normalize() {
    for (int i = 0; i < samples.size(); i++) {
      TreeSet<Column.Entry> entries = new TreeSet<Column.Entry>();
      for (int j = 0; j < cols.size(); j++) {
        Column c = cols.get(j);
        if (c.values.get(i) != null) {
          entries.add(c.entry(i));
        }
      }

      int ns = entries.size();
      int j = 0;
      for (Column.Entry e : entries) {
        int cidx = ids.get(e.id());
        float ff = (float) j / (float) ns;
        cols.get(cidx).values.set(i, ff);
      }

      if (i > 0) {
        if (i % 100 == 0) {
          System.out.print(".");
          System.out.flush();
        }
      }
    }
    System.out.println();
  }
 void tagV(String name, Vector attrs) {
   String s[] = new String[attrs.size()];
   for (int i = 0; i < attrs.size(); i++) {
     s[i] = (String) attrs.elementAt(i);
   }
   startTagPrim(name, s, true);
 }
  /**
   * Is used to remember the order of variables so that the message returned to the OA does not
   * contain randomly ordered data.
   *
   * @param message The RuleML message
   * @return An array containing the order of the variables.
   */
  public static String[] getVariableOrder(String message) {
    Vector<String> variables = new Vector<String>();
    String[] variableList;
    // Break string up
    StringTokenizer st = new StringTokenizer(message, "<");

    String temp = ""; // Temporary storage
    String tempVar = ""; // Temporary variable storage

    // While information remains
    while (st.hasMoreTokens()) {
      temp = st.nextToken();
      // If it is a variable
      if (temp.startsWith("Var>")) {
        tempVar = "";
        // Get the name of the variable
        for (int i = 4; i < temp.length(); i++) {
          if (temp.charAt(i) == '<') break;
          else tempVar = tempVar + temp.charAt(i);
        }
        variables.addElement(tempVar); // Store the variable name
      }
    }
    // Convert the vector to an array
    variableList = new String[variables.size()];
    for (int i = 0; i < variables.size(); i++) {
      variableList[i] = variables.elementAt(i);
    }
    return variableList;
  }
Esempio n. 11
0
 /**
  * Gets the urlClassLoader that enables to access to the objects jar files.
  *
  * @return an URLClassLoader
  */
 public URLClassLoader getObjectsClassLoader() {
   if (objectsClassLoader == null) {
     try {
       if (isExecutionMode()) {
         URL[] listUrl = new URL[1];
         listUrl[0] = instance.getTangaraPath().toURI().toURL();
         objectsClassLoader = new URLClassLoader(listUrl);
       } else {
         File f = new File(instance.getTangaraPath().getParentFile(), "objects");
         File[] list = f.listFiles();
         Vector<URL> vector = new Vector<URL>();
         for (int i = 0; i < list.length; i++) {
           if (list[i].getName().endsWith(".jar")) vector.add(list[i].toURI().toURL());
         }
         File flib =
             new File(
                 instance.getTangaraPath().getParentFile().getAbsolutePath().replace("\\", "/")
                     + "/objects/lib");
         File[] listflib = flib.listFiles();
         for (int j = 0; j < listflib.length; j++) {
           if (listflib[j].getName().endsWith(".jar")) vector.add(listflib[j].toURI().toURL());
         }
         URL[] listUrl = new URL[vector.size()];
         for (int j = 0; j < vector.size(); j++) listUrl[j] = vector.get(j);
         objectsClassLoader = new URLClassLoader(listUrl);
       }
     } catch (Exception e1) {
       displayError("URL MAL FORMED " + e1);
       return null;
     }
   }
   return objectsClassLoader;
 }
Esempio n. 12
0
  public IrepLocSegs FindSegment(Vector<IrepConstRange> segs, boolean msf) {
    Integer hash_nr = new Integer(segs.size());
    SegEntry entry = null;
    IrepLocSegs loc_segs;
    int i = 0;

    entry = (SegEntry) _segList.get(hash_nr);

    if (entry == null) {
      entry = new SegEntry(segs.size());
      _segList.put(hash_nr, entry);
    }

    for (i = 0; i < entry._segs.size(); i++) {
      loc_segs = (IrepLocSegs) entry._segs.get(i);

      if (loc_segs._msf == msf && loc_segs._segs.equals(segs)) {
        return loc_segs;
      }
    }

    loc_segs = new IrepLocSegs(segs, msf);
    loc_segs._index = entry._segs.size();
    entry._segs.add(loc_segs);

    return loc_segs;
  }
Esempio n. 13
0
  /** Tail-recursive algorithm to generate all factory signatures */
  private static void makeFactoryNames(
      String prefix, Vector arguments, int startIndex, Vector results) {

    // if startIndex == arguments.size, then simply add the prefix to the results
    if (startIndex == arguments.size()) {
      if (s_allFactorySignatures.contains(prefix))
        throw new RuntimeException(
            "Constructor signature collision detected: Factory already registered with prefix "
                + prefix);

      results.add(prefix);
      assert (DebugMsg.debugMsg("ClassWriter", "makeFactoryNames:adding:" + prefix));
      s_allFactorySignatures.add(prefix);
      return;
    }

    // Otherwise, iterate over each element of arguments, and call recursively with adjusted input
    Vector currentAlternates = (Vector) arguments.elementAt(startIndex);
    for (int i = 0; i < currentAlternates.size(); i++) {
      makeFactoryNames(
          prefix + ":" + (String) currentAlternates.elementAt(i),
          arguments,
          startIndex + 1,
          results);
    }
  }
  private void doSave() {
    ObjectOutputStream objectStream = getObjectOutputStream();

    if (objectStream != null) {
      try {
        System.out.println("Saving " + selectedChildrenPaths.size() + " Selected Generations...");

        for (int i = 0; i < selectedChildrenPaths.size(); i++) {
          // Get the userObject at the supplied path
          Object selectedPath =
              ((TreePath) selectedChildrenPaths.elementAt(i)).getLastPathComponent();
          DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selectedPath;

          objectStream.writeObject(selectedNode.getUserObject());
        }

        objectStream.close();
        System.out.println("Save completed successfully.");
      } catch (IOException e) {
        System.err.println(e);
      }
    } else {
      System.out.println("Save Selected Files has been aborted!");
    }
  }
  public void save(File f) throws IOException {
    PrintStream ps = new PrintStream(new FileOutputStream(f));
    String[] genes = genes();

    Vector<Map<String, Double>> maps = new Vector<Map<String, Double>>();
    for (int j = 0; j < coefs.size(); j++) {
      maps.add(coefs.get(j).geneValues(args.compare));
    }

    ps.print("gene");
    for (int i = 0; i < coefs.size(); i++) {
      ps.print(" " + keys.get(i));
    }
    ps.println();

    for (int i = 0; i < genes.length; i++) {
      ps.print(String.format("%s", genes[i]));

      for (int j = 0; j < coefs.size(); j++) {
        Map<String, Double> map = maps.get(j);
        Double value = map.containsKey(genes[i]) ? map.get(genes[i]) : null;

        ps.print(String.format(" %s", value != null ? String.format("%.2f", value) : "N/A"));
      }

      ps.println();
    }

    ps.println();
    ps.close();
  }
Esempio n. 16
0
  public void saveFile(File f) throws IOException {
    PrintStream ps = new PrintStream(new FileOutputStream(f));
    ps.print("ID");
    for (Column c : cols) {
      ps.print(String.format("\t%s", c.id));
    }
    ps.println();
    for (int i = 0; i < samples.size(); i++) {
      ps.print(samples.get(i));
      for (int j = 0; j < cols.size(); j++) {
        Float ff = cols.get(j).values.get(i);
        if (ff == null) {
          ps.print("\tnull");
        } else {
          ps.print(String.format("\t%.2f", ff));
        }
      }
      ps.println();

      if (i > 0) {
        if (i % 100 == 0) {
          System.out.print(".");
          System.out.flush();
        }
      }
    }
    System.out.println();
    ps.close();
  }
Esempio n. 17
0
 /**
  * @param j The ungapped index into the multiple alignment.
  * @return An array of characters, corresponding to a particular column from the multiple
  *     alignment.
  */
 public char[] alignedChars(int j) {
   char[] array = new char[ordering.size()];
   for (int i = 0; i < ordering.size(); i++) {
     String species = ordering.get(i);
     array[i] = gappedAlignments.get(species).gappedChar(j);
   }
   return array;
 }
Esempio n. 18
0
 public Tuple[] rdgp(Tuple template) {
   Vector matchingTuples = new Vector();
   for (int i = 0; i < ts.size(); i++) {
     Tuple tuple = (Tuple) ts.get(i);
     if (template.matches(tuple)) matchingTuples.add(tuple);
   }
   if (matchingTuples.size() == 0) return null;
   return (Tuple[]) matchingTuples.toArray(new Tuple[0]);
 }
 void write(ClassEnv e, CodeAttr ce, DataOutputStream out) throws IOException, jasError {
   out.writeShort(e.getCPIndex(attr));
   out.writeInt(2 + 10 * (vars.size()));
   out.writeShort(vars.size());
   for (Enumeration en = vars.elements(); en.hasMoreElements(); ) {
     LocalVarEntry lv = (LocalVarEntry) (en.nextElement());
     lv.write(e, ce, out);
   }
 }
Esempio n. 20
0
  /**
   * 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
Esempio n. 21
0
  public static void generate(String argv[]) throws SilentExit {
    Vector files = parseOptions(argv);

    if (files.size() > 0) {
      for (int i = 0; i < files.size(); i++) generate((File) files.elementAt(i));
    } else {
      new MainFrame();
    }
  }
 public XmlUIElement getXmlElement(UserInput uiArg) {
   String type = "textfield";
   Qualifier qual = uiArg.getQualifier();
   String enumNames[] = null;
   String enumValues[] = null;
   if (qual != null) {
     type = qual.getType();
     Vector enumVec = qual.getEnums();
     if (enumVec.size() > 0) {
       enumNames = new String[enumVec.size()];
       enumValues = new String[enumVec.size()];
       for (int i = 0; i < enumNames.length; i++) {
         com.adventnet.management.config.xml.Enum e =
             (com.adventnet.management.config.xml.Enum) enumVec.elementAt(i);
         enumNames[i] = e.getName();
         enumValues[i] = e.getValue();
         if (enumNames[i] == null) {
           enumNames[i] = enumValues[i];
         }
       }
     }
   }
   XmlUIElement el = getXmlUIElementFor(type);
   if (el == null) {
     return null;
   }
   el.setDescription(uiArg.getDescription());
   if (enumNames != null) {
     el.setEnumeratedValues(enumNames, enumValues);
   }
   if ((qual != null) && (qual.getRange() != null) && (!(qual.getRange().equals("")))) {
     el.setRange(qual.getRange());
   }
   if (uiArg.getDefaultValue() != null) {
     el.setValue(uiArg.getDefaultValue());
   }
   String isEditable = uiArg.getAttribute("editable");
   if (isEditable != null) {
     if (isEditable.trim().equals("false")) {
       el.setEditable(false);
     } else {
       el.setEditable(true);
     }
   }
   String required = uiArg.getAttribute("required");
   {
     if (required.trim().equals("true")) {
       el.setRequired(true);
       numberOfRequiredFields++;
     } else {
       el.setRequired(false);
     }
   }
   el.setLabelName(uiArg.getLabel());
   return el;
 }
Esempio n. 23
0
 public void outputBinary(DataOutputStream dos) throws IOException {
   dos.writeInt(samples.size());
   for (String s : samples) {
     dos.writeUTF(s);
   }
   dos.writeInt(cols.size());
   for (Column c : cols) {
     c.outputBinary(dos);
   }
 }
Esempio n. 24
0
 static Visual[] getTrueColor16(Client c) {
   Vector vec = new Vector();
   vec.addElement(new Visual(Resource.fakeClientId(c), 4, 6, 64, 0xf800, 0x7e0, 0x1f));
   Visual[] v = new Visual[vec.size()];
   for (int i = 0; i < vec.size(); i++) {
     v[i] = (Visual) vec.elementAt(i);
   }
   vec.removeAllElements();
   return v;
 }
Esempio n. 25
0
  public Vector<String> getUserNames() {
    int i;
    Vector<String> names = new Vector<String>(connections.size());

    for (i = 0; i < connections.size(); i++) {
      names.addElement((String) connections.elementAt(i).nickname);
    }

    return names;
  }
Esempio n. 26
0
 static Visual[] getPseudoColor8(Client c) {
   Vector vec = new Vector();
   vec.addElement(new Visual(Resource.fakeClientId(c), 3, 6, 256, 0, 0, 0));
   Visual[] v = new Visual[vec.size()];
   for (int i = 0; i < vec.size(); i++) {
     v[i] = (Visual) vec.elementAt(i);
   }
   vec.removeAllElements();
   return v;
 }
  /**
   * This Method returns the 2D Array which is the list of the Items for the selected WorkOrder of
   * the Customer.
   *
   * @param workorderId - WorkOrder Id Foreign Key of WRK_ORDR_DETS table
   * @return Object[][] - 2D Array which is List of the Items for the WorkOrder
   */
  public Object[][] getWorkOrderItems(long workorderId) throws RemoteException {

    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    RHCCBlgKeys blgkeys_obj = new RHCCBlgKeys(conn);

    Vector workorderdetList = wrkordrdts_obj.getProductList(workorderId);

    // Hashtable BSysList = (Hashtable) USFEnv.getBillSystems();
    BlgSys blgsys = new BlgSys();

    Hashtable BSysList = (Hashtable) blgsys.searchBlgSys();

    Enumeration BSys = BSysList.keys();

    // The 2-Dimensional array to hold the Items Billing System wise.
    Object[][] prodList = new Object[BSysList.size()][workorderdetList.size() + 1];

    // The Number of Billing Systems are assumed to be equal to the
    // Static Load Billing Systems Hashtable size. The Billing Systems will
    // be in order starting from 1 and incrementing by one.
    for (int i = 0; i < BSysList.size(); i++) {
      // Set the 2D array to store the Billing System as the first element
      // of each row.
      prodList[i][0] = String.valueOf(i + 1);
    }

    // Loop throught the WorkOrder Items List and place them in the appropriate
    // positions in the 2D array.
    for (int j = 0; j < workorderdetList.size(); j++) {
      // Determine the Billing System of the Product
      Vector tmpVector = new Vector();

      WrkOrdrDets workorderObj = (WrkOrdrDets) workorderdetList.elementAt(j);

      RHCCBlgKeys bkObj =
          blgkeys_obj.searchRHCCBlgKeys(((WrkOrdrDets) workorderdetList.elementAt(j)).getRBKID());
      int bsid = (new Long(bkObj.getBsId())).intValue();

      tmpVector.addElement(bkObj);
      tmpVector.addElement(workorderObj);

      // Based on the Billing System Id retreived place the Product Object
      // in the 2D array.
      int k = 1;
      while (prodList[bsid - 1][k] != null) {
        k = k + 1;
      }
      prodList[bsid - 1][k] = tmpVector;
    }

    // Return the 2D array
    return prodList;
  }
Esempio n. 28
0
  private void writeListErrors(
      FileWriter fileOut,
      Vector deviationMessages,
      Vector databaseValues,
      String ind,
      char delimeter,
      String variable,
      String value,
      String date,
      String ref,
      String comm) {

    try {

      if (errorList.size() > 0 || deviationMessages.size() > 0 || warningList.size() > 0) {
        fileOut.write("#--------------------------------------------------\n");
      }
      if (errorList.size() > 0) {
        for (int i = 0; i < errorList.size(); i++) {
          fileOut.write("#" + (String) errorList.get(i) + "\n");
        }
      }
      if (warningList.size() > 0) {
        for (int i = 0; i < warningList.size(); i++) {
          fileOut.write("#" + (String) warningList.get(i) + "\n");
        }
      }

      if (deviationMessages.size() > 0) {
        for (int i = 0; i < deviationMessages.size(); i++) {
          fileOut.write("#" + (String) deviationMessages.elementAt(i) + "\n");
        }
        // write old values
        fileOut.write("#" + databaseValues.elementAt(0) + "\n");
      }
      // if there are errors, the string is "Outcommented"
      if (errorList.size() > 0) {
        fileOut.write("#");
      }

      // write original string
      fileOut.write(
          ind + delimeter + variable + delimeter + value + delimeter + date + delimeter + ref
              + delimeter + comm + "\n");

      if (errorList.size() > 0 || deviationMessages.size() > 0 || warningList.size() > 0) {
        fileOut.write("#--------------------------------------------------\n");
      }

    } // try
    catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }
Esempio n. 29
0
 /**
  * Returns the value of the named parameter as a String, or null if the parameter was not sent or
  * was sent without a value. The value is guaranteed to be in its normal, decoded form. If the
  * parameter has multiple values, only the last one is returned (for backward compatibility). For
  * parameters with multiple values, it's possible the last "value" may be null.
  *
  * @param name the parameter name.
  * @return the parameter value.
  */
 public String getParameter(String name) {
   try {
     Vector values = (Vector) parameters.get(name);
     if (values == null || values.size() == 0) {
       return null;
     }
     String value = (String) values.elementAt(values.size() - 1);
     return value;
   } catch (Exception e) {
     return null;
   }
 }
Esempio n. 30
0
 /**
  * Returns the values of the named parameter as a String array, or null if the parameter was not
  * sent. The array has one entry for each parameter field sent. If any field was sent without a
  * value that entry is stored in the array as a null. The values are guaranteed to be in their
  * normal, decoded form. A single value is returned as a one-element array.
  *
  * @param name the parameter name.
  * @return the parameter values.
  */
 public String[] getParameterValues(String name) {
   try {
     Vector values = (Vector) parameters.get(name);
     if (values == null || values.size() == 0) {
       return null;
     }
     String[] valuesArray = new String[values.size()];
     values.copyInto(valuesArray);
     return valuesArray;
   } catch (Exception e) {
     return null;
   }
 }