private MasterPlaylist( List<PlaylistData> playlists, List<IFrameStreamInfo> iFramePlaylists, List<MediaData> mediaData, List<String> unknownTags) { mPlaylists = DataUtil.emptyOrUnmodifiable(playlists); mIFramePlaylists = DataUtil.emptyOrUnmodifiable(iFramePlaylists); mMediaData = DataUtil.emptyOrUnmodifiable(mediaData); mUnknownTags = DataUtil.emptyOrUnmodifiable(unknownTags); }
public HttpParams(HttpServletRequest request) throws UnsupportedEncodingException { // 检测是否是一个文件上传请求 this.request = request; isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); upload.setHeaderEncoding("UTF-8"); RequestContext requestContext = new ServletRequestContext(request); try { List<FileItem> items = upload.parseRequest(requestContext); Iterator<FileItem> itr = items.iterator(); avs = new HashMap<String, String>(); fileitemMap = new HashMap<String, FileItem>(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); String fieldName = item.getFieldName(); if (item.isFormField()) { avs.put(fieldName, item.getString("UTF-8")); } else { fileitemMap.put(fieldName, item); } } } catch (Exception ex) { ex.printStackTrace(); } } else { // 非文件上传请求 (参数加密) request.setCharacterEncoding("utf-8"); String s = request.getParameter("__"); // s = URLDecoder.decode(s,"UTF-8"); // logger.info("http reqeust params: "+s); if (s != null && !s.equals("")) { try { encoded = true; // String str = DataUtil.decodeECBString(password, DataUtil.HexString2Bytes(s)); String str = DataUtil.decodeECBString(password, DataUtil.decodeBase64(s)); String[] pairs = str.split("&"); params = new HashMap<String, String>(); for (int i = 0; i < pairs.length; i++) { // String[] tokens = pairs[i].split("="); int index = pairs[i].indexOf("="); String key = pairs[i].substring(0, index); String value = pairs[i].substring(index + 1, pairs[i].length()); params.put(key, URLDecoder.decode(value, "UTF-8")); } } catch (Exception ex) { ex.printStackTrace(); } } } }
/** * This is to be called from all JavaFX representing classes. This takes care for incrementing and * decrementing the references, if required, along with comparing the equality of the given * parameters. * * @param oldObj * @param newObj * @return True if both are equal */ @SuppressWarnings({"rawtypes", "unchecked"}) public static boolean equals(Object oldObj, Object newObj) { if (DataUtil.equals(oldObj, newObj)) { return true; } return false; }
public DATA_CLASS[] get(int[] ids, String language) { return RequestHelper.INSTANCE.getRequest( webResource, dataClassArray, "ids", DataUtil.intsToCommaSeparatedString(ids), "lang", language); }
/** * Returns the next Data from the input stream, or null if there is none available * * @return a Data or null * @throws edu.cmu.sphinx.frontend.DataProcessingException */ private Data readNextFrame() throws DataProcessingException { // read one frame's worth of bytes int read; int totalRead = 0; final int bytesToRead = bytesPerRead; byte[] samplesBuffer = new byte[bytesPerRead]; long collectTime = System.currentTimeMillis(); long firstSample = totalValuesRead; try { do { read = dataStream.read(samplesBuffer, totalRead, bytesToRead - totalRead); if (read > 0) { totalRead += read; } } while (read != -1 && totalRead < bytesToRead); if (totalRead <= 0) { closeDataStream(); return null; } // shrink incomplete frames totalValuesRead += (totalRead / bytesPerValue); if (totalRead < bytesToRead) { totalRead = (totalRead % 2 == 0) ? totalRead + 2 : totalRead + 3; byte[] shrinkedBuffer = new byte[totalRead]; System.arraycopy(samplesBuffer, 0, shrinkedBuffer, 0, totalRead); samplesBuffer = shrinkedBuffer; closeDataStream(); } } catch (IOException ioe) { throw new DataProcessingException("Error reading data", ioe); } // turn it into an Data object double[] doubleData; if (bigEndian) { doubleData = DataUtil.bytesToValues(samplesBuffer, 0, totalRead, bytesPerValue, signedData); } else { doubleData = DataUtil.littleEndianBytesToValues( samplesBuffer, 0, totalRead, bytesPerValue, signedData); } return new DoubleData(doubleData, sampleRate, collectTime, firstSample); }
ClayLump read(NBTTagCompound tag) { minX = tag.getByte("lx"); minY = tag.getByte("ly"); minZ = tag.getByte("lz"); maxX = tag.getByte("hx"); maxY = tag.getByte("hy"); maxZ = tag.getByte("hz"); if (tag.hasKey("icon_id")) { icon_id = DataUtil.getBlock(tag.getShort("icon_id")); } else { icon_id = DataUtil.getBlockFromName(tag.getString("icon_idC")); } icon_md = tag.getByte("icon_md"); if (tag.hasKey("icon_sd")) { icon_side = tag.getByte("icon_sd"); } else { icon_side = -1; } quat = Quaternion.loadFromTag(tag, "r"); return this; }
void write(ArrayList<Object> out) { out.add(minX); out.add(minY); out.add(minZ); out.add(maxX); out.add(maxY); out.add(maxZ); out.add((short) DataUtil.getId(icon_id)); out.add(icon_md); out.add(icon_side); out.add(quat); }
ClayLump read(ByteBuf in) throws IOException { minX = in.readByte(); minY = in.readByte(); minZ = in.readByte(); maxX = in.readByte(); maxY = in.readByte(); maxZ = in.readByte(); icon_id = DataUtil.getBlock(in.readShort()); icon_md = in.readByte(); icon_side = in.readByte(); quat = Quaternion.read(in); return this; }
public void visit(TournamentSnapshotPacket packet) { try { String name = "n/a"; int players = 0; int regged = 0; int cap = 0; for (Param p : packet.params) { if (p.key.equals(TournamentAttributes.NAME.toString())) name = convertParamToStringParameter(p).getValue(); if (p.key.equals(TournamentAttributes.REGISTERED.toString())) regged = DataUtil.byteArrayToInt(p.value); if (p.key.equals(TournamentAttributes.CAPACITY.toString())) cap = DataUtil.byteArrayToInt(p.value); if (p.key.equals(TournamentAttributes.ACTIVE_PLAYERS.toString())) players = DataUtil.byteArrayToInt(p.value); } String info = "MTT [" + packet.mttid + "]\t " + name + "\t (" + players + ") " + regged + "/" + cap + "\t " + "domain: " + packet.address; // info += printParameters(packet.params); System.out.println(info); } catch (Exception e) { e.printStackTrace(); } }
/** * _more_ * * @param dataChoice _more_ * @param selection _more_ * @param timeDriverTimes _more_ * @return _more_ */ public List getAllTimesForTimeDriver( DataChoice dataChoice, DataSelection selection, List<DateTime> timeDriverTimes) { List results = null; List<DateTime> collectionTimes = new ArrayList(); DateTime[] soundingTimes = raobDataSet.getSoundingAdapter().getSoundingTimes(); for (int i = 0; i < soundingTimes.length; i++) { collectionTimes.add(soundingTimes[i]); } try { results = DataUtil.selectTimesFromList(collectionTimes, timeDriverTimes); } catch (Exception e) { } initTimes = results; return results; }
/** * @Title: encryptParams @Description: TODO(这里用一句话描述这个方法的作用) * * @param @param params * @param @return * @param @throws Exception 设定文件 * @return String 把url参数加密 * @throws */ public static String encryptParams(Map<String, String> params) throws Exception { Iterator<String> iter = params.keySet().iterator(); StringBuffer sb = new StringBuffer(); while (iter.hasNext()) { String k = iter.next(); String v = params.get(k); if (sb.length() > 0) sb.append("&"); sb.append(k); sb.append('='); sb.append(URLEncoder.encode(v, "UTF-8")); } String str = sb.toString(); // return "__=" + DataUtil.encodeECBAsHexString(password, str); return "__=" + DataUtil.encodeECBAsBase64String(password, str); }
void write(NBTTagCompound tag) { tag.setByte("lx", minX); tag.setByte("ly", minY); tag.setByte("lz", minZ); tag.setByte("hx", maxX); tag.setByte("hy", maxY); tag.setByte("hz", maxZ); // tag.setShort("icon_id", (short) FzUtil.getId(icon_id)); String iname = DataUtil.getName(icon_id); if (iname != null) { tag.setString("icon_idC", iname); } tag.setByte("icon_md", icon_md); tag.setByte("icon_sd", icon_side); quat.writeToTag(tag, "r"); }
/** * _more_ * * @return _more_ * @throws Exception _more_ */ private boolean initConnection() throws Exception { if (getConnection() == null) { return false; } // jdbc:postgresql://eol-rt-data.guest.ucar.edu/real-time // evaluate("CREATE RULE update AS ON UPDATE TO global_attributes DO NOTIFY current;"); Statement stmt; ResultSet results; SqlUtil.Iterator iter; EolDbTrackInfo trackInfo = new EolDbTrackInfo(this, "TRACK"); Hashtable cats = new Hashtable(); try { stmt = select("*", TABLE_CATEGORIES); iter = SqlUtil.getIterator(stmt); while ((results = iter.getNext()) != null) { cats.put(results.getString(COL_VARIABLE), results.getString(COL_CATEGORY)); } } catch (Exception exc) { // exc.printStackTrace(); } missingMap = new Hashtable(); stmt = select("*", TABLE_GLOBALS); globals = new Hashtable(); boolean gotCoords = false; description = "<b>Globals</b><br>"; iter = SqlUtil.getIterator(stmt); while ((results = iter.getNext()) != null) { String globalName = results.getString(1).trim(); String globalValue = results.getString(2).trim(); globals.put(globalName, globalValue); description = description + "<tr valign=\"top\"><td>" + globalName + "</td><td>" + globalValue + "</td></tr>"; // System.err.println(globalName +"=" + globalValue); if (globalName.equals(GLOBAL_STARTTIME)) { startTime = new DateTime(DateUtil.parse(globalValue)); } else if (globalName.equals(GLOBAL_ENDTIME)) { endTime = new DateTime(DateUtil.parse(globalValue)); } else if (globalName.equals(GLOBAL_COORDINATES)) { List toks = StringUtil.split(globalValue, " ", true, true); if (toks.size() != 4) { throw new BadDataException("Incorrect coordinates value in database:" + globalValue); } gotCoords = true; System.err.println("coords:" + toks); trackInfo.setCoordinateVars( (String) toks.get(0), (String) toks.get(1), (String) toks.get(2), (String) toks.get(3)); trackInfo.setCoordinateVars("GGLON", "GGLAT", "GGALT", "datetime"); } } description = description + "</table>"; if (!gotCoords) { throw new BadDataException("No coordinates found in database"); } this.name = (String) globals.get(GLOBAL_PROJECTNAME); String flight = (String) globals.get(GLOBAL_FLIGHTNUMBER); if ((this.name != null) && (flight != null) && (flight.length() != 0)) { this.name += " - " + flight; } stmt = select("*", TABLE_VARIABLE_LIST); iter = SqlUtil.getIterator(stmt); while ((results = iter.getNext()) != null) { String name = results.getString(COL_NAME).trim(); String desc = results.getString(COL_LONG_NAME).trim(); Unit unit = DataUtil.parseUnit(results.getString(COL_UNITS).trim()); String cat = (String) cats.get(name); double missing = results.getDouble(COL_MISSING_VALUE); VarInfo variable = new VarInfo(name, desc, cat, unit, missing); trackInfo.addVariable(variable); } addTrackInfo(trackInfo); return true; }
public static Parameter<Integer> convertParamToByteParameter(Param p) { int i = DataUtil.byteArrayToInt(p.value); Parameter<Integer> param = new Parameter<Integer>(p.key, i, Type.STRING); return param; }