id stringlengths 21 23 | content stringlengths 1.65k 252k |
|---|---|
codereval_java_data_1 | /**
* Trim the elements of the given String array, calling <code>String.trim()</code> on each of them.
* @param array the original String array
* @return the resulting array (of the same size) with trimmed elements
*/
public static String[] trimArrayElements(String[] array){
if (Objects.isEmpty(array)) {
r... |
codereval_java_data_2 | /**
* <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... |
codereval_java_data_3 | /**
* Pops an abstract type from the output frame stack and returns its value.
* @return the abstract type that has been popped from the output frame stack.
*/
private int pop(){
if (outputStackTop > 0) {
return outputStack[--outputStackTop];
}
else {
return STACK_KIND | -(--outputStackStart);
}
}
... |
codereval_java_data_4 | /**
* <p>Converts an array of object Booleans to primitives.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
* @param array a <code>Boolean</code> array, may be <code>null</code>
* @return a <code>boolean</code> array, <code>null</code> if null array input
* @throws NullPoint... |
codereval_java_data_5 | /**
* Returns true if the message should be printed in the given timestamp, otherwise returns false. If this method returns false, the message will not be printed. The timestamp is in seconds granularity.
*/
public boolean shouldPrintMessage(int timestamp,String message){
if (messages.containsKey(message)) {
... |
codereval_java_data_6 | /**
* <p>Gets the <code>toString</code> of an <code>Object</code> returning an empty string ("") if <code>null</code> input.</p> <pre> ObjectUtils.toString(null) = "" ObjectUtils.toString("") = "" ObjectUtils.toString("bat") = "bat" ObjectUtils.toString(Boolean.TRUE) = "true" </pre>
* @see S... |
codereval_java_data_7 | /**
* Decodes octets to characters using the UTF-8 decoding and appends the characters to a StringBuffer.
* @return the index to the next unchecked character in the string to decode
*/
private static int decodeOctets(int i,ByteBuffer bb,StringBuilder sb){
if (bb.limit() == 1 && (bb.get(0) & 0xFF) < 0x80) {
... |
codereval_java_data_8 | /**
* Starts the visit of a new stack map frame, stored in {@link #currentFrame}.
* @param offset the bytecode offset of the instruction to which the frame corresponds.
* @param numLocal the number of local variables in the frame.
* @param numStack the number of stack elements in the frame.
* @return the index... |
codereval_java_data_9 | /**
* Enlarges this byte vector so that it can receive 'size' more bytes.
* @param size number of additional bytes that this byte vector should be able to receive.
*/
private void enlarge(final int size){
int doubleCapacity=2 * data.length;
int minimalCapacity=length + size;
byte[] newData=new byte[doubleCa... |
codereval_java_data_10 | /**
* Delete's the specified file if it exists
*/
protected static void deleteFile(String fileName){
File file=new File(fileName);
if (file.exists()) {
file.delete();
}
}
package org.apache.log4j;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreemen... |
codereval_java_data_11 | /**
* Return a hash code based on the contents of the specified array. If <code>array</code> is <code>null</code>, this method returns 0.
* @param array the long array to obtain a hashcode
* @return the long array's hashcode, which could be 0 if the array is null.
*/
public static int nullSafeHashCode(long[] arr... |
codereval_java_data_12 | /**
* Performs a right node rotation.
* @param node a node to rotate
* @return a new parent of the {@code node}
*/
private TreeNode<T> rotateRight(TreeNode<T> node){
TreeNode<T> left=node.left;
left.parent=null;
node.setLeftChild(left.right);
left.setRightChild(node);
node.updateHeightAndSubtreeSize();... |
codereval_java_data_13 | /**
* Add all the jar files in a dir to the classpath, represented as a Vector of URLs.
*/
@SuppressWarnings("unchecked") public static void addToClassPath(Vector<URL> cpV,String dir){
try {
String cpComp[]=getFilesByExt(dir,".jar");
if (cpComp != null) {
int jarCount=cpComp.length;
for (int ... |
codereval_java_data_14 | /**
* Produces a formatted string as specified by the conversion pattern.
*/
public String format(LoggingEvent event){
if (sbuf.capacity() > MAX_CAPACITY) {
sbuf=new StringBuffer(BUF_SIZE);
}
else {
sbuf.setLength(0);
}
PatternConverter c=head;
while (c != null) {
c.format(sbuf,event);
c... |
codereval_java_data_15 | /**
* Retrieve the content length of the request.
* @return The content length of the request.
* @since 1.3
*/
public long contentLength(){
long size;
try {
size=Long.parseLong(request.getHeader(FileUpload.CONTENT_LENGTH));
}
catch ( NumberFormatException e) {
size=request.getContentLength();
}... |
codereval_java_data_16 | /**
* Returns the index of the last directory separator character. <p> This method will handle a file in either Unix or Windows format. The position of the last forward or backslash is returned. <p> The output will be the same irrespective of the machine that the code is running on.
* @param filename the filename t... |
codereval_java_data_17 | /**
* Skips bytes until the end of the current line.
* @param headerPart The headers, which are being parsed.
* @param end Index of the last byte, which has yet been processed.
* @return Index of the \r\n sequence, which indicates end of line.
*/
private int parseEndOfLine(String headerPart,int end){
int inde... |
codereval_java_data_18 | /**
* Finds the last index within a String, handling <code>null</code>. This method uses {@link String#lastIndexOf(String)}.
*/
public static int lastIndexOf(String str,String searchStr){
if (StringUtils.isEmpty(str)) {
return StringUtils.INDEX_NOT_FOUND;
}
return str.lastIndexOf(searchStr);
}
/*
* ... |
codereval_java_data_19 | /**
* Writes <code>b.length</code> bytes from the specified byte array to this output stream.
* @param b The array of bytes to be written.
* @exception IOException if an error occurs.
*/
@Override public void write(byte b[]) throws IOException {
checkThreshold(b.length);
getStream().write(b);
written+=b.le... |
codereval_java_data_20 | /**
* @return the row id
*/
public String id(String entityId){
if (entityId == null) {
return String.valueOf(point);
}
else {
return point + Const.ID_CONNECTOR + entityId;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTIC... |
codereval_java_data_21 | /**
* <p>Converts a Boolean to a boolean handling <code>null</code> by returning <code>false</code>.</p> <pre> BooleanUtils.toBoolean(Boolean.TRUE) = true BooleanUtils.toBoolean(Boolean.FALSE) = false BooleanUtils.toBoolean(null) = false </pre>
* @param bool the boolean to convert
* @return <code>true</c... |
codereval_java_data_22 | /**
* Computes an identity automorphism (i.e. a self-mapping of a graph in which each vertex also maps to itself).
* @param graph the input graph
* @param < V > the graph vertex type
* @param < E > the graph edge type
* @return a mapping from graph to graph
*/
public static <V,E>IsomorphicGraphMapping<V,E> ide... |
codereval_java_data_23 | /**
* Schedules a file to be deleted when JVM exits. If file is directory delete it and all sub-directories.
* @param file file or directory to delete, must not be {@code null}
* @throws NullPointerException if the file is {@code null}
* @throws IOException in case deletion is unsuccessful
*/
public static voi... |
codereval_java_data_24 | /**
* Add a log record message to be displayed in the LogTable. This method is thread-safe as it posts requests to the SwingThread rather than processing directly.
*/
public void addMessage(final LogRecord lr){
if (_isDisposed == true) {
return;
}
SwingUtilities.invokeLater(new Runnable(){
public voi... |
codereval_java_data_25 | /**
* Construct a complete bipartite graph
*/
@Override public void generateGraph(Graph<V,E> target,Map<String,V> resultMap){
for (int i=0; i < sizeA; i++) {
partitionA.add(target.addVertex());
}
for (int i=0; i < sizeB; i++) {
partitionB.add(target.addVertex());
}
for ( V u : partitionA) {
... |
codereval_java_data_26 | /**
* Searches for a byte of specified value in the <code>buffer</code>, starting at the specified <code>position</code>.
* @param value The value to find.
* @param pos The starting position for searching.
* @return The position of byte found, counting from beginning of the<code>buffer</code>, or <code>-1</code>... |
codereval_java_data_27 | /**
* Serializes the {@code message}, prefixed with its length, into an {@link OutputStream}.
* @return the size of the message
*/
public static <T>int writeDelimitedTo(OutputStream out,T message,Schema<T> schema,LinkedBuffer buffer) throws IOException {
if (buffer.start != buffer.offset) throw new IllegalA... |
codereval_java_data_28 | /**
* <p> Gets the String built by this builder. </p>
* @return the built string
*/
public String toString(){
if (this.getObject() == null) {
return this.getStyle().getNullText();
}
Class<?> clazz=this.getObject().getClass();
this.appendFieldsIn(clazz);
while (clazz.getSuperclass() != null && clazz ... |
codereval_java_data_29 | /**
* This method does actual writing
*/
protected void subAppend(LoggingEvent event){
try {
File tmp=File.createTempFile(prefix,suffix,dir);
Writer out=new BufferedWriter(new FileWriter(tmp));
out.write(event.message);
out.close();
}
catch ( Exception e) {
errorHandler.error("Error durin... |
codereval_java_data_30 | /**
* Adds a type in the type table of this symbol table. Does nothing if the type table already contains a similar type.
* @param value an internal class name.
* @return the index of a new or already existing type Symbol with the given value.
*/
int addType(final String value){
int hashCode=hash(Symbol.TYPE_T... |
codereval_java_data_31 | /**
* Resolves the arguments for the {@code genericType} using the type variable information for the{@code targetType}. Returns {@code null} if {@code genericType} is not parameterized or ifarguments cannot be resolved.
*/
public static Class<?>[] resolveArguments(Type genericType,Class<?> targetType){
Class<?... |
codereval_java_data_32 | /**
* Accept the data into the cache and merge with the existing value. This method is not thread safe, should avoid concurrency calling.
* @param data to be added potentially.
*/
@Override public void accept(final METRICS data){
final String id=data.id();
final METRICS existed=buffer.get(id);
if (existed =... |
codereval_java_data_33 | /**
* Inserts this bucket in the data structure before the {@code bucket}.
* @param bucket the bucket, that will be the next to this bucket.
*/
void insertBefore(Bucket bucket){
this.next=bucket;
if (bucket != null) {
this.prev=bucket.prev;
if (bucket.prev != null) {
bucket.prev.next=this;
... |
codereval_java_data_34 | /**
* @see InputStream#available()
*/
@Override public int available() throws IOException {
return this.index < this.length ? this.length - this.index : this.length >= 0 && this.reader.ready() ? 1 : 0;
}
/*
* Copyright 2008-2009 the original author or authors.
*
* Licensed under the Apache License, Version... |
codereval_java_data_35 | /**
* Returns mappings with fields that not exist in the input mappings. The input mappings should be history mapping from current index. Do not return _source config to avoid current index update conflict.
*/
public Mappings diffStructure(String tableName,Mappings mappings){
if (!structures.containsKey(tableNam... |
codereval_java_data_36 | /**
* Add a new target channels.
*/
public void addNewTarget(Channels channels,IConsumer consumer){
Group group=new Group(channels,consumer);
ArrayList<Group> newList=new ArrayList<Group>();
for ( Group target : consumeTargets) {
newList.add(target);
}
newList.add(group);
consumeTargets=newList;
... |
codereval_java_data_37 | /**
* Creates the directory where the MRU file list will be written. The "lf5" directory is created in the Documents and Settings directory on Windows 2000 machines and where ever the user.home variable points on all other platforms.
*/
public static void createConfigurationDirectory(){
String home=System.getPro... |
codereval_java_data_38 | /**
* Reads a signed long 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 lo... |
codereval_java_data_39 | /**
* Returns true if the contents of the internal array and the provided array match.
*/
public boolean equals(final byte[] data,int offset,final int len){
final byte[] bytes=this.bytes;
if (len != bytes.length) return false;
for (int i=0; i < len; ) {
if (bytes[i++] != data[offset++]) {
return ... |
codereval_java_data_40 | /**
* <p>Defensive programming technique to change a <code>null</code> reference to an empty one.</p> <p>This method returns an empty array for a <code>null</code> input array.</p> <p>As a memory optimizing technique an empty array passed in will be overridden with the empty <code>public static</code> references in t... |
codereval_java_data_41 | /**
* sends a message to each of the clients in telnet-friendly output.
*/
public synchronized void send(final String message){
Iterator ce=connections.iterator();
for (Iterator e=writers.iterator(); e.hasNext(); ) {
ce.next();
PrintWriter writer=(PrintWriter)e.next();
writer.print(message);
i... |
codereval_java_data_42 | /**
* <p>Defensive programming technique to change a <code>null</code> reference to an empty one.</p> <p>This method returns an empty array for a <code>null</code> input array.</p> <p>As a memory optimizing technique an empty array passed in will be overridden with the empty <code>public static</code> references in t... |
codereval_java_data_43 | /**
* Place a {@link LoggingEvent} in the buffer. If the buffer is fullthen the event is <b>silently dropped</b>. It is the caller's responsability to make sure that the buffer has free space.
*/
public void put(LoggingEvent o){
if (numElements != maxSize) {
buf[next]=o;
if (++next == maxSize) {
... |
codereval_java_data_44 | /**
* Split time ranges to insure the start time and end time is small then {@link #FETCH_DATA_DURATION}
*/
protected List<TimeRange> buildTimeRanges(long start,long end){
if (start >= end) {
return null;
}
end+=1;
final List<TimeRange> timeRanges=new ArrayList<>();
do {
long batchEnd=Math.min(s... |
codereval_java_data_45 | /**
* <p>Converts an array of object Bytes to primitives.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
* @param array a <code>Byte</code> array, may be <code>null</code>
* @return a <code>byte</code> array, <code>null</code> if null array input
* @throws NullPointerExcepti... |
codereval_java_data_46 | /**
* Follow the dayStep to re-format the time bucket literal long value. Such as, in dayStep == 11, 20000105 re-formatted time bucket is 20000101, 20000115 re-formatted time bucket is 20000112, 20000123 re-formatted time bucket is 20000123
*/
static long compressTimeBucket(long timeBucket,int dayStep){
if (dayS... |
codereval_java_data_47 | /**
* Computes the size of the utf8 string beginning at the specified {@code index} with the specified {@code length}.
*/
public static int computeUTF8Size(final CharSequence str,final int index,final int len){
int size=len;
for (int i=index; i < len; i++) {
final char c=str.charAt(i);
if (c < 0x0080)... |
codereval_java_data_48 | /**
* Array to List. <p> Works like {@link Arrays#asList(Object)}, but handles null arrays.
* @return a list backed by the array.
*/
public static <T>List<T> asList(T[] a){
if (a == null) return Collections.emptyList();
return Arrays.asList(a);
}
// =======================================================... |
codereval_java_data_49 | /**
* Removes a value from the set. Returns true if the set contained the specified element.
*/
public boolean remove(int val){
if (map.containsKey(val)) {
map.remove(val);
values.remove(values.indexOf(val));
return true;
}
return false;
}
//Design a data structure that supports all following ... |
codereval_java_data_50 | /**
* Returns {@code true} if the given string starts with the specified case-insensitive prefix, {@code false} otherwise.
* @param str the String to check
* @param prefix the prefix to look for
* @return {@code true} if the given string starts with the specified case-insensitive prefix, {@code false} otherwise.
... |
codereval_java_data_51 | /**
* Compute all vertices that have positive degree by iterating over the edges on purpose. This keeps the complexity to $O(m)$ where $m$ is the number of edges.
* @return set of vertices with positive degree
*/
private Set<V> initVisibleVertices(){
Set<V> visibleVertex=new HashSet<>();
for ( E e : graph.ed... |
codereval_java_data_52 | /**
* <p>Reverses a String as per {@link StringBuilder#reverse()}.</p> <p>A <code>null</code> String returns <code>null</code>.</p> <pre> StringUtils.reverse(null) = null StringUtils.reverse("") = "" StringUtils.reverse("bat") = "tab" </pre>
* @param str the String to reverse, may be null
* @return the revers... |
codereval_java_data_53 | /**
* Gets a substring from the specified String avoiding exceptions.
*/
public static String sub(String str,int start,int end){
return StringUtils.substring(str,start,end);
}
/*
* Copyright 2008-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you... |
codereval_java_data_54 | /**
* 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 copied.
... |
codereval_java_data_55 | /**
* Wrap an {@link HttpServletRequest}.
* @param request {@link HttpServletRequest}
* @return an {@link AtmosphereRequest}
*/
public static AtmosphereRequest wrap(HttpServletRequest request){
if (AtmosphereRequestImpl.class.isAssignableFrom(request.getClass())) {
return (AtmosphereRequestImpl)request;
... |
codereval_java_data_56 | /**
* Writes the utf8-encoded bytes from the string into the {@link LinkedBuffer}.
*/
public static LinkedBuffer writeUTF8(final CharSequence str,final WriteSession session,final LinkedBuffer lb){
final int len=str.length();
if (len == 0) return lb;
return lb.offset + len > lb.buffer.length ? writeUTF8(st... |
codereval_java_data_57 | /**
* Removes this edge from both doubly linked lists of tree edges.
*/
public void removeFromTreeEdgeList(){
for (int dir=0; dir < 2; dir++) {
if (prev[dir] != null) {
prev[dir].next[dir]=next[dir];
}
else {
head[1 - dir].first[dir]=next[dir];
}
if (next[dir] != null) {
next[d... |
codereval_java_data_58 | /**
* Find the value corresponding to <code>key</code> in <code>props</code>. Then perform variable substitution on the found value.
*/
public static String findAndSubst(String key,Properties props){
String value=props.getProperty(key);
if (value == null) return null;
try {
return substVars(value,props... |
codereval_java_data_59 | /**
* <p>Append to the <code>toString</code> the detail of an <code>int</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>
*/
p... |
codereval_java_data_60 | /**
* Session ID.
*/
public static String sessionId(){
HttpSession httpSession=servletSession();
if (httpSession == null) {
return null;
}
return httpSession.getId();
}
/*
* Copyright 2008-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* ... |
codereval_java_data_61 | /**
* <p>Checks whether the <code>String</code> contains only digit characters.</p> <p><code>Null</code> and empty String will return <code>false</code>.</p>
* @param str the <code>String</code> to check
* @return <code>true</code> if str contains only unicode numeric
*/
public static boolean isDigits(String st... |
codereval_java_data_62 | /**
* Determine whether a parameter name ends at the current position, that is, whether the given character qualifies as a separator.
*/
private static boolean isParameterSeparator(final char c){
if (Character.isWhitespace(c)) {
return true;
}
for ( char separator : PARAMETER_SEPARATORS) {
if (c ==... |
codereval_java_data_63 | /**
* <p>Check if a String ends with a specified suffix (optionally case insensitive).</p>
* @see String#endsWith(String)
* @param str the String to check, may be null
* @param suffix the suffix to find, may be null
* @param ignoreCase inidicates whether the compare should ignore case(case insensitive) or not.
... |
codereval_java_data_64 | /**
* Decode the path component of a URI as path segments.
* @param u the URI. If the path component is an absolute path componentthen the leading '/' is ignored and is not considered a delimiator of a path segment.
* @param decode true if the path segments of the path componentshould be in decoded form.
* @return... |
codereval_java_data_65 | /**
* <p>Defensive programming technique to change a <code>null</code> reference to an empty one.</p> <p>This method returns an empty array for a <code>null</code> input array.</p> <p>As a memory optimizing technique an empty array passed in will be overridden with the empty <code>public static</code> references in t... |
codereval_java_data_66 | /**
* @return true if getThrown().toString() is a non-empty string.
*/
public boolean hasThrown(){
Throwable thrown=getThrown();
if (thrown == null) {
return false;
}
String thrownString=thrown.toString();
return thrownString != null && thrownString.trim().length() != 0;
}
/*
* Licensed to the Apa... |
codereval_java_data_67 | /**
* Looks at the last diagnostic context at the top of this NDC without removing it. <p>The returned value is the value that was pushed last. If no context is available, then the empty string "" is returned.
* @return String The innermost diagnostic context.
*/
public static String peek(){
Stack stack=getCurr... |
codereval_java_data_68 | /**
* Accumulate the value with existing value in the same given key.
*/
public void valueAccumulation(String key,Long value){
Long element=data.get(key);
if (element == null) {
element=value;
}
else {
element+=value;
}
data.put(key,element);
}
/*
* Licensed to the Apache Software Foundation ... |
codereval_java_data_69 | /**
* Return the next {@link java.io.File} object or {@code null} if no more files areavailable.
*/
public InputStream next() throws IOException {
if (stack.isEmpty()) {
current=null;
return null;
}
else {
current=stack.removeLast();
return current;
}
}
package org.atmosphere.util.annotat... |
codereval_java_data_70 | /**
* Check if the named logger exists in the hierarchy. If so return its reference, otherwise returns <code>null</code>.
* @param name The name of the logger to search for.
*/
public Logger exists(String name){
Object o=ht.get(new CategoryKey(name));
if (o instanceof Logger) {
return (Logger)o;
}
else... |
codereval_java_data_71 | /**
* Look up and return any registered {@link Converter} for the specifieddestination class; if there is no registered Converter, return <code>null</code>.
* @param clazz Class for which to return a registered Converter
* @return The registered {@link Converter} or <code>null</code> if not found
*/
public Conv... |
codereval_java_data_72 | /**
* Read a raw Varint from the stream.
*/
public long readRawVarint64() throws IOException {
int shift=0;
long result=0;
while (shift < 64) {
final byte b=readRawByte();
result|=(long)(b & 0x7F) << shift;
if ((b & 0x80) == 0) {
return result;
}
shift+=7;
}
throw ProtobufExcept... |
codereval_java_data_73 | /**
* <p>Defensive programming technique to change a <code>null</code> reference to an empty one.</p> <p>This method returns an empty array for a <code>null</code> input array.</p> <p>As a memory optimizing technique an empty array passed in will be overridden with the empty <code>public static</code> references in t... |
codereval_java_data_74 | /**
* Pops as many abstract types from the output frame stack as described by the given descriptor.
* @param descriptor a type or method descriptor (in which case its argument types are popped).
*/
private void pop(final String descriptor){
char firstDescriptorChar=descriptor.charAt(0);
if (firstDescriptorCha... |
codereval_java_data_75 | /**
* Writes <code>len</code> bytes from the specified byte array starting at offset <code>off</code> to this byte array output stream.
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
*/
@Override public void write(final byte b[],final int off,final i... |
codereval_java_data_76 | /**
* Swaps the two elements at the specified indices in the given array.
* @param < V > the type of elements in the array
* @param arr the array
* @param i the index of the first element
* @param j the index of the second element
*/
public static final <V>void swap(V[] arr,int i,int j){
V tmp=arr[j];
arr[... |
codereval_java_data_77 | /**
* Check if the actual response is a Partial Content (HTTP 206 code)
* @return is partial content or not
*/
public Boolean isPartialContentResponse(){
Integer limit=drc.getLimit() == null ? 0 : drc.getLimit();
Long count=drc.getCount() == null ? 0 : drc.getCount();
return !((limit + 1) >= count);
}
/*
... |
codereval_java_data_78 | /**
* <p>Checks if an array of primitive doubles is empty or <code>null</code>.</p>
* @param array the array to test
* @return <code>true</code> if the array is empty or <code>null</code>
* @since 2.1
*/
public static boolean isEmpty(final double[] array){
return array == null || array.length == 0;
}
/*
*... |
codereval_java_data_79 | /**
* The last time, in milliseconds, a write operation occurred.
* @return this
*/
public long lastWriteTimeStampInMilliseconds(){
return lastWrite == -1 ? System.currentTimeMillis() : lastWrite;
}
/*
* Copyright 2008-2022 Async-IO.org
*
* Licensed under the Apache License, Version 2.0 (the "License"); you m... |
codereval_java_data_80 | /**
* Add an edge to the index.
* @param sourceVertex the source vertex
* @param targetVertex the target vertex
* @param e the edge
*/
protected void addToIndex(V sourceVertex,V targetVertex,E e){
Pair<V,V> vertexPair=new Pair<>(sourceVertex,targetVertex);
Set<E> edgeSet=touchingVerticesToEdgeMap.get(vertex... |
codereval_java_data_81 | /**
* Returns the class path of the current JVM instance as an array of {@link File} objects.
*/
private static File[] classPath(){
final String[] fileNames=System.getProperty("java.class.path").split(File.pathSeparator);
final File[] files=new File[fileNames.length];
for (int i=0; i < files.length; ++i) {
... |
codereval_java_data_82 | /**
* This method creates a copy of the provided array, and ensures that all the strings in the newly created array contain only lower-case letters. <p> Using this method to copy string arrays means that changes to the src array do not modify the dst array.
*/
private static String[] copyStrings(final String[] src... |
codereval_java_data_83 | /**
* Split a box along the x axis into two equal boxes.
* @param box the box to split
* @return a pair with the two resulting boxes
*/
public static Pair<Box2D,Box2D> splitAlongXAxis(Box2D box){
double newWidth=box.getWidth() / 2d;
double height=box.getHeight();
return Pair.of(Box2D.of(box.getMinX(),box.g... |
codereval_java_data_84 | /**
* Enlarges this byte vector so that it can receive 'size' more bytes.
* @param size number of additional bytes that this byte vector should be able to receive.
*/
private void enlarge(final int size){
int doubleCapacity=2 * data.length;
int minimalCapacity=length + size;
byte[] newData=new byte[doubleCa... |
codereval_java_data_85 | /**
* Returns <code>true</code> if the specified appender is in the list of attached appenders, <code>false</code> otherwise.
* @since 1.2
*/
public boolean isAttached(Appender appender){
if (appenderList == null || appender == null) return false;
int size=appenderList.size();
Appender a;
for (int i=0;... |
codereval_java_data_86 | /**
* Compares two floating point values. Returns 0 if they are equal, -1 if {@literal o1 < o2}, 1 otherwise
* @param o1 the first value
* @param o2 the second value
* @return 0 if they are equal, -1 if {@literal o1 < o2}, 1 otherwise
*/
@Override public int compare(Double o1,Double o2){
if (Math.abs(o1 - o2... |
codereval_java_data_87 | /**
* Inserts a value to the set. Returns true if the set did not already contain the specified element.
*/
public boolean insert(int val){
if (!map.containsKey(val)) {
map.put(val,val);
values.add(val);
return true;
}
else {
return false;
}
}
//Design a data structure that supports all f... |
codereval_java_data_88 | /**
* Returns ture when the input fields have already been stored in the properties.
*/
private boolean containsAllFields(Fields fields){
if (this.properties.size() < fields.properties.size()) {
return false;
}
boolean isContains=fields.properties.entrySet().stream().allMatch(item -> Objects.equals(prope... |
codereval_java_data_89 | /**
* Reverse of Introspector.decapitalize
*/
public static String capitalize(String name){
if (name == null || name.length() == 0) {
return name;
}
char chars[]=name.toCharArray();
chars[0]=Character.toUpperCase(chars[0]);
return new String(chars);
}
/*
* Copyright 2008-2022 Async-IO.org
*
* Li... |
codereval_java_data_90 | /**
* Writes the contents of the {@link LinkedBuffer} into the {@link DataOutput}.
* @return the total content size of the buffer.
*/
public static int writeTo(final DataOutput out,LinkedBuffer node) throws IOException {
int contentSize=0, len;
do {
if ((len=node.offset - node.start) > 0) {
out.wri... |
codereval_java_data_91 | /**
* <p>Checks if a <code>Boolean</code> value is <i>not</i> <code>true</code>, handling <code>null</code> by returning <code>true</code>.</p> <pre> BooleanUtils.isNotTrue(Boolean.TRUE) = false BooleanUtils.isNotTrue(Boolean.FALSE) = true BooleanUtils.isNotTrue(null) = true </pre>
* @param bool the boole... |
codereval_java_data_92 | /**
* Returns a textual representation of the queue.
* @return a textual representation of the queue.
*/
public String toString(){
StringBuilder s=new StringBuilder();
for (int j=i; j < n; j++) s.append(vs[j]).append(" ");
return s.toString();
}
/*
* (C) Copyright 2017-2021, by Joris Kinable and Contri... |
codereval_java_data_93 | /**
* Create a string supplier which returns unique strings. The returns strings are simply integers starting from start.
* @param start where to start the sequence
* @return a string supplier
*/
@SuppressWarnings("unchecked") public static Supplier<String> createStringSupplier(int start){
int[] container=new ... |
codereval_java_data_94 | /**
* Formats a logging event to a writer.
* @param event logging event to be formatted.
*/
public String format(final LoggingEvent event){
StringBuffer buf=new StringBuffer();
for (PatternConverter c=head; c != null; c=c.next) {
c.format(buf,event);
}
return buf.toString();
}
/*
* Licensed to the ... |
codereval_java_data_95 | /**
* <p>Converts an array of object Doubles to primitives.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
* @param array a <code>Double</code> array, may be <code>null</code>
* @return a <code>double</code> array, <code>null</code> if null array input
* @throws NullPointerE... |
codereval_java_data_96 | /**
* Adds an abstract type to the list of types on which a constructor is invoked in the basic block.
* @param abstractType an abstract type on a which a constructor is invoked.
*/
private void addInitializedType(final int abstractType){
if (initializations == null) {
initializations=new int[2];
}
int ... |
codereval_java_data_97 | /**
* Puts some abstract types of {@link #currentFrame} in {@link #stackMapTableEntries} , using theJVMS verification_type_info format used in StackMapTable attributes.
* @param start index of the first type in {@link #currentFrame} to write.
* @param end index of last type in {@link #currentFrame} to write (exclu... |
codereval_java_data_98 | /**
* Clear and fill the buffer of this {@code ClassFileBuffer} with thesupplied byte stream. The read pointer is reset to the start of the byte array.
*/
public void readFrom(final InputStream in) throws IOException {
pointer=0;
size=0;
int n;
do {
n=in.read(buffer,size,buffer.length - size);
if ... |
codereval_java_data_99 | /**
* @see OutputStream#write(byte[])
*/
@Override public void write(final byte[] b) throws IOException {
if (this.encoding == null) {
this.writer.write(new String(b));
}
else {
this.writer.write(new String(b,this.encoding));
}
}
/*
* Copyright 2008-2009 the original author or authors.
*
* Lic... |
codereval_java_data_100 | /**
* Serialize to JSON {@link String}
* @param features features to be enabled in serialization
* @return JSON {@link String}
*/
@SuppressWarnings("unchecked") public String toString(JSONWriter.Feature... features){
try (JSONWriter writer=JSONWriter.of(features)){
if ((writer.context.features & NONE_DIRE... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.