id
stringlengths
24
24
input
stringlengths
58
605
output
stringlengths
57
725
636767021a6d9265ec0178bf
/** * <p>Convert the input object into a java.lang.Character.</p> * @param type Data type to which this value should be converted. * @param value The input value to be converted. * @return The converted value. * @throws Exception if conversion cannot be performed successfully * @since 1.8.0 */ @Override protect...
@Override protected Object convertToType(final Class<?> type,final Object value) throws Exception { String string=value.toString(); if (string.length() == 0) { return BeanUtils.getDefaultValue(type); } else { return string.charAt(0); } }
6367670b1a6d9265ec017a0f
/** * Case in-sensitive Checks if the String contains any character in the given set of string. */ public static boolean containsAnyIgnoreCase(String str,List<String> searchStrArray){
public static boolean containsAnyIgnoreCase(String str,List<String> searchStrArray){ if (StringUtils.isEmpty(str) || searchStrArray == null || searchStrArray.isEmpty()) { return false; } for ( String item : searchStrArray) { if (containsIgnoreCase(str,item)) { return true; } } return false;...
636766a81a6d9265ec01758e
/** * Returns a prime number which is <code>&gt;= desiredCapacity</code> and very close to <code>desiredCapacity</code> (within 11% if <code>desiredCapacity &gt;= 1000</code>). * @param desiredCapacity the capacity desired by the user. * @return the capacity which should be used for a hashtable. */ public static i...
public static int nextPrime(int desiredCapacity){ if (desiredCapacity >= largestPrime) { return largestPrime; } int i=Arrays.binarySearch(primeCapacities,desiredCapacity); if (i < 0) { i=-i - 1; } return primeCapacities[i]; }
6367670a1a6d9265ec0179cf
/** * <p>Converts the Character to a char handling <code>null</code>.</p> <pre> CharUtils.toChar(null, 'X') = 'X' CharUtils.toChar(' ', 'X') = ' ' CharUtils.toChar('A', 'X') = 'A' </pre> * @param ch the character to convert * @param defaultValue the value to use if the Character is null * @return the char val...
public static char toChar(final Character ch,final char defaultValue){ if (ch == null) { return defaultValue; } return ch.charValue(); }
6367676b1a6d9265ec0181e2
/** * Return the first element in '<code>candidates</code>' that is contained in '<code>source</code>'. If no element in '<code>candidates</code>' is present in '<code>source</code>' returns <code>null</code>. Iteration order is {@link Collection} implementation specific. * @param source the source Collection * @pa...
public static Object findFirstMatch(Collection source,Collection candidates){ if (isEmpty(source) || isEmpty(candidates)) { return null; } for ( Object candidate : candidates) { if (source.contains(candidate)) { return candidate; } } return null; }
6367676b1a6d9265ec0181ee
/** * Trim trailing whitespace from the given String. * @param str the String to check * @return the trimmed String * @see java.lang.Character#isWhitespace */ public static String trimTrailingWhitespace(String str){
public static String trimTrailingWhitespace(String str){ if (!hasLength(str)) { return str; } StringBuilder sb=new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
636767dc1a6d9265ec0186cb
/** * initialize config, such as check dist path */ public void init(){
public void init(){ File dist=new File(analyzeResultDist); if (!dist.exists()) { dist.mkdirs(); return; } if (dist.isFile()) { throw new IllegalArgumentException(analyzeResultDist + " must be a directory"); } }
636767a31a6d9265ec018552
/** * Read a {@code string} field value from the stream. */ @Override public String readString() throws IOException {
@Override public String readString() throws IOException { final int size=readRawVarint32(); if (size <= (bufferSize - bufferPos) && size > 0) { final String result=STRING.deser(buffer,bufferPos,size); bufferPos+=size; return result; } else { return STRING.deser(readRawBytes(size)); } }
636767a61a6d9265ec0185b7
/** * Interpret a character as a digit (in any base up to 36) and return the numeric value. This is like {@code Character.digit()} but we don't accept non-ASCII digits. */ private static int digitValue(final char c){
private static int digitValue(final char c){ if ('0' <= c && c <= '9') { return c - '0'; } else if ('a' <= c && c <= 'z') { return c - 'a' + 10; } else { return c - 'A' + 10; } }
636767e01a6d9265ec018755
/** * build content,if it has ats someone set the ats */ private Map<String,Object> buildContent(JsonObject jsonObject){
private Map<String,Object> buildContent(JsonObject jsonObject){ Map<String,Object> content=new HashMap<>(); content.put("msg_type",jsonObject.get("msg_type").getAsString()); if (jsonObject.get("ats") != null) { String ats=jsonObject.get("ats").getAsString(); String text=jsonObject.get("content").getAsJson...
6367667f1a6d9265ec017458
/** * Remove an {@link AtmosphereHandler}. * @param mapping the mapping used when invoking {@link #addAtmosphereHandler(String,AtmosphereHandler)}; * @return true if removed */ public AtmosphereFramework removeAtmosphereHandler(String mapping){
public AtmosphereFramework removeAtmosphereHandler(String mapping){ if (mapping.endsWith("/")) { mapping+=mappingRegex; } atmosphereHandlers.remove(mapping); return this; }
636767a21a6d9265ec018517
/** * Returns a single byte array containg all the contents written to the buffer(s). */ public final byte[] toByteArray(){
public final byte[] toByteArray(){ LinkedBuffer node=head; int offset=0, len; final byte[] buf=new byte[size]; do { if ((len=node.offset - node.start) > 0) { System.arraycopy(node.buffer,node.start,buf,offset,len); offset+=len; } } while ((node=node.next) != null); return buf; }
6367667d1a6d9265ec017401
/** * <p>Unescapes any Java literals found in the <code>String</code>. For example, it will turn a sequence of <code>'\'</code> and <code>'n'</code> into a newline character, unless the <code>'\'</code> is preceded by another <code>'\'</code>.</p> * @param str the <code>String</code> to unescape, may be null * @ret...
public static String unescapeJava(String str) throws Exception { if (str == null) { return null; } StringWriter writer=new StringWriter(str.length()); unescapeJava(writer,str); return writer.toString(); }
636766f01a6d9265ec01763e
/** * Translate a MIME standard character set name into the Java equivalent. * @param charset The MIME standard name. * @return The Java equivalent for this name. */ private static String javaCharset(String charset){
private static String javaCharset(String charset){ if (charset == null) { return null; } String mappedCharset=MIME2JAVA.get(charset.toLowerCase(Locale.ENGLISH)); if (mappedCharset == null) { return charset; } return mappedCharset; }
6367676a1a6d9265ec0181bf
/** * Turn the given Object into a String with single quotes if it is a String; keeping the Object as-is else. * @param obj the input Object (e.g. "myString") * @return the quoted String (e.g. "'myString'"),or the input object as-is if not a String */ public static Object quoteIfString(Object obj){
public static Object quoteIfString(Object obj){ return (obj instanceof String ? quote((String)obj) : obj); }
636767501a6d9265ec017e86
/** * {@inheritDoc} */ @Override public ListNode<E> previousNode(){
@Override public ListNode<E> previousNode(){ checkForComodification(); if (!hasPrevious()) { throw new NoSuchElementException(); } last=next=next.prev; nextIndex--; return last; }
636766f21a6d9265ec017667
/** * Reads a signed short value in this {@link ClassReader}. <i>This method is intended for {@link Attribute} sub classes, and is normally not needed by class generators or adapters.</i> * @param offset the start offset of the value to be read in this {@link ClassReader}. * @return the read value. */ public sho...
public short readShort(final int offset){ byte[] classBuffer=classFileBuffer; return (short)(((classBuffer[offset] & 0xFF) << 8) | (classBuffer[offset + 1] & 0xFF)); }
636767031a6d9265ec0178ef
/** * Returns a copy of the given array of size 1 greater than the argument. The last value of the array is left to the default value. * @param array The array to copy, must not be <code>null</code>. * @param newArrayComponentType If <code>array</code> is <code>null</code>, create asize 1 array of this type. * @re...
private static Object copyArrayGrow1(final Object array,final Class<?> newArrayComponentType){ if (array != null) { int arrayLength=Array.getLength(array); Object newArray=Array.newInstance(array.getClass().getComponentType(),arrayLength + 1); System.arraycopy(array,0,newArray,0,arrayLength); return n...
636767431a6d9265ec017c8d
/** * Computes floor($\log_2 (n)$) $+ 1$ */ private int computeBinaryLog(int n){
private int computeBinaryLog(int n){ assert n >= 0; int result=0; while (n > 0) { n>>=1; ++result; } return result; }
636767611a6d9265ec018116
/** * Efficient way to compute the intersection between two sets * @param set1 set $1$ * @param set2 set $2$ * @return intersection of set $1$ and $2$ */ private Set<V> intersection(Set<V> set1,Set<V> set2){
private Set<V> intersection(Set<V> set1,Set<V> set2){ Set<V> a; Set<V> b; if (set1.size() <= set2.size()) { a=set1; b=set2; } else { a=set2; b=set1; } return a.stream().filter(b::contains).collect(Collectors.toSet()); }
636766f71a6d9265ec017730
/** * Converts the given Collection into an array of Strings. The returned array does not contain <code>null</code> entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element is <code>null</code>. * @param collection The collection to convert * @return A new arr...
static String[] toNoNullStringArray(Collection<?> collection){ if (collection == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } return toNoNullStringArray(collection.toArray()); }
636767081a6d9265ec0179a2
/** * <p>Utility method for {@link #createNumber(String)}.</p> <p>Returns <code>true</code> if s is <code>null</code>.</p> * @param s the String to check * @return if it is all zeros or <code>null</code> */ private static boolean isAllZeros(String s){
private static boolean isAllZeros(String s){ if (s == null) { return true; } for (int i=s.length() - 1; i >= 0; i--) { if (s.charAt(i) != '0') { return false; } } return s.length() > 0; }
636766821a6d9265ec0174b3
/** * Invoke the {@link BroadcastFilter} * @param msg * @return */ protected Object filter(Object msg){
protected Object filter(Object msg){ BroadcastAction a=bc.filter(msg); if (a.action() == BroadcastAction.ACTION.ABORT || msg == null) return null; else return a.message(); }
636767e01a6d9265ec018764
/** * Convert process properties to source data */ private JsonObject convertProperties(List<KeyStringValuePair> properties){
private JsonObject convertProperties(List<KeyStringValuePair> properties){ final JsonObject result=new JsonObject(); for ( KeyStringValuePair kv : properties) { result.addProperty(kv.getKey(),kv.getValue()); } return result; }
6367677e1a6d9265ec018314
/** * Removes any inactive nodes from the Category tree. */ protected int removeUnusedNodes(){
protected int removeUnusedNodes(){ int count=0; CategoryNode root=_categoryModel.getRootCategoryNode(); Enumeration enumeration=root.depthFirstEnumeration(); while (enumeration.hasMoreElements()) { CategoryNode node=(CategoryNode)enumeration.nextElement(); if (node.isLeaf() && node.getNumberOfContainedR...
636766ff1a6d9265ec017853
/** * Returns the label corresponding to the given bytecode offset. The default implementation of this method creates a label for the given offset if it has not been already created. * @param bytecodeOffset a bytecode offset in a method. * @param labels the already created labels, indexed by their offset. If a labe...
protected Label readLabel(final int bytecodeOffset,final Label[] labels){ if (labels[bytecodeOffset] == null) { labels[bytecodeOffset]=new Label(); } return labels[bytecodeOffset]; }
6367677d1a6d9265ec0182fd
/** * If <code>value</code> is "true", then <code>true</code> is returned. If <code>value</code> is "false", then <code>true</code> is returned. Otherwise, <code>default</code> is returned. <p>Case of value is unimportant. */ public static boolean toBoolean(String value,boolean dEfault){
public static boolean toBoolean(String value,boolean dEfault){ if (value == null) return dEfault; String trimmedVal=value.trim(); if ("true".equalsIgnoreCase(trimmedVal)) return true; if ("false".equalsIgnoreCase(trimmedVal)) return false; return dEfault; }
6367676a1a6d9265ec0181cd
/** * Trim leading whitespace from the given String. * @param str the String to check * @return the trimmed String * @see java.lang.Character#isWhitespace */ public static String trimLeadingWhitespace(String str){
public static String trimLeadingWhitespace(String str){ if (!hasLength(str)) { return str; } StringBuilder sb=new StringBuilder(str); while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) { sb.deleteCharAt(0); } return sb.toString(); }
636766fe1a6d9265ec01782a
/** * Reads a CONSTANT_Utf8 constant pool entry in {@link #classFileBuffer}. * @param constantPoolEntryIndex the index of a CONSTANT_Utf8 entry in the class's constant pooltable. * @param charBuffer the buffer to be used to read the string. This buffer must be sufficientlylarge. It is not automatically resized. *...
final String readUtf(final int constantPoolEntryIndex,final char[] charBuffer){ String value=constantUtf8Values[constantPoolEntryIndex]; if (value != null) { return value; } int cpInfoOffset=cpInfoOffsets[constantPoolEntryIndex]; return constantUtf8Values[constantPoolEntryIndex]=readUtf(cpInfoOffset + 2,r...
636766851a6d9265ec01751b
/** * Helper to decode half of a hexadecimal number from a string. * @param c The ASCII character of the hexadecimal number to decode.Must be in the range {@code [0-9a-fA-F]}. * @return The hexadecimal value represented in the ASCII charactergiven, or {@link Character#MAX_VALUE} if the character is invalid. */ p...
private static char decodeHexNibble(final char c){ if ('0' <= c && c <= '9') { return (char)(c - '0'); } else if ('a' <= c && c <= 'f') { return (char)(c - 'a' + 10); } else if ('A' <= c && c <= 'F') { return (char)(c - 'A' + 10); } else { return Character.MAX_VALUE; } }
636766f21a6d9265ec01767d
/** * Object to String ,when null object then null else return toString(); */ public static String toString(Object object){
public static String toString(Object object){ return (object == null) ? null : object.toString(); }
636767581a6d9265ec017fc4
/** * Calculate the factorial of $n$. * @param n the input number * @return the factorial */ public static long factorial(int n){
public static long factorial(int n){ long multi=1; for (int i=1; i <= n; i++) { multi=multi * i; } return multi; }
636767511a6d9265ec017eb6
/** * Either finds and returns a circulator to the node on the boundary of the component, which satisfies the {@code predicate} or returns a circulator to the {@code stop} node. * @param predicate the condition the desired node should satisfy * @param start the node to start the search from * @param stop the node...
private OuterFaceCirculator selectOnOuterFace(Predicate<Node> predicate,Node start,Node stop,int dir){ OuterFaceCirculator circulator=start.iterator(dir); Node current=circulator.next(); while (current != stop && !predicate.test(current)) { current=circulator.next(); } return circulator; }
636767841a6d9265ec0183e8
/** * Add an <code>event</code> as the last event in the buffer. */ public void add(LoggingEvent event){
public void add(LoggingEvent event){ ea[last]=event; if (++last == maxSize) last=0; if (numElems < maxSize) numElems++; else if (++first == maxSize) first=0; }
636767a41a6d9265ec01857e
/** * Compares the two specified {@code long} values. The sign of the value returned is the same as that of{@code ((Long) a).compareTo(b)}. <p> <b>Note for Java 7 and later:</b> this method should be treated as deprecated; use the equivalent {@link Long#compare} method instead. * @param a the first {@code long} to...
private static int compareSigned(long a,long b){ return (a < b) ? -1 : ((a > b) ? 1 : 0); }
636767691a6d9265ec0181ae
/** * Copy the given Enumeration into a String array. The Enumeration must contain String elements only. * @param enumeration the Enumeration to copy * @return the String array (<code>null</code> if the passed-inEnumeration was <code>null</code>) */ public static String[] toStringArray(Enumeration<String> enumerat...
public static String[] toStringArray(Enumeration<String> enumeration){ if (enumeration == null) { return null; } List<String> list=java.util.Collections.list(enumeration); return list.toArray(new String[list.size()]); }
636766a91a6d9265ec0175ae
/** * Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary. * @param byteArrayValue an array of bytes. May be {@literal null} to put {@code byteLength} nullbytes into this byte vector. * @param byteOffset index of the first byte of byteArrayValue that must be copi...
public ByteVector putByteArray(final byte[] byteArrayValue,final int byteOffset,final int byteLength){ if (length + byteLength > data.length) { enlarge(byteLength); } if (byteArrayValue != null) { System.arraycopy(byteArrayValue,byteOffset,data,length,byteLength); } length+=byteLength; return this; ...
636766f11a6d9265ec01764f
/** * Returns the values for the BeanMap. * @return values for the BeanMap. The returned collection is not modifiable. */ public Collection<Object> values(){
public Collection<Object> values(){ ArrayList<Object> answer=new ArrayList<>(readMethods.size()); for (Iterator<Object> iter=valueIterator(); iter.hasNext(); ) { answer.add(iter.next()); } return Collections.unmodifiableList(answer); }
636766f81a6d9265ec017758
/** * Returns a hash code value for this type. * @return a hash code value for this type. */ @Override public int hashCode(){
@Override public int hashCode(){ int hashCode=13 * (sort == INTERNAL ? OBJECT : sort); if (sort >= ARRAY) { for (int i=valueBegin, end=valueEnd; i < end; i++) { hashCode=17 * (hashCode + valueBuffer.charAt(i)); } } return hashCode; }
6367676c1a6d9265ec01820b
/** * Delete any character in a given String. * @param inString the original String * @param charsToDelete a set of characters to delete.E.g. "az\n" will delete 'a's, 'z's and new lines. * @return the resulting String */ public static String deleteAny(String inString,String charsToDelete){
public static String deleteAny(String inString,String charsToDelete){ if (!hasLength(inString) || !hasLength(charsToDelete)) { return inString; } StringBuilder sb=new StringBuilder(); for (int i=0; i < inString.length(); i++) { char c=inString.charAt(i); if (charsToDelete.indexOf(c) == -1) { s...
636766861a6d9265ec01755a
/** * Match a URI against the pattern. * @param uri the uri to match against the template. * @return the match result, otherwise null if no match occurs. */ public final MatchResult match(CharSequence uri){
public final MatchResult match(CharSequence uri){ if (uri == null || uri.length() == 0) return (regexPattern == null) ? EMPTY_STRING_MATCH_RESULT : null; else if (regexPattern == null) return null; Matcher m=regexPattern.matcher(uri); if (!m.matches()) return null; return (groupIndexes.length > 0) ? ne...
636766f91a6d9265ec01777d
/** * @param b An ASCII encoded character 0-9 a-f A-F * @return The byte value of the character 0-16. */ public static byte convertHexDigit(byte b){
public static byte convertHexDigit(byte b){ if ((b >= '0') && (b <= '9')) return (byte)(b - '0'); if ((b >= 'a') && (b <= 'f')) return (byte)(b - 'a' + 10); if ((b >= 'A') && (b <= 'F')) return (byte)(b - 'A' + 10); throw new IllegalArgumentException("!hex:" + Integer.toHexString(0xff & b)); }
636766801a6d9265ec017477
/** * Add the specified files in reverse order. */ private void addReverse(final InputStream[] files){
private void addReverse(final InputStream[] files){ for (int i=files.length - 1; i >= 0; --i) { stack.add(files[i]); } }
636767de1a6d9265ec01871e
/** * @param modelName model name of the entity * @throws IllegalStateException if sharding key indices are not continuous */ private void check(String modelName) throws IllegalStateException {
private void check(String modelName) throws IllegalStateException { for (int i=0; i < keys.size(); i++) { final ModelColumn modelColumn=keys.get(i); if (modelColumn == null) { throw new IllegalStateException("Sharding key index=" + i + " is missing in "+ modelName); } } }
636766f81a6d9265ec01774b
/** * Reads a byte from the <code>buffer</code>, and refills it as necessary. * @return The next byte from the input stream. * @throws IOException if there is no more data available. */ public byte readByte() throws IOException {
public byte readByte() throws IOException { if (head == tail) { head=0; tail=input.read(buffer,head,bufSize); if (tail == -1) { throw new IOException("No more data is available"); } } return buffer[head++]; }
636766851a6d9265ec017515
/** * Automatically suspend the {@link AtmosphereResource} based on {@link AtmosphereResource.TRANSPORT} value. * @param r a {@link AtmosphereResource} * @return {@link Action#CONTINUE} */ @Override public Action inspect(AtmosphereResource r){
@Override public Action inspect(AtmosphereResource r){ switch (r.transport()) { case JSONP: case AJAX: case LONG_POLLING: r.resumeOnBroadcast(true); break; default : break; } return Action.CONTINUE; }
636767611a6d9265ec018106
/** * Compute the sum of the weights entering a vertex * @param v the vertex * @return the sum of the weights entering a vertex */ public double vertexWeight(Set<V> v){
public double vertexWeight(Set<V> v){ double wsum=0.0; for ( DefaultWeightedEdge e : workingGraph.edgesOf(v)) { wsum+=workingGraph.getEdgeWeight(e); } return wsum; }
636767841a6d9265ec0183f2
/** * @see Comparator */ public int compare(Object aObj1,Object aObj2){
public int compare(Object aObj1,Object aObj2){ if ((aObj1 == null) && (aObj2 == null)) { return 0; } else if (aObj1 == null) { return -1; } else if (aObj2 == null) { return 1; } final EventDetails le1=(EventDetails)aObj1; final EventDetails le2=(EventDetails)aObj2; if (le1.getTimeStamp()...
636767861a6d9265ec01844c
/** * Remove the appender with the name passed as parameter form the list of appenders. */ public void removeAppender(String name){
public void removeAppender(String name){ if (name == null || appenderList == null) return; int size=appenderList.size(); for (int i=0; i < size; i++) { if (name.equals(((Appender)appenderList.elementAt(i)).getName())) { appenderList.removeElementAt(i); break; } } }
636767781a6d9265ec018242
/** * Call the <code>doAppend</code> method on all attached appenders. */ public int appendLoopOnAppenders(LoggingEvent event){
public int appendLoopOnAppenders(LoggingEvent event){ int size=0; Appender appender; if (appenderList != null) { size=appenderList.size(); for (int i=0; i < size; i++) { appender=(Appender)appenderList.elementAt(i); appender.doAppend(event); } } return size; }
6367670c1a6d9265ec017a2a
/** * <p>Converts an array of object Integers to primitives.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * @param array a <code>Integer</code> array, may be <code>null</code> * @return an <code>int</code> array, <code>null</code> if null array input * @throws NullPointerE...
public static int[] toPrimitive(final Integer[] array){ if (array == null) { return null; } else if (array.length == 0) { return ArrayUtils.EMPTY_INT_ARRAY; } final int[] result=new int[array.length]; for (int i=0; i < array.length; i++) { result[i]=array[i].intValue(); } return result; }
636767041a6d9265ec017911
/** * <p> Registers the given object. Used by the reflection methods to avoid infinite loops. </p> * @param value The object to register. */ static void register(Object value){
static void register(Object value){ if (value != null) { Map m=getRegistry(); if (m == null) { m=new WeakHashMap(); REGISTRY.set(m); } m.put(value,null); } }
636767511a6d9265ec017eb0
/** * Get the number of non-zero entries of a row. * @param row the row * @return the number of non-zero entries of a row */ public int nonZeros(int row){
public int nonZeros(int row){ assert row >= 0 && row < rowOffsets.length; return rowOffsets[row + 1] - rowOffsets[row]; }
6367676c1a6d9265ec018223
/** * Check whether the given Collection contains the given element instance. <p>Enforces the given instance to be present, rather than returning <code>true</code> for an equal element as well. * @param collection the Collection to check * @param element the element to look for * @return <code>true</code> if found...
public static boolean containsInstance(Collection collection,Object element){ if (collection != null) { for ( Object candidate : collection) { if (candidate == element) { return true; } } } return false; }
636766fa1a6d9265ec01779d
/** * <p>Checks whether the character is ASCII 7 bit control.</p> <pre> CharUtils.isAsciiControl('a') = false CharUtils.isAsciiControl('A') = false CharUtils.isAsciiControl('3') = false CharUtils.isAsciiControl('-') = false CharUtils.isAsciiControl('\n') = true CharUtils.isAsciiControl('&copy;') = false </pre> *...
public static boolean isAsciiControl(final char ch){ return ch < 32 || ch == 127; }
6367670b1a6d9265ec0179f2
/** * Return <code>true</code> if this map contains a mapping for the specified key. * @param key the key to be searched for * @return true if the map contains the key */ @Override public boolean containsKey(final Object key){
@Override public boolean containsKey(final Object key){ if (this.fast) { return this.map.containsKey(key); } else { synchronized (this.map) { return this.map.containsKey(key); } } }
636766fa1a6d9265ec017796
/** * <p>Converts an array of primitive booleans to objects.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * @param array a <code>boolean</code> array * @return a <code>Boolean</code> array, <code>null</code> if null array input */ public static Boolean[] toObject(final boo...
public static Boolean[] toObject(final boolean[] array){ if (array == null) { return null; } else if (array.length == 0) { return ArrayUtils.EMPTY_BOOLEAN_OBJECT_ARRAY; } final Boolean[] result=new Boolean[array.length]; for (int i=0; i < array.length; i++) { result[i]=array[i] ? Boolean.TRUE :...
636767aa1a6d9265ec01864a
/** * Copies bytes to a {@code byte[]}. */ public byte[] toByteArray(){
public byte[] toByteArray(){ final int size=bytes.length; final byte[] copy=new byte[size]; System.arraycopy(bytes,0,copy,0,size); return copy; }
636767561a6d9265ec017f7c
/** * Transform from a Set representation to a graph path. * @param tour a set containing the edges of the tour * @param graph the graph * @return a graph path */ protected GraphPath<V,E> edgeSetToTour(Set<E> tour,Graph<V,E> graph){
protected GraphPath<V,E> edgeSetToTour(Set<E> tour,Graph<V,E> graph){ List<V> vertices=new ArrayList<>(tour.size() + 1); MaskSubgraph<V,E> tourGraph=new MaskSubgraph<>(graph,v -> false,e -> !tour.contains(e)); new DepthFirstIterator<>(tourGraph).forEachRemaining(vertices::add); return vertexListToTour(vertices,...
6367670a1a6d9265ec0179f1
/** * <p>Converts an array of primitive shorts to objects.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * @param array a <code>short</code> array * @return a <code>Short</code> array, <code>null</code> if null array input */ public static Short[] toObject(final short[] arr...
public static Short[] toObject(final short[] array){ if (array == null) { return null; } else if (array.length == 0) { return ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY; } final Short[] result=new Short[array.length]; for (int i=0; i < array.length; i++) { result[i]=new Short(array[i]); } return r...
636766fe1a6d9265ec017823
/** * Adds a CONSTANT_NameAndType_info to the constant pool of this symbol table. Does nothing if the constant pool already contains a similar item. * @param name a field or method name. * @param descriptor a field or method descriptor. * @return a new or already existing Symbol with the given value. */ int addCo...
int addConstantNameAndType(final String name,final String descriptor){ final int tag=Symbol.CONSTANT_NAME_AND_TYPE_TAG; int hashCode=hash(tag,name,descriptor); Entry entry=get(hashCode); while (entry != null) { if (entry.tag == tag && entry.hashCode == hashCode && entry.name.equals(name) && entry.value.equa...
636767461a6d9265ec017d17
/** * Unescape a string DOT identifier. * @param input the input * @return the unescaped output */ private String unescapeId(String input){
private String unescapeId(String input){ final char quote='"'; if (input.charAt(0) != quote || input.charAt(input.length() - 1) != quote) { return input; } String noQuotes=input.subSequence(1,input.length() - 1).toString(); String unescaped=unescapeId.translate(noQuotes); return unescaped; }
6367676c1a6d9265ec018204
/** * Concatenate the given String arrays into one, with overlapping array elements included twice. <p>The order of elements in the original arrays is preserved. * @param array1 the first array (can be <code>null</code>) * @param array2 the second array (can be <code>null</code>) * @return the new array (<code>nul...
public static String[] concatenateStringArrays(String[] array1,String[] array2){ if (Objects.isEmpty(array1)) { return array2; } if (Objects.isEmpty(array2)) { return array1; } String[] newArr=new String[array1.length + array2.length]; System.arraycopy(array1,0,newArr,0,array1.length); System.arra...
636767641a6d9265ec018190
/** * Moves all vertices from the bucket with label {@code minLabel} to the bucket with label 0.Clears the bucket with label {@code minLabel}. Updates the labeling accordingly. * @param bucketsByLabel the buckets vertices are stored in * @param labels the labels of the vertices * @param minLabel the minimum valu...
private void reload(List<Set<Integer>> bucketsByLabel,List<Integer> labels,int minLabel){ if (minLabel != 0 && minLabel < bucketsByLabel.size()) { Set<Integer> bucket=bucketsByLabel.get(minLabel); for ( Integer vertex : bucket) { labels.set(vertex,0); bucketsByLabel.get(0).add(vertex); } ...
6367676a1a6d9265ec0181d4
/** * Append the given String to the given String array, returning a new array consisting of the input array contents plus the given String. * @param array the array to append to (can be <code>null</code>) * @param str the String to append * @return the new array (never <code>null</code>) */ public static String[...
public static String[] addStringToArray(String[] array,String str){ if (Objects.isEmpty(array)) { return new String[]{str}; } String[] newArr=new String[array.length + 1]; System.arraycopy(array,0,newArr,0,array.length); newArr[array.length]=str; return newArr; }
6367676b1a6d9265ec0181dd
/** * Returns the number of occurrences the substring {@code sub} appears in string {@code str}. * @param str string to search in. Return 0 if this is null. * @param sub string to search for. Return 0 if this is null. * @return the number of occurrences the substring {@code sub} appears in string {@code str}. */...
public static int countOccurrencesOf(String str,String sub){ if (str == null || sub == null || str.length() == 0 || sub.length() == 0) { return 0; } int count=0; int pos=0; int idx; while ((idx=str.indexOf(sub,pos)) != -1) { ++count; pos=idx + sub.length(); } return count; }
636766811a6d9265ec017499
/** * <p> Checks in the specified list if there is at least one instance of the given {@link AtmosphereInterceptor interceptor} implementation class.</p> * @param interceptorList the interceptors * @param c the interceptor class * @return {@code false} if an instance of the class already exists in th...
private boolean checkDuplicate(final List<AtmosphereInterceptor> interceptorList,Class<? extends AtmosphereInterceptor> c){ for ( final AtmosphereInterceptor i : interceptorList) { if (i.getClass().equals(c)) { return true; } } return false; }
636766fe1a6d9265ec017821
/** * <p>Append to the <code>toString</code> the detail of a <code>byte</code> array.</p> * @param buffer the <code>StringBuffer</code> to populate * @param fieldName the field name, typically not used as already appended * @param array the array to add to the <code>toString</code>,not <code>null</code> */ pro...
protected void appendDetail(StringBuffer buffer,String fieldName,byte[] array){ buffer.append(arrayStart); for (int i=0; i < array.length; i++) { if (i > 0) { buffer.append(arraySeparator); } appendDetail(buffer,fieldName,array[i]); } buffer.append(arrayEnd); }
636767561a6d9265ec017f63
/** * Checks whether there exist unvisited vertices. * @return true if there exist unvisited vertices. */ @Override public boolean hasNext(){
@Override public boolean hasNext(){ if (current != null) { return true; } current=advance(); if (current != null && nListeners != 0) { fireVertexTraversed(createVertexTraversalEvent(current)); } return current != null; }
636766a81a6d9265ec017586
/** * Pops the given number of abstract types from the output frame stack. * @param elements the number of abstract types that must be popped. */ private void pop(final int elements){
private void pop(final int elements){ if (outputStackTop >= elements) { outputStackTop-=elements; } else { outputStackStart-=elements - outputStackTop; outputStackTop=0; } }
636767e11a6d9265ec018795
/** * @return true if the bucket is same. */ public boolean isCompatible(DataTable dataset){
public boolean isCompatible(DataTable dataset){ final List<String> sortedKeys=dataset.sortedKeys(new HeatMap.KeyComparator(true)); long[] existedBuckets=new long[sortedKeys.size()]; for (int i=0; i < sortedKeys.size(); i++) { String key=sortedKeys.get(i); if (key.equals(Bucket.INFINITE_NEGATIVE)) { ...
636767791a6d9265ec018263
/** * Find class given class name. * @param className class name, may not be null. * @return class, will not be null. * @throws ClassNotFoundException thrown if class can not be found. */ private Class findClass(final String className) throws ClassNotFoundException {
private Class findClass(final String className) throws ClassNotFoundException { try { return Thread.currentThread().getContextClassLoader().loadClass(className); } catch ( ClassNotFoundException e) { try { return Class.forName(className); } catch ( ClassNotFoundException e1) { return g...
636767611a6d9265ec018112
/** * {@inheritDoc} */ @Override protected V provideNextVertex(){
@Override protected V provideNextVertex(){ V v=super.provideNextVertex(); for (int i=path.size() - 1; i >= 0; --i) { if (graph.containsEdge(path.get(i),v)) { break; } path.remove(i); } path.add(v); return v; }
636767131a6d9265ec017b23
/** * Adds a source line number corresponding to this label. * @param lineNumber a source line number (which should be strictly positive). */ final void addLineNumber(final int lineNumber){
final void addLineNumber(final int lineNumber){ if (this.lineNumber == 0) { this.lineNumber=(short)lineNumber; } else { if (otherLineNumbers == null) { otherLineNumbers=new int[LINE_NUMBERS_CAPACITY_INCREMENT]; } int otherLineNumberIndex=++otherLineNumbers[0]; if (otherLineNumberIndex >= ...
6367675a1a6d9265ec018010
/** * Removes this bucket from the data structure. */ void removeSelf(){
void removeSelf(){ if (next != null) { next.prev=prev; } if (prev != null) { prev.next=next; } }
636767dd1a6d9265ec0186f3
/** * Keep the same name replacement as {@link ColumnName#overrideName(String,String)} * @param oldName to be replaced. * @param newName to use in the storage level. */ public void overrideName(String oldName,String newName){
public void overrideName(String oldName,String newName){ for (int i=0; i < columns.length; i++) { if (columns[i].equals(oldName)) { columns[i]=newName; } } }
636767631a6d9265ec018171
/** * Remove the non null {@code node} from the list. */ private boolean unlink(ListNodeImpl<E> node){
private boolean unlink(ListNodeImpl<E> node){ ListNodeImpl<E> prev=node.prev; ListNodeImpl<E> next=node.next; if (removeListNode(node)) { if (size == 0) { head=null; } else { link(prev,next); if (head == node) { head=next; } } return true; } return false; }
636767de1a6d9265ec018726
/** * build current profiles segment snapshot search sequence ranges */ public List<SequenceRange> buildSequenceRanges(){
public List<SequenceRange> buildSequenceRanges(){ ArrayList<SequenceRange> ranges=new ArrayList<>(); do { int batchMax=Math.min(minSequence + SEQUENCE_RANGE_BATCH_SIZE,maxSequence); ranges.add(new SequenceRange(minSequence,batchMax)); minSequence=batchMax; } while (minSequence < maxSequence); retur...
6367667c1a6d9265ec0173f7
/** * True is the body is a byte array * @return True is the body is a byte array */ public boolean hasBytes(){
public boolean hasBytes(){ return dataBytes != null; }
6367676c1a6d9265ec018220
/** * Strip the filename extension from the given path, e.g. "mypath/myfile.txt" -&gt; "mypath/myfile". * @param path the file path (may be <code>null</code>) * @return the path with stripped filename extension,or <code>null</code> if none */ public static String stripFilenameExtension(String path){
public static String stripFilenameExtension(String path){ if (path == null) { return null; } int extIndex=path.lastIndexOf(EXTENSION_SEPARATOR); if (extIndex == -1) { return path; } int folderIndex=path.lastIndexOf(FOLDER_SEPARATOR); if (folderIndex > extIndex) { return path; } return path...
636766fe1a6d9265ec017838
/** * <p>Converts an array of object Characters to primitives.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * @param array a <code>Character</code> array, may be <code>null</code> * @return a <code>char</code> array, <code>null</code> if null array input * @throws NullPoin...
public static char[] toPrimitive(final Character[] array){ if (array == null) { return null; } else if (array.length == 0) { return ArrayUtils.EMPTY_CHAR_ARRAY; } final char[] result=new char[array.length]; for (int i=0; i < array.length; i++) { result[i]=array[i].charValue(); } return resu...
636766fa1a6d9265ec01779c
/** * Parses out a token until any of the given terminators is encountered. * @param terminators the array of terminating characters. Any of these characters when encountered signify the end of the token * @return the token */ private String parseToken(final char[] terminators){
private String parseToken(final char[] terminators){ char ch; i1=pos; i2=pos; while (hasChar()) { ch=chars[pos]; if (isOneOf(ch,terminators)) { break; } i2++; pos++; } return getToken(false); }
636767691a6d9265ec0181a7
/** * Trim all occurrences of the supplied leading character from the given String. * @param str the String to check * @param leadingCharacter the leading character to be trimmed * @return the trimmed String */ public static String trimLeadingCharacter(String str,char leadingCharacter){
public static String trimLeadingCharacter(String str,char leadingCharacter){ if (!hasLength(str)) { return str; } StringBuilder sb=new StringBuilder(str); while (sb.length() > 0 && sb.charAt(0) == leadingCharacter) { sb.deleteCharAt(0); } return sb.toString(); }
636767041a6d9265ec01790f
/** * <p>Converts an array of primitive ints to objects.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * @param array an <code>int</code> array * @return an <code>Integer</code> array, <code>null</code> if null array input */ public static Integer[] toObject(final int[] arr...
public static Integer[] toObject(final int[] array){ if (array == null) { return null; } else if (array.length == 0) { return ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY; } final Integer[] result=new Integer[array.length]; for (int i=0; i < array.length; i++) { result[i]=new Integer(array[i]); } ...
636766fa1a6d9265ec0177a4
/** * <p>Converts an array of primitive doubles to objects.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * @param array a <code>double</code> array * @return a <code>Double</code> array, <code>null</code> if null array input */ public static Double[] toObject(final double[...
public static Double[] toObject(final double[] array){ if (array == null) { return null; } else if (array.length == 0) { return ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY; } final Double[] result=new Double[array.length]; for (int i=0; i < array.length; i++) { result[i]=new Double(array[i]); } re...
636767461a6d9265ec017d0e
/** * Computes a suffix sum of the {@code bounds}. Returns computed suffix sum and the sum of all elements in the {@code bounds list}. * @param bounds list of integers. * @return computed pair of suffix sum list and a sum of all elements. */ private Pair<List<Integer>,Long> computeSuffixSum(List<Integer> bounds)...
private Pair<List<Integer>,Long> computeSuffixSum(List<Integer> bounds){ List<Integer> suffixSum=new ArrayList<>(Collections.nCopies(bounds.size(),0)); long sum=0; for (int i=bounds.size() - 1; i >= 0; i--) { suffixSum.set(i,(int)Math.min(Integer.MAX_VALUE,sum)); sum+=bounds.get(i); } return Pair.of(s...
636767491a6d9265ec017d90
/** * Reverses the order of the elements in the specified range within the given array. * @param < V > the type of elements in the array * @param arr the array * @param from the index of the first element (inclusive) inside the range to reverse * @param to the index of the last element (inclusive) inside the rang...
public static final <V>void reverse(V[] arr,int from,int to){ for (int i=from, j=to; i < j; ++i, --j) { swap(arr,i,j); } }
6367674a1a6d9265ec017da9
/** * Atomically moves all {@link ListNode ListNodes} from {@code list} to this list as if eachnode was removed with {@link #removeListNode(ListNodeImpl)} from {@code list} andsubsequently added to this list by {@link #addListNode(ListNodeImpl)}. */ private void moveAllListNodes(DoublyLinkedList<E> list){
private void moveAllListNodes(DoublyLinkedList<E> list){ for (ListNodeIteratorImpl it=list.new ListNodeIteratorImpl(0); it.hasNext(); ) { ListNodeImpl<E> node=it.nextNode(); assert node.list == list; node.list=this; } size+=list.size; list.size=0; modCount++; list.modCount++; }
636767151a6d9265ec017b6b
/** * <p>Check if a String starts with a specified prefix (optionally case insensitive).</p> * @see String#startsWith(String) * @param str the String to check, may be null * @param prefix the prefix to find, may be null * @param ignoreCase inidicates whether the compare should ignore case(case insensitive) or no...
private static boolean startsWith(final String str,final String prefix,final boolean ignoreCase){ if (str == null || prefix == null) { return str == null && prefix == null; } if (prefix.length() > str.length()) { return false; } return str.regionMatches(ignoreCase,0,prefix,0,prefix.length()); }
636766fe1a6d9265ec01781c
/** * <p>Converts the character to a Character.</p> <p>For ASCII 7 bit characters, this uses a cache that will return the same Character object each time.</p> <pre> CharUtils.toCharacterObject(' ') = ' ' CharUtils.toCharacterObject('A') = 'A' </pre> * @param ch the character to convert * @return a Character of t...
public static Character toCharacterObject(final char ch){ if (ch < CharUtils.CHAR_ARRAY.length) { return CharUtils.CHAR_ARRAY[ch]; } return new Character(ch); }
636766fb1a6d9265ec0177c1
/** * <p>Checks whether the character is ASCII 7 bit alphabetic upper case.</p> <pre> CharUtils.isAsciiAlphaUpper('a') = false CharUtils.isAsciiAlphaUpper('A') = true CharUtils.isAsciiAlphaUpper('3') = false CharUtils.isAsciiAlphaUpper('-') = false CharUtils.isAsciiAlphaUpper('\n') = false CharUtils.isAsciiAlphaU...
public static boolean isAsciiAlphaUpper(final char ch){ return ch >= 'A' && ch <= 'Z'; }
636767781a6d9265ec018250
/** * Returns {@link Filter#NEUTRAL} is there is no string match. */ public int decide(LoggingEvent event){
public int decide(LoggingEvent event){ String msg=event.getRenderedMessage(); if (msg == null || stringToMatch == null) return Filter.NEUTRAL; if (msg.indexOf(stringToMatch) == -1) { return Filter.NEUTRAL; } else { if (acceptOnMatch) { return Filter.ACCEPT; } else { return Filter.DEN...
636766861a6d9265ec017553
/** * Ascertain if a template variable is a member of this template. * @param name name The template variable. * @return true if the template variable is a member of the template, otherwisefalse. */ public final boolean isTemplateVariablePresent(String name){
public final boolean isTemplateVariablePresent(String name){ for ( String s : templateVariables) { if (s.equals(name)) return true; } return false; }
636767071a6d9265ec017962
/** * Puts all of the writable properties from the given BeanMap into this BeanMap. Read-only and Write-only properties will be ignored. * @param map the BeanMap whose properties to put */ public void putAllWriteable(BeanMap map){
public void putAllWriteable(BeanMap map){ Iterator<String> readableKeys=map.readMethods.keySet().iterator(); while (readableKeys.hasNext()) { String key=readableKeys.next(); if (getWriteMethod(key) != null) { this.put(key,map.get(key)); } } }
6367670a1a6d9265ec0179d9
/** * Gets a String's length or <code>0</code> if the String is <code>null</code>. * @param str a String or <code>null</code> * @return String length or <code>0</code> if the String is <code>null</code>. * @since 2.4 */ public static int length(final String str){
public static int length(final String str){ return str == null ? 0 : str.length(); }
636767ab1a6d9265ec018676
/** * Is this a hex digit? */ private static boolean isHex(final char c){
private static boolean isHex(final char c){ return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F'); }
636766f81a6d9265ec017748
/** * Decoding a string to a string follow the Base64 regular. */ public static String base64Decode(final String s){
public static String base64Decode(final String s){ byte[] b=Base64.base64DecodeToArray(s); if (b == null) { return null; } if (b.length == 0) { return ""; } return new String(b,StandardCharsets.UTF_8); }
636766f11a6d9265ec017663
/** * <p>Checks whether two arrays are the same length, treating <code>null</code> arrays as length <code>0</code>.</p> * @param array1 the first array, may be <code>null</code> * @param array2 the second array, may be <code>null</code> * @return <code>true</code> if length of arrays matches, treating<code>null</c...
public static boolean isSameLength(final double[] array1,final double[] array2){ if (array1 == null && array2 != null && array2.length > 0 || array2 == null && array1 != null && array1.length > 0 || array1 != null && array2 != null && array1.length != array2.length) { return false; } return true; }
6367667d1a6d9265ec0173ff
/** * Retrieve an instance of {@link Meteor} based on the {@link HttpServletRequest}. * @param r {@link HttpServletRequest} * @return a {@link Meteor} or null if not found */ public static Meteor lookup(HttpServletRequest r){
public static Meteor lookup(HttpServletRequest r){ Object o=r.getAttribute(METEOR); return o == null ? null : Meteor.class.isAssignableFrom(o.getClass()) ? (Meteor)o : null; }
636767691a6d9265ec0181a6
/** * Split a String at the first occurrence of the delimiter. Does not include the delimiter in the result. * @param toSplit the string to split * @param delimiter to split the string up with * @return a two element array with index 0 being before the delimiter, andindex 1 being after the delimiter (neither eleme...
public static String[] split(String toSplit,String delimiter){ if (!hasLength(toSplit) || !hasLength(delimiter)) { return null; } int offset=toSplit.indexOf(delimiter); if (offset < 0) { return null; } String beforeDelimiter=toSplit.substring(0,offset); String afterDelimiter=toSplit.substring(offs...