_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q29700
File.setExecutable
train
public boolean setExecutable(boolean executable, boolean ownerOnly) { return doChmod(ownerOnly ? S_IXUSR : (S_IXUSR | S_IXGRP | S_IXOTH), executable); }
java
{ "resource": "" }
q29701
File.setReadable
train
public boolean setReadable(boolean readable, boolean ownerOnly) { return doChmod(ownerOnly ? S_IRUSR : (S_IRUSR | S_IRGRP | S_IROTH), readable); }
java
{ "resource": "" }
q29702
File.setWritable
train
public boolean setWritable(boolean writable, boolean ownerOnly) { return doChmod(ownerOnly ? S_IWUSR : (S_IWUSR | S_IWGRP | S_IWOTH), writable); }
java
{ "resource": "" }
q29703
File.getTotalSpace
train
public long getTotalSpace() { try { StructStatVfs sb = Libcore.os.statvfs(path); return sb.f_blocks * sb.f_bsize; // total block count * block size in bytes. } catch (ErrnoException errnoException) { return 0; } }
java
{ "resource": "" }
q29704
File.getUsableSpace
train
public long getUsableSpace() { try { StructStatVfs sb = Libcore.os.statvfs(path); return sb.f_bavail * sb.f_bsize; // non-root free block count * block size in bytes. } catch (ErrnoException errnoException) { return 0; } }
java
{ "resource": "" }
q29705
File.getFreeSpace
train
public long getFreeSpace() { try { StructStatVfs sb = Libcore.os.statvfs(path); return sb.f_bfree * sb.f_bsize; // free block count * block size in bytes. } catch (ErrnoException errnoException) { return 0; } }
java
{ "resource": "" }
q29706
ArrayDeque.allocateElements
train
private void allocateElements(int numElements) { int initialCapacity = MIN_INITIAL_CAPACITY; // Find the best power of two to hold elements. // Tests "<=" because arrays aren't kept full. if (numElements >= initialCapacity) { initialCapacity = numElements; initial...
java
{ "resource": "" }
q29707
ArrayDeque.doubleCapacity
train
private void doubleCapacity() { assert head == tail; int p = head; int n = elements.length; int r = n - p; // number of elements to the right of p int newCapacity = n << 1; if (newCapacity < 0) throw new IllegalStateException("Sorry, deque too big"); O...
java
{ "resource": "" }
q29708
ArrayDeque.addFirst
train
public void addFirst(E e) { if (e == null) throw new NullPointerException(); elements[head = (head - 1) & (elements.length - 1)] = e; if (head == tail) doubleCapacity(); }
java
{ "resource": "" }
q29709
ArrayDeque.addLast
train
public void addLast(E e) { if (e == null) throw new NullPointerException(); elements[tail] = e; if ( (tail = (tail + 1) & (elements.length - 1)) == head) doubleCapacity(); }
java
{ "resource": "" }
q29710
ArrayDeque.clear
train
public void clear() { int h = head; int t = tail; if (h != t) { // clear all cells head = tail = 0; int i = h; int mask = elements.length - 1; do { elements[i] = null; i = (i + 1) & mask; } while (i != t)...
java
{ "resource": "" }
q29711
TrieBuilder.isInZeroBlock
train
public boolean isInZeroBlock(int ch) { // valid, uncompacted trie and valid c? if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < UCharacter.MIN_VALUE) { return true; } return m_index_[ch >> SHIFT_] == 0; }
java
{ "resource": "" }
q29712
TrieBuilder.equal_int
train
protected static final boolean equal_int(int[] array, int start1, int start2, int length) { while(length>0 && array[start1]==array[start2]) { ++start1; ++start2; --length; } return length==0; }
java
{ "resource": "" }
q29713
TrieBuilder.findSameIndexBlock
train
protected static final int findSameIndexBlock(int index[], int indexLength, int otherBlock) { for (int block = BMP_INDEX_LENGTH_; block < indexLength; block += SURROGATE_BLOCK_COUNT_) { if(equal_int(index, block, otherBlock, SURROG...
java
{ "resource": "" }
q29714
SerializerBase.fireEndElem
train
protected void fireEndElem(String name) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENDELEMENT,name, (Attributes)null); } }
java
{ "resource": "" }
q29715
SerializerBase.fireCharEvent
train
protected void fireCharEvent(char[] chars, int start, int length) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CHARACTERS, chars, start,length); } }
java
{ "resource": "" }
q29716
SerializerBase.addAttribute
train
public void addAttribute(String name, final String value) { if (m_elemContext.m_startTagOpen) { final String patchedName = patchName(name); final String localName = getLocalName(patchedName); final String uri = getNamespaceURI(patchedName, false); add...
java
{ "resource": "" }
q29717
SerializerBase.addAttributes
train
public void addAttributes(Attributes atts) throws SAXException { int nAtts = atts.getLength(); for (int i = 0; i < nAtts; i++) { String uri = atts.getURI(i); if (null == uri) uri = ""; addAttributeAlways( uri, ...
java
{ "resource": "" }
q29718
SerializerBase.endEntity
train
public void endEntity(String name) throws org.xml.sax.SAXException { if (name.equals("[dtd]")) m_inExternalDTD = false; m_inEntityRef = false; if (m_tracer != null) this.fireEndEntity(name); }
java
{ "resource": "" }
q29719
SerializerBase.subPartMatch
train
private static final boolean subPartMatch(String p, String t) { return (p == t) || ((null != p) && (p.equals(t))); }
java
{ "resource": "" }
q29720
SerializerBase.getNamespaceURI
train
public String getNamespaceURI(String qname, boolean isElement) { String uri = EMPTYSTRING; int col = qname.lastIndexOf(':'); final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING; if (!EMPTYSTRING.equals(prefix) || isElement) { if (m_prefixMap !...
java
{ "resource": "" }
q29721
SerializerBase.entityReference
train
public void entityReference(String name) throws org.xml.sax.SAXException { flushPending(); startEntity(name); endEntity(name); if (m_tracer != null) fireEntityReference(name); }
java
{ "resource": "" }
q29722
SerializerBase.setTransformer
train
public void setTransformer(Transformer t) { m_transformer = t; // If this transformer object implements the SerializerTrace interface // then assign m_tracer to the transformer object so it can be used // to fire trace events. if ((m_transformer instanceof Serializer...
java
{ "resource": "" }
q29723
SerializerBase.characters
train
public void characters(org.w3c.dom.Node node) throws org.xml.sax.SAXException { flushPending(); String data = node.getNodeValue(); if (data != null) { final int length = data.length(); if (length > m_charsBuff.length) { m_ch...
java
{ "resource": "" }
q29724
SerializerBase.fireStartEntity
train
protected void fireStartEntity(String name) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENTITYREF, name); } }
java
{ "resource": "" }
q29725
SerializerBase.fireCDATAEvent
train
protected void fireCDATAEvent(char[] chars, int start, int length) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CDATA, chars, start,length); } }
java
{ "resource": "" }
q29726
SerializerBase.fireCommentEvent
train
protected void fireCommentEvent(char[] chars, int start, int length) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_COMMENT, new String(chars, start, length)); } }
java
{ "resource": "" }
q29727
SerializerBase.fireEndEntity
train
public void fireEndEntity(String name) throws org.xml.sax.SAXException { if (m_tracer != null) flushMyWriter(); // we do not need to handle this. }
java
{ "resource": "" }
q29728
SerializerBase.fireStartDoc
train
protected void fireStartDoc() throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_STARTDOCUMENT); } }
java
{ "resource": "" }
q29729
SerializerBase.fireEndDoc
train
protected void fireEndDoc() throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENDDOCUMENT); } }
java
{ "resource": "" }
q29730
SerializerBase.fireStartElem
train
protected void fireStartElem(String elemName) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_STARTELEMENT, elemName, m_attributes); } }
java
{ "resource": "" }
q29731
SerializerBase.fireEscapingEvent
train
protected void fireEscapingEvent(String name, String data) throws org.xml.sax.SAXException { if (m_tracer != null) { flushMyWriter(); m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_PI,name, data); } }
java
{ "resource": "" }
q29732
SerializerBase.resetSerializerBase
train
private void resetSerializerBase() { this.m_attributes.clear(); this.m_CdataElems = null; this.m_cdataTagOpen = false; this.m_docIsEmpty = true; this.m_doctypePublic = null; this.m_doctypeSystem = null; this.m_doIndent = false; this.m_elemContext = new ElemContext...
java
{ "resource": "" }
q29733
SerializerBase.getElementURI
train
private String getElementURI() { String uri = null; // At this point in processing we have received all the // namespace mappings // As we still don't know the elements namespace, // we now figure it out. String prefix = getPrefixPart(m_elemContext.m_elementName); ...
java
{ "resource": "" }
q29734
SerializerBase.getOutputProperty
train
public String getOutputProperty(String name) { String val = getOutputPropertyNonDefault(name); // If no explicit value, try to get the default value if (val == null) val = getOutputPropertyDefault(name); return val; }
java
{ "resource": "" }
q29735
SerializerBase.getFirstCharLocName
train
static char getFirstCharLocName(String name) { final char first; int i = name.indexOf('}'); if (i < 0) first = name.charAt(0); else first = name.charAt(i+1); return first; }
java
{ "resource": "" }
q29736
Functionizer.makeFunction
train
private FunctionDeclaration makeFunction(MethodDeclaration method) { ExecutableElement elem = method.getExecutableElement(); TypeElement declaringClass = ElementUtil.getDeclaringClass(elem); boolean isInstanceMethod = !ElementUtil.isStatic(elem) && !ElementUtil.isConstructor(elem); FunctionDeclaration ...
java
{ "resource": "" }
q29737
Functionizer.makeAllocatingConstructor
train
private FunctionDeclaration makeAllocatingConstructor( MethodDeclaration method, boolean releasing) { assert method.isConstructor(); ExecutableElement element = method.getExecutableElement(); TypeElement declaringClass = ElementUtil.getDeclaringClass(element); String name = releasing ? nameTable....
java
{ "resource": "" }
q29738
Functionizer.setFunctionCaller
train
private void setFunctionCaller(MethodDeclaration method, ExecutableElement methodElement) { TypeMirror returnType = methodElement.getReturnType(); TypeElement declaringClass = ElementUtil.getDeclaringClass(methodElement); Block body = new Block(); method.setBody(body); method.removeModifiers(Modifie...
java
{ "resource": "" }
q29739
Functionizer.addDisallowedConstructors
train
private void addDisallowedConstructors(TypeDeclaration node) { TypeElement typeElement = node.getTypeElement(); TypeElement superClass = ElementUtil.getSuperclass(typeElement); if (ElementUtil.isPrivateInnerType(typeElement) || ElementUtil.isAbstract(typeElement) || superClass == null // If ...
java
{ "resource": "" }
q29740
OuterReferenceResolver.findScopeForType
train
private Scope findScopeForType(TypeElement type) { Scope scope = peekScope(); while (scope != null) { if (scope.kind != ScopeKind.METHOD && type.equals(scope.type)) { return scope; } scope = scope.outer; } return null; }
java
{ "resource": "" }
q29741
OuterReferenceResolver.whenNeedsOuterParam
train
private void whenNeedsOuterParam(TypeElement type, Runnable runnable) { if (captureInfo.needsOuterParam(type)) { runnable.run(); } else if (ElementUtil.isLocal(type)) { Scope scope = findScopeForType(type); if (scope != null) { scope.onOuterParam.add(captureCurrentScope(runnable)); ...
java
{ "resource": "" }
q29742
OuterReferenceResolver.addSuperOuterPath
train
private void addSuperOuterPath(TypeDeclaration node) { TypeElement superclass = ElementUtil.getSuperclass(node.getTypeElement()); if (superclass != null && captureInfo.needsOuterParam(superclass)) { node.setSuperOuter(getOuterPathInherited(ElementUtil.getDeclaringClass(superclass))); } }
java
{ "resource": "" }
q29743
CharsetEncoder.replaceWith
train
public final CharsetEncoder replaceWith(byte[] newReplacement) { if (newReplacement == null) throw new IllegalArgumentException("Null replacement"); int len = newReplacement.length; if (len == 0) throw new IllegalArgumentException("Empty replacement"); if (len > m...
java
{ "resource": "" }
q29744
CharsetEncoder.isLegalReplacement
train
public boolean isLegalReplacement(byte[] repl) { /* J2ObjC: Removed use of WeakReference. WeakReference<CharsetDecoder> wr = cachedDecoder; CharsetDecoder dec = null; if ((wr == null) || ((dec = wr.get()) == null)) {*/ CharsetDecoder dec = cachedDecoder; if (dec == null) ...
java
{ "resource": "" }
q29745
CharsetEncoder.onUnmappableCharacter
train
public final CharsetEncoder onUnmappableCharacter(CodingErrorAction newAction) { if (newAction == null) throw new IllegalArgumentException("Null action"); unmappableCharacterAction = newAction; implOnUnmappableCharacter(newAct...
java
{ "resource": "" }
q29746
CharsetEncoder.encode
train
public final ByteBuffer encode(CharBuffer in) throws CharacterCodingException { int n = (int)(in.remaining() * averageBytesPerChar()); ByteBuffer out = ByteBuffer.allocate(n); if ((n == 0) && (in.remaining() == 0)) return out; reset(); for (;;) { ...
java
{ "resource": "" }
q29747
CharsetEncoder.canEncode
train
public boolean canEncode(char c) { CharBuffer cb = CharBuffer.allocate(1); cb.put(c); cb.flip(); return canEncode(cb); }
java
{ "resource": "" }
q29748
ParserFactory.makeParser
train
public static Parser makeParser () throws ClassNotFoundException, IllegalAccessException, InstantiationException, NullPointerException, ClassCastException { String className = System.getProperty("org.xml.sax.parser"); if (className == null) { throw new NullPointerException("No va...
java
{ "resource": "" }
q29749
ParserFactory.makeParser
train
public static Parser makeParser (String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException, ClassCastException { return (Parser) NewInstance.newInstance ( NewInstance.getClassLoader (), className); }
java
{ "resource": "" }
q29750
X509CertificatePair.generateCertificatePair
train
public static synchronized X509CertificatePair generateCertificatePair (byte[] encoded) throws CertificateException { Object key = new Cache.EqualByteArray(encoded); X509CertificatePair pair = cache.get(key); if (pair != null) { return pair; } pair = new X...
java
{ "resource": "" }
q29751
X509CertificatePair.getEncoded
train
public byte[] getEncoded() throws CertificateEncodingException { try { if (encoded == null) { DerOutputStream tmp = new DerOutputStream(); emit(tmp); encoded = tmp.toByteArray(); } } catch (IOException ex) { throw new Ce...
java
{ "resource": "" }
q29752
StringMatcher.addMatchSetTo
train
@Override public void addMatchSetTo(UnicodeSet toUnionTo) { int ch; for (int i=0; i<pattern.length(); i+=UTF16.getCharCount(ch)) { ch = UTF16.charAt(pattern, i); UnicodeMatcher matcher = data.lookupMatcher(ch); if (matcher == null) { toUnionTo.add(...
java
{ "resource": "" }
q29753
CertificatePolicySet.encode
train
public void encode(DerOutputStream out) throws IOException { DerOutputStream tmp = new DerOutputStream(); for (int i = 0; i < ids.size(); i++) { ids.elementAt(i).encode(tmp); } out.write(DerValue.tag_Sequence,tmp); }
java
{ "resource": "" }
q29754
SimpleTimeZone.makeRulesCompatible
train
private void makeRulesCompatible() { switch (startMode) { case DOM_MODE: startDay = 1 + (startDay / 7); startDayOfWeek = Calendar.SUNDAY; break; case DOW_GE_DOM_MODE: // A day-of-month of 1 is equivalent to DOW_IN_MONTH_MODE // tha...
java
{ "resource": "" }
q29755
SimpleTimeZone.packRules
train
private byte[] packRules() { byte[] rules = new byte[6]; rules[0] = (byte)startDay; rules[1] = (byte)startDayOfWeek; rules[2] = (byte)endDay; rules[3] = (byte)endDayOfWeek; // As of serial version 2, include time modes rules[4] = (byte)startTimeMode; ...
java
{ "resource": "" }
q29756
SimpleTimeZone.unpackRules
train
private void unpackRules(byte[] rules) { startDay = rules[0]; startDayOfWeek = rules[1]; endDay = rules[2]; endDayOfWeek = rules[3]; // As of serial version 2, include time modes if (rules.length >= 6) { startTimeMode = rules[4]; ...
java
{ "resource": "" }
q29757
Collections.get
train
private static <T> T get(ListIterator<? extends T> i, int index) { T obj = null; int pos = i.nextIndex(); if (pos <= index) { do { obj = i.next(); } while (pos++ < index); } else { do { obj = i.previous(); } ...
java
{ "resource": "" }
q29758
Collections.shuffle
train
public static void shuffle(List<?> list) { Random rnd = r; if (rnd == null) r = rnd = new Random(); // harmless race. shuffle(list, rnd); }
java
{ "resource": "" }
q29759
Collections.singletonMap
train
public static <K,V> Map<K,V> singletonMap(K key, V value) { return new SingletonMap<>(key, value); }
java
{ "resource": "" }
q29760
Collections.enumeration
train
public static <T> Enumeration<T> enumeration(final Collection<T> c) { return new Enumeration<T>() { private final Iterator<T> i = c.iterator(); public boolean hasMoreElements() { return i.hasNext(); } public T nextElement() { retu...
java
{ "resource": "" }
q29761
Collections.list
train
public static <T> ArrayList<T> list(Enumeration<T> e) { ArrayList<T> l = new ArrayList<>(); while (e.hasMoreElements()) l.add(e.nextElement()); return l; }
java
{ "resource": "" }
q29762
ElemExtensionCall.getElemExtensionDecl
train
private ElemExtensionDecl getElemExtensionDecl(StylesheetRoot stylesheet, String namespace) { ElemExtensionDecl decl = null; int n = stylesheet.getGlobalImportCount(); for (int i = 0; i < n; i++) { Stylesheet imported = stylesheet.getGlobalImport(i); for (ElemTemplateElement c...
java
{ "resource": "" }
q29763
ElemExtensionCall.execute
train
public void execute(TransformerImpl transformer) throws TransformerException { if (transformer.getStylesheet().isSecureProcessing()) throw new TransformerException( XSLMessages.createMessage( XSLTErrorResources.ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, ne...
java
{ "resource": "" }
q29764
Normalizer.normalize
train
@Deprecated public static String normalize(int char32, Mode mode, int options) { if(mode == NFD && options == 0) { String decomposition = Normalizer2.getNFCInstance().getDecomposition(char32); if(decomposition == null) { decomposition = UTF16.valueOf(char32); ...
java
{ "resource": "" }
q29765
Normalizer.current
train
@Deprecated public int current() { if(bufferPos<buffer.length() || nextNormalize()) { return buffer.codePointAt(bufferPos); } else { return DONE; } }
java
{ "resource": "" }
q29766
StringReplacer.addReplacementSetTo
train
@Override public void addReplacementSetTo(UnicodeSet toUnionTo) { int ch; for (int i=0; i<output.length(); i+=UTF16.getCharCount(ch)) { ch = UTF16.charAt(output, i); UnicodeReplacer r = data.lookupReplacer(ch); if (r == null) { toUnionTo.add(ch); ...
java
{ "resource": "" }
q29767
CalendarDataUtility.retrieveFieldValueName
train
public static String retrieveFieldValueName(String id, int field, int value, int style, Locale locale) { // Android-changed: delegate to ICU. if (field == Calendar.ERA) { // For era the field value does not always equal the index into the names array. switch (normaliz...
java
{ "resource": "" }
q29768
ToSAXHandler.setContentHandler
train
public void setContentHandler(ContentHandler _saxHandler) { this.m_saxHandler = _saxHandler; if (m_lexHandler == null && _saxHandler instanceof LexicalHandler) { // we are not overwriting an existing LexicalHandler, and _saxHandler // is also implements LexicalHandler...
java
{ "resource": "" }
q29769
ToSAXHandler.startElement
train
public void startElement(String uri, String localName, String qName) throws SAXException { if (m_state != null) { m_state.resetState(getTransformer()); } // fire off the start element event if (m_tracer != null) super.fireStartElem(qName); ...
java
{ "resource": "" }
q29770
ToSAXHandler.characters
train
public void characters(org.w3c.dom.Node node) throws org.xml.sax.SAXException { // remember the current node if (m_state != null) { m_state.setCurrentNode(node); } // Get the node's value as a String and use that String as if // it were an...
java
{ "resource": "" }
q29771
ToSAXHandler.addUniqueAttribute
train
public void addUniqueAttribute(String qName, String value, int flags) throws SAXException { addAttribute(qName, value); }
java
{ "resource": "" }
q29772
UResourceBundle.findTopLevel
train
@Deprecated protected UResourceBundle findTopLevel(String aKey) { // NOTE: this only works for top-level resources. For resources at lower // levels, it fails when you fall back to the parent, since you're now // looking at root resources, not at the corresponding nested resource. f...
java
{ "resource": "" }
q29773
UResourceBundle.getString
train
public String getString(int index) { ICUResourceBundle temp = (ICUResourceBundle)get(index); if (temp.getType() == STRING) { return temp.getString(); } throw new UResourceTypeMismatchException(""); }
java
{ "resource": "" }
q29774
UResourceBundle.findTopLevel
train
@Deprecated protected UResourceBundle findTopLevel(int index) { // NOTE: this _barely_ works for top-level resources. For resources at lower // levels, it fails when you fall back to the parent, since you're now // looking at root resources, not at the corresponding nested resource. ...
java
{ "resource": "" }
q29775
UResourceBundle.keySet
train
@Override @Deprecated public Set<String> keySet() { // TODO: Java 6 ResourceBundle has keySet() which calls handleKeySet() // and caches the results. // When we upgrade to Java 6, we still need to check for isTopLevelResource(). // Keep the else branch as is. The if body should j...
java
{ "resource": "" }
q29776
UResourceBundle.handleGetObjectImpl
train
private Object handleGetObjectImpl(String aKey, UResourceBundle requested) { Object obj = resolveObject(aKey, requested); if (obj == null) { UResourceBundle parentBundle = getParent(); if (parentBundle != null) { obj = parentBundle.handleGetObjectImpl(aKey, reques...
java
{ "resource": "" }
q29777
UResourceBundle.resolveObject
train
private Object resolveObject(String aKey, UResourceBundle requested) { if (getType() == STRING) { return getString(); } UResourceBundle obj = handleGet(aKey, null, requested); if (obj != null) { if (obj.getType() == STRING) { return obj.getString()...
java
{ "resource": "" }
q29778
HttpClient.newClient
train
public static HttpClient<ByteBuf, ByteBuf> newClient(String host, int port) { return newClient(new InetSocketAddress(host, port)); }
java
{ "resource": "" }
q29779
HttpClient.newClient
train
public static HttpClient<ByteBuf, ByteBuf> newClient(ConnectionProviderFactory<ByteBuf, ByteBuf> providerFactory, Observable<Host> hostStream) { return HttpClientImpl.create(providerFactory, hostStream); }
java
{ "resource": "" }
q29780
HttpServerInterceptorChain.start
train
public static <R, W> HttpServerInterceptorChain<R, W, R, W> start() { return new HttpServerInterceptorChain<>(new TransformingInterceptor<R, W, R, W>() { @Override public RequestHandler<R, W> intercept(RequestHandler<R, W> handler) { return handler; } ...
java
{ "resource": "" }
q29781
InterceptingServer.sendHello
train
private static Interceptor<ByteBuf, ByteBuf> sendHello() { return in -> newConnection -> newConnection.writeString(Observable.just("Hello\n")) .concatWith(in.handle(newConnection)); }
java
{ "resource": "" }
q29782
TrailingHeaders.setHeader
train
public TrailingHeaders setHeader(CharSequence name, Object value) { lastHttpContent.trailingHeaders().set(name, value); return this; }
java
{ "resource": "" }
q29783
TrailingHeaders.setHeader
train
public TrailingHeaders setHeader(CharSequence name, Iterable<Object> values) { lastHttpContent.trailingHeaders().set(name, values); return this; }
java
{ "resource": "" }
q29784
DisposableContentSource.dispose
train
public void dispose() { if (onSubscribe.disposed.compareAndSet(false, true)) { for (Object chunk : onSubscribe.chunks) { ReferenceCountUtil.release(chunk); } onSubscribe.chunks.clear(); } }
java
{ "resource": "" }
q29785
PooledConnection.reuse
train
public void reuse(Subscriber<? super PooledConnection<R, W>> connectionSubscriber) { unsafeNettyChannel().pipeline().fireUserEventTriggered(new ConnectionReuseEvent<>(connectionSubscriber, this)); }
java
{ "resource": "" }
q29786
TcpClient.newClient
train
public static TcpClient<ByteBuf, ByteBuf> newClient(ConnectionProviderFactory<ByteBuf, ByteBuf> providerFactory, Observable<Host> hostStream) { return TcpClientImpl.create(providerFactory, hostStream); }
java
{ "resource": "" }
q29787
Connection.ignoreInput
train
public Observable<Void> ignoreInput() { return getInput().map(new Func1<R, Void>() { @Override public Void call(R r) { ReferenceCountUtil.release(r); return null; } }).ignoreElements(); }
java
{ "resource": "" }
q29788
CompositePoolLimitDeterminationStrategy.getAvailablePermits
train
@Override public int getAvailablePermits() { int minPermits = Integer.MAX_VALUE; for (PoolLimitDeterminationStrategy strategy : strategies) { int availablePermits = strategy.getAvailablePermits(); minPermits = Math.min(minPermits, availablePermits); } return m...
java
{ "resource": "" }
q29789
UriInfoHolder.getPath
train
private static String getPath(String uri) { int offset = 0; if (uri.startsWith("http://")) { offset = "http://".length(); } else if (uri.startsWith("https://")) { offset = "https://".length(); } if (offset == 0) { return uri; } else { ...
java
{ "resource": "" }
q29790
Clock.getDuration
train
public long getDuration(TimeUnit targetUnit) { if (isRunning()) { throw new IllegalStateException("The clock is not yet stopped."); } return targetUnit.convert(durationNanos, TimeUnit.NANOSECONDS); }
java
{ "resource": "" }
q29791
WsUtils.sha1
train
public static byte[] sha1(byte[] data) { try { //Attempt to get a MessageDigest that uses SHA1 MessageDigest md = MessageDigest.getInstance("SHA1"); //Hash the data return md.digest(data); } catch (NoSuchAlgorithmException e) { //Alright, you m...
java
{ "resource": "" }
q29792
WsUtils.randomBytes
train
public static byte[] randomBytes(int size) { byte[] bytes = new byte[size]; for (int index = 0; index < size; index++) { bytes[index] = (byte) randomNumber(0, 255); } return bytes; }
java
{ "resource": "" }
q29793
Utils.isSelinuxFlagInEnabled
train
public static boolean isSelinuxFlagInEnabled() { try { Class<?> c = Class.forName("android.os.SystemProperties"); Method get = c.getMethod("get", String.class); String selinux = (String) get.invoke(c, "ro.build.selinux"); return "1".equals(selinux); } catc...
java
{ "resource": "" }
q29794
RootBeer.isRootedWithoutBusyBoxCheck
train
public boolean isRootedWithoutBusyBoxCheck() { return detectRootManagementApps() || detectPotentiallyDangerousApps() || checkForBinary(BINARY_SU) || checkForDangerousProps() || checkForRWPaths() || detectTestKeys() || checkSuExists() || checkForRootNative() || checkForMagiskBina...
java
{ "resource": "" }
q29795
RootBeer.detectRootManagementApps
train
public boolean detectRootManagementApps(String[] additionalRootManagementApps) { // Create a list of package names to iterate over from constants any others provided ArrayList<String> packages = new ArrayList<>(Arrays.asList(Const.knownRootAppsPackages)); if (additionalRootManagementApps!=null ...
java
{ "resource": "" }
q29796
RootBeer.detectPotentiallyDangerousApps
train
public boolean detectPotentiallyDangerousApps(String[] additionalDangerousApps) { // Create a list of package names to iterate over from constants any others provided ArrayList<String> packages = new ArrayList<>(); packages.addAll(Arrays.asList(Const.knownDangerousAppsPackages)); if (ad...
java
{ "resource": "" }
q29797
RootBeer.detectRootCloakingApps
train
public boolean detectRootCloakingApps(String[] additionalRootCloakingApps) { // Create a list of package names to iterate over from constants any others provided ArrayList<String> packages = new ArrayList<>(Arrays.asList(Const.knownRootCloakingPackages)); if (additionalRootCloakingApps!=null &&...
java
{ "resource": "" }
q29798
RootBeer.isAnyPackageFromListInstalled
train
private boolean isAnyPackageFromListInstalled(List<String> packages){ boolean result = false; PackageManager pm = mContext.getPackageManager(); for (String packageName : packages) { try { // Root app detected pm.getPackageInfo(packageName, 0); ...
java
{ "resource": "" }
q29799
RootBeer.checkForDangerousProps
train
public boolean checkForDangerousProps() { final Map<String, String> dangerousProps = new HashMap<>(); dangerousProps.put("ro.debuggable", "1"); dangerousProps.put("ro.secure", "0"); boolean result = false; String[] lines = propsReader(); if (lines == null){ ...
java
{ "resource": "" }