List of usage examples for java.lang Number longValue
public abstract long longValue();
From source file:edu.kit.dama.staging.util.DataOrganizationUtils.java
/** * Return the number of files which are part the current KIT Data Manager * instance. Only the FileNodes in the view 'default' are counted. * * @return The number of all FileNodes aor 0 if no amount could be obtained. *//*from w w w . j a v a 2 s . c o m*/ public static Long getAssociatedFileCount() { IMetaDataManager doMdm = MetaDataManagement.getMetaDataManagement() .getMetaDataManager(PersistenceFacade.getInstance().getPersistenceUnitName()); doMdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { Number result = (Number) doMdm .findSingleResult("SELECT COUNT(a) FROM DataOrganizationNode a WHERE a.viewName='" + Constants.DEFAULT_VIEW + "' AND TYPE(a)=FileNode"); return (result != null) ? result.longValue() : 0l; } catch (UnauthorizedAccessAttemptException ex) { return 0l; } finally { doMdm.close(); } }
From source file:net.ontopia.topicmaps.impl.rdbms.Occurrence.java
@Override public long getLength() { Number length = this.<Number>loadField(LF_length); long len = (length == null ? 0 : length.longValue()); if (len < 0) return len * -1L; else/*from w w w .jav a2s .c o m*/ return len; }
From source file:org.openepics.discs.ccdb.core.ejb.ApplicationService.java
private void checkUnitsTable() { final Number oldSchemaColumns = (Number) em .createNativeQuery(//from w ww.j av a 2s.com "SELECT COUNT(*) " + "FROM information_schema.columns " + "WHERE table_schema = 'public' " + "AND table_name = 'unit' " + "AND column_name IN " + "('quantity')") .getSingleResult(); if (oldSchemaColumns.longValue() > 0) { LOGGER.log(Level.WARNING, "Database table 'unit' contains columns which are no longer needed. " + "Execute 'postgres-db-schemas/unit_update1.sql' SQL queries to remove them."); LOGGER.log(Level.WARNING, "* * * THIS IS A POSTGRESQL SCRIPT. TRANSLATE IF USING ANOTHER BACKEND! * * *"); } }
From source file:org.xenei.jdbc4sparql.iface.TypeConverter.java
private static <T> T fromNumber(final Object columnObject, final Class<T> resultingClass) throws SQLException { final Number n = Number.class.cast(columnObject); if (resultingClass == BigDecimal.class) { return resultingClass.cast(new BigDecimal(n.toString())); }/* w ww . jav a 2s .c o m*/ if (resultingClass == BigInteger.class) { return resultingClass.cast(new BigInteger(n.toString())); } if (resultingClass == Byte.class) { return resultingClass.cast(new Byte(n.byteValue())); } if (resultingClass == Double.class) { return resultingClass.cast(new Double(n.doubleValue())); } if (resultingClass == Float.class) { return resultingClass.cast(new Float(n.floatValue())); } if (resultingClass == Integer.class) { return resultingClass.cast(new Integer(n.intValue())); } if (resultingClass == Long.class) { return resultingClass.cast(new Long(n.longValue())); } if (resultingClass == Short.class) { return resultingClass.cast(new Short(n.shortValue())); } if (resultingClass == String.class) { return resultingClass.cast(n.toString()); } if (resultingClass == Boolean.class) { if (n.byteValue() == 0) { return resultingClass.cast(Boolean.FALSE); } if (n.byteValue() == 1) { return resultingClass.cast(Boolean.TRUE); } } if (resultingClass == byte[].class) { return resultingClass.cast(n.toString().getBytes()); } if (resultingClass == Blob.class) { return resultingClass.cast(new SerialBlob(n.toString().getBytes())); } if (resultingClass == Clob.class) { return resultingClass.cast(new SerialClob(n.toString().toCharArray())); } return null; }
From source file:com.bdb.weather.display.summary.TemperatureDeviationPlotPanel.java
public TemperatureDeviationPlotPanel(SummaryInterval interval, ViewLauncher theLauncher, SummarySupporter theSupporter) { this.setPrefSize(500, 300); this.interval = interval; chart = ChartFactory.createXYBarChart("Deviation from Average Temperature", "Date", true, "Deviation (" + Temperature.getDefaultUnit() + ")", null, PlotOrientation.VERTICAL, true, true, false);//from w ww . j av a 2 s . c o m chartViewer = new ChartViewer(chart); chartViewer.setPrefSize(500, 300); chartViewer.addChartMouseListener(new ChartMouseListenerFX() { @Override public void chartMouseClicked(ChartMouseEventFX event) { ChartEntity entity = event.getEntity(); // // Was a point on the plot selected? // if (entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; XYDataset dataset = itemEntity.getDataset(); Number x = dataset.getXValue(itemEntity.getSeriesIndex(), itemEntity.getItem()); LocalDate date = LocalDate.from(Instant.ofEpochMilli(x.longValue())); boolean doubleClick = event.getTrigger().getClickCount() == 2; if (doubleClick) { supporter.launchView(launcher, date); } } } @Override public void chartMouseMoved(ChartMouseEventFX event) { // Do nothing } }); deviationPlot = (XYPlot) chart.getPlot(); this.launcher = theLauncher; this.supporter = theSupporter; DateFormat dateFormat = interval.getLegacyFormat(); StandardXYItemLabelGenerator labelGen = new StandardXYItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, dateFormat, Temperature.getDefaultFormatter()); StandardXYToolTipGenerator ttGen = new StandardXYToolTipGenerator( StandardCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING, dateFormat, Temperature.getDefaultFormatter()); valueAxis = deviationPlot.getRangeAxis(); valueAxis.setUpperMargin(.20); valueAxis.setLowerMargin(.20); deviationPlot.getDomainAxis().setVerticalTickLabels(true); DateAxis dateAxis = (DateAxis) deviationPlot.getDomainAxis(); dateAxis.setDateFormatOverride(dateFormat); //dateAxis.setTickUnit(interval.getDateTickUnit()); //DefaultTableColumnModel colModel = new DefaultTableColumnModel(); dataTable = new TableView(); //dataTable.setModel(tableModel); //dataTable.setColumnModel(colModel); //dataTable.setAutoCreateColumnsFromModel(false); for (int i = 0; i < TABLE_HEADINGS.length; i++) { TableColumn col = new TableColumn(); col.setText(TABLE_HEADINGS[i]); //col.setModelIndex(i); //colModel.addColumn(col); } //tableModel.setColumnCount(TABLE_HEADINGS.length); this.setTabContents(chartViewer, dataTable); lowRenderer.setBasePaint(Color.BLUE); lowRenderer.setBaseItemLabelGenerator(labelGen); lowRenderer.setBaseToolTipGenerator(ttGen); lowRenderer.setBarAlignmentFactor(.6); lowRenderer.setShadowVisible(false); meanRenderer.setSeriesPaint(0, Color.CYAN); meanRenderer.setBaseItemLabelGenerator(labelGen); meanRenderer.setBaseToolTipGenerator(ttGen); meanRenderer.setBarAlignmentFactor(.3); meanRenderer.setShadowVisible(false); highRenderer.setSeriesPaint(0, Color.GRAY); highRenderer.setBaseItemLabelGenerator(labelGen); highRenderer.setBaseToolTipGenerator(ttGen); highRenderer.setShadowVisible(false); }
From source file:org.nuxeo.ecm.quota.count.DocumentsCountUpdater.java
protected long getCount(DocumentModel doc) { if (doc.hasFacet(FOLDERISH)) { if (doc.hasFacet(DOCUMENTS_COUNT_STATISTICS_FACET)) { Number count = (Number) doc.getPropertyValue(DOCUMENTS_COUNT_STATISTICS_DESCENDANTS_COUNT_PROPERTY); return count == null ? 0 : count.longValue(); } else {/*from ww w .j a v a 2s. c o m*/ return 0; } } else { return 1; } }
From source file:de.huxhorn.sulky.plist.impl.PropertyListWriter.java
private void writeValue(XMLStreamWriter writer, Object value) throws XMLStreamException { if (value == null) { return;//from www . j a v a2 s. c o m } if (value instanceof String) { StaxUtilities.writeSimpleTextNode(writer, null, null, STRING_NODE, (String) value); return; } if (value instanceof Boolean) { Boolean bool = (Boolean) value; if (bool) { StaxUtilities.writeEmptyElement(writer, null, null, TRUE_NODE); } else { StaxUtilities.writeEmptyElement(writer, null, null, FALSE_NODE); } return; } if (value instanceof Character) { StaxUtilities.writeSimpleTextNode(writer, null, null, STRING_NODE, value.toString()); return; } if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) { Number number = (Number) value; StaxUtilities.writeSimpleTextNode(writer, null, null, INTEGER_NODE, Long.toString(number.longValue())); return; } if (value instanceof Float || value instanceof Double) { Number number = (Number) value; StaxUtilities.writeSimpleTextNode(writer, null, null, REAL_NODE, Double.toString(number.doubleValue())); return; } if (value instanceof byte[]) { byte[] data = (byte[]) value; writeData(writer, data); return; } if (value instanceof Date) { Date date = (Date) value; writeDate(writer, date); return; } if (value instanceof Map) { Map map = (Map) value; writeDict(writer, map); return; } if (value instanceof Collection) { Collection collection = (Collection) value; writeArray(writer, collection); return; } Class valueClass = value.getClass(); if (valueClass.isArray()) { List<?> list; // we handled byte[] already if (value instanceof short[]) { short[] array = (short[]) value; ArrayList<Short> arrayList = new ArrayList<Short>(array.length); for (short v : array) { arrayList.add(v); } list = arrayList; } else if (valueClass == int[].class) { int[] array = (int[]) value; ArrayList<Integer> arrayList = new ArrayList<Integer>(array.length); for (int v : array) { arrayList.add(v); } list = arrayList; } else if (valueClass == long[].class) { long[] array = (long[]) value; ArrayList<Long> arrayList = new ArrayList<Long>(array.length); for (long v : array) { arrayList.add(v); } list = arrayList; } else if (valueClass == float[].class) { float[] array = (float[]) value; ArrayList<Float> arrayList = new ArrayList<Float>(array.length); for (float v : array) { arrayList.add(v); } list = arrayList; } else if (valueClass == double[].class) { double[] array = (double[]) value; ArrayList<Double> arrayList = new ArrayList<Double>(array.length); for (double v : array) { arrayList.add(v); } list = arrayList; } else if (valueClass == boolean[].class) { boolean[] array = (boolean[]) value; ArrayList<Boolean> arrayList = new ArrayList<Boolean>(array.length); for (boolean v : array) { arrayList.add(v); } list = arrayList; } else if (valueClass == char[].class) { char[] array = (char[]) value; String s = new String(array); StaxUtilities.writeSimpleTextNode(writer, null, null, STRING_NODE, s); return; } else { list = Arrays.asList((Object[]) value); // special handling of container Object[] } writeArray(writer, list); return; } if (logger.isDebugEnabled()) logger.debug("No suitable conversion found for {}. Will save it as string.", valueClass.getName()); StaxUtilities.writeSimpleTextNode(writer, null, null, STRING_NODE, value.toString()); }
From source file:es.logongas.ix3.web.json.impl.JsonReaderImplEntityJackson.java
private boolean emptyKey(Object primaryKey) { if (primaryKey == null) { return true; }//from w ww . j a va2 s .c o m if (primaryKey instanceof Number) { Number number = (Number) primaryKey; if (number.longValue() == 0) { return true; } } if (primaryKey instanceof String) { String s = (String) primaryKey; if (s.trim().equals("")) { return true; } } return false; }
From source file:org.grails.datastore.mapping.engine.EntityPersister.java
protected void incrementVersion(final EntityAccess ea) { if (Number.class.isAssignableFrom(ea.getPropertyType("version"))) { Number currentVersion = (Number) ea.getProperty("version"); if (currentVersion == null) { currentVersion = 0L;//from ww w . ja va2 s . com } ea.setProperty("version", currentVersion.longValue() + 1); } else { setDateVersion(ea); } }
From source file:org.mifos.customers.personnel.persistence.LegacyPersonnelDao.java
public boolean isUserExist(String userName) throws PersistenceException { HashMap<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("USER_NAME", userName); Number count = (Number) execUniqueResultNamedQuery(NamedQueryConstants.GET_PERSONNEL_WITH_NAME, queryParameters);//from w ww . j av a2 s. c o m if (count != null) { return count.longValue() > 0; } return false; }