List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:edu.hawaii.soest.pacioos.text.SimpleTextSource.java
/** * Constructor: create an instance of the simple SimpleTextSource * @param xmlConfig //from www . ja va 2 s . co m */ public SimpleTextSource(XMLConfiguration xmlConfig) throws ConfigurationException { this.xmlConfig = xmlConfig; // Pull the general configuration from the properties file Configuration config = new PropertiesConfiguration("textsource.properties"); this.archiveMode = config.getString("textsource.archive_mode"); this.rbnbChannelName = config.getString("textsource.rbnb_channel"); this.serverName = config.getString("textsource.server_name "); this.delimiter = config.getString("textsource.delimiter"); this.pollInterval = config.getInt("textsource.poll_interval"); this.retryInterval = config.getInt("textsource.retry_interval"); this.defaultDateFormat = new SimpleDateFormat(config.getString("textsource.default_date_format")); // parse the record delimiter from the config file // set the XML configuration in the simple text source for later use this.setConfiguration(xmlConfig); // set the common configuration fields String connectionType = this.xmlConfig.getString("connectionType"); this.setConnectionType(connectionType); String channelName = xmlConfig.getString("channelName"); this.setChannelName(channelName); String identifier = xmlConfig.getString("identifier"); this.setIdentifier(identifier); String rbnbName = xmlConfig.getString("rbnbName"); this.setRBNBClientName(rbnbName); String rbnbServer = xmlConfig.getString("rbnbServer"); this.setServerName(rbnbServer); int rbnbPort = xmlConfig.getInt("rbnbPort"); this.setServerPort(rbnbPort); int archiveMemory = xmlConfig.getInt("archiveMemory"); this.setCacheSize(archiveMemory); int archiveSize = xmlConfig.getInt("archiveSize"); this.setArchiveSize(archiveSize); // set the default channel information Object channels = xmlConfig.getList("channels.channel.name"); int totalChannels = 1; if (channels instanceof Collection) { totalChannels = ((Collection<?>) channels).size(); } // find the default channel with the ASCII data string for (int i = 0; i < totalChannels; i++) { boolean isDefaultChannel = xmlConfig.getBoolean("channels.channel(" + i + ")[@default]"); if (isDefaultChannel) { String name = xmlConfig.getString("channels.channel(" + i + ").name"); this.setChannelName(name); String dataPattern = xmlConfig.getString("channels.channel(" + i + ").dataPattern"); this.setPattern(dataPattern); String fieldDelimiter = xmlConfig.getString("channels.channel(" + i + ").fieldDelimiter"); // handle hex-encoded field delimiters if (fieldDelimiter.startsWith("0x") || fieldDelimiter.startsWith("\\x")) { Byte delimBytes = Byte.parseByte(fieldDelimiter.substring(2), 16); byte[] delimAsByteArray = new byte[] { delimBytes.byteValue() }; String delim = null; try { delim = new String(delimAsByteArray, 0, delimAsByteArray.length, "ASCII"); } catch (UnsupportedEncodingException e) { throw new ConfigurationException("There was an error parsing the field delimiter." + " The message was: " + e.getMessage()); } this.setDelimiter(delim); } else { this.setDelimiter(fieldDelimiter); } String[] recordDelimiters = xmlConfig .getStringArray("channels.channel(" + i + ").recordDelimiters"); this.setRecordDelimiters(recordDelimiters); // set the date formats list List<String> dateFormats = (List<String>) xmlConfig .getList("channels.channel(" + i + ").dateFormats.dateFormat"); if (dateFormats.size() != 0) { for (String dateFormat : dateFormats) { // validate the date format string try { SimpleDateFormat format = new SimpleDateFormat(dateFormat); } catch (IllegalFormatException ife) { String msg = "There was an error parsing the date format " + dateFormat + ". The message was: " + ife.getMessage(); if (log.isDebugEnabled()) { ife.printStackTrace(); } throw new ConfigurationException(msg); } } setDateFormats(dateFormats); } else { log.warn("No date formats have been configured for this instrument."); } // set the date fields list List<String> dateFieldList = xmlConfig.getList("channels.channel(" + i + ").dateFields.dateField"); List<Integer> dateFields = new ArrayList<Integer>(); if (dateFieldList.size() != 0) { for (String dateField : dateFieldList) { try { Integer newDateField = new Integer(dateField); dateFields.add(newDateField); } catch (NumberFormatException e) { String msg = "There was an error parsing the dateFields. The message was: " + e.getMessage(); throw new ConfigurationException(msg); } } setDateFields(dateFields); } else { log.warn("No date fields have been configured for this instrument."); } String timeZone = xmlConfig.getString("channels.channel(" + i + ").timeZone"); this.setTimezone(timeZone); break; } } // Check the record delimiters length and set the first and optionally second delim characters if (this.recordDelimiters.length == 1) { this.firstDelimiterByte = (byte) Integer.decode(this.recordDelimiters[0]).byteValue(); } else if (this.recordDelimiters.length == 2) { this.firstDelimiterByte = (byte) Integer.decode(this.recordDelimiters[0]).byteValue(); this.secondDelimiterByte = (byte) Integer.decode(this.recordDelimiters[1]).byteValue(); } else { throw new ConfigurationException("The recordDelimiter must be one or two characters, " + "separated by a pipe symbol (|) if there is more than one delimiter character."); } byte[] delimiters = new byte[] {}; }
From source file:de.questmaster.fatremote.fragments.RemoteFragment.java
@Override public void onClick(View v) { // show button again EditText text = (EditText) c.findViewById(R.id.enterText); if (text.getVisibility() == View.VISIBLE) { hideKeyboard();//w w w . j a v a 2s . c om } // solve to code if (v instanceof ImageView) { ImageView bv = (ImageView) v; // NOSONAR String t = (String) bv.getTag(); if (t.equals("text")) { showKeyboard(); return; } else { keyCode = Integer.decode(t).shortValue(); } } keyModifier = 0x00; // send keyCode invokeSend(); }
From source file:org.jbpm.formModeler.components.editor.WysiwygFormEditor.java
public void actionStartEdit(CommandRequest request) throws Exception { checkEditionContext(request);/*from w ww . j av a 2s . c o m*/ Integer pos = Integer.decode(request.getParameter("position")); setCurrentEditFieldPosition(pos.intValue()); Field editField = getCurrentEditField(); Form formToEdit = getFormForFieldEdition(editField); if (formToEdit != null) { String editNamespace = getFieldEditionNamespace(editField); getFormProcessor().clear(formToEdit, editNamespace); getFormProcessor().read(formToEdit, editNamespace, editField.asMap()); } getEditionContext().setOriginalFieldType(editField.getFieldType()); }
From source file:org.jbpm.formModeler.core.processing.fieldHandlers.multipleSubform.SubFormSendHandler.java
public void previewItem(CommandRequest request, boolean doIt) throws Exception { String[] uids = request.getRequestObject().getParameterValues("child_uid_value"); String uid = ""; if (uids != null) { for (int i = 0; i < uids.length; i++) { if (uids[i] != null && !"".equals(uids[i])) uid = uids[i];/*w w w.j ava2s .c o m*/ } } String index = request.getParameter(uid + "_index"); String parentFormId = request.getParameter(uid + "_parentFormId"); String parentNamespace = request.getParameter(uid + "_parentNamespace"); String inputName = request.getParameter(uid + "_inputName"); Form form = subformFinderService.getFormById(Long.decode(parentFormId), parentNamespace); getFormProcessor().setValues(form, parentNamespace, request.getRequestObject().getParameterMap(), request.getFilesByParamName()); if (doIt) { helper.setPreviewFieldPosition(inputName, Integer.decode(index)); } else { helper.clearPreviewFieldPositions(inputName); } getFormProcessor().clearFieldErrors(form, parentNamespace); }
From source file:org.apache.jmeter.protocol.jdbc.AbstractJDBCwoTimeOutTestElement.java
private static int getJdbcType(final String jdbcType) throws SQLException { Integer entry = mapJdbcNameToInt.get(jdbcType.toLowerCase(java.util.Locale.ENGLISH)); if (entry == null) { try {//from w w w .jav a2 s .co m entry = Integer.decode(jdbcType); } catch (final NumberFormatException e) { throw new SQLException("Invalid data type: " + jdbcType); } } return (entry).intValue(); }
From source file:org.jboss.dashboard.workspace.export.WorkspaceBuilder.java
protected void createPanel(CreateResult result, Section section, XMLNode node, Map attributes, boolean onStartup) throws Exception { String id = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_ID); String instanceId = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_INSTANCE_ID); String regionId = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_REGION_ID); String position = node.getAttributes().getProperty(ExportVisitor.PANEL_ATTR_POSITION); Panel panel = new Panel(); panel.setSection(section);//from ww w. jav a 2s . c o m panel.setPosition(Integer.decode(position).intValue()); panel.setPanelId(Long.decode(id)); panel.setInstanceId(Long.decode(instanceId)); if (regionId != null) { panel.getProvider().getDriver().fireBeforePanelPlacedInRegion(panel, section.getLayout().getRegion(regionId)); panel.setLayoutRegionId(regionId); } UIServices.lookup().getPanelsManager().store(panel); // Add panel to section section.assignPanel(panel, regionId); UIServices.lookup().getSectionsManager().store(section); panel.getProvider().getDriver().fireAfterPanelPlacedInRegion(panel, null); for (int i = 0; i < node.getChildren().size(); i++) { XMLNode child = (XMLNode) node.getChildren().get(i); if (ExportVisitor.PERMISSION.equals(child.getObjectName())) { createPermission(result, panel.getWorkspace(), panel, child, attributes); } } }
From source file:org.apache.easyant.core.EasyAntMain.java
/** * Process command line arguments. When ant is started from Launcher, launcher-only arguments do not get passed * through to this routine.//w ww . j a v a2 s . co m * * @since Ant 1.6 */ private void processArgs(CommandLine line) { String searchForThis; PrintStream logTo = null; if (line.hasOption("help")) { printUsage(); return; } if (easyAntConfiguration.getMsgOutputLevel() >= Project.MSG_VERBOSE || line.hasOption("version")) { printVersion(); if (line.hasOption("version")) { return; } } if (line.hasOption("showMemoryDetails")) { easyAntConfiguration.setShowMemoryDetails(true); } if (line.hasOption("diagnostics")) { Diagnostics.doReport(System.out, easyAntConfiguration.getMsgOutputLevel()); return; } if (line.hasOption("quiet")) { easyAntConfiguration.setMsgOutputLevel(Project.MSG_WARN); } if (line.hasOption("verbose")) { easyAntConfiguration.setMsgOutputLevel(Project.MSG_VERBOSE); } if (line.hasOption("debug")) { easyAntConfiguration.setMsgOutputLevel(Project.MSG_DEBUG); } if (line.hasOption("noinput")) { easyAntConfiguration.setAllowInput(false); } if (line.hasOption("logfile")) { try { File logFile = new File(line.getOptionValue("logfile")); logTo = new PrintStream(new FileOutputStream(logFile)); isLogFileUsed = true; } catch (IOException ioe) { String msg = "Cannot write on the specified log file. " + "Make sure the path exists and you have write " + "permissions."; throw new BuildException(msg); } catch (ArrayIndexOutOfBoundsException aioobe) { String msg = "You must specify a log file when " + "using the -log argument"; throw new BuildException(msg); } } if (line.hasOption("buildmodule")) { File buildModule = new File(line.getOptionValue("buildmodule").replace('/', File.separatorChar)); easyAntConfiguration.setBuildModule(buildModule); } if (line.hasOption("buildfile")) { File buildFile = new File(line.getOptionValue("buildfile").replace('/', File.separatorChar)); easyAntConfiguration.setBuildFile(buildFile); } if (line.hasOption("buildconf")) { easyAntConfiguration.getActiveBuildConfigurations().add(line.getOptionValue("buildconf")); } File easyantConfFile = null; if (line.hasOption("configfile")) { easyantConfFile = new File(line.getOptionValue("configfile").replace('/', File.separatorChar)); } else { // if no command line switch is specified check the default location File easyantHome = new File( System.getProperty(EasyAntMagicNames.EASYANT_HOME).replace('/', File.separatorChar)); File defaultGlobalEasyantConfFile = new File(easyantHome, EasyAntConstants.DEFAULT_GLOBAL_EASYANT_CONF_FILE); if (defaultGlobalEasyantConfFile.exists()) { easyantConfFile = defaultGlobalEasyantConfFile; } } if (easyantConfFile != null) { try { easyAntConfiguration = EasyantConfigurationFactory.getInstance() .createConfigurationFromFile(easyAntConfiguration, easyantConfFile.toURI().toURL()); } catch (Exception e) { throw new BuildException(e); } } if (line.hasOption("listener")) { easyAntConfiguration.getListeners().add(line.getOptionValue("listener")); } if (line.hasOption("D")) { easyAntConfiguration.getDefinedProps().putAll(line.getOptionProperties("D")); } if (line.hasOption("logger")) { if (easyAntConfiguration.getLoggerClassname() != null) { throw new BuildException("Only one logger class may be specified."); } easyAntConfiguration.setLoggerClassname(line.getOptionValue("logger")); } if (line.hasOption("inputhandler")) { if (easyAntConfiguration.getInputHandlerClassname() != null) { throw new BuildException("Only one input handler class may " + "be specified."); } easyAntConfiguration.setInputHandlerClassname(line.getOptionValue("inputhandler")); } if (line.hasOption("emacs")) { easyAntConfiguration.setEmacsMode(true); } if (line.hasOption("projecthelp")) { // set the flag to display the targets and quit projectHelp = true; } if (line.hasOption("find")) { // eat up next arg if present, default to module.ivy if (line.getOptionValues("find").length > 0) { searchForThis = line.getOptionValue("find"); } else { searchForThis = EasyAntConstants.DEFAULT_BUILD_MODULE; } easyAntConfiguration.setBuildModule(new File(searchForThis)); easyAntConfiguration.setBuildModuleLookupEnabled(true); } if (line.hasOption("propertyfile")) { propertyFiles.add(line.getOptionValue("propertyfile")); } if (line.hasOption("keep-going")) { easyAntConfiguration.setKeepGoingMode(true); } if (line.hasOption("offline")) { easyAntConfiguration.setOffline(true); } if (line.hasOption("nice")) { easyAntConfiguration.setThreadPriority(Integer.decode(line.getOptionValue("nice"))); if (easyAntConfiguration.getThreadPriority() < Thread.MIN_PRIORITY || easyAntConfiguration.getThreadPriority() > Thread.MAX_PRIORITY) { throw new BuildException("Niceness value is out of the range 1-10"); } } if (line.hasOption("autoproxy")) { easyAntConfiguration.setProxy(true); } if (!line.getArgList().isEmpty()) { for (Object o : line.getArgList()) { String target = (String) o; easyAntConfiguration.getTargets().add(target); } } // Load the property files specified by -propertyfile loadPropertyFiles(); if (logTo != null) { easyAntConfiguration.setOut(logTo); easyAntConfiguration.setErr(logTo); System.setOut(easyAntConfiguration.getOut()); System.setErr(easyAntConfiguration.getErr()); } readyToRun = true; }
From source file:org.kchine.r.server.http.RHttpProxy.java
private static GDDevice newDevice(String url, String sessionId, int width, int height, boolean broadcasted) throws TunnelingException { GetMethod getNewDevice = null;//from w ww .j a va 2 s . c om try { Object result = null; mainHttpClient = new HttpClient(); if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) { mainHttpClient.getHostConfiguration().setProxy(System.getProperty("proxy_host"), Integer.decode(System.getProperty("proxy_port"))); } getNewDevice = new GetMethod(url + "?method=newdevice" + "&width=" + width + "&height=" + height + "&broadcasted=" + broadcasted); try { if (sessionId != null && !sessionId.equals("")) { getNewDevice.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); getNewDevice.setRequestHeader("Cookie", "JSESSIONID=" + sessionId); } mainHttpClient.executeMethod(getNewDevice); result = new ObjectInputStream(getNewDevice.getResponseBodyAsStream()).readObject(); } catch (ConnectException e) { throw new ConnectionFailedException(); } catch (Exception e) { throw new TunnelingException("", e); } if (result != null && result instanceof TunnelingException) { throw (TunnelingException) result; } String deviceName = (String) result; return (GDDevice) RHttpProxy.getDynamicProxy(url, sessionId, deviceName, new Class[] { GDDevice.class }, new HttpClient(new MultiThreadedHttpConnectionManager())); } finally { if (getNewDevice != null) { getNewDevice.releaseConnection(); } if (mainHttpClient != null) { } } }
From source file:org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.java
private static int getJdbcType(String jdbcType) throws SQLException { Integer entry = (Integer) mapJdbcNameToInt.get(jdbcType.toLowerCase(java.util.Locale.ENGLISH)); if (entry == null) { try {/* w ww . j a v a2s .c om*/ entry = Integer.decode(jdbcType); } catch (NumberFormatException e) { throw new SQLException("Invalid data type: " + jdbcType); } } return (entry).intValue(); }
From source file:org.apache.jackrabbit.core.persistence.bundle.BundleDbPersistenceManager.java
/** * Sets the minimum blob size. This size defines the threshold of which * size a property is included in the bundle or is stored in the blob store. * * @param minBlobSize the minimum blobsize in bytes. *///from w ww . jav a 2 s . c om public void setMinBlobSize(String minBlobSize) { this.minBlobSize = Integer.decode(minBlobSize).intValue(); }