List of usage examples for java.lang Integer MAX_VALUE
int MAX_VALUE
To view the source code for java.lang Integer MAX_VALUE.
Click Source Link
From source file:com.karumi.maxibonkata.DevelopersGenerator.java
@Override public Developer generate(SourceOfRandomness random, GenerationStatus status) { String name = RandomStringUtils.randomAlphabetic(random.nextInt(16)); int numberOfMaxibons = random.nextInt(0, Integer.MAX_VALUE); return new Developer(name, numberOfMaxibons); }
From source file:com.qualogy.qafe.business.integration.filter.page.PageCreator.java
/** * Method to create a page object based page data in the datastore. * If no data supplied for the page, null is returned * @param id/*from w w w .j a v a 2 s .c om*/ * @return */ public static Page create(DataIdentifier id) { Page page = null; Object objPageNr = DataStore.findValue(id, DataStore.KEY_WORD_PAGE_NUMBER); Object objPageSize = DataStore.findValue(id, DataStore.KEY_WORD_PAGESIZE); if (objPageSize != null) { int pagesize = 0; if (objPageSize instanceof Number) pagesize = ((Number) objPageSize).intValue(); else if (objPageSize instanceof String && NumberUtils.isNumber((String) objPageSize)) pagesize = Integer.parseInt((String) objPageSize); if (pagesize > -1) { int pagenumber = 0; if (objPageNr instanceof Number) pagenumber = ((Number) objPageNr).intValue(); else if (objPageNr instanceof String && NumberUtils.isNumber((String) objPageNr)) pagenumber = Integer.parseInt((String) objPageNr); else if (objPageNr instanceof String && ((String) objPageNr).toUpperCase().equals(DataStore.KEY_WORD_PAGE_NUMBER_LAST)) pagenumber = Integer.MAX_VALUE; boolean countPages = false; Object objCountPages = DataStore.findValue(id, DataStore.KEY_WORD_CALCULATEPAGESAVAILABLE); if (objCountPages instanceof String) countPages = Boolean.valueOf((String) objCountPages).booleanValue(); else if (objCountPages instanceof Boolean) countPages = ((Boolean) objCountPages).booleanValue(); page = Page.create(pagenumber, pagesize, countPages, id); } } return page; }
From source file:net.dv8tion.jda.core.utils.IOUtil.java
/** * Used as an alternate to Java's nio Files.readAllBytes. * <p>/*ww w. jav a2 s. c om*/ * This customized version for File is provide (instead of just using {@link #readFully(java.io.InputStream)} with a FileInputStream) * because * with a File we can determine the total size of the array and do not need to have a buffer. This results * in a memory footprint that is half the size of {@link #readFully(java.io.InputStream)} * <p> * Code provided from <a href="http://stackoverflow.com/a/6276139">http://stackoverflow.com/a/6276139</a> * * @param file * The file from which we should retrieve the bytes from * @return * A byte[] containing all of the file's data * @throws IOException * Thrown if there is a problem while reading the file. */ public static byte[] readFully(File file) throws IOException { Args.notNull(file, "File"); Args.check(file.exists(), "Provided file does not exist!"); try (InputStream is = new FileInputStream(file)) { // Get the size of the file long length = file.length(); // You cannot create an array using a long type. // It needs to be an int type. // Before converting to an int type, check // to ensure that file is not larger than Integer.MAX_VALUE. if (length > Integer.MAX_VALUE) { throw new IOException("Cannot read the file into memory completely due to it being too large!"); // File is too large } // Create the byte array to hold the data byte[] bytes = new byte[(int) length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } // Close the input stream and return bytes is.close(); return bytes; } }
From source file:com.bigdata.dastor.db.filter.IdentityQueryFilter.java
/** * Only for use in testing; will read entire CF into memory. *//*from ww w. j av a 2s . co m*/ public IdentityQueryFilter(String key, QueryPath path) { super(key, path, ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false, Integer.MAX_VALUE); }
From source file:Main.java
/** * Make a textview to a collapsible textview with the indicator on the right of the textview * //w ww . j a va 2s . c om * @param tv , {@link TextView} to be converted * @param upDrawableResId , drawable resource id to be used as up indicator * @param downDrawableResId , drawable resource id to be used as down indicator * @param lineTreshold , no of line to be displayed for the collapsed state */ public static void makeCollapsible(final TextView tv, int upDrawableResId, int downDrawableResId, final int lineTreshold) { final Drawable[] drawables = tv.getCompoundDrawables(); final Drawable up = tv.getContext().getResources().getDrawable(upDrawableResId); final Drawable down = tv.getContext().getResources().getDrawable(downDrawableResId); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); tv.setEllipsize(TruncateAt.END); tv.setMaxLines(lineTreshold); tv.setTag(true); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v instanceof TextView) { TextView tv = (TextView) v; boolean snippet = (Boolean) tv.getTag(); if (snippet) { // show everything snippet = false; tv.setMaxLines(Integer.MAX_VALUE); tv.setEllipsize(null); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], up, drawables[3]); } else { // show snippet snippet = true; tv.setMaxLines(lineTreshold); tv.setEllipsize(TruncateAt.END); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); } tv.setTag(snippet); } } }); } else { tv.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { ViewTreeObserver vto = tv.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onGlobalLayout() { tv.setEllipsize(TruncateAt.END); int line = tv.getLineCount(); tv.setMaxLines(lineTreshold); if (line <= lineTreshold) { tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // empty listener // Log.d("line count", "count: "+ // tv.getLineCount()); } }); if (tv.getLayout() != null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { tv.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { tv.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } return; } tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); tv.setTag(true); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v instanceof TextView) { TextView tv = (TextView) v; boolean snippet = (Boolean) tv.getTag(); if (snippet) { snippet = false; // show everything tv.setMaxLines(Integer.MAX_VALUE); tv.setEllipsize(null); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], up, drawables[3]); } else { snippet = true; // show snippet tv.setMaxLines(lineTreshold); tv.setEllipsize(TruncateAt.END); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); } tv.setTag(snippet); } } }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { tv.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { tv.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } }); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); } }
From source file:IndexService.IndexMergePartitioner.java
@Override public int getPartition(IndexKey key, IndexValue value, int numPartitions) { return (key.getfvs().get(0).hashCode() & Integer.MAX_VALUE) % numPartitions; }
From source file:com.softwarementors.extjs.djn.router.processor.standard.form.upload.DiskFileItemFactory2.java
@Override public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName) { return new DiskFileItem2(fieldName, contentType, isFormField, fileName, Integer.MAX_VALUE, getRepository()); }
From source file:IORoutines.java
public static byte[] load(File file) throws IOException { long fileLength = file.length(); if (fileLength > Integer.MAX_VALUE) { throw new IOException("File '" + file.getName() + "' too big"); }//from w w w . j a v a 2 s . co m InputStream in = new FileInputStream(file); try { return loadExact(in, (int) fileLength); } finally { in.close(); } }
From source file:Main.java
/** * <p>Finds the last index of the given object within the array.</p> * * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p> * /*from ww w . j a v a 2s. c o m*/ * @param array the array to travers backwords looking for the object, may be <code>null</code> * @param objectToFind the object to find, may be <code>null</code> * @return the last index of the object within the array, * {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input */ public static int lastIndexOf(Object[] array, Object objectToFind) { return lastIndexOf(array, objectToFind, Integer.MAX_VALUE); }
From source file:com.zimbra.common.util.BufferStreamRequestEntity.java
public BufferStreamRequestEntity(long sizeHint) { this(sizeHint, Integer.MAX_VALUE); }