code
stringlengths
73
34.1k
label
stringclasses
1 value
public String getJavaCreateString() { StringBuilder sb = new StringBuilder(); sb.append("new com.caucho.v5.make.DependencyList()"); for (int i = 0; i < _dependencyList.size(); i++) { sb.append(".add("); sb.append(_dependencyList.get(i).getJavaCreateString()); sb.append(")"); } ...
java
protected void initRequest() { _hostHeader = null; _xForwardedHostHeader = null; _expect100Continue = false; _cookies.clear(); _contentLengthIn = -1; _hasReadStream = false; _readEncoding = null; //_request = request; //_requestFacade = getHttp().createFacade(this); _...
java
public void clientDisconnect() { try { OutHttpApp responseStream = _responseStream; if (responseStream != null) { responseStream.close(); } } catch (Exception e) { log.log(Level.FINER, e.toString(), e); } ConnectionTcp conn = connTcp(); if (conn != null...
java
public int getServerPort() { String host = null; CharSequence rawHost; if ((rawHost = getHost()) != null) { int length = rawHost.length(); int i; for (i = length - 1; i >= 0; i--) { if (rawHost.charAt(i) == ':') { int port = 0; for (i++; i < length; i++) { ...
java
public CharSegment getHeaderBuffer(String name) { String value = header(name); if (value != null) return new CharBuffer(value); else return null; }
java
protected boolean addHeaderInt(char []keyBuf, int keyOff, int keyLen, CharSegment value) { if (keyLen < 4) { return true; } int key1 = keyBuf[keyOff] | 0x20 | (keyLen << 8); switch (key1) { case CONNECTION_KEY: if (match(keyBuf, keyOff, keyLen, CO...
java
private boolean match(char []a, int aOff, int aLength, char []b) { int bLength = b.length; if (aLength != bLength) return false; for (int i = aLength - 1; i >= 0; i--) { char chA = a[aOff + i]; char chB = b[i]; if (chA != chB && chA + 'a' - 'A' != chB) { return false; ...
java
public Enumeration<String> getHeaders(String name) { String value = header(name); if (value == null) { return Collections.emptyEnumeration(); } ArrayList<String> list = new ArrayList<String>(); list.add(value); return Collections.enumeration(list); }
java
public void getHeaderBuffers(String name, ArrayList<CharSegment> resultList) { String value = header(name); if (value != null) resultList.add(new CharBuffer(value)); }
java
public int getIntHeader(String key) { CharSegment value = getHeaderBuffer(key); if (value == null) return -1; int len = value.length(); if (len == 0) throw new NumberFormatException(value.toString()); int iValue = 0; int i = 0; int ch = value.charAt(i); int sign = 1; ...
java
public String encoding() { if (_readEncoding != null) return _readEncoding; CharSegment value = getHeaderBuffer("Content-Type"); if (value == null) return null; int i = value.indexOf("charset"); if (i < 0) return null; int len = value.length(); for (i += 7; i < len &&...
java
CookieWeb []fillCookies() { int size = _cookies.size(); if (size > 0) { CookieWeb []cookiesIn = new WebCookie[size]; for (int i = size - 1; i >= 0; i--) { cookiesIn[i] = _cookies.get(i); } return cookiesIn; } else { return NULL_COOKIES; } }
java
private void finishRequest() throws IOException { try { cleanup(); } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } finally { //_requestFacade = null; } }
java
public final OutHttpApp out() { OutHttpApp stream = _responseStream; if (stream == null) { stream = createOut(); _responseStream = stream; } return stream; }
java
public boolean containsHeaderOut(String name) { ArrayList<String> headerKeys = _headerKeysOut; int size = headerKeys.size(); for (int i = 0; i < size; i++) { String oldKey = headerKeys.get(i); if (oldKey.equalsIgnoreCase(name)) { return true; } } if (name.equalsIgn...
java
public String headerOut(String name) { ArrayList<String> keys = _headerKeysOut; int headerSize = keys.size(); for (int i = 0; i < headerSize; i++) { String oldKey = keys.get(i); if (oldKey.equalsIgnoreCase(name)) { return (String) _headerValuesOut.get(i); } } /* if...
java
public void addHeaderOutImpl(String key, String value) { if (headerOutSpecial(key, value)) { return; } ArrayList<String> keys = _headerKeysOut; ArrayList<String> values = _headerValuesOut; int size = keys.size(); // webapp/1k32 for (int i = 0; i < size; i++) { if...
java
private boolean headerOutSpecial(String key, String value) { int length = key.length(); if (length == 0) { return false; } int ch = key.charAt(0); if ('A' <= ch && ch <= 'Z') { ch += 'a' - 'A'; } int code = (length << 8) + ch; switch (code) { ca...
java
public void setFooter(String key, String value) { Objects.requireNonNull(value); int i = 0; boolean hasFooter = false; for (i = _footerKeys.size() - 1; i >= 0; i--) { String oldKey = _footerKeys.get(i); if (oldKey.equalsIgnoreCase(key)) { if (hasFooter) { _footerKeys.r...
java
public void addFooter(String key, String value) { if (headerOutSpecial(key, value)) { return; } _footerKeys.add(key); _footerValues.add(value); }
java
public final boolean isOutCommitted() { OutHttpApp stream = out(); if (stream.isCommitted()) { return true; } // server/05a7 if (_contentLengthOut > 0 && _contentLengthOut <= stream.contentLength()) { return true; } return false; }
java
public long contentLengthSent() { OutHttpApp stream = _responseStream; // stream can be null for duplex (websocket) if (stream != null) { return stream.contentLength(); } else { return Math.max(_contentLengthOut, 0); } }
java
private boolean enableKeepalive(PollController conn, boolean isNew) throws IOException { if (_selectMax <= _connectionCount.get()) { throw new IllegalStateException(this + " keepalive overflow " + _connectionCount + " max=" +...
java
private void runSelectTask() { if (_lifecycle.isActive() || _lifecycle.isAfterStopping()) { log.warning(this + " cannot start because an instance is active"); return; } initNative(_fd); synchronized (_thread) { _thread.notify(); } if (! _lifecycle.toActive()) { log.w...
java
@SuppressWarnings("unchecked") private void initTypesMapping() { if (mapping == null) { throw new IllegalStateException("Mapping does contain any information in " + "DeployerTypesResolver " + this); } if (mapping.containsKey(NODE_TYPES_MAPPING_SECTION)) { ...
java
@Override public int addressRemote(byte []buffer, int offset, int length) { return _socket.getRemoteAddress(buffer, offset, length); }
java
@Override public void requestWake() { try { _state = _state.toWake(); requestLoop(); } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } /* if (_stateRef.get().toWake(_stateRef)) { offer(getConnectionTask()); } */ }
java
private StateConnection processPoll() throws IOException { PortTcp port = _port; if (port.isClosed()) { return StateConnection.DESTROY; } if (readStream().available() > 0) { return StateConnection.ACTIVE; } long timeout = _idleTimeout; _idleStartTime = CurrentTime.curre...
java
private void initSocket() throws IOException { _idleTimeout = _port.getKeepaliveTimeout(); _port.ssl(_socket); writeStream().init(_socket.stream()); // ReadStream cannot use getWriteStream or auto-flush // because of duplex mode // ReadStream is = getReadStream(); _readStream.init(_...
java
private void destroy() { if (log.isLoggable(Level.FINEST)) { log.finest(this + " destroying connection"); } try { _socket.forceShutdown(); } catch (Throwable e) { } try { closeConnection(); } catch (Throwable e) { log.log(Level.FINER, e.toString(), e); } ...
java
private boolean isCacheValid() { long now = CurrentTime.currentTime(); if ((now - _lastTime < 100) && ! CurrentTime.isTest()) return true; long oldLastModified = _lastModified; long oldLength = _length; long newLastModified = getBacking().getLastModified(); long newLength = getBac...
java
@Override public void setContextLoader(ClassLoader loader) { if (loader != null) _loaderRef = new WeakReference<ClassLoader>(loader); else _loaderRef = null; }
java
public static JClassLoaderWrapper create(ClassLoader loader) { JClassLoaderWrapper jLoader = _localClassLoader.getLevel(loader); if (jLoader == null) { jLoader = new JClassLoaderWrapper(loader); _localClassLoader.set(jLoader, loader); } return jLoader; }
java
private ByExpressionBuilder parseBy() { ByExpressionBuilder by = new ByExpressionBuilder(); int x = _parseIndex; Token token = scanToken(); if (token == null) throw new IllegalStateException(L.l("expected field name at {0} in {1}", x, ...
java
public static boolean isCaseInsensitive() { Boolean value = _caseInsensitive.get(); if (value == null) { return _isCaseInsensitive; } else return value.booleanValue(); }
java
@Override public void validate() throws ConfigException { for (int i = 0; i < _jarList.size(); i++) { _jarList.get(i).validate(); } }
java
@Override public void getResources(Vector<URL> vector, String name) { if (_pathMap != null) { String cleanName = name; if (cleanName.endsWith("/")) cleanName = cleanName.substring(0, cleanName.length() - 1); JarMap.JarList jarEntryList = _pathMap.get(cleanName); fo...
java
@Override public PathImpl getPath(String pathName) { if (_pathMap != null) { String cleanPathName = pathName; if (cleanPathName.endsWith("/")) cleanPathName = cleanPathName.substring(0, cleanPathName.length() - 1); JarMap.JarList jarEntryList = _pathMap.get(cleanPathName)...
java
protected void clearJars() { synchronized (this) { ArrayList<JarEntry> jars = new ArrayList<JarEntry>(_jarList); _jarList.clear(); if (_pathMap != null) _pathMap.clear(); for (int i = 0; i < jars.size(); i++) { JarEntry jarEntry = jars.get(i); JarPath jarPath...
java
public final double sampleSigma(int n) { synchronized (_lock) { long count = _count.get(); long lastCount = _lastStdCount; _lastStdCount = count; double sum = _sum.get(); double lastSum = _lastStdSum; _lastStdSum = sum; double sumSquare = _sumSquare; _sumSquare = ...
java
public static int getInt(String strValue) { int value = 0; if (StringUtils.isNotBlank(strValue)) { Matcher m = Pattern.compile("^(\\d+)(?:\\w+|%)?$").matcher(strValue); if (m.find()) { value = Integer.parseInt(m.group(1)); } } return value; }
java
boolean isKeepaliveAllowed(long connectionStartTime) { if (! _lifecycle.isActive()) { return false; } else if (connectionStartTime + _keepaliveTimeMax < CurrentTime.currentTime()) { return false; } else if (_keepaliveMax <= _keepaliveAllocateCount.get()) { return false; } ...
java
int keepaliveThreadRead(ReadStream is, long timeoutConn) throws IOException { if (isClosed()) { return -1; } int available = is.availableBuffer(); if (available > 0) { return available; } long timeout = Math.min(getKeepaliveTimeout(), getSocketTimeout()); if (timeou...
java
@Friend(ConnectionTcp.class) void freeConnection(ConnectionTcp conn) { if (removeConnection(conn)) { _idleConn.free(conn); } else if (isActive()) { // Thread.dumpStack(); System.out.println("Possible Double Close: " + this + " " + conn); } //_connThreadPool.wake(); }
java
public void init(String dc_sync_period, String resources_keep_alive_period, String manager_ip, String manager_port) { if (registryInitialized) throw new RuntimeException("Registry was already initialized"); if (dc_sync_period != null) { CONFIG_SYNC_PERIOD = Integer.parseInt(dc...
java
public static void addResource(String type, String id, String url){ //add the new resource to the list of the managed resources logger.info("Adding the following new resource to the Data Collector Descriptor: {}, {}", type, id); try { resources.put(new InternalCompo...
java
static Throwable cause(Throwable e) { while (e.getCause() != null && (e instanceof InstantiationException || e instanceof InvocationTargetException || e.getClass().equals(RuntimeExceptionConfig.class))) { e = e.getCause(); } return e; }
java
@Override public void alarm(DeployService2Impl<I> deploy, Result<I> result) { LifecycleState state = deploy.getState(); if (! state.isActive()) { result.ok(deploy.get()); } else if (deploy.isModifiedNow()) { // baratine/801g deploy.logModified(deploy.getLog()); deploy.re...
java
String parseLine(CharCursor is, LineMap lineMap) throws IOException { int ch = is.read(); _buf.clear(); String filename = null; int line = 0; // Take 3: match /.*:\d+:/ _token.clear(); line: for (; ch != is.DONE; ch = is.read()) { while (ch == ':') { line = 0; ...
java
public static long generate(long crc, long value) { crc = next(crc, (byte) (value >> 56)); crc = next(crc, (byte) (value >> 48)); crc = next(crc, (byte) (value >> 40)); crc = next(crc, (byte) (value >> 32)); crc = next(crc, (byte) (value >> 24)); crc = next(crc, (byte) (value >> 16)); crc ...
java
@Override public String toObjectExpr(String columnName) { if (_value == null) { return "null"; } else if (_value instanceof String) { return "'" + _value + "'"; } else { return String.valueOf(_value); } }
java
public int copyTo(byte []buffer, int rowOffset, int blobTail) { byte []blockBuffer = _block.getBuffer(); System.arraycopy(blockBuffer, _rowOffset, buffer, rowOffset, _length); return _row.copyBlobs(blockBuffer, _rowOffset, buffer, rowOffset, blobTail); }
java
@Override public PathImpl schemeWalk(String userPath, Map<String,Object> newAttributes, String newPath, int offset) { return getWrappedPath().schemeWalk(userPath, newAttributes, newPath, offset); }
java
final void executorTimeout(ExecutorThrottle executor, long timeout) { _executor = executor; _activeSlowExpireTime = CurrentTime.getCurrentTimeActual() + timeout; }
java
@Override public void run() { try { _launcher.onChildIdleBegin(); _launcher.onChildThreadLaunchBegin(); _pool.addThread(this); runTasks(); } catch (Throwable e) { log.log(Level.WARNING, e.toString(), e); } finally { _pool.removeThread(this); _launcher.onC...
java
private void runTasks() { ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); ThreadPoolBase pool = _pool; Thread thread = this; Outbox outbox = outbox(); boolean isWake = false; setName(_name); while (! _isClose) { RunnableItem taskItem = pool.poll(isWake)...
java
private static long addDigest(long digest, long v) { digest = Crc64.generate(digest, (byte) (v >> 24)); digest = Crc64.generate(digest, (byte) (v >> 16)); digest = Crc64.generate(digest, (byte) (v >> 8)); digest = Crc64.generate(digest, (byte) v); return digest; }
java
private int compareView(ViewRef<?> viewA, ViewRef<?> viewB, Class<?> type) { int cmp = viewB.priority() - viewA.priority(); if (cmp != 0) { return cmp; } cmp = typeDepth(viewA.type(), type) - typeDepth(viewB.type(), type); if (c...
java
private int typeDepth(Class<?> match, Class<?> actual) { if (actual == null) { return Integer.MAX_VALUE / 2; } if (match.equals(Object.class)) { return Integer.MAX_VALUE / 4; } if (match.equals(actual)) { return 0; } int cost = 1 + typeDepth(match, actual.g...
java
public final void configure(Object bean) { Objects.requireNonNull(bean); Thread thread = Thread.currentThread(); ClassLoader loader = thread.getContextClassLoader(); /* ContextConfig oldContext = ContextConfig.getCurrent(); try { ContextConfig.setCurrent(new ContextConfig(...
java
final public void configureImpl(Object bean) // , ConfigType<?> type) throws ConfigException { Objects.requireNonNull(bean); //Objects.requireNonNull(type); try { //type.beforeConfigure(bean); // ioc/23e7 InjectContext env = InjectContextImpl.CONTEXT; injectTop(be...
java
public boolean add(String srcFilename, int srcLine, int dstLine) { return add(srcFilename, srcLine, dstLine, false); }
java
public void addLine(int startLine, String sourceFile, int repeatCount, int outputLine, int outputIncrement) { _lines.add(new Line(startLine, sourceFile, repeatCount, outputLine, outputIncrement)); }
java
public String convertError(String filename, int line, int column, String message) { String srcFilename = null; int destLine = 0; int srcLine = 0; for (int i = 0; i < _lines.size(); i++) { Line map = _lines.get(i); if (filename != null && ! filename.endsWi...
java
private void convertError(CharBuffer buf, int line) { String srcFilename = null; int destLine = 0; int srcLine = 0; int srcTailLine = Integer.MAX_VALUE; for (int i = 0; i < _lines.size(); i++) { Line map = (Line) _lines.get(i); if (map._dstLine <= line && line <= map.getLastDesti...
java
public void copyFrom(Invocation invocation) { _classLoader = invocation._classLoader; _rawHost = invocation._rawHost; _rawURI = invocation._rawURI; _hostName = invocation._hostName; _port = invocation._port; _uri = invocation._uri; _depend = invocation._depend; _querySt...
java
final public void print(long v) { Writer out = this.out; if (out == null) return; if (v == 0x8000000000000000L) { print("-9223372036854775808"); return; } try { if (v < 0) { out.write('-'); v = -v; } else if (v == 0) { out.write('0'); ...
java
final public void println(long v) { Writer out = this.out; if (out == null) return; print(v); try { out.write(_newline, 0, _newline.length); } catch (IOException e) { log.log(Level.FINE, e.toString(), e); } }
java
public void exportCode(JavaClass source, JavaClass target) throws Exception { ExportAnalyzer analyzer = new ExportAnalyzer(source, target); CodeEnhancer visitor = new CodeEnhancer(source, this); visitor.analyze(analyzer, false); visitor.update(); }
java
@Override protected void fillChunkHeader(TempBuffer tBuf, int length) { if (length == 0) throw new IllegalStateException(); byte []buffer = tBuf.buffer(); buffer[0] = (byte) '\r'; buffer[1] = (byte) '\n'; buffer[2] = hexDigit(length >> 12); buffer[3] = hexDigit(length >> 8); ...
java
public static <T> Key<T> of(Type type, Class<? extends Annotation> []annTypes) { return new Key<>(type, annTypes); }
java
public static <T> Key<T> of(Class<T> type, Class<? extends Annotation> annType) { Objects.requireNonNull(type); Objects.requireNonNull(annType); return new Key<>(type, new Class[] { annType }); }
java
public static <T> Key<T> of(Class<T> type, Annotation ann) { Objects.requireNonNull(type); Objects.requireNonNull(ann); return new Key<>(type, new Annotation[] { ann }); }
java
public Class<T> rawClass() { Type type = type(); if (type instanceof Class) { return (Class) type; } else if (type instanceof ParameterizedType) { ParameterizedType pType = (ParameterizedType) type; return (Class) pType.getRawType(); } else { throw new UnsupportedOper...
java
public boolean isAnnotationPresent(Class<? extends Annotation> annTypeTest) { for (Class<?> annType : _annTypes) { if (annType.equals(annTypeTest)) { return true; } } return false; }
java
public boolean isAssignableFrom(Key<? super T> key) { Objects.requireNonNull(key); for (Class<? extends Annotation> annType : _annTypes) { if (! containsType(annType, key._annTypes)) { return false; } } if (_type instanceof ParameterizedType) { if (! (key._type instanceof P...
java
public static void syslog(int facility, int severity, String text) { _jniTroubleshoot.checkIsValid(); if (! _isOpen) { _isOpen = true; nativeOpenSyslog(); } int priority = facility * 8 + severity; nativeSyslog(priority, text); }
java
public Object removeAttribute(String name) { if (_attributes == null) return null; else return _attributes.remove(name); }
java
@Override public InputStream getResourceAsStream(String name) { ResourceEntry entry = _resourceCacheMap.get(name); if (entry == null || entry.isModified()) { URL resource = super.getResource(name); entry = new ResourceEntry(resource); _resourceCacheMap.put(name, entry); ...
java
private void initListeners() { ClassLoader parent = getParent(); for (; parent != null; parent = parent.getParent()) { if (parent instanceof EnvironmentClassLoader) { EnvironmentClassLoader loader = (EnvironmentClassLoader) parent; if (_stopListener == null) _stopListener = n...
java
@Override public void addURL(URL url, boolean isScanned) { if (containsURL(url)) { return; } super.addURL(url, isScanned); if (isScanned) _pendingScanRoots.add(new ScanRoot(url, null)); }
java
@Override public String getHash() { String superHash = super.getHash(); // ioc/0p61 - package needed for hash to enable scan long crc = Crc64.generate(superHash); for (String pkg : _packageList) { crc = Crc64.generate(crc, pkg); } return Long.toHexString(Math.abs(crc)); ...
java
public void start() { if (! getLifecycle().toStarting()) { startListeners(); return; } //sendAddLoaderEvent(); //bind(); try { make(); } catch (Exception e) { log().log(Level.WARNING, e.toString(), e); e.printStackTrace(); } startListeners(); ...
java
@Override public void stop() { if (! getLifecycle().toStop()) { return; } ArrayList<EnvLoaderListener> listeners = getEnvironmentListeners(); Thread thread = Thread.currentThread(); ClassLoader oldLoader = thread.getContextClassLoader(); thread.setContextClassLoader(this); t...
java
@Override public void destroy() { Thread thread = Thread.currentThread(); ClassLoader oldLoader = thread.getContextClassLoader(); try { thread.setContextClassLoader(this); WeakStopListener stopListener = _stopListener; _stopListener = null; super.destroy(); ...
java
@Override public void update(Result<Integer> result, int nodeIndex, String sql, Object[] args) { NodePodAmp node = _podKraken.getNode(nodeIndex); for (int i = 0; i < node.serverCount(); i++) { ServerBartender server = node.server(i);...
java
@Override protected void doAttach() throws Exception { if (file == null) { // Remove the "file:///" // LocalFileName localFileName = (LocalFileName) getName(); String fileName = rootFile + getName().getPathDecoded(); // fileName = UriParser.decode(fileName); ...
java
@Override protected FileType doGetType() throws Exception { // JDK BUG: 6192331 // if (!file.exists()) if (!file.exists() && file.length() < 1) { return FileType.IMAGINARY; } if (file.isDirectory()) { return FileType.FOLDER; } // In d...
java
@Override protected void doRename(final FileObject newfile) throws Exception { AludraLocalFile newLocalFile = (AludraLocalFile) FileObjectUtils.getAbstractFileObject(newfile); if (!file.renameTo(newLocalFile.getLocalFile())) { throw new FileSystemException("vfs.provider.local/rename-fil...
java
@Override //@Direct public void openWrite(Result<OutputStream> result, WriteOption ...options) { result.ok(_root.openWriteFile(_path, options)); }
java
@Override @Direct public void renameTo(String relPath, Result<Boolean> result, WriteOption ...options) { _root.renameTo(_path, toAbsolute(relPath), result, options); }
java
@Override public void get(byte []tableKey, byte []key, long version, Result<GetStreamResult> result) { _tableManager.getKelpBacking().getLocal(tableKey, key, version, result.then(gs->getImpl(gs))); }
java
@Override public void put(byte []tableKey, StreamSource rowSource, Result<Boolean> result) { putImpl(tableKey, rowSource, PutType.PUT, result); }
java
@Override public void remove(byte []tableKey, byte []rowKey, long version, Result<Boolean> result) { _tableManager.getKelpBacking().remove(tableKey, rowKey, version, result); }
java
@Override public void find(byte []tableKey, Object arg, Result<byte[]> result) { TableKraken table = _tableManager.getTable(tableKey); if (table == null) { throw new QueryException(L.l("'{0}' is an unknown table.", Hex.toS...
java
@Override public void requestStartupUpdates(String from, byte []tableKey, int podIndex, long deltaTime, Result<Boolean> cont) { if (log.isLoggable(Level.FINEST)) { ...
java
public PathImpl fsWalk(String userPath, Map<String,Object> attributes, String path) { return new ClasspathPath(_root, userPath, path); }
java
@Override public boolean exists() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); return loader.getResource(getTrimPath()) != null; }
java
public char setIndex(int pos) { if (pos < 0) { _pos = 0; return DONE; } else if (_length <= pos) { _pos = _length; return DONE; } else { _pos = pos; return _string.charAt(pos); } }
java
public char skip(int n) { _pos += n; if (_length <= _pos) { _pos = _string.length(); return DONE; } else return _string.charAt(_pos); }
java