List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:PVGraph.java
public static void main(String[] args) { loadProperties();/*from w w w . j a v a 2 s. com*/ try { Class.forName("com.mysql.jdbc.Driver").newInstance(); getDatabaseConnection(); } catch (SQLException e) { System.err.println("Cannot establish database connection: " + e.getMessage()); } catch (Exception e) { System.err.println(e.getMessage()); } if (conn != null) { // create first window new PVGraph(); int smatoolPeriod = Integer.decode(props.getProperty("smatool.period", "0")); while (smatoolPeriod > 0) { loadProperties(); smatoolPeriod = Integer.decode(props.getProperty("smatool.period", "0")); int smatoolStartHour = Integer.decode(props.getProperty("smatool.starthour", "0")); int smatoolEndHour = Integer.decode(props.getProperty("smatool.endhour", "24")); GregorianCalendar now = new GregorianCalendar(); int nowHour = now.get(Calendar.HOUR_OF_DAY); if (nowHour >= smatoolStartHour && nowHour < smatoolEndHour) { try { runSmatool(); synchronized (graphs) { for (PVGraph g : graphs) g.updateView(); } } catch (IOException ioe) { System.err.println(ioe.getMessage()); } } try { Thread.sleep(smatoolPeriod * 60 * 1000); } catch (InterruptedException ie) { // break; } } } }
From source file:org.kchine.r.server.RListener.java
public static String[] makeRLink(final String mode, final String[] params, final String[] name) { if (name.length > 1) { String[] rlinkNames = new String[name.length]; for (int i = 0; i < name.length; ++i) { String result[] = makeRLink(mode, params, name[i]); rlinkNames[i] = result[0];/*from w w w . j av a 2 s . co m*/ } return rlinkNames; } else { try { final String rlinkName = "RLINK_" + (RLINK_COUNTER++); _rlinkHash.put(rlinkName, new RLink(rlinkName, null)); new Thread(new Runnable() { public void run() { try { // _rlinkHash.get(rlinkName).setR(ServerManager.createR(rlinkName)); Properties props = new Properties(); if (params != null && params.length > 0) { for (int i = 0; i < params.length; i++) { String element = params[i]; int p = element.indexOf('='); if (p == -1) { props.put(element.toLowerCase(), ""); } else { props.put(element.substring(0, p).trim().toLowerCase(), element.substring(p + 1, element.length()).trim()); } } } System.out.println(props); RServices r = null; if (mode.equalsIgnoreCase("self")) { r = DirectJNI.getInstance().getRServices(); } else if (mode.equalsIgnoreCase("new")) { if (props.get("naming.mode") == null) { props.put("naming.mode", "self"); } String codeServerHost = null; int codeServerPort = -1; if ((System.getProperty("code.server.host") != null) && (System.getProperty("code.server.port") != null) && !System.getProperty("code.server.host").equals("") && !System.getProperty("code.server.port").equals("")) { codeServerHost = System.getProperty("code.server.host"); codeServerPort = Integer.decode(System.getProperty("code.server.port")); System.out.println("code.server.host:" + codeServerHost); System.out.println("code.server.port:" + codeServerPort); } else { codeServerHost = PoolUtils.getHostIp(); codeServerPort = LocalHttpServer.getLocalHttpServerPort(); } boolean useEmbeddedR = props.getProperty("use_embedded_r") == null || props.getProperty("use_embedded_r").equals("") ? false : new Boolean(props.getProperty("use_embedded_r")); r = ServerManager.createR(props.getProperty("r.binary"), useEmbeddedR, false, codeServerHost, codeServerPort, props, props.get("memorymin") == null ? ServerDefaults._memoryMin : Integer.decode(props.getProperty("memorymin")), props.get("memorymax") == null ? ServerDefaults._memoryMax : Integer.decode(props.getProperty("memorymax")), name[0], false, null, null, System.getProperty("application_type"), null, "127.0.0.1"); r.consoleSubmit("setwd('" + DirectJNI.getInstance().getRServices() .getWorkingDirectory().replace('\\', '/') + "')"); r.consoleSubmit("father=rlink.make('rmi',c('stub=" + DirectJNI.getInstance().getRServices().getStub() + "'))"); } else if (mode.equalsIgnoreCase("rmi")) { try { if (props.getProperty("stub") != null) { r = (RServices) PoolUtils.hexToStub(props.getProperty("stub"), RListener.class.getClassLoader()); } else { r = (RServices) ServerDefaults.getRegistry(props).lookup(name[0]); } } catch (Exception e) { e.printStackTrace(); DirectJNI.getInstance().getRServices().consoleSubmit(convertToPrintCommand( "RLink Creation Failed\nuse rlink.show to see creation error")); _rlinkHash.get(rlinkName).setCreationException(e); } } else if (mode.equalsIgnoreCase("http")) { try { HashMap<String, Object> options = new HashMap<String, Object>(); if (props.getProperty("privatename") != null) { options.put("privatename", props.getProperty("privatename")); } if (props.getProperty("memorymin") != null) { options.put("memorymin", props.getProperty("memorymin")); } if (props.getProperty("memorymax") != null) { options.put("memorymax", props.getProperty("memorymax")); } final String sessionId = RHttpProxy.logOn(props.getProperty("url"), "", props.getProperty("login") == null ? "guest" : props.getProperty("login"), props.getProperty("password") == null ? "guest" : props.getProperty("password"), options); r = RHttpProxy.getR(props.getProperty("url"), sessionId, true, 30); } catch (Exception e) { e.printStackTrace(); DirectJNI.getInstance().getRServices().consoleSubmit(convertToPrintCommand( "RLink Creation Failed\nuse rlink.show to see creation error")); _rlinkHash.get(rlinkName).setCreationException(e); } } _rlinkHash.get(rlinkName).setR(r); try { DirectJNI.getInstance().getRServices().consoleSubmit(convertToPrintCommand( "RLink Creation Succeeded\nuse rlink.show to get creation details")); } catch (Exception e) { e.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); _rlinkHash.get(rlinkName).setCreationException(ex); try { DirectJNI.getInstance().getRServices().consoleSubmit(convertToPrintCommand( "RLink Creation Failed!\n" + PoolUtils.getStackTraceAsString(ex))); } catch (Exception e) { e.printStackTrace(); } } } }).start(); return new String[] { rlinkName }; } catch (Exception e) { e.printStackTrace(); return new String[] { "NOK", convertToPrintCommand("couldn't create rlink") }; } } }
From source file:org.ohmage.query.impl.DocumentQueries.java
/** * Gets the directory to which a new file should be saved. This should be * used instead of accessing the class-level variable directly as it * handles the creation of new folders and the checking that the current * folder is not full./*from w ww . ja va 2 s .c o m*/ * * @return A File object for where a document should be written. */ private File getDirectory() throws DataAccessException { // Get the maximum number of items in a directory. int numFilesPerDirectory; try { numFilesPerDirectory = Integer.decode( PreferenceCache.instance().lookup(PreferenceCache.KEY_MAXIMUM_NUMBER_OF_FILES_PER_DIRECTORY)); } catch (CacheMissException e) { throw new DataAccessException("Preference cache doesn't know about 'known' key: " + PreferenceCache.KEY_MAXIMUM_NUMBER_OF_FILES_PER_DIRECTORY, e); } catch (NumberFormatException e) { throw new DataAccessException("Stored value for key '" + PreferenceCache.KEY_MAXIMUM_NUMBER_OF_FILES_PER_DIRECTORY + "' is not decodable as a number.", e); } // If the leaf directory was never initialized, then we should do // that. Note that the initialization is dumb in that it will get to // the end of the structure and not check to see if the leaf node is // full. if (currLeafDirectory == null) { init(numFilesPerDirectory); } File[] documents = currLeafDirectory.listFiles(); // If the _currLeafDirectory directory is full, traverse the tree and // find a new directory. if (documents.length >= numFilesPerDirectory) { getNewDirectory(numFilesPerDirectory); } return currLeafDirectory; }
From source file:org.ohmage.query.impl.DocumentQueries.java
/** * Initializes the directory structure by drilling down to the leaf * directory with each step choosing the directory with the largest * integer value./*w ww.ja va 2 s .com*/ */ private void init(int numFilesPerDirectory) throws DataAccessException { // Get the lock. DIRECTORY_CREATION_LOCK.lock(); try { // If the current leaf directory has been set, we weren't the // first to call init(), so we can just unlock the lock and back // out. if (currLeafDirectory != null) { return; } // Get the root directory from the preference cache based on the // key. String rootFile; try { rootFile = PreferenceCache.instance().lookup(PreferenceCache.KEY_DOCUMENT_DIRECTORY); } catch (CacheMissException e) { throw new DataAccessException("Preference cache doesn't know about 'known' key: " + PreferenceCache.KEY_DOCUMENT_DIRECTORY, e); } File rootDirectory = new File(rootFile); if (!rootDirectory.exists()) { throw new DataAccessException( "The root file doesn't exist suggesting an incomplete installation: " + rootFile); } else if (!rootDirectory.isDirectory()) { throw new DataAccessException("The root file isn't a directory."); } // Get the number of folders deep that documents are stored. int fileDepth; try { fileDepth = Integer .decode(PreferenceCache.instance().lookup(PreferenceCache.KEY_FILE_HIERARCHY_DEPTH)); } catch (CacheMissException e) { throw new DataAccessException("Preference cache doesn't know about 'known' key: " + PreferenceCache.KEY_FILE_HIERARCHY_DEPTH, e); } catch (NumberFormatException e) { throw new DataAccessException("Stored value for key '" + PreferenceCache.KEY_FILE_HIERARCHY_DEPTH + "' is not decodable as a number.", e); } DirectoryFilter directoryFilter = new DirectoryFilter(); File currDirectory = rootDirectory; for (int currDepth = 0; currDepth < fileDepth; currDepth++) { // Get the list of directories in the current directory. File[] currDirectories = currDirectory.listFiles(directoryFilter); // If there aren't any, create the first subdirectory in this // directory. if (currDirectories.length == 0) { String newFolderName = directoryNameBuilder(0, numFilesPerDirectory); currDirectory = new File(currDirectory.getAbsolutePath() + "/" + newFolderName); currDirectory.mkdir(); } // If the directory is overly full, step back up in the // structure. This should never happen, as it indicates that // there is an overflow in the structure. else if (currDirectories.length > numFilesPerDirectory) { LOGGER.warn("Too many subdirectories in: " + currDirectory.getAbsolutePath()); // Take a step back in our depth. currDepth--; // If, while backing up the tree, we back out of the root // directory, we have filled up the space. if (currDepth < 0) { throw new DataAccessException("Document structure full!"); } // Get the next parent and the current directory to it. int nextDirectoryNumber = Integer.decode(currDirectory.getName()) + 1; currDirectory = new File(currDirectory.getParent() + "/" + nextDirectoryNumber); // If the directory already exists, then there is either a // concurrency issue or someone else is adding files. // Either way, this shouldn't happen. if (currDirectory.exists()) { LOGGER.error("Somehow the 'new' directory already exists. This should be looked into: " + currDirectory.getAbsolutePath()); } // Otherwise, create the directory. else { currDirectory.mkdir(); } } // Drill down to the directory with the largest, numeric value. else { currDirectory = getLargestSubfolder(currDirectories); } } // After we have found a suitable directory, set it. currLeafDirectory = currDirectory; } catch (SecurityException e) { throw new DataAccessException( "The current process doesn't have sufficient permiossions to create new directories.", e); } finally { // No matter what happens, unlock the lock. DIRECTORY_CREATION_LOCK.unlock(); } }
From source file:com.l2jfree.gameserver.handler.admincommands.AdminEditNpc.java
private List<L2TradeList> getTradeLists(int merchantID) { String target = "npc_%objectId%_Buy"; String content = HtmCache.getInstance().getHtm("data/html/merchant/" + merchantID + ".htm"); if (content == null) { content = HtmCache.getInstance().getHtm("data/html/merchant/30001.htm"); if (content == null) return null; }/*from w w w . j a v a 2 s. c o m*/ List<L2TradeList> tradeLists = new FastList<L2TradeList>(); String[] lines = content.split("\n"); int pos = 0; for (String line : lines) { pos = line.indexOf(target); if (pos >= 0) { int tradeListID = Integer.decode((line.substring(pos + target.length() + 1)).split("\"")[0]); L2TradeList tl = TradeListTable.getInstance().getBuyList(tradeListID); if (!tl.isCustom()) tradeLists.add(tl); } } return tradeLists; }
From source file:edu.stanford.epad.epadws.service.RemotePACService.java
/** * Query a Remote PAC given patient/studydate filters of filter by DICOM TagGroup/Element/Value * @param pac/*ww w . ja v a2 s.c om*/ * @param patientNameFilter * @param patientIDFilter * @param studyIDFilter * @param studyDateFilter * @param tagGroups, eg tagGroups = {"0x0008"}; tagElements={"0x0070"}; tagValues={"GE Medical Systems"}; * @param tagElements * @param tagValues * @param patientsOnly * @param studiesOnly * @return * @throws Exception */ public synchronized List<RemotePACEntity> queryRemoteData(RemotePAC pac, String patientNameFilter, String patientIDFilter, String studyIDFilter, String studyDateFilter, String modality, String[] tagGroups, String[] tagElements, String[] tagValues, String[] tagTypes, boolean patientsOnly, boolean studiesOnly) throws Exception { try { String qlevel = null; if (studiesOnly) qlevel = "STUDY"; if (patientsOnly) qlevel = "PATIENT"; log.info("Remote PAC Query, pacID:" + pac.pacID + " patientName:" + patientNameFilter + " patientID:" + patientIDFilter + " studyDate:" + studyDateFilter + " studyIDFilter:" + studyIDFilter + " patientsOnly:" + patientsOnly + " studiesOnly:" + studiesOnly + " tagValues:" + tagValues); if ((patientNameFilter == null || patientNameFilter.length() == 0) && (patientIDFilter == null || patientIDFilter.length() == 0 || patientIDFilter.equals("1*")) && (tagGroups == null || tagGroups.length == 0) && patientsOnly) { if (patientCache.containsKey(pac.pacID)) return patientCache.get(pac.pacID); } if (currentPACQueries.containsKey(pac.pacID)) throw new Exception("Last query to this PAC still in progress"); if (patientNameFilter != null && patientNameFilter.equals("*")) patientNameFilter = ""; if (patientIDFilter != null && patientIDFilter.equals("*")) patientIDFilter = ""; this.setCurrentRemoteQueryInformationModel(pac.pacID); SpecificCharacterSet specificCharacterSet = new SpecificCharacterSet((String[]) null); AttributeList filter = new AttributeList(); currentPACQueries.put(pac.pacID, filter); { AttributeTag t = TagFromName.PatientName; Attribute a = new PersonNameAttribute(t, specificCharacterSet); if (patientNameFilter != null && patientNameFilter.length() > 0) { a.addValue(patientNameFilter.toUpperCase()); } filter.put(t, a); qlevel = "PATIENT"; } { AttributeTag t = TagFromName.PatientID; Attribute a = new ShortStringAttribute(t, specificCharacterSet); if (patientIDFilter != null && patientIDFilter.length() > 0) { a.addValue(patientIDFilter); } filter.put(t, a); qlevel = "PATIENT"; } // StudyDate formats: // from/to: 20071001-20080220 // before: -20080220 // after: 20071001- { AttributeTag t = TagFromName.StudyDate; Attribute a = new DateAttribute(t); if (studyDateFilter != null && studyDateFilter.length() > 0) { a.addValue(studyDateFilter); } filter.put(t, a); } { AttributeTag t = TagFromName.StudyInstanceUID; Attribute a = new UniqueIdentifierAttribute(t); if (studyIDFilter != null && studyIDFilter.length() > 0) { if (studyIDFilter.startsWith(pac.pacID + ":")) studyIDFilter = studyIDFilter.substring(studyIDFilter.indexOf(":") + 1); a.addValue(studyIDFilter); } filter.put(t, a); qlevel = "STUDY"; } { AttributeTag t = TagFromName.ModalitiesInStudy; Attribute a = new CodeStringAttribute(t); if (modality != null && modality.length() > 0) { a.addValue(modality.toUpperCase()); } filter.put(t, a); } if (tagGroups != null && tagElements != null && tagValues != null) { for (int i = 0; i < tagGroups.length && i < tagElements.length && i < tagValues.length; i++) { try { AttributeTag t = new AttributeTag(Integer.decode(tagGroups[i]), Integer.decode(tagElements[i])); Attribute a = null; if (tagTypes != null && tagTypes.length > i) { log.info("Attribute:" + t.toString() + " type:" + tagTypes[i] + " value:" + tagValues[i]); if (tagTypes[i].equalsIgnoreCase("LongString")) a = new LongStringAttribute(t, specificCharacterSet); else if (tagTypes[i].equalsIgnoreCase("ShortString")) a = new ShortStringAttribute(t, specificCharacterSet); else if (tagTypes[i].equalsIgnoreCase("Date")) a = new DateAttribute(t); else if (tagTypes[i].equalsIgnoreCase("Time")) a = new TimeAttribute(t); else if (tagTypes[i].equalsIgnoreCase("Integer")) a = new IntegerStringAttribute(t); else if (tagTypes[i].equalsIgnoreCase("Decimal")) a = new DecimalStringAttribute(t); else if (tagTypes[i].equalsIgnoreCase("Code")) a = new CodeStringAttribute(t); } else log.info("Attribute:" + t.toString() + " type:" + tagTypes + " value:" + tagValues[i]); if (a == null) a = new LongStringAttribute(t, specificCharacterSet); a.addValue(tagValues[i].toUpperCase()); filter.put(t, a); qlevel = "SERIES"; } catch (Exception x) { log.warning("Error decoding entered tag id" + tagGroups[i] + "," + tagElements[i], x); } } } if (qlevel != null) { AttributeTag t = TagFromName.QueryRetrieveLevel; Attribute a = new CodeStringAttribute(t); a.addValue(qlevel); if (!filter.containsKey(t)) { filter.put(t, a); } } { AttributeTag t = TagFromName.PatientBirthDate; Attribute a = new DateAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.PatientSex; Attribute a = new CodeStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.StudyID; Attribute a = new ShortStringAttribute(t, specificCharacterSet); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.StudyDescription; Attribute a = new LongStringAttribute(t, specificCharacterSet); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.StudyTime; Attribute a = new TimeAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } //{ AttributeTag t = TagFromName.PatientAge; Attribute a = new AgeStringAttribute(t); if (!filter.containsKey(t)) filter.put(t,a); } { AttributeTag t = TagFromName.SeriesDescription; Attribute a = new LongStringAttribute(t, specificCharacterSet); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SeriesNumber; Attribute a = new IntegerStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.Manufacturer; Attribute a = new LongStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.Modality; Attribute a = new CodeStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SeriesDate; Attribute a = new DateAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SeriesTime; Attribute a = new TimeAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.InstanceNumber; Attribute a = new IntegerStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.ContentDate; Attribute a = new DateAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.ContentTime; Attribute a = new TimeAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.ImageType; Attribute a = new CodeStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.NumberOfFrames; Attribute a = new IntegerStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.WindowCenter; Attribute a = new DecimalStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.WindowWidth; Attribute a = new DecimalStringAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SeriesInstanceUID; Attribute a = new UniqueIdentifierAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SOPInstanceUID; Attribute a = new UniqueIdentifierAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SOPClassUID; Attribute a = new UniqueIdentifierAttribute(t); if (!filter.containsKey(t)) filter.put(t, a); } { AttributeTag t = TagFromName.SpecificCharacterSet; Attribute a = new CodeStringAttribute(t); filter.put(t, a); a.addValue("ISO_IR 100"); } if (remoteQueryCache.keySet().size() > MAX_CACHE_ENTRIES) clearQueryCache(); List<RemotePACEntity> remoteEntities = new ArrayList<RemotePACEntity>(); String key = pac.pacID; long startTime = System.currentTimeMillis(); patientIds = new HashSet<String>(); QueryTreeModel treeModel = currentRemoteQueryInformationModel.performHierarchicalQuery(filter); long endTime = System.currentTimeMillis(); //log.info("Remote PAC Query took " + (endTime-startTime) + " msecs"); QueryTreeRecord root = (QueryTreeRecord) treeModel.getRoot(); remoteEntities = traverseTree(root, 0, remoteEntities, key, patientsOnly, studiesOnly); long traverseTime = System.currentTimeMillis(); log.info("Remote PAC tree records took " + (traverseTime - startTime) + " msecs. Number of entities returned:" + remoteEntities.size()); if (patientsOnly && remoteEntities.size() > 0) remoteEntities.remove(0); // Remove AE record else if (studiesOnly && remoteEntities.size() > 0) remoteEntities.remove(0); // Remove AE record if (studyIDFilter != null && studyIDFilter.length() > 0 && !studiesOnly && remoteEntities.size() > 1) { remoteEntities.remove(0); // Remove AE record remoteEntities.remove(0); // Remove Study Record } if (patientIDFilter != null && patientIDFilter.trim().length() > 0) { EpadProjectOperations projectOperations = DefaultEpadProjectOperations.getInstance(); EpadDatabaseOperations databaseOperations = EpadDatabase.getInstance().getEPADDatabaseOperations(); for (RemotePACEntity rpe : remoteEntities) { if (rpe.entityType.equalsIgnoreCase("Study")) { if (databaseOperations .hasStudyInDCM4CHE(rpe.entityID.substring(rpe.entityID.indexOf(":") + 1))) rpe.inEpad = true; } else if (rpe.entityType.equalsIgnoreCase("Series")) { if (databaseOperations .hasSeriesInEPadDatabase(rpe.entityID.substring(rpe.entityID.indexOf(":") + 1))) rpe.inEpad = true; } } } if ((patientNameFilter == null || patientNameFilter.length() == 0) && (patientIDFilter == null || patientIDFilter.length() == 0 || patientIDFilter.equals("1*")) && patientsOnly) { patientCache.put(pac.pacID, remoteEntities); } log.info("Returning " + remoteEntities.size() + " records"); return remoteEntities; } catch (Exception e) { e.printStackTrace(); throw e; } finally { currentPACQueries.remove(pac.pacID); } }
From source file:com.l2jfree.gameserver.handler.admincommands.AdminEditNpc.java
private List<L2TradeList> getCustomTradeLists(int merchantID) { String target = "npc_%objectId%_Buy"; String content = HtmCache.getInstance().getHtm("data/html/merchant/" + merchantID + ".htm"); if (content == null) { content = HtmCache.getInstance().getHtm("data/html/merchant/30001.htm"); if (content == null) return null; }//w ww. j a v a2 s .c o m List<L2TradeList> tradeLists = new FastList<L2TradeList>(); String[] lines = content.split("\n"); int pos = 0; for (String line : lines) { pos = line.indexOf(target); if (pos >= 0) { int tradeListID = Integer.decode((line.substring(pos + target.length() + 1)).split("\"")[0]); L2TradeList tl = TradeListTable.getInstance().getBuyList(tradeListID); if (tl.isCustom()) tradeLists.add(tl); } } return tradeLists; }
From source file:PVGraph.java
private static void runSmatool() throws IOException { String cmd = props.getProperty("smatool.cmd", "smatool"); System.out.println("Executing " + cmd + " at " + new java.util.Date()); Process p = Runtime.getRuntime().exec(cmd); if (Integer.decode(props.getProperty("smatool.printstdout", "0")) != 0) { BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line;// ww w . ja v a 2s . c om while ((line = br.readLine()) != null) { System.out.println(line); } } if (Integer.decode(props.getProperty("smatool.printstderr", "1")) != 0) { BufferedReader br = new BufferedReader(new InputStreamReader(p.getErrorStream())); String line; while ((line = br.readLine()) != null) { System.err.println(line); } } try { p.waitFor(); } catch (InterruptedException ie) { // relax } }
From source file:org.apache.ofbiz.base.util.UtilHttp.java
/** * Given multi form data with the ${param}_o_N notation, creates a Collection * of Maps for the submitted rows. Each Map contains the key/value pairs * of a particular row. The keys will be stripped of the _o_N suffix. * There is an additionaly key "row" for each Map that holds the * index of the row./* w ww. j ava2 s . c om*/ */ public static Collection<Map<String, Object>> parseMultiFormData(Map<String, Object> parameters) { Map<Integer, Map<String, Object>> rows = new HashMap<Integer, Map<String, Object>>(); // stores the rows keyed by row number // first loop through all the keys and create a hashmap for each ${ROW_SUBMIT_PREFIX}${N} = Y for (String key : parameters.keySet()) { // skip everything that is not ${ROW_SUBMIT_PREFIX}N if (key == null || key.length() <= ROW_SUBMIT_PREFIX_LENGTH) continue; if (key.indexOf(MULTI_ROW_DELIMITER) <= 0) continue; if (!key.substring(0, ROW_SUBMIT_PREFIX_LENGTH).equals(ROW_SUBMIT_PREFIX)) continue; if (!parameters.get(key).equals("Y")) continue; // decode the value of N and create a new map for it Integer n = Integer.decode(key.substring(ROW_SUBMIT_PREFIX_LENGTH, key.length())); Map<String, Object> m = new HashMap<String, Object>(); m.put("row", n); // special "row" = N tuple rows.put(n, m); // key it to N } // next put all parameters with matching N in the right map for (Map.Entry<String, Object> entry : parameters.entrySet()) { String key = entry.getKey(); // skip keys without DELIMITER and skip ROW_SUBMIT_PREFIX if (key == null) continue; int index = key.indexOf(MULTI_ROW_DELIMITER); if (index <= 0) continue; if (key.length() > ROW_SUBMIT_PREFIX_LENGTH && key.substring(0, ROW_SUBMIT_PREFIX_LENGTH).equals(ROW_SUBMIT_PREFIX)) continue; // get the map with index N Integer n = Integer.decode(key.substring(index + MULTI_ROW_DELIMITER_LENGTH, key.length())); // N from ${param}${DELIMITER}${N} Map<String, Object> map = rows.get(n); if (map == null) continue; // get the key without the <DELIMITER>N suffix and store it and its value String newKey = key.substring(0, index); map.put(newKey, entry.getValue()); } // return only the values, which is the list of maps return rows.values(); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
private void ChangeToTool(String changeToolString) { int i = Integer.decode(changeToolString); String[] toolNames = machineConfiguration.getToolNames(); if (i < 0 || i > toolNames.length) { Log("<span style='color:red'>" + translator.get("InvalidTool") + i + "</span>"); i = 0;/*from ww w.j a va 2 s .c om*/ } JOptionPane.showMessageDialog(null, translator.get("ChangeToolPrefix") + toolNames[i] + translator.get("ChangeToolPostfix")); }