Exemplo n.º 1
1
    // create from a dataset
    public VariableBean(Variable vs) {
      this.vs = vs;
      // vs = (v instanceof VariableEnhanced) ? (VariableEnhanced) v : new VariableStandardized( v);

      setName(vs.getShortName());
      setDescription(vs.getDescription());
      setUnits(vs.getUnitsString());
      setDataType(vs.getDataType().toString());

      // Attribute csAtt = vs.findAttribute("_coordSystems");
      // if (csAtt != null)
      //  setCoordSys( csAtt.getStringValue());

      // collect dimensions
      StringBuilder lens = new StringBuilder();
      StringBuilder names = new StringBuilder();
      java.util.List dims = vs.getDimensions();
      for (int j = 0; j < dims.size(); j++) {
        ucar.nc2.Dimension dim = (ucar.nc2.Dimension) dims.get(j);
        if (j > 0) {
          lens.append(",");
          names.append(",");
        }
        String name = dim.isShared() ? dim.getName() : "anon";
        names.append(name);
        lens.append(dim.getLength());
      }
      setDimensions(names.toString());
      setShape(lens.toString());
    }
Exemplo n.º 2
1
  @SuppressWarnings("unchecked")
  public ResidentConverter(List<ObjectConverter.ColumnInfo> allColumns) throws java.io.IOException {
    Optional<ObjectConverter.ColumnInfo> column;

    final java.util.List<ObjectConverter.ColumnInfo> columns =
        allColumns
            .stream()
            .filter(
                it ->
                    "mixinReference".equals(it.typeSchema) && "Resident_entity".equals(it.typeName))
            .collect(Collectors.toList());
    columnCount = columns.size();

    readers = new ObjectConverter.Reader[columnCount];
    for (int i = 0; i < readers.length; i++) {
      readers[i] = (instance, rdr, ctx) -> StringConverter.skip(rdr, ctx);
    }

    final java.util.List<ObjectConverter.ColumnInfo> columnsExtended =
        allColumns
            .stream()
            .filter(
                it ->
                    "mixinReference".equals(it.typeSchema)
                        && "-ngs_Resident_type-".equals(it.typeName))
            .collect(Collectors.toList());
    columnCountExtended = columnsExtended.size();

    readersExtended = new ObjectConverter.Reader[columnCountExtended];
    for (int i = 0; i < readersExtended.length; i++) {
      readersExtended[i] = (instance, rdr, ctx) -> StringConverter.skip(rdr, ctx);
    }

    column = columns.stream().filter(it -> "id".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'id' column in mixinReference Resident_entity. Check if DB is in sync");
    __index___id = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "id".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'id' column in mixinReference Resident. Check if DB is in sync");
    __index__extended_id = (int) column.get().order - 1;

    column = columns.stream().filter(it -> "birth".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'birth' column in mixinReference Resident_entity. Check if DB is in sync");
    __index___birth = (int) column.get().order - 1;

    column = columnsExtended.stream().filter(it -> "birth".equals(it.columnName)).findAny();
    if (!column.isPresent())
      throw new java.io.IOException(
          "Unable to find 'birth' column in mixinReference Resident. Check if DB is in sync");
    __index__extended_birth = (int) column.get().order - 1;
  }
Exemplo n.º 3
0
 /**
  * ** Gets a list of all the argument key names ** @return a list of all the argument key names
  */
 public java.util.List<String> getArgNames() {
   java.util.List<String> knList = new Vector<String>();
   for (KeyVal kv : this.getKeyValList()) {
     knList.add(kv.getKey());
   }
   return knList;
 }
Exemplo n.º 4
0
 private void jj_add_error_token(int kind, int pos) {
   if (pos >= 100) return;
   if (pos == jj_endpos + 1) {
     jj_lasttokens[jj_endpos++] = kind;
   } else if (jj_endpos != 0) {
     jj_expentry = new int[jj_endpos];
     for (int i = 0; i < jj_endpos; i++) {
       jj_expentry[i] = jj_lasttokens[i];
     }
     jj_entries_loop:
     for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext(); ) {
       int[] oldentry = (int[]) (it.next());
       if (oldentry.length == jj_expentry.length) {
         for (int i = 0; i < jj_expentry.length; i++) {
           if (oldentry[i] != jj_expentry[i]) {
             continue jj_entries_loop;
           }
         }
         jj_expentries.add(jj_expentry);
         break jj_entries_loop;
       }
     }
     if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
   }
 }
Exemplo n.º 5
0
 /** Generate ParseException. */
 public ParseException generateParseException() {
   jj_expentries.clear();
   boolean[] la1tokens = new boolean[11];
   if (jj_kind >= 0) {
     la1tokens[jj_kind] = true;
     jj_kind = -1;
   }
   for (int i = 0; i < 3; i++) {
     if (jj_la1[i] == jj_gen) {
       for (int j = 0; j < 32; j++) {
         if ((jj_la1_0[i] & (1 << j)) != 0) {
           la1tokens[j] = true;
         }
       }
     }
   }
   for (int i = 0; i < 11; i++) {
     if (la1tokens[i]) {
       jj_expentry = new int[1];
       jj_expentry[0] = i;
       jj_expentries.add(jj_expentry);
     }
   }
   jj_endpos = 0;
   jj_rescan_token();
   jj_add_error_token(0, 0);
   int[][] exptokseq = new int[jj_expentries.size()][];
   for (int i = 0; i < jj_expentries.size(); i++) {
     exptokseq[i] = jj_expentries.get(i);
   }
   return new ParseException(token, exptokseq, tokenImage);
 }
Exemplo n.º 6
0
 static {
   _jspx_dependants = new java.util.ArrayList(4);
   _jspx_dependants.add("/inc/sharedFunctions.jsp");
   _jspx_dependants.add("/inc/header.jsp");
   _jspx_dependants.add("/inc/login_form.jsp");
   _jspx_dependants.add("/inc/footer.jsp");
 }
Exemplo n.º 7
0
  private void spawnRandomers() {
    for (int i = 0; i < randomN; i++) {
      float x = (float) Math.random() * width;
      float y = (float) Math.random() * height;
      float r =
          (float)
              Math.sqrt(
                  Math.pow(((Player) players.get(0)).getX() - x, 2)
                      + Math.pow(((Player) players.get(0)).getY() - x, 2));

      while (r < distanceLimit) {
        x = (float) Math.random() * width;
        y = (float) Math.random() * height;
        r =
            (float)
                Math.sqrt(
                    Math.pow(((Player) players.get(0)).getX() - x, 2)
                        + Math.pow(((Player) players.get(0)).getY() - y, 2));
      }

      enemies.add(new EnemyTypes.Random(x, y, 0.5f, borders));
    }

    spawnRandomersB = false;
  }
Exemplo n.º 8
0
  /* return status codes for account/device */
  public static int[] getStatusCodes(String accountID, String deviceID) throws DBException {

    /* account-id specified? */
    if (StringTools.isBlank(accountID)) {
      return new int[0];
    }

    /* device-id specified? */
    if (StringTools.isBlank(deviceID)) {
      deviceID = ALL_DEVICES;
    }

    /* select */
    // DBSelect: SELECT statucCode FROM StatusCode WHERE (accountID='acct') AND (deviceID='*') ORDER
    // BY statucCode
    DBSelect<StatusCode> dsel = new DBSelect<StatusCode>(StatusCode.getFactory());
    dsel.setSelectedFields(StatusCode.FLD_statusCode);
    DBWhere dwh = dsel.createDBWhere();
    dsel.setWhere(
        dwh.WHERE_(
            dwh.AND(
                dwh.EQ(StatusCode.FLD_accountID, accountID),
                dwh.EQ(StatusCode.FLD_deviceID, deviceID))));
    dsel.setOrderByFields(StatusCode.FLD_statusCode);

    /* get list */
    java.util.List<Integer> codeList = new Vector<Integer>();
    Statement stmt = null;
    ResultSet rs = null;
    try {
      stmt = DBConnection.getDefaultConnection().execute(dsel.toString());
      rs = stmt.getResultSet();
      while (rs.next()) {
        int code = rs.getInt(StatusCode.FLD_statusCode);
        codeList.add(new Integer(code));
      }
    } catch (SQLException sqe) {
      throw new DBException("Getting StatusCode List", sqe);
    } finally {
      if (rs != null) {
        try {
          rs.close();
        } catch (Throwable t) {
        }
      }
      if (stmt != null) {
        try {
          stmt.close();
        } catch (Throwable t) {
        }
      }
    }

    /* return array of status codes */
    int codeListInt[] = new int[codeList.size()];
    for (int i = 0; i < codeListInt.length; i++) {
      codeListInt[i] = codeList.get(i).intValue();
    }
    return codeListInt;
  }
Exemplo n.º 9
0
  private int writeHTML(PrintWriter out, int level, ReportData rd) throws ReportException {

    /* no ReportData */
    if (rd == null) {
      return 0;
    }

    /* simple report */
    if (!rd.isSingleDeviceOnly() || (rd.getDeviceCount() <= 1)) {
      return this._writeHTML(out, level, rd, -1);
    }

    /* multiple per-device reports */
    ReportDeviceList rdl = rd.getReportDeviceList();
    java.util.List<ReportDeviceList.DeviceHolder> dhList = rdl.getDeviceHolderList(true);
    rdl.clear();
    int rcdCount = 0;
    int devCount = dhList.size();
    for (int i = 0; i < devCount; i++) {
      if (i > 0) {
        out.print("<br>\n");
      }
      rdl.setDevice(null, dhList.get(i));
      rcdCount += this._writeHTML(out, level, rd, i);
    }
    return rcdCount;
  }
Exemplo n.º 10
0
  public void parseGroup(Group g) throws Hdf5Exception, EndOfSequenceException {
    startGroup(g);

    java.util.List members = g.getMemberList();

    // NOTE: parsing contents twice to ensure subgroups are handled before datasets
    // This is mainly because synapse_props groups will need to be parsed before dataset of
    // connections

    for (int j = 0; j < members.size(); j++) {
      HObject obj = (HObject) members.get(j);

      if (obj instanceof Group) {
        Group subGroup = (Group) obj;

        logger.logComment("---------    Found a sub group: " + subGroup.getName());

        parseGroup(subGroup);
      }
    }

    for (int j = 0; j < members.size(); j++) {
      HObject obj = (HObject) members.get(j);

      if (obj instanceof Dataset) {
        Dataset ds = (Dataset) obj;

        logger.logComment("Found a dataset: " + ds.getName());

        dataSet(ds);
      }
    }

    endGroup(g);
  }
Exemplo n.º 11
0
  private Locale getLocale() {

    java.util.List result = new java.util.ArrayList();
    String language = "";
    String country = "";
    String variant = "";

    // -----------------------------------------------------------------
    // <locale language="en" country="GB" variant="J" />
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_LOCALE);
    if (result.size() == 1) {
      Element el = (Element) result.get(0);
      language = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_LANGUAGE);
      country = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_COUNTRY);
      variant = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_VARIANT);
    }

    if (language.length() == 0) {
      return null;
    }
    // if (country.length() == 0) {
    // return new Locale(language);
    // }
    // if (variant.length() == 0) {
    // return new Locale(language, country);
    // }

    return new Locale(language, country, variant);
  }
Exemplo n.º 12
0
 /**
  * Sets the accelerator sequence
  *
  * @param accSeq The new accelSeq value
  */
 public void setAccelSeq(AcceleratorSeq accSeq) {
   java.util.List<AcceleratorNode> accNodes = accSeq.getNodesOfType(Electromagnet.s_strType);
   java.util.Iterator<AcceleratorNode> itr = accNodes.iterator();
   while (itr.hasNext()) {
     Electromagnet emg = (Electromagnet) itr.next();
     if (emg.getStatus()) {
       emg.setUseFieldReadback(false);
     }
   }
   ringFoilPosCorr.setAccelSeq(accSeq);
 }
Exemplo n.º 13
0
  private void setMpeg() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <diashow>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_VDR);
    if (result.size() == 1) {
      // support vdr (make for example mpeg files)
      mpeg = true;
    }
  }
Exemplo n.º 14
0
 public static String GetPropertyString_OBDII(long dtcFault[]) {
   if (ListTools.isEmpty(dtcFault)) {
     return GetPropertyString_OBDII("");
   } else {
     java.util.List<String> dtc = new Vector<String>();
     for (int i = 0; i < dtcFault.length; i++) {
       if (dtcFault[i] != 0L) {
         dtc.add(GetFaultString(dtcFault[i]));
       }
     }
     return GetPropertyString_OBDII(dtc);
   }
 }
Exemplo n.º 15
0
  // =====================================================
  // private: setPreftch()
  //
  // <prefetch plus="2" minus="0"/>
  //
  // =====================================================
  private void setPrefetch() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <datum>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_PREFETCH);
    if (result.size() == 1) {
      Element elPrefetch = (Element) result.get(0);
      prefetchPlus = PM_XML_Utils.getAttributeInt(elPrefetch, ATTR_PREFETCH_PLUS);
      prefetchMinus = PM_XML_Utils.getAttributeInt(elPrefetch, ATTR_PREFETCH_MINUS);
    }
  }
Exemplo n.º 16
0
  // =====================================================
  // private: setDatumJahrVonBis()
  //
  // <datum jahr-von="1998" jahr-bis="2007"/>
  //
  // =====================================================
  private void setDateFromTo() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <datum>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_DATUM);
    if (result.size() == 1) {
      Element elDatum = (Element) result.get(0);
      datumJahrVon = PM_XML_Utils.getAttributeInt(elDatum, ATTR_DATUM_JAHR_VON);
      datumJahrBis = PM_XML_Utils.getAttributeInt(elDatum, ATTR_DATUM_JAHR_BIS);
    }
  }
Exemplo n.º 17
0
 /** Concatenate params for URL string */
 String concatParams(Properties props) {
   if (props == null) {
     return null;
   }
   java.util.List list = new ArrayList();
   for (Iterator iter = props.keySet().iterator(); iter.hasNext(); ) {
     String key = (String) iter.next();
     String val = props.getProperty(key);
     if (!StringUtil.isNullString(val)) {
       list.add(key + "=" + urlEncode(val));
     }
   }
   return StringUtil.separatedString(list, "&");
 }
Exemplo n.º 18
0
 // =====================================================
 // private: setHomeBilder()
 //
 // <home>
 // <bilder> ..path.. </bilder>
 // </home>
 //
 // =====================================================
 private void setHomeBilder(String path) {
   Element root = document.getRootElement();
   // pr�fen,ob home-tag vorhanden
   java.util.List homeListe = PM_XML_Utils.getElementListe(document, "//" + TAG_HOME);
   Element homeElement = null;
   if (homeListe.isEmpty()) {
     homeElement = new org.dom4j.tree.DefaultElement(TAG_HOME);
     addTag(homeElement, TAG_BILDER, path);
     root.add(homeElement);
   } else {
     homeElement = (Element) homeListe.get(0);
     addTag(homeElement, TAG_BILDER, path);
   }
 }
Exemplo n.º 19
0
  private void setSlideshow() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <diashow>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_DIASHOW);
    if (result.size() == 1) {
      Element el = (Element) result.get(0);
      slideshowText1 = PM_XML_Utils.getAttribute(el, ATTR_DIASHOW_TEXT1);
      slideshowText2 = PM_XML_Utils.getAttribute(el, ATTR_DIASHOW_TEXT2);
      slideshowText3 = PM_XML_Utils.getAttribute(el, ATTR_DIASHOW_TEXT3);
    }
  }
Exemplo n.º 20
0
  /* return list of all Devices within the specified DeviceGroup (NOT SCALABLE BEYOND A FEW HUNDRED GROUPS) */
  public static java.util.List<String> getUsersForGroup(String acctId, String groupId)
      throws DBException {

    /* valid account/groupId? */
    if (StringTools.isBlank(acctId)) {
      return null;
    } else if (StringTools.isBlank(groupId)) {
      return null;
    }

    /* get db selector */
    DBSelect dsel = GroupList._getUserListSelect(acctId, groupId);
    if (dsel == null) {
      return null;
    }

    /* read users for group */
    java.util.List<String> usrList = new Vector<String>();
    DBConnection dbc = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
      dbc = DBConnection.getDefaultConnection();
      stmt = dbc.execute(dsel.toString());
      rs = stmt.getResultSet();
      while (rs.next()) {
        String usrId = rs.getString(GroupList.FLD_userID);
        usrList.add(usrId);
      }
    } catch (SQLException sqe) {
      throw new DBException("Get Group GroupeList", sqe);
    } finally {
      if (rs != null) {
        try {
          rs.close();
        } catch (Throwable t) {
        }
      }
      if (stmt != null) {
        try {
          stmt.close();
        } catch (Throwable t) {
        }
      }
      DBConnection.release(dbc);
    }

    /* return list */
    return usrList;
  }
 String[] getContactList() {
   java.util.List cl = new java.util.LinkedList();
   StringTokenizer st = new StringTokenizer(contactList.getText());
   StringBuffer sb = new StringBuffer();
   StringBuffer dbg = new StringBuffer("test applet contactlist: ");
   while (st.hasMoreTokens()) {
     String loginId = st.nextToken().trim();
     if (loginId.length() == 0) continue;
     dbg.append("'" + loginId + "' ");
     cl.add(loginId);
     sb.append(loginId).append('\n');
   }
   CAT.info(dbg.toString());
   contactList.setText(sb.toString());
   return (String[]) cl.toArray(new String[cl.size()]);
 }
Exemplo n.º 22
0
 /** @param element */
 private void init(Element element) {
   RStack stack = new RStack(element);
   id_ = URelaxer.getAttributePropertyAsString(element, "id");
   xmlLang_ = URelaxer.getAttributePropertyAsString(element, "xml:lang");
   setTitle(new FtTitle(stack));
   if (FtSubtitle.isMatch(stack)) {
     setSubtitle(new FtSubtitle(stack));
   }
   if (FtVersion.isMatch(stack)) {
     setVersion(new FtVersion(stack));
   }
   if (FtType.isMatch(stack)) {
     setType(new FtType(stack));
   }
   if (FtAuthors.isMatch(stack)) {
     setAuthors(new FtAuthors(stack));
   }
   notice_.clear();
   while (true) {
     if (FtNotice.isMatch(stack)) {
       addNotice(new FtNotice(stack));
     } else {
       break;
     }
   }
   if (FtAbstract.isMatch(stack)) {
     setAbstract(new FtAbstract(stack));
   }
 }
Exemplo n.º 23
0
 public static void drawImage(int[][][] pixels, int startX, int startY) {
   // Key idea: draw a bunch (lots of rectangles) with the appropriate color
   DrawObject R = new DrawObject();
   R.pixels = pixels;
   R.startX = startX;
   R.startY = startY;
   R.sequenceNum = currentSequenceNum;
   images.add(R);
   // Rescale if needed.
   int leftX = startX;
   int rightX = startX + pixels.length;
   int lowY = startY;
   int highY = startY + pixels[0].length;
   if (minX > leftX) {
     minX = leftX;
   }
   if (maxX < rightX) {
     maxX = rightX;
   }
   if (minY > lowY) {
     minY = lowY;
   }
   if (maxY < highY) {
     maxY = highY;
   }
   drawArea.repaint();
 }
 private int setDataDescriptors(java.util.List<DdsBean> beanList, DataDescriptor dds, int seqno) {
   for (DataDescriptor key : dds.getSubKeys()) {
     beanList.add(new DdsBean(key, seqno++));
     if (key.getSubKeys() != null) seqno = setDataDescriptors(beanList, key, seqno);
   }
   return seqno;
 }
  public void setBufrFile(RandomAccessFile raf) throws IOException {
    this.raf = raf;
    java.util.List<MessageBean> beanList = new ArrayList<MessageBean>();

    scan = new MessageScanner(raf);
    while (scan.hasNext()) {
      Message m = scan.next();
      if (m == null) continue;

      beanList.add(new MessageBean(m));
    }

    messageTable.setBeans(beanList);
    obsTable.setBeans(new ArrayList());
    ddsTable.setBeans(new ArrayList());
  }
Exemplo n.º 26
0
  public void addRioxxVersionSection(List upload, Item item) throws WingException {
    String version = item.getMetadata("rioxxterms.version");

    if (StringUtils.isNotBlank(version) && !"NA".equals(version)) {
      try {
        DCInputsReader a = new DCInputsReader();
        java.util.List<String> pairs = a.getPairs("rioxxterms_version");
        int humanReadable = pairs.indexOf(version) - 1;
        version = pairs.get(humanReadable);
      } catch (DCInputsReaderException e) {
        log.error(e.getMessage(), e);
      }
      upload
          .addItem("upload-rioxx-version-warning", "upload-rioxx-version-warning")
          .addContent(T_rioxx_version.parameterize(version));
    }
  }
Exemplo n.º 27
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
Exemplo n.º 28
0
  /**
   * Print a list of definitions in different format: fqdn, vdlt, and vdlx
   *
   * @param writer the target to output the list
   * @param defList a list of definitions
   * @param format the output format
   * @see #FORMAT_FQDN
   * @see #FORMAT_VDLT
   * @see #FORMAT_VDLX NOTE: might be better to move into another module?
   */
  public void printDefinitionList(Writer writer, java.util.List defList, int format)
      throws IOException {
    if (defList == null || defList.isEmpty()) return;
    Definitions defs = new Definitions();
    if (format != FORMAT_FQDN) {
      defs.setDefinition(defList);
      if (format == FORMAT_VDLX) defs.toXML(writer, "");
      else if (format == FORMAT_VDLT) defs.toString(writer);
    } else {
      for (Iterator i = defList.iterator(); i.hasNext(); ) {
        Definition def = (Definition) i.next();

        writer.write(def.identify());
        writer.write("\n");
      }
      writer.flush();
    }
  }
Exemplo n.º 29
0
 public static void drawPoint(double x, double y) {
   DrawObject p = new DrawObject();
   p.color = pointColor;
   p.x = x;
   p.y = y;
   p.diameter = pointDiameter;
   p.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animPoints) {
       animPoints.add(p);
     }
   } else {
     synchronized (points) {
       points.add(p);
     }
   }
   drawArea.repaint();
 }
Exemplo n.º 30
0
 public static void drawLabel(double x, double y, String str) {
   DrawObject L = new DrawObject();
   L.color = labelColor;
   L.x = x;
   L.y = y;
   L.str = str;
   L.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animLabels) {
       animLabels.add(L);
     }
   } else {
     synchronized (labels) {
       labels.add(L);
     }
   }
   drawArea.repaint();
 }