Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

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

Click Source Link

Document

A constant holding the minimum value an int can have, -231.

Usage

From source file:org.literacyapp.web.content.multimedia.video.VideoEditController.java

@RequestMapping(value = "/{id}", method = RequestMethod.POST)
public String handleSubmit(HttpSession session, Video video, @RequestParam("bytes") MultipartFile multipartFile,
        BindingResult result, Model model) {
    logger.info("handleSubmit");

    if (StringUtils.isBlank(video.getTitle())) {
        result.rejectValue("title", "NotNull");
    } else {/*from  w w w .j a v a 2s. co  m*/
        Video existingVideo = videoDao.read(video.getTitle(), video.getLocale());
        if ((existingVideo != null) && !existingVideo.getId().equals(video.getId())) {
            result.rejectValue("title", "NonUnique");
        }
    }

    try {
        byte[] bytes = multipartFile.getBytes();
        if (multipartFile.isEmpty() || (bytes == null) || (bytes.length == 0)) {
            result.rejectValue("bytes", "NotNull");
        } else {
            String originalFileName = multipartFile.getOriginalFilename();
            logger.info("originalFileName: " + originalFileName);
            if (originalFileName.toLowerCase().endsWith(".m4v")) {
                video.setVideoFormat(VideoFormat.M4V);
            } else if (originalFileName.toLowerCase().endsWith(".mp4")) {
                video.setVideoFormat(VideoFormat.MP4);
            } else {
                result.rejectValue("bytes", "typeMismatch");
            }

            if (video.getVideoFormat() != null) {
                String contentType = multipartFile.getContentType();
                logger.info("contentType: " + contentType);
                video.setContentType(contentType);

                video.setBytes(bytes);

                // TODO: convert to a default video format?
            }
        }
    } catch (IOException e) {
        logger.error(e);
    }

    if (result.hasErrors()) {
        model.addAttribute("video", video);
        model.addAttribute("contentLicenses", ContentLicense.values());
        model.addAttribute("literacySkills", LiteracySkill.values());
        model.addAttribute("numeracySkills", NumeracySkill.values());
        model.addAttribute("contentCreationEvents", contentCreationEventDao.readAll(video));
        return "content/multimedia/video/edit";
    } else {
        video.setTitle(video.getTitle().toLowerCase());
        video.setTimeLastUpdate(Calendar.getInstance());
        video.setRevisionNumber(Integer.MIN_VALUE);
        videoDao.update(video);

        Contributor contributor = (Contributor) session.getAttribute("contributor");

        ContentCreationEvent contentCreationEvent = new ContentCreationEvent();
        contentCreationEvent.setContributor(contributor);
        contentCreationEvent.setContent(video);
        contentCreationEvent.setCalendar(Calendar.getInstance());
        contentCreationEventDao.update(contentCreationEvent);

        if (EnvironmentContextLoaderListener.env == Environment.PROD) {
            String text = URLEncoder
                    .encode(contributor.getFirstName() + " just edited an Video:\n" + " Language: \""
                            + video.getLocale().getLanguage() + "\n" + " Title: \"" + video.getTitle()
                            + "\"\n" + " Video format: " + video.getVideoFormat() + "\n" + "See ")
                    + "http://literacyapp.org/content/multimedia/video/list";
            String iconUrl = contributor.getImageUrl();
            SlackApiHelper.postMessage(Team.CONTENT_CREATION, text, iconUrl, "http://literacyapp.org/video/"
                    + video.getId() + "." + video.getVideoFormat().toString().toLowerCase());
        }

        return "redirect:/content/multimedia/video/list";
    }
}

From source file:com.netbase.insightapi.bestpractice.TopicDownloader.java

/**
 * Demonstration main program. Arguments are provided as system properties,
 * using the "-D" syntax at the command line. This is intended as a
 * demonstration of the capability, rather than a useful utility in its own
 * right./*from   w w  w  .j  a  v  a 2s  .  c o m*/
 */
public static void main(String[] args) {
    try {
        // get the arguments from system properties
        String username = System.getProperty("username");
        String password = System.getProperty("password");
        String server = System.getProperty("server");
        String topicName = System.getProperty("topicName");
        String outputFile = System.getProperty("outputFile",
                File.createTempFile("topic", ".json").getAbsolutePath());

        // create the user channel
        UserChannel user = new UserChannel(username, password, server);

        // create the InsightAPI query to be used as a prototype by the
        // downloader
        InsightAPIQuery query = new InsightAPIQuery("retrieveDocuments");
        query.setParameter("sizeNeeded", 500);
        query.setParameter("topics", topicName);

        // for demonstration purposes, extract only Tweets; other filters
        // can be added here.
        query.setParameter("domains", "twitter.com");

        // set a very large timeout. Large settings of "sizeNeeded" will
        // require this unless your network connection is very fast.
        query.setTimeout(1000000);

        // this causes log messages to describe what the downloader is
        // doing.
        query.setDebug(true);

        // create the result handler, which opens the output file
        MyResultHandler handler = new MyResultHandler(outputFile);

        // run the download
        System.out.println("downloading history of topic '" + topicName + "' to file: " + outputFile);
        downloadHistory(query, user, Integer.MIN_VALUE, Integer.MAX_VALUE, handler);
        System.out.println("download of " + handler.numDocs + " complete");

        // finish up
        handler.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:net.aksingh.owmjapis.OpenWeatherMap.java

/**
 * Constructor//from   ww w  .  j  a v  a  2 s . c o m
 *
 * @param units  Any constant from Units
 * @param lang   Any constant from Language
 * @param apiKey API key from OWM.org
 * @see net.aksingh.owmjapis.OpenWeatherMap.Units
 * @see net.aksingh.owmjapis.OpenWeatherMap.Language
 * @see <a href="http://openweathermap.org/current#multi">OWM.org's Multilingual support</a>
 * @see <a href="http://openweathermap.org/appid">OWM.org's API Key</a>
 */
public OpenWeatherMap(Units units, Language lang, String apiKey) {
    this.owmAddress = new OWMAddress(units, lang, apiKey);
    this.owmProxy = new OWMProxy(null, Integer.MIN_VALUE, null, null);
    this.owmResponse = new OWMResponse(owmAddress, owmProxy);
}

From source file:eu.stratosphere.nephele.io.channels.DistributedChannelWithAccessInfo.java

@Override
public void disposeSilently() {

    this.referenceCounter.set(Integer.MIN_VALUE);
    this.reservedWritePosition.set(Long.MIN_VALUE);

    if (this.channel.isOpen()) {
        try {/* ww  w. j av a  2  s .  c  o m*/
            this.channel.close();
            if (this.deleteOnClose.get()) {
                this.fs.delete(this.checkpointFile, false);
            }
        } catch (Throwable t) {
        }
    }
}

From source file:com.epam.catgenome.entity.vcf.VcfFilterForm.java

/**
 * Filter variations by positions, using only variation's start index
 * @param builder/*  w  w  w.j av a 2s  .c om*/
 */
private void addPositionFilter(BooleanQuery.Builder builder) {
    if (startIndex != null && endIndex != null) {
        builder.add(IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), startIndex, endIndex),
                BooleanClause.Occur.MUST);
    } else {
        if (startIndex != null) {
            builder.add(IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), startIndex,
                    Integer.MAX_VALUE), BooleanClause.Occur.MUST);
        } else if (endIndex != null) {
            builder.add(IntPoint.newRangeQuery(FeatureIndexFields.START_INDEX.getFieldName(), Integer.MIN_VALUE,
                    endIndex), BooleanClause.Occur.MUST);
        }
    }
}

From source file:edu.cmu.sphinx.speakerid.SpeakerIdentification.java

/**
 * @param start/*from  ww  w  .j  a v a2s  . co m*/
 *            The starting frame
 * @param length
 *            The length of the interval, as numbers of frames
 * @param features
 *            The matrix build with feature vectors as rows
 * @return Returns the changing point in the input represented by features
 * 
 */

private int getPoint(int start, int length, int step, Array2DRowRealMatrix features) {
    double max = Double.NEGATIVE_INFINITY;
    int ncols = features.getColumnDimension(), point = 0;
    Array2DRowRealMatrix sub = (Array2DRowRealMatrix) features.getSubMatrix(start, start + length - 1, 0,
            ncols - 1);
    double bicValue = getBICValue(sub);
    for (int i = Segment.FEATURES_SIZE + 1; i < length - Segment.FEATURES_SIZE; i += step) {
        double aux = getLikelihoodRatio(bicValue, i, sub);
        if (aux > max) {
            max = aux;
            point = i;
        }
    }
    if (max < 0)
        point = Integer.MIN_VALUE;
    return point + start;
}

From source file:gov.nih.nci.cabig.caaers.accesscontrol.query.impl.AbstractIdFetcher.java

/**
 * Will fetch all the accessible investigators per-role
 * @param loginId - username//from  w  ww .  j  a va 2 s . c  om
 * @return
 */
public List fetch(String loginId) {

    IndexEntry allSiteEntry = new IndexEntry(Integer.MIN_VALUE, 0);

    Map<Integer, IndexEntry> indexEntryMap = new LinkedHashMap<Integer, IndexEntry>();
    int orgAllSiteBit = getOrganizationAllSiteAccessRoles(loginId);

    //for all site scoped roles
    UserGroupType[] siteScopedRoles = getApplicableSiteScopedRoles();
    if (siteScopedRoles != null) {
        for (UserGroupType role : siteScopedRoles) {
            if (role.isSelected(orgAllSiteBit)) {
                allSiteEntry.addRole(role);
                continue;
            }

            //fetch the organization specific investigators
            String sql = getSiteScopedSQL(role);
            boolean nativeSql = sql != null;
            String hql = nativeSql ? sql : getSiteScopedHQL(role);
            AbstractQuery query = createQuery(loginId, hql, nativeSql);
            List<Integer> ids = (List<Integer>) search(query);
            if (CollectionUtils.isEmpty(ids))
                continue;
            for (Integer id : ids) {
                if (!indexEntryMap.containsKey(id))
                    indexEntryMap.put(id, new IndexEntry(id, 0));
                indexEntryMap.get(id).addRole(role);
            }
        }
    }

    //for all study scoped roles
    UserGroupType[] studyScopedRoles = getApplicableStudyScopedRoles();
    if (studyScopedRoles != null) {

        int studyAllSiteRoleBit = getStudyAllSiteAccessRoles(loginId);

        for (UserGroupType role : studyScopedRoles) {
            //is all site all study ?  - all entities in the system
            if (role.isSelected(orgAllSiteBit) && role.isSelected(studyAllSiteRoleBit)) {
                allSiteEntry.addRole(role);
                continue;
            }

            //all other cases - I can access entities on the study-sites I manage .
            //What are study-site ? - study-orgs that I have access-to via orgainzation and study indexes.
            String sql = getStudyScopedSQL(role);
            boolean nativeSql = sql != null;
            String hql = nativeSql ? sql : getStudyScopedHQL(role);
            AbstractQuery query = createQuery(loginId, hql, nativeSql);
            List<Integer> ids = (List<Integer>) search(query);
            if (CollectionUtils.isEmpty(ids))
                continue;
            for (Integer id : ids) {
                if (!indexEntryMap.containsKey(id))
                    indexEntryMap.put(id, new IndexEntry(id, 0));
                indexEntryMap.get(id).addRole(role);
            }
        }
    }

    List<IndexEntry> list = new ArrayList<IndexEntry>();

    if (allSiteEntry.hasRoles())
        list.add(allSiteEntry);

    list.addAll(indexEntryMap.values());
    if (log.isInfoEnabled()) {
        log.info("Fetcher (" + getClass().getName() + " fetched " + String.valueOf(list));
    }
    return list;
}

From source file:eu.stratosphere.pact.common.io.RecordOutputFormat.java

/**
 * {@inheritDoc}//  w  ww .j  a  v  a2  s  .  c o m
 */
@Override
public void configure(Configuration parameters) {
    super.configure(parameters);

    this.numFields = parameters.getInteger(NUM_FIELDS_PARAMETER, -1);
    if (this.numFields < 1) {
        throw new IllegalArgumentException(
                "Invalid configuration for RecordOutputFormat: " + "Need to specify number of fields > 0.");
    }

    @SuppressWarnings("unchecked")
    Class<Value>[] arr = new Class[this.numFields];
    this.classes = arr;

    for (int i = 0; i < this.numFields; i++) {
        @SuppressWarnings("unchecked")
        Class<? extends Value> clazz = (Class<? extends Value>) parameters
                .getClass(FIELD_TYPE_PARAMETER_PREFIX + i, null);
        if (clazz == null) {
            throw new IllegalArgumentException(
                    "Invalid configuration for RecordOutputFormat: " + "No type class for parameter " + i);
        }

        this.classes[i] = clazz;
    }

    this.recordPositions = new int[this.numFields];
    boolean anyRecordPosDefined = false;
    boolean allRecordPosDefined = true;

    for (int i = 0; i < this.numFields; i++) {

        int pos = parameters.getInteger(RECORD_POSITION_PARAMETER_PREFIX + i, Integer.MIN_VALUE);

        if (pos != Integer.MIN_VALUE) {
            anyRecordPosDefined = true;

            if (pos < 0) {
                throw new IllegalArgumentException("Invalid configuration for RecordOutputFormat: "
                        + "Invalid record position for parameter " + i);
            }

            this.recordPositions[i] = pos;

        } else {
            allRecordPosDefined = false;

            this.recordPositions[i] = i;
        }
    }

    if (anyRecordPosDefined && !allRecordPosDefined) {
        throw new IllegalArgumentException("Invalid configuration for RecordOutputFormat: "
                + "Either none or all record positions must be defined.");
    }

    this.recordDelimiter = parameters.getString(RECORD_DELIMITER_PARAMETER,
            AbstractConfigBuilder.NEWLINE_DELIMITER);
    if (this.recordDelimiter == null) {
        throw new IllegalArgumentException("The delimiter in the DelimitedOutputFormat must not be null.");
    }
    this.charsetName = parameters.getString(RECORD_DELIMITER_ENCODING, null);
    this.fieldDelimiter = parameters.getString(FIELD_DELIMITER_PARAMETER, "|");
    this.lenient = parameters.getBoolean(LENIENT_PARSING, false);
}

From source file:net.sourceforge.cobertura.metrics.model.coverage.scope.AbstractCoverageScope.java

/**
 * {@inheritDoc}//from   w  w w.j  a v a 2  s  .c  o m
 */
@Override
public int compareTo(final CoverageScope that) {

    // Check sanity
    if (that == null) {
        return Integer.MIN_VALUE;
    }
    if (that == this) {
        return 0;
    }

    // Compare parts.
    int toReturn = getLowestScope().compareTo(that.getLowestScope());
    if (toReturn == 0) {

        for (LocationScope current : LocationScope.values()) {
            if (current.compareTo(getLowestScope()) > 0) {
                break;
            }

            toReturn = get(current).pattern().compareTo(that.get(current).pattern());
            if (toReturn != 0) {
                break;
            }
        }
    }

    // Compare the names
    if (toReturn == 0) {
        toReturn = this.getName().compareTo(that.getName());
    }

    // All done.
    return toReturn;
}

From source file:com.yoncabt.ebr.executor.BaseReport.java

public ReportDefinition loadDefinition(File reportFile, File jsonFile)
        throws AssertionError, IOException, JSONException {
    ReportDefinition ret = new ReportDefinition(reportFile);
    if (!jsonFile.exists()) {
        ret.setCaption(jsonFile.getName().replace(".ebr.json", ""));
        return ret;
    }/*from ww  w  .  ja  v a  2  s .c o m*/
    String jsonComment = FileUtils.readFileToString(jsonFile, "utf-8");
    JSONObject jsonObject = new JSONObject(jsonComment);
    ret.setCaption(jsonObject.optString("title", "NOT ITTLE"));
    ret.setDataSource(jsonObject.optString("datasource", "default"));
    ret.setTextEncoding(jsonObject.optString("text-encoding", "utf-8"));
    ret.setTextTemplate(jsonObject.optString("text-template", "SUITABLE"));
    if (jsonObject.has("fields")) {
        JSONArray fieldsArray = jsonObject.getJSONArray("fields");
        for (int i = 0; i < fieldsArray.length(); i++) {
            JSONObject field = fieldsArray.getJSONObject(i);
            FieldType fieldType = FieldType.valueOfJSONName(field.getString("type"));
            switch (fieldType) {
            case DATE: {
                ReportParam<Date> rp = new ReportParam<>(Date.class);
                readCommon(ret, rp, field);
                if (field.has("default-value")) {
                    rp.setDefaultValue(new Date(field.getLong("default-value")));
                }
                break;
            }
            case STRING: {
                ReportParam<String> rp = new ReportParam<>(String.class);
                readCommon(ret, rp, field);
                if (field.has("default-value")) {
                    rp.setDefaultValue(field.getString("default-value"));
                }
                break;
            }
            case INTEGER: {
                ReportParam<Integer> rp = new ReportParam<>(Integer.class);
                readCommon(ret, rp, field);
                int min = field.has("min") ? field.getInt("min") : Integer.MIN_VALUE;
                int max = field.has("max") ? field.getInt("max") : Integer.MAX_VALUE;
                rp.setMax(max);
                rp.setMin(min);
                if (field.has("default-value")) {
                    rp.setDefaultValue(field.getInt("default-value"));
                }
                break;
            }
            case LONG: {
                ReportParam<Long> rp = new ReportParam<>(Long.class);
                readCommon(ret, rp, field);
                long min = field.has("min") ? field.getLong("min") : Long.MIN_VALUE;
                long max = field.has("max") ? field.getLong("max") : Long.MAX_VALUE;
                rp.setMax(max);
                rp.setMin(min);
                if (field.has("default-value")) {
                    rp.setDefaultValue(field.getLong("default-value"));
                }
                break;
            }
            case DOUBLE: {
                ReportParam<Double> rp = new ReportParam<>(Double.class);
                readCommon(ret, rp, field);
                double min = field.has("min") ? field.getLong("min") : Double.MIN_VALUE;
                double max = field.has("max") ? field.getLong("max") : Double.MAX_VALUE;
                rp.setMax(max);
                rp.setMin(min);
                if (field.has("default-value")) {
                    rp.setDefaultValue(field.getDouble("default-value"));
                }
                break;
            }
            default: {
                throw new AssertionError(fieldType);
            }
            }
        }
    }
    return ret;
}