List of usage examples for java.lang Number longValue
public abstract long longValue();
From source file:com.haulmont.chile.core.datatypes.impl.AdaptiveNumberDatatype.java
protected Number requestedType(Number number) { if (type.equals(Integer.class)) return number.intValue(); if (type.equals(Long.class)) return number.longValue(); if (type.equals(Double.class)) return number.doubleValue(); if (type.equals(Float.class)) return number.floatValue(); return number; }
From source file:org.pentaho.di.trans.steps.pentahoreporting.urlrepository.FileObjectContentEntity.java
/** * Updates the attribute value for the given attribute domain and name. If the element is not writable or the * attribute could not be updated for any other reason, the method will return false. This method only returns true, * if the attribute has been updated successfully. * * @param domain the attribute domain./*from w w w. j a v a 2s .c o m*/ * @param key the attribute name * @param value the new attribute value. * @return true, if the update was successful, false otherwise. */ public boolean setAttribute(final String domain, final String key, final Object value) { try { if (LibRepositoryBoot.REPOSITORY_DOMAIN.equals(domain)) { if (LibRepositoryBoot.VERSION_ATTRIBUTE.equals(key)) { if (value instanceof Date) { final Date date = (Date) value; backend.getContent().setLastModifiedTime(date.getTime()); return true; } else if (value instanceof Number) { final Number time = (Number) value; backend.getContent().setLastModifiedTime(time.longValue()); return true; } } } return false; } catch (FileSystemException ex) { throw new RuntimeException(ex); } }
From source file:net.ontopia.topicmaps.impl.rdbms.ReadOnlyOccurrence.java
@Override public long getLength() { Number length = this.<Number>loadField(Occurrence.LF_length); long len = (length == null ? 0 : length.longValue()); if (len < 0) return len * -1L; else// ww w .j av a2s.co m return len; }
From source file:io.kazuki.v0.internal.v2schema.types.UTCDateSecsTransform.java
@Override public Object unpack(Number instance) throws TransformException { if (instance == null) { throw new TransformException("must not be null"); }// w w w.j a v a2s .c om return format.print(new DateTime(instance.longValue() * 1000L, DateTimeZone.UTC)); }
From source file:at.ac.tuwien.qse.sepm.dao.impl.JDBCTagDAO.java
/** * Create a Tag in the data store/*w w w .j av a 2s.c o m*/ * * @param t Tag which to create * @return the created Tag * @throws DAOException If the Tag can not be created or the data store fails to create a record. */ public Tag create(Tag t) throws DAOException, ValidationException { logger.debug("Creating Tag {}", t); TagValidator.validate(t); if (exists(t)) { throw new ValidationException("Tag already exists"); } try { Map<String, Object> parameters = new HashMap<String, Object>(1); String name = t.getName(); name = name.substring(0, Math.min(name.length(), MAX_TAG_LENGTH)); parameters.put("name", name); Number newId = insertTag.executeAndReturnKey(parameters); t.setId((int) newId.longValue()); addedCallbacks.forEach(cb -> cb.accept(t)); return t; } catch (DataAccessException e) { throw new DAOException("Failed to create Tag", e); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJInt16Editor.java
public boolean isEditValid() { final String S_ProcName = "isEditValid"; if (!hasValue()) { setValue(null);/*from w w w. ja va 2s.c o m*/ return (true); } boolean retval = super.isEditValid(); if (retval) { try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = false; } else if (obj instanceof Short) { Short s = (Short) obj; short v = s.shortValue(); if ((v < getMinValue()) || (v > getMaxValue())) { retval = false; } } else if (obj instanceof Integer) { Integer i = (Integer) obj; int v = i.intValue(); if ((v < getMinValue()) || (v > getMaxValue())) { retval = false; } } else if (obj instanceof Long) { Long l = (Long) obj; long v = l.longValue(); if ((v < getMinValue()) || (v > getMaxValue())) { retval = false; } } else if (obj instanceof Number) { Number n = (Number) obj; long v = n.longValue(); if ((v < getMinValue()) || (v > getMaxValue())) { retval = false; } } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, or Number"); } } return (retval); }
From source file:org.nuxeo.ecm.quota.size.QuotaAwareDocument.java
@Override public long getInnerSize() { try {/*from ww w. j ava 2s . c o m*/ Number size = (Number) doc.getPropertyValue(DOCUMENTS_SIZE_INNER_SIZE_PROPERTY); return size == null ? 0 : size.longValue(); } catch (PropertyException e) { return 0; } }
From source file:org.nuxeo.ecm.quota.size.QuotaAwareDocument.java
@Override public long getTotalSize() { try {//from w w w. ja va 2 s . co m Number size = (Number) doc.getPropertyValue(DOCUMENTS_SIZE_TOTAL_SIZE_PROPERTY); return size == null ? 0 : size.longValue(); } catch (PropertyException e) { return 0; } }
From source file:org.nuxeo.ecm.quota.size.QuotaAwareDocument.java
@Override public long getTrashSize() { try {/*w w w .j a v a 2 s. com*/ Number size = (Number) doc.getPropertyValue(DOCUMENTS_SIZE_TRASH_SIZE_PROPERTY); return size == null ? 0 : size.longValue(); } catch (PropertyException e) { return 0; } }
From source file:org.nuxeo.ecm.quota.size.QuotaAwareDocument.java
@Override public long getVersionsSize() { try {/* ww w. ja va 2 s .co m*/ Number size = (Number) doc.getPropertyValue(DOCUMENTS_SIZE_VERSIONS_SIZE_PROPERTY); return size == null ? 0 : size.longValue(); } catch (PropertyException e) { return 0; } }