Example usage for java.lang Long MIN_VALUE

List of usage examples for java.lang Long MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Long MIN_VALUE.

Prototype

long MIN_VALUE

To view the source code for java.lang Long MIN_VALUE.

Click Source Link

Document

A constant holding the minimum value a long can have, -263.

Usage

From source file:com.linkedin.pinot.controller.helix.retention.RetentionManagerTest.java

private SegmentMetadata getTimeSegmentMetadataImpl(final String startTime, final String endTime,
        final String timeUnit) {
    if (startTime == null || endTime == null || timeUnit == null) {
        long startTimeValue = System.currentTimeMillis();
        return getTimeSegmentMetadataImpl(startTimeValue + "", startTimeValue + "",
                TimeUnit.MILLISECONDS.toString());
    }//from w w w .  j  a va2s.  c om

    final long creationTime = System.currentTimeMillis();
    final String segmentName = _testTableName + creationTime;

    SegmentMetadata segmentMetadata = new SegmentMetadata() {
        TimeUnit segmentTimeUnit = TimeUtils.timeUnitFromString(timeUnit);
        Duration _timeGranularity = new Duration(segmentTimeUnit.toMillis(1));
        Interval _timeInterval = new Interval(segmentTimeUnit.toMillis(Long.parseLong(startTime)),
                segmentTimeUnit.toMillis(Long.parseLong(endTime)));

        @Override
        public Map<String, String> toMap() {
            final Map<String, String> ret = new HashMap<String, String>();
            ret.put(V1Constants.MetadataKeys.Segment.TABLE_NAME, getTableName());
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_TOTAL_DOCS, String.valueOf(getTotalDocs()));
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_VERSION, getVersion());
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_NAME, getName());
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_CRC, getCrc());
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_CREATION_TIME, getIndexCreationTime() + "");
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_START_TIME, startTime);
            ret.put(V1Constants.MetadataKeys.Segment.SEGMENT_END_TIME, endTime);
            ret.put(V1Constants.MetadataKeys.Segment.TIME_UNIT, timeUnit);

            return ret;
        }

        @Override
        public String getVersion() {
            return SegmentVersion.v1.toString();
        }

        @Override
        public int getTotalDocs() {
            return 0;
        }

        @Override
        public int getTotalRawDocs() {
            return 0;
        }

        @Override
        public Interval getTimeInterval() {
            return _timeInterval;
        }

        @Override
        public Duration getTimeGranularity() {
            return _timeGranularity;
        }

        @Override
        public String getShardingKey() {
            return null;
        }

        @Override
        public Schema getSchema() {
            return null;
        }

        @Override
        public String getTableName() {
            return _testTableName;
        }

        @Override
        public String getName() {
            return segmentName;
        }

        @Override
        public String getIndexType() {
            return "offline";
        }

        @Override
        public String getIndexDir() {
            return null;
        }

        @Override
        public long getIndexCreationTime() {
            return creationTime;
        }

        @Override
        public String getCrc() {
            return creationTime + "";
        }

        @Override
        public long getPushTime() {
            return Long.MIN_VALUE;
        }

        @Override
        public long getRefreshTime() {
            return Long.MIN_VALUE;
        }

        @Override
        public boolean hasDictionary(String columnName) {
            return false;
        }

        @Override
        public boolean hasStarTree() {
            return false;
        }

        @Override
        public StarTreeMetadata getStarTreeMetadata() {
            return null;
        }

        @Override
        public boolean close() {
            return false;
        }

        @Override
        public String getForwardIndexFileName(String column, String segmentVersion) {
            throw new UnsupportedOperationException(
                    "getForwardIndexFileName not supported in " + this.getClass());
        }

        @Override
        public String getDictionaryFileName(String column, String segmentVersion) {
            throw new UnsupportedOperationException(
                    "getDictionaryFileName not supported in " + this.getClass());
        }

        @Override
        public String getBitmapInvertedIndexFileName(String column, String segmentVersion) {
            throw new UnsupportedOperationException(
                    "getBitmapInvertedIndexFileName not supported in " + this.getClass());
        }

        @Nullable
        @Override
        public String getCreatorName() {
            return null;
        }

        @Override
        public Character getPaddingCharacter() {
            return V1Constants.Str.DEFAULT_STRING_PAD_CHAR;
        }

        @Override
        public int getHllLog2m() {
            return HllConstants.DEFAULT_LOG2M;
        }

    };
    return segmentMetadata;
}

From source file:com.eurelis.opencms.admin.fileinformation.CmsFileInformationList.java

/**
 * @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
 *//*w w w  .  j av a 2s .c  om*/
protected List getListItems() {

    List ret = new ArrayList();

    //LOG.debug("getListItems... ");

    CmsAdminSettings settings = new CmsAdminSettings(getSession());

    String folder = settings.getSettingsFilesFolderValue(getCms(), getSession());
    if (CmsStringUtil.isEmptyOrWhitespaceOnly(folder)) {
        return ret;
    }
    if (!getCms().existsResource(folder)) {
        return ret;
    }
    LOG.debug("getListItems... : folder=" + folder + " ");

    String forcedfolder = null;
    if (getParameterMap() != null && getParameterMap().containsKey(PARAM_FORCEDFOLDER)) {
        forcedfolder = getParameterMap().get(PARAM_FORCEDFOLDER)[0];
    }
    LOG.debug("getListItems... : forcedfolder=" + forcedfolder + " ");

    int minLength = settings.getSettingsFilesMinLengthValue(getCms(), getSession());
    int maxLength = settings.getSettingsFilesMaxLengthValue(getCms(), getSession());
    LOG.debug("getListItems... : minLength=" + minLength + " maxLength=" + maxLength);

    long createdBefore = settings.getSettingsFilesCreatedBeforeValue(getCms(), getSession());
    long createdAfter = settings.getSettingsFilesCreatedAfterValue(getCms(), getSession());
    LOG.debug("getListItems... : createdBefore=" + createdBefore + " ("
            + CmsDateUtil.getDateTimeShort(createdBefore) + ")" + " createdAfter=" + createdAfter + " ("
            + CmsDateUtil.getDateTimeShort(createdAfter) + ")");

    //recuperation des fichiers
    List<CmsResource> allRsc = new ArrayList<CmsResource>();
    try {
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(forcedfolder)) {
            allRsc = getCms().readResources(folder, CmsResourceFilter.ALL.addRequireFile(), true);
            LOG.debug("getListItems... " + allRsc.size() + " files in " + folder);
        } else {
            String currentSiteRoot1 = getCms().getRequestContext().getSiteRoot();
            getCms().getRequestContext().setSiteRoot("/");
            allRsc = getCms().readResources(forcedfolder, CmsResourceFilter.ALL.addRequireFile(), true);
            getCms().getRequestContext().setSiteRoot(currentSiteRoot1);
            LOG.debug("getListItems... " + allRsc.size() + " files in " + forcedfolder);
        }
        if (allRsc == null) {
            LOG.warn("getListItems... allRsc null");
            return ret;
        }

        //on passe sur siteroot "/"
        String currentSiteRoot = getCms().getRequestContext().getSiteRoot();
        getCms().getRequestContext().setSiteRoot("/");

        Iterator<CmsResource> i = allRsc.iterator();
        while (i.hasNext()) {
            CmsResource resource = (CmsResource) i.next();
            CmsListItem item = getList().newItem(resource.getRootPath());

            // type
            String type = OpenCms.getResourceManager().getResourceType(resource.getTypeId()).getTypeName();
            // type icon
            String iconpath = OpenCms.getSystemInfo().getContextPath() + "/resources/"
                    + CmsWorkplace.RES_PATH_FILETYPES
                    + OpenCms.getWorkplaceManager().getExplorerTypeSetting(type).getIcon();

            // lock
            CmsLock lock = getCms().getLock(resource);
            String lockiconpath = null;
            if (!lock.isUnlocked()) {
                lockiconpath = OpenCms.getSystemInfo().getContextPath() + "/resources/explorer/lock_other.gif";
                if (lock.isDirectlyOwnedBy(getCms().getRequestContext().getCurrentUser())) {
                    lockiconpath = OpenCms.getSystemInfo().getContextPath()
                            + "/resources/explorer/lock_user.gif";
                }
                if (lock.isOwnedBy(getCms().getRequestContext().getCurrentUser()) && lock.isShared()) {
                    lockiconpath = OpenCms.getSystemInfo().getContextPath()
                            + "/resources/explorer/lock_shared.gif";
                }
            }

            // state
            String state = "";
            if (resource.getState().isChanged())
                state = getJsp().label("checkresources.label.state.changed");
            if (resource.getState().isDeleted())
                state = getJsp().label("checkresources.label.state.deleted");
            if (resource.getState().isNew())
                state = getJsp().label("checkresources.label.state.new");
            if (resource.getState().isUnchanged())
                state = getJsp().label("checkresources.label.state.unchanged");
            String spancolor = "";
            if (resource.getState().isChanged())
                spancolor = "color:#B40000;";
            if (resource.getState().isDeleted())
                spancolor = "";
            if (resource.getState().isNew())
                spancolor = "color:#00A;";
            if (resource.getState().isUnchanged())
                spancolor = "";
            String spanitalic = "";
            if (!resource.isReleasedAndNotExpired(System.currentTimeMillis()))
                spanitalic = "font-style:italic;";
            String spanlined = "";
            if (resource.getState().isDeleted())
                spanlined = "text-decoration: line-through;";

            //project
            String projecticonpath = null;
            if (resource.getState().isChanged())
                projecticonpath = OpenCms.getSystemInfo().getContextPath()
                        + "/resources/explorer/project_this.png";
            if (resource.getState().isDeleted())
                projecticonpath = OpenCms.getSystemInfo().getContextPath()
                        + "/resources/explorer/project_this.png";
            if (resource.getState().isNew())
                projecticonpath = OpenCms.getSystemInfo().getContextPath()
                        + "/resources/explorer/project_this.png";
            if (resource.getState().isUnchanged())
                projecticonpath = null;

            // rootpath
            String rootPath = resource.getRootPath();

            // title property
            CmsProperty property = getCms().readPropertyObject(resource.getRootPath(), "Title", false);
            String title = (property != null && property.getValue() != null) ? property.getValue() : "";

            // size
            String size = resource.getLength() + "";

            // root
            String siteroot = OpenCms.getSiteManager().getSiteForRootPath(resource.getRootPath()).getSiteRoot();
            CmsProperty siterootproperty = getCms().readPropertyObject(siteroot, "Title", false);
            String siteroottitle = siterootproperty != null ? siterootproperty.getValue() : "";

            item.set(LIST_COLUMN_TYPEICON,
                    "<img src=\"" + iconpath + "\" border=\"0\" width=\"16\" height=\"16\" alt=\"\"/>");
            item.set(LIST_COLUMN_LOCKICON,
                    lockiconpath != null
                            ? "<img src=\"" + lockiconpath
                                    + "\" border=\"0\" width=\"16\" height=\"16\" alt=\"\"/>"
                            : "");
            item.set(LIST_COLUMN_PROJECTICON,
                    projecticonpath != null
                            ? "<img src=\"" + projecticonpath
                                    + "\" border=\"0\" width=\"16\" height=\"16\" alt=\"\"/>"
                            : "");
            item.set(LIST_COLUMN_STATE,
                    "<span style=\"" + spancolor + spanitalic + spanlined + "\">" + state + "</span>");
            item.set(LIST_COLUMN_PATH,
                    "<span style=\"" + spancolor + spanitalic + spanlined + "\">" + rootPath + "</span>");
            item.set(LIST_COLUMN_TITLE,
                    "<span style=\"" + spancolor + spanitalic + spanlined + "\">" + title + "</span>");
            item.set(LIST_COLUMN_TYPE,
                    "<span style=\"" + spancolor + spanitalic + spanlined + "\">" + type + "</span>");
            item.set(LIST_COLUMN_SIZE,
                    "<span style=\"" + spancolor + spanitalic + spanlined + "\">" + size + "</span>");
            item.set(LIST_COLUMN_ROOT,
                    "<span style=\"" + spancolor + spanitalic + spanlined + "\">" + siteroottitle + "</span>");
            item.set(LIST_COLUMN_CREATIONDATE, "<span style=\"" + spancolor + spanitalic + spanlined + "\">"
                    + CmsDateUtil.getDateTimeShort(resource.getDateCreated()) + "</span>");

            boolean displayed = true;
            if (resource.getLength() < minLength) {
                displayed = false;
            }
            if (maxLength != -1) {
                LOG.debug("getListItems... filter on max length " + maxLength);
                if (resource.getLength() > maxLength) {
                    displayed = false;
                }
            }
            if (createdBefore != Long.MIN_VALUE && createdBefore != Long.MAX_VALUE && createdBefore != 0) {
                LOG.debug("getListItems... filter on creation date < "
                        + CmsDateUtil.getDateTimeShort(createdBefore));
                if (resource.getDateCreated() > createdBefore) {
                    displayed = false;
                }
            }
            if (createdBefore != Long.MIN_VALUE && createdAfter != Long.MAX_VALUE && createdAfter != 0) {
                LOG.debug("getListItems... filter on creation date > "
                        + CmsDateUtil.getDateTimeShort(createdBefore));
                if (resource.getDateCreated() < createdAfter) {
                    displayed = false;
                }
            }

            if (displayed) {
                ret.add(item);
            }

        }

        getCms().getRequestContext().setSiteRoot(currentSiteRoot);

    } catch (CmsException e) {
        e.printStackTrace();
        LOG.error(e, e);
    }

    LOG.debug("getListItems... " + ret.size() + " files found");
    return ret;
}

From source file:it.doqui.index.ecmengine.business.personalization.multirepository.node.index.IndexTransactionTracker.java

/**
 * Checks that each of the transactions is present in the index.  As soon as one is found that
 * isn't, all the following transactions will be reindexed.  After the reindexing, the sequence
 * of transaction IDs will be examined for any voids.  These will be recorded.
 *
 * @param txns      transactions ordered by time ascending
 * @return          returns the//  w  w  w  . j a  v a  2s .  c  o m
 */
private void reindexTransactions(List<Transaction> txns) {
    if (txns.isEmpty()) {
        return;
    }

    Set<Long> processedTxnIds = new HashSet<Long>(13);

    Map<Long, TxnRecord> curVoids = voidsMap.get(RepositoryManager.getCurrentRepository()); // Map is mutable

    boolean forceReindex = false;
    long minNewTxnId = Long.MAX_VALUE;
    long maxNewTxnId = Long.MIN_VALUE;
    long maxNewTxnCommitTime = System.currentTimeMillis();
    for (Transaction txn : txns) {
        Long txnId = txn.getId();
        long txnIdLong = txnId.longValue();
        if (txnIdLong < minNewTxnId) {
            minNewTxnId = txnIdLong;
        }
        if (txnIdLong > maxNewTxnId) {
            maxNewTxnId = txnIdLong;
            maxNewTxnCommitTime = txn.getCommitTimeMs();
        }
        // Keep track of it for void checking
        processedTxnIds.add(txnId);
        // Remove this entry from the void list - it is not void
        curVoids.remove(txnId);

        // Reindex the transaction if we are forcing it or if it isn't in the index already
        if (forceReindex || isTxnIdPresentInIndex(txnId) == InIndex.NO) {
            // Any indexing means that all the next transactions have to be indexed
            forceReindex = true;
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Reindexing transaction: " + txn);
                }
                // We try the reindex, but for the sake of continuity, have to let it run on
                reindexTransaction(txnId);
            } catch (Throwable e) {
                logger.warn("\n" + "Reindex of transaction failed: \n" + "   Transaction ID: " + txnId + "\n"
                        + "   Error: " + e.getMessage(), e);
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Reindex skipping transaction: " + txn);
            }
        }
    }
    // We have to search for voids now.  Don't start at the min transaction,
    // but start at the least of the lastMaxTxnId and minNewTxnId
    long voidCheckStartTxnId = (lastMaxTxnId < minNewTxnId ? lastMaxTxnId : minNewTxnId) + 1;
    long voidCheckEndTxnId = maxNewTxnId;
    // Check for voids in new transactions
    for (long i = voidCheckStartTxnId; i <= voidCheckEndTxnId; i++) {
        Long txnId = Long.valueOf(i);
        if (processedTxnIds.contains(txnId)) {
            // It is there
            continue;
        }

        // First make sure that it is a real void.  Sometimes, transactions are in the table but don't
        // fall within the commit time window that we queried.  If they're in the DB AND in the index,
        // then they're not really voids and don't need further checks.  If they're missing from either,
        // then they're voids and must be processed.
        Transaction voidTxn = nodeDaoService.getTxnById(txnId);
        if (voidTxn != null && isTxnIdPresentInIndex(txnId) != InIndex.NO) {
            // It is a real transaction (not a void) and is already in the index, so just ignore it.
            continue;
        }

        // Calculate an age for the void.  We can't use the current time as that will mean we keep all
        // discovered voids, even if they are very old.  Rather, we use the commit time of the last transaction
        // in the set as it represents the query time for this iteration.
        TxnRecord voidRecord = new TxnRecord();
        voidRecord.txnCommitTime = maxNewTxnCommitTime;
        curVoids.put(txnId, voidRecord);
        if (logger.isDebugEnabled()) {
            logger.debug("Void detected: " + txnId);
        }
    }
    // Having searched for the nodes, we've recorded all the voids.  So move the lastMaxTxnId up.
    lastMaxTxnId = voidCheckEndTxnId;
}

From source file:com.androzic.location.LocationService.java

public long getTrackStartTime() {
    long res = Long.MIN_VALUE;
    if (trackDB == null)
        openDatabase();/*from   w  w  w .j av  a2s .  com*/
    if (trackDB == null)
        return res;
    Cursor cursor = trackDB.rawQuery("SELECT MIN(datetime) FROM track WHERE datetime > 0", null);
    if (cursor.moveToFirst())
        res = cursor.getLong(0);
    cursor.close();
    return res;
}

From source file:au.edu.uq.cmm.paul.grabber.Analyser.java

private SortedSet<DatasetMetadata> buildInFolderMetadata() {
    TreeSet<DatasetMetadata> inFolder = new TreeSet<DatasetMetadata>(ORDER_BY_BASE_PATH_AND_TIME);
    String folderName = getFacility().getFolderName();
    if (folderName == null) {
        return inFolder;
    }// www .j  a va 2s. c o  m
    File localDir = uncNameMapper.mapUncPathname(folderName);
    if (localDir == null) {
        return inFolder;
    }
    fsm.getStatus(getFacility()).setLocalDirectory(localDir);
    analyseTree(localDir, Long.MIN_VALUE, Long.MAX_VALUE);
    for (Runnable runnable : queue) {
        WorkEntry entry = (WorkEntry) runnable;
        SessionDetails session = fsm.getSessionDetails(getFacility(), entry.getTimestamp().getTime(),
                entry.getBaseFile());
        entry.pretendToGrabFiles();
        inFolder.add(entry.assembleDatasetMetadata(null, session, new File("")));
    }
    return inFolder;
}

From source file:de.innovationgate.wgpublisher.design.fs.DesignFileDocument.java

private long determineLastModifiedTime(FileObject mdFile) throws FileSystemException, WGDesignSyncException,
        InstantiationException, IllegalAccessException, IOException {
    long mdLastModifiedTime = Long.MIN_VALUE;
    if (mdFile.exists()) {
        mdLastModifiedTime = getLastModifiedTime(mdFile);
    }//from   w w w.  j a  va2 s . co m
    long codeLastModifiedTime = getLastModifiedTime(getCodeFile());

    long lastModified = Math.max(mdLastModifiedTime, codeLastModifiedTime);
    if (getType() == WGDocument.TYPE_FILECONTAINER && _manager.isStrictFCDateDetermination()) {
        lastModified = determineFileContainerLastModified();
    }
    return lastModified;
}

From source file:net.sf.json.TestJSONObject.java

public void testFromBean_use_wrappers() {
    JSONObject json = JSONObject.fromObject(Boolean.TRUE);
    assertTrue(json.isEmpty());//from w w w .j a v  a 2  s.c o  m
    json = JSONObject.fromObject(new Byte(Byte.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Short(Short.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Integer(Integer.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Long(Long.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Float(Float.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Double(Double.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Character('A'));
    assertTrue(json.isEmpty());
}

From source file:net.java.sip.communicator.impl.history.HistoryReaderImpl.java

/**
 * Evaluetes does <tt>timestamp</tt> is in the given time period.
 *
 * @param timestamp Date/*from  w ww  . jav  a 2  s. co m*/
 * @param startDate Date the start of the period
 * @param endDate Date the end of the period
 * @return boolean
 */
static boolean isInPeriod(Date timestamp, Date startDate, Date endDate) {
    Long startLong;
    Long endLong;
    Long tsLong = timestamp.getTime();

    if (startDate == null)
        startLong = Long.MIN_VALUE;
    else
        startLong = startDate.getTime();

    if (endDate == null)
        endLong = Long.MAX_VALUE;
    else
        endLong = endDate.getTime();

    return startLong <= tsLong && tsLong < endLong;
}

From source file:org.alfresco.opencmis.dictionary.AbstractTypeDefinitionWrapper.java

/**
 * Creates a property definition object.
 *//*from  w w  w  . ja  v  a2  s.c  om*/
protected PropertyDefinition<?> createPropertyDefinition(CMISMapping cmisMapping, String id,
        QName alfrescoPropName, DictionaryService dictionaryService,
        org.alfresco.service.cmr.dictionary.PropertyDefinition propDef, boolean inherited) {
    PropertyType datatype = cmisMapping.getDataType(propDef.getDataType());
    if (datatype == null) {
        return null;
    }

    AbstractPropertyDefinition<?> result = null;

    switch (datatype) {
    case BOOLEAN:
        result = new PropertyBooleanDefinitionImpl();
        break;
    case DATETIME:
        result = new PropertyDateTimeDefinitionImpl();
        break;
    case DECIMAL:
        result = new PropertyDecimalDefinitionImpl();
        break;
    case HTML:
        result = new PropertyHtmlDefinitionImpl();
        break;
    case ID:
        result = new PropertyIdDefinitionImpl();
        break;
    case INTEGER:
        result = new PropertyIntegerDefinitionImpl();
        break;
    case STRING:
        result = new PropertyStringDefinitionImpl();
        break;
    case URI:
        result = new PropertyUriDefinitionImpl();
        break;
    default:
        throw new RuntimeException("Unknown datatype! Spec change?");
    }

    if (id.equals(PropertyIds.OBJECT_TYPE_ID) || id.equals(PropertyIds.SOURCE_ID)
            || id.equals(PropertyIds.TARGET_ID)) {
        // the CMIS spec requirement
        result.setUpdatability(Updatability.ONCREATE);
    } else {
        result.setUpdatability(propDef.isProtected() ? Updatability.READONLY : Updatability.READWRITE);
    }

    result.setId(id);
    result.setLocalName(alfrescoPropName.getLocalName());
    result.setLocalNamespace(alfrescoPropName.getNamespaceURI());
    result.setDisplayName(null);
    result.setDescription(null);
    result.setPropertyType(datatype);
    result.setCardinality(propDef.isMultiValued() ? Cardinality.MULTI : Cardinality.SINGLE);
    result.setIsInherited(inherited);
    result.setIsRequired(propDef.isMandatory());
    addDefaultValue(propDef.getDefaultValue(), result);

    // query and order
    result.setQueryName(ISO9075.encodeSQL(cmisMapping.buildPrefixEncodedString(alfrescoPropName)));
    result.setIsQueryable(propDef.isIndexed());
    result.setIsOrderable(false);

    if (result.isQueryable()) {
        if (result.getCardinality() == Cardinality.SINGLE) {
            IndexTokenisationMode indexTokenisationMode = IndexTokenisationMode.TRUE;
            if (propDef.getIndexTokenisationMode() != null) {
                indexTokenisationMode = propDef.getIndexTokenisationMode();
            }

            switch (indexTokenisationMode) {
            case BOTH:
            case FALSE:
                result.setIsOrderable(true);
                break;
            case TRUE:
            default:
                if (propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.DATE)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.DATETIME)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.INT)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.LONG)
                        || propDef.getDataType().getName().equals(DataTypeDefinition.PATH)) {
                    result.setIsOrderable(true);
                }
            }
        }
    }

    // MNT-9089 fix, set min/max values for numeric properties
    // MNT-11304 fix, use default boundaries only for numeric types
    if (result instanceof PropertyIntegerDefinitionImpl) {
        if (propDef.getDataType().getName().equals(DataTypeDefinition.INT)) {
            ((PropertyIntegerDefinitionImpl) result).setMinValue(BigInteger.valueOf(Integer.MIN_VALUE));
            ((PropertyIntegerDefinitionImpl) result).setMaxValue(BigInteger.valueOf(Integer.MAX_VALUE));
        }
        if (propDef.getDataType().getName().equals(DataTypeDefinition.LONG)) {
            ((PropertyIntegerDefinitionImpl) result).setMinValue(BigInteger.valueOf(Long.MIN_VALUE));
            ((PropertyIntegerDefinitionImpl) result).setMaxValue(BigInteger.valueOf(Long.MAX_VALUE));
        }
    }
    // end MNT-9089

    // constraints and choices
    for (ConstraintDefinition constraintDef : propDef.getConstraints()) {
        Constraint constraint = constraintDef.getConstraint();
        if (constraint instanceof ListOfValuesConstraint) {
            addChoiceList((ListOfValuesConstraint) constraint, result);
        }

        if ((constraint instanceof StringLengthConstraint)
                && (result instanceof PropertyStringDefinitionImpl)) {
            StringLengthConstraint slc = (StringLengthConstraint) constraint;
            ((PropertyStringDefinitionImpl) result).setMaxLength(BigInteger.valueOf(slc.getMaxLength()));
        }

        if (constraint instanceof NumericRangeConstraint) {
            NumericRangeConstraint nrc = (NumericRangeConstraint) constraint;
            if (result instanceof PropertyIntegerDefinitionImpl) {
                ((PropertyIntegerDefinitionImpl) result)
                        .setMinValue(BigInteger.valueOf(((Double) nrc.getMinValue()).longValue()));
                ((PropertyIntegerDefinitionImpl) result)
                        .setMaxValue(BigInteger.valueOf(((Double) nrc.getMaxValue()).longValue()));
            }
            if (result instanceof PropertyDecimalDefinitionImpl) {
                ((PropertyDecimalDefinitionImpl) result).setMinValue(BigDecimal.valueOf(nrc.getMinValue()));
                ((PropertyDecimalDefinitionImpl) result).setMaxValue(BigDecimal.valueOf(nrc.getMaxValue()));
            }
        }
    }

    return result;
}

From source file:net.aksingh.java.api.owm.CurrentWeatherData.java

/**
 * Parameterized constructor/* w  w w.j  av  a2 s  .c  o  m*/
 * <p>
 * Initializes variables from values from the given JSON object.
 * <p>
 * @param jsonObj JSON object containing current weather data
 */
public CurrentWeatherData(JSONObject jsonObj) {
    super(jsonObj);

    this.base = (jsonObj != null) ? jsonObj.optString(this.JSON_BASE, null) : null;
    this.cityID = (jsonObj != null) ? jsonObj.optLong(this.JSON_CITY_ID, Long.MIN_VALUE) : Long.MIN_VALUE;
    this.cityName = (jsonObj != null) ? jsonObj.optString(this.JSON_CITY_NAME, null) : null;
    this.responseCode = (jsonObj != null) ? jsonObj.optInt(this.JSON_RESPONSE_CODE, Integer.MIN_VALUE)
            : Integer.MIN_VALUE;

    JSONObject jsonObjClouds = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_CLOUDS) : null;
    this.clouds = (jsonObjClouds != null) ? new Clouds(jsonObjClouds) : new Clouds();

    JSONObject jsonObjCoord = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_COORD) : null;
    this.coord = (jsonObjCoord != null) ? new Coord(jsonObjCoord) : new Coord();

    JSONObject jsonObjMain = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_MAIN) : null;
    this.main = (jsonObjMain != null) ? new Main(jsonObjMain) : new Main();

    JSONObject jsonObjRain = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_RAIN) : null;
    this.rain = (jsonObjRain != null) ? new Rain(jsonObjRain) : new Rain();

    JSONObject jsonObjSys = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_SYS) : null;
    this.sys = (jsonObjSys != null) ? new Sys(jsonObjSys) : new Sys();

    JSONArray jsonArrWeather = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_WEATHER) : null;
    this.weatherList = (jsonArrWeather != null) ? new ArrayList<Weather>(jsonArrWeather.length())
            : Collections.EMPTY_LIST;
    if (this.weatherList != Collections.EMPTY_LIST) {
        for (int i = 0; i < jsonArrWeather.length(); i++) {
            JSONObject jsonObjWeather = jsonArrWeather.optJSONObject(i);
            if (jsonObjWeather != null) {
                this.weatherList.add(new Weather(jsonObjWeather));
            }
        }
    }
    this.weatherListCount = this.weatherList.size();

    JSONObject jsonObjWind = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_WIND) : null;
    this.wind = (jsonObjWind != null) ? new Wind(jsonObjWind) : new Wind();
}