List of usage examples for java.lang Byte byteValue
@HotSpotIntrinsicCandidate public byte byteValue()
From source file:org.apache.nutch.crawl.MapWritable.java
private byte getClassId(Class clazz) { Byte classId = CLASS_ID_MAP.get(clazz); if (classId != null) { return classId.byteValue(); }/*from w w w. j a v a 2s . c om*/ ClassIdEntry entry = fIdFirst; while (entry != null) { if (entry.fclazz.equals(clazz)) { return entry.fId; } entry = entry.fNextIdEntry; } return -128; }
From source file:org.acmsl.commons.utils.ConversionUtils.java
/** * Converts given String to byte./* w ww. j a v a 2 s . co m*/ * @param value the value to convert. * @return the converted value. */ public byte toByte(@Nullable final String value) { byte result = 0; @Nullable final Byte t_Result = toByteIfNotNull(value); if (t_Result != null) { result = t_Result.byteValue(); } return result; }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationPropertiesWithByteArray() { ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); Byte byteValue = config.byteArray[0]; assertEquals(Byte.class, byteValue.getClass()); assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); assertEquals(8, config.byteArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationXMLWithByteArray() { ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); Byte byteValue = config.byteArray[0]; assertEquals(Byte.class, byteValue.getClass()); assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); assertEquals(8, config.byteArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationPropertiesWithByteList() { ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); Byte byteValue = config.byteList.get(0); assertEquals(Byte.class, byteValue.getClass()); assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); assertEquals(8, config.byteList.size()); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationXMLWithByteList() { ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); Byte byteValue = config.byteList.get(0); assertEquals(Byte.class, byteValue.getClass()); assertEquals(Byte.MAX_VALUE, byteValue.byteValue()); assertEquals(8, config.byteList.size()); }
From source file:com.germinus.easyconf.ComponentProperties.java
public byte getByte(String key, Filter filter) { Byte value = getByte(key, filter, null); validateValue(key, value);/* www. j av a 2 s.c o m*/ return value.byteValue(); }
From source file:edu.hawaii.soest.pacioos.text.SimpleTextSource.java
/** * Constructor: create an instance of the simple SimpleTextSource * @param xmlConfig //from ww w.j a va 2 s . c o 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:com.google.gwt.sample.dynatablemvp.server.svc.SchoolCalendarService.java
public List<Person> getPeople(List<PersonRelation> personRelations, Integer startIndex, Integer maxCount, Byte filter) throws NoResultException { final List<Person> resultList; if (filter != null && filter != WeekDayStorage.ALL_DAYS) { int index = 0; final List<Person> allPersons = personService.fetchAllPersons(); resultList = new ArrayList<Person>(); for (Person person : allPersons) { lazyLoader.activateRelations(Arrays.asList(PersonRelation.SHEDULE), person); final Schedule classSchedule = person.getClassSchedule(); if (classSchedule != null) { final List<TimeSlot> resultTimes = new ArrayList<TimeSlot>(); List<TimeSlot> timeSlots = classSchedule.getTimeSlots(); WeekDayStorage weekDayStorage = new WeekDayStorage(); for (TimeSlot timeSlot : timeSlots) { weekDayStorage.setWeekDayBits((byte) 0); weekDayStorage.setWeekDayValue(timeSlot.getDayOfWeek(), true); if ((weekDayStorage.getWeekDayBits() & filter.byteValue()) != 0) { resultTimes.add(timeSlot); }/*from w w w . j a v a 2 s .c o m*/ } if (resultTimes.isEmpty() == false) { if ((startIndex < 0 ? true : index >= startIndex) && (maxCount > 0 ? resultList.size() < maxCount : true)) { classSchedule.setTimeSlots(resultTimes); lazyLoader.activateRelations(personRelations, person); resultList.add(person); } index++; } } } return resultList; } else { resultList = personService.fetchAllPersons(startIndex, maxCount); if (personRelations != null && personRelations.isEmpty() == false) for (Person person : resultList) { lazyLoader.activateRelations(personRelations, person); } } return resultList; }
From source file:com.sun.honeycomb.admin.mgmt.server.HCCellAdapterBase.java
public BigInteger setCellProps(EventSender evt, HCCellProps value, Byte cellid) throws MgmtException { boolean updateSwitch = false; boolean updateSp = false; boolean isUpdateLocal = (localCellid == cellid.byteValue()) ? true : false; HashMap map = new HashMap(); if (!value.getAdminVIP().equals(MultiCellLib.getInstance().getAdminVIP())) { updateSp = true;//from w ww .jav a 2 s.c om updateSwitch = true; map.put(MultiCellLib.PROP_ADMIN_VIP, value.getAdminVIP()); } if (!value.getDataVIP().equals(MultiCellLib.getInstance().getDataVIP())) { updateSp = true; updateSwitch = true; map.put(MultiCellLib.PROP_DATA_VIP, value.getDataVIP()); } if (!value.getSpVIP().equals(MultiCellLib.getInstance().getSPVIP())) { updateSwitch = true; updateSp = true; map.put(MultiCellLib.PROP_SP_VIP, value.getSpVIP()); } if (!value.getSubnet().equals(MultiCellLib.getInstance().getSubnet())) { updateSwitch = true; updateSp = true; map.put(MultiCellLib.PROP_SUBNET, value.getSubnet()); } if (!value.getGateway().equals(MultiCellLib.getInstance().getGateway())) { updateSwitch = true; updateSp = true; map.put(MultiCellLib.PROP_GATEWAY, value.getGateway()); } if (map.size() != 0) { if (!isUpdateLocal) { // Update the of silo_info.xml properties on the local cell MultiCellLib.getInstance().updateProperties(cellid.byteValue(), map); try { evt.sendAsynchronousEvent( "successfully updated the " + "configuration [cell " + localCellid + "]"); } catch (MgmtException e) { logger.severe("failed to send synchronous event " + e); } // // Other cells-- on which no configuration change occur need to // notify Multicell about those changes. // Cell updatedCell = new Cell(cellid.byteValue(), value.getAdminVIP(), value.getDataVIP(), value.getSpVIP(), null, value.getSubnet(), value.getGateway()); // TODO: This code isn't valid for the emulator // Proxy calls don't seem to be supported. The // call to api.cahngeCellCfg() will fail with a class not // found exception. Need to fix for the emulator MultiCellIntf api = MultiCellIntf.Proxy.getMultiCellAPI(); if (api == null) { logger.severe("failed to grab multicellAPI"); if (MultiCellLib.getInstance().isCellMaster()) { throw new MgmtException("Internal error while " + "notifying services on master cell. Will " + " require a reboot of the master cell [cell " + localCellid + "]"); } else { return BigInteger.valueOf(-1); } } try { api.changeCellCfg(updatedCell); } catch (Exception e) { logger.log(Level.SEVERE, "failed to update Multicell service", e); if (MultiCellLib.getInstance().isCellMaster()) { throw new MgmtException("Internal error while " + "notifying services on master cell. Will " + " require a reboot of the master cell [cell " + localCellid + "]"); } else { return BigInteger.valueOf(-1); } } } else { // // We need to preform those config/update and any subsequent // operation in an async way because the dataVIP may be // reconfigured under our feet and the CLI gets screwed. // try { evt.sendAsynchronousEvent( "will update the configuration " + " and reboot the cell [cell " + localCellid + "]"); } catch (MgmtException e) { logger.severe("failed to send synchronous event " + e); } updatePropertiesAndRebootCell(map, updateSwitch, updateSp); } } return BigInteger.valueOf(0); }