code
stringlengths
73
34.1k
label
stringclasses
1 value
private static void searchProbableMaster(AuroraListener listener, final GlobalStateInfo globalInfo, HostAddress probableMaster) { AuroraProtocol protocol = getNewProtocol(listener.getProxy(), globalInfo, listener.getUrlParser()); try { protocol.setHostAddress(probableMaster); p...
java
public static AuroraProtocol getNewProtocol(FailoverProxy proxy, final GlobalStateInfo globalInfo, UrlParser urlParser) { AuroraProtocol newProtocol = new AuroraProtocol(urlParser, globalInfo, proxy.lock); newProtocol.setProxy(proxy); return newProtocol; }
java
@Override public void reset() { insertIds.clear(); updateCounts.clear(); insertIdNumber = 0; hasException = false; rewritten = false; }
java
private boolean readNextValue() throws IOException, SQLException { byte[] buf = reader.getPacketArray(false); //is error Packet if (buf[0] == ERROR) { protocol.removeActiveStreamingResult(); protocol.removeHasMoreResults(); protocol.setHasWarnings(false); ErrorPacket errorPacket = n...
java
protected void deleteCurrentRowData() throws SQLException { //move data System.arraycopy(data, rowPointer + 1, data, rowPointer, dataSize - 1 - rowPointer); data[dataSize - 1] = null; dataSize--; lastRowPointer = -1; previous(); }
java
public void close() throws SQLException { isClosed = true; if (!isEof) { lock.lock(); try { while (!isEof) { dataSize = 0; //to avoid storing data readNextValue(); } } catch (SQLException queryException) { throw ExceptionMapper.getException(queryExc...
java
private int nameToIndex(String parameterName) throws SQLException { parameterMetadata.readMetadataFromDbIfRequired(); for (int i = 1; i <= parameterMetadata.getParameterCount(); i++) { String name = parameterMetadata.getName(i); if (name != null && name.equalsIgnoreCase(parameterName)) { ret...
java
private int nameToOutputIndex(String parameterName) throws SQLException { parameterMetadata.readMetadataFromDbIfRequired(); for (int i = 0; i < parameterMetadata.getParameterCount(); i++) { String name = parameterMetadata.getName(i + 1); if (name != null && name.equalsIgnoreCase(parameterName)) { ...
java
private int indexToOutputIndex(int parameterIndex) throws SQLException { try { if (outputParameterMapper[parameterIndex - 1] == -1) { //this is not an outputParameter throw new SQLException("Parameter in index '" + parameterIndex + "' is not declared as output parameter with method...
java
public void writeTo(PacketOutputStream pos) throws IOException { pos.write(QUOTE); if (length == Long.MAX_VALUE) { pos.write(reader, true, noBackslashEscapes); } else { pos.write(reader, length, true, noBackslashEscapes); } pos.write(QUOTE); }
java
@Override public void reset() throws SQLException { cmdPrologue(); try { writer.startPacket(0); writer.write(COM_RESET_CONNECTION); writer.flush(); getResult(new Results()); //clear prepare statement cache if (options.cachePrepStmts && options.useServerPrepStmts) { ...
java
@Override public void executeQuery(boolean mustExecuteOnMaster, Results results, final String sql) throws SQLException { cmdPrologue(); try { writer.startPacket(0); writer.write(COM_QUERY); writer.write(sql); writer.flush(); getResult(results); } catch (SQLException ...
java
public void executeQuery(boolean mustExecuteOnMaster, Results results, final ClientPrepareResult clientPrepareResult, ParameterHolder[] parameters) throws SQLException { cmdPrologue(); try { if (clientPrepareResult.getParamCount() == 0 && !clientPrepareResult .isQueryMultiValuesRewr...
java
private void executeBatch(Results results, final List<String> queries) throws SQLException { if (!options.useBatchMultiSend) { String sql = null; SQLException exception = null; for (int i = 0; i < queries.size() && !isInterrupted(); i++) { try { sql = queries.get(i); ...
java
@Override public ServerPrepareResult prepare(String sql, boolean executeOnMaster) throws SQLException { cmdPrologue(); lock.lock(); try { if (options.cachePrepStmts && options.useServerPrepStmts) { ServerPrepareResult pr = serverPrepareStatementCache.get(database + "-" + sql); if ...
java
private void executeBatchRewrite(Results results, final ClientPrepareResult prepareResult, List<ParameterHolder[]> parameterList, boolean rewriteValues) throws SQLException { cmdPrologue(); ParameterHolder[] parameters; int currentIndex = 0; int totalParameterList = parameterList.size(); ...
java
public boolean executeBatchServer(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, String sql, final List<ParameterHolder[]> parametersList, boolean hasLongData) throws SQLException { cmdPrologue(); if (options.useBulkStmts && !hasLongData ...
java
@Override public void executePreparedQuery(boolean mustExecuteOnMaster, ServerPrepareResult serverPrepareResult, Results results, ParameterHolder[] parameters) throws SQLException { cmdPrologue(); try { int parameterCount = serverPrepareResult.getParameters().length; //send b...
java
public void rollback() throws SQLException { cmdPrologue(); lock.lock(); try { if (inTransaction()) { executeQuery("ROLLBACK"); } } catch (Exception e) { /* eat exception */ } finally { lock.unlock(); } }
java
public boolean forceReleasePrepareStatement(int statementId) throws SQLException { if (lock.tryLock()) { try { checkClose(); try { writer.startPacket(0); writer.write(COM_STMT_CLOSE); writer.writeInt(statementId); writer.flush(); return tru...
java
@Override public void cancelCurrentQuery() throws SQLException { try (MasterProtocol copiedProtocol = new MasterProtocol(urlParser, new GlobalStateInfo(), new ReentrantLock())) { copiedProtocol.setHostAddress(getHostAddress()); copiedProtocol.connect(); //no lock, because there is alread...
java
@Override public void releasePrepareStatement(ServerPrepareResult serverPrepareResult) throws SQLException { //If prepared cache is enable, the ServerPrepareResult can be shared in many PrepStatement, //so synchronised use count indicator will be decrement. serverPrepareResult.decrementShareCounter(); ...
java
@Override public void setTimeout(int timeout) throws SocketException { lock.lock(); try { this.socket.setSoTimeout(timeout); } finally { lock.unlock(); } }
java
public void setTransactionIsolation(final int level) throws SQLException { cmdPrologue(); lock.lock(); try { String query = "SET SESSION TRANSACTION ISOLATION LEVEL"; switch (level) { case Connection.TRANSACTION_READ_UNCOMMITTED: query += " READ UNCOMMITTED"; break; ...
java
private void readPacket(Results results) throws SQLException { Buffer buffer; try { buffer = reader.getPacket(true); } catch (IOException e) { throw handleIoException(e); } switch (buffer.getByteAt(0)) { //**************************************************************************...
java
private void readOkPacket(Buffer buffer, Results results) { buffer.skipByte(); //fieldCount final long updateCount = buffer.getLengthEncodedNumeric(); final long insertId = buffer.getLengthEncodedNumeric(); serverStatus = buffer.readShort(); hasWarnings = (buffer.readShort() > 0); if ((serverS...
java
private SQLException readErrorPacket(Buffer buffer, Results results) { removeHasMoreResults(); this.hasWarnings = false; buffer.skipByte(); final int errorNumber = buffer.readShort(); String message; String sqlState; if (buffer.readByte() == '#') { sqlState = new String(buffer.readRawB...
java
private void readLocalInfilePacket(Buffer buffer, Results results) throws SQLException { int seq = 2; buffer.getLengthEncodedNumeric(); //field pos String fileName = buffer.readStringNullEnd(StandardCharsets.UTF_8); try { // Server request the local file (LOCAL DATA LOCAL INFILE) // We do a...
java
private void readResultSet(Buffer buffer, Results results) throws SQLException { long fieldCount = buffer.getLengthEncodedNumeric(); try { //read columns information's ColumnInformation[] ci = new ColumnInformation[(int) fieldCount]; for (int i = 0; i < fieldCount; i++) { ci[i] = new...
java
public void prolog(long maxRows, boolean hasProxy, MariaDbConnection connection, MariaDbStatement statement) throws SQLException { if (explicitClosed) { throw new SQLException("execute() is called on closed connection"); } //old failover handling if (!hasProxy && shouldReconnectWithout...
java
public SQLException handleIoException(Exception initialException) { boolean mustReconnect; boolean driverPreventError = false; if (initialException instanceof MaxAllowedPacketException) { mustReconnect = ((MaxAllowedPacketException) initialException).isMustReconnect(); driverPreventError = !mus...
java
public void writeTo(final PacketOutputStream pos) throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); sdf.setTimeZone(timeZone); String dateString = sdf.format(time); pos.write(QUOTE); pos.write(dateString.getBytes()); int microseconds = (int) (time.getTime() % 1000) *...
java
public Connection connect(final String url, final Properties props) throws SQLException { UrlParser urlParser = UrlParser.parse(url, props); if (urlParser == null || urlParser.getHostAddresses() == null) { return null; } else { return MariaDbConnection.newConnection(urlParser, null); } }
java
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { if (url != null) { UrlParser urlParser = UrlParser.parse(url, info); if (urlParser == null || urlParser.getOptions() == null) { return new DriverPropertyInfo[0]; } List<DriverP...
java
@Override public void initializeConnection() throws SQLException { super.initializeConnection(); try { reconnectFailedConnection(new SearchFilter(true)); } catch (SQLException e) { //initializeConnection failed checkInitialConnection(e); } }
java
public void checkWaitingConnection() throws SQLException { if (isSecondaryHostFail()) { proxy.lock.lock(); try { Protocol waitingProtocol = waitNewSecondaryProtocol.getAndSet(null); if (waitingProtocol != null && pingSecondaryProtocol(waitingProtocol)) { lockAndSwitchSecondary(...
java
public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException { if (!searchFilter.isInitialConnection() && (isExplicitClosed() || (searchFilter.isFineIfFoundOnlyMaster() && !isMasterHostFail()) || searchFilter.isFineIfFoundOnlySlave() && !isSecondaryHostFail())) { ...
java
public void foundActiveMaster(Protocol newMasterProtocol) { if (isMasterHostFail()) { if (isExplicitClosed()) { newMasterProtocol.close(); return; } if (!waitNewMasterProtocol.compareAndSet(null, newMasterProtocol)) { newMasterProtocol.close(); } } else { ne...
java
public void lockAndSwitchMaster(Protocol newMasterProtocol) throws ReconnectDuringTransactionException { if (masterProtocol != null && !masterProtocol.isClosed()) { masterProtocol.close(); } if (!currentReadOnlyAsked || isSecondaryHostFail()) { //actually on a secondary read-only because ...
java
public void foundActiveSecondary(Protocol newSecondaryProtocol) throws SQLException { if (isSecondaryHostFail()) { if (isExplicitClosed()) { newSecondaryProtocol.close(); return; } if (proxy.lock.tryLock()) { try { lockAndSwitchSecondary(newSecondaryProtocol); ...
java
public void lockAndSwitchSecondary(Protocol newSecondaryProtocol) throws SQLException { if (secondaryProtocol != null && !secondaryProtocol.isClosed()) { secondaryProtocol.close(); } //if asked to be on read only connection, switching to this new connection if (currentReadOnlyAsked || (urlParser....
java
public HandleErrorResult primaryFail(Method method, Object[] args, boolean killCmd) { boolean alreadyClosed = masterProtocol == null || !masterProtocol.isConnected(); boolean inTransaction = masterProtocol != null && masterProtocol.inTransaction(); //in case of SocketTimeoutException due to having set sock...
java
public void reconnect() throws SQLException { SearchFilter filter; boolean inTransaction = false; if (currentReadOnlyAsked) { filter = new SearchFilter(true, true); } else { inTransaction = masterProtocol != null && masterProtocol.inTransaction(); filter = new SearchFilter(true, urlPar...
java
private boolean pingSecondaryProtocol(Protocol protocol) { try { if (protocol != null && protocol.isConnected() && protocol.ping()) { return true; } } catch (Exception e) { protocol.close(); if (setSecondaryHostFail()) { addToBlacklist(protocol.getHostAddress()); }...
java
public HandleErrorResult secondaryFail(Method method, Object[] args, boolean killCmd) throws Throwable { proxy.lock.lock(); try { if (pingSecondaryProtocol(this.secondaryProtocol)) { return relaunchOperation(method, args); } } finally { proxy.lock.unlock(); } if (!is...
java
public List<HostAddress> connectedHosts() { List<HostAddress> usedHost = new ArrayList<>(); if (isMasterHostFail()) { Protocol masterProtocol = waitNewMasterProtocol.get(); if (masterProtocol != null) { usedHost.add(masterProtocol.getHostAddress()); } } else { usedHost.add(m...
java
public HandleErrorResult handleFailover(SQLException qe, Method method, Object[] args, Protocol protocol) throws Throwable { if (isExplicitClosed()) { throw new SQLException("Connection has been closed !"); } //check that failover is due to kill command boolean killCmd = qe != null ...
java
public boolean setSecondaryHostFail() { if (secondaryHostFail.compareAndSet(false, true)) { secondaryHostFailNanos = System.nanoTime(); currentConnectionAttempts.set(0); return true; } return false; }
java
public void remove() { for (int i = 0; i < buf.length; i++) { buf[i] = null;// force null for easier garbage } buf = null; }
java
public PooledConnection getPooledConnection(String user, String password) throws SQLException { return new MariaDbPooledConnection((MariaDbConnection) getConnection(user, password)); }
java
@Override public void initializeConnection() throws SQLException { super.initializeConnection(); this.currentProtocol = null; //launching initial loop reconnectFailedConnection(new SearchFilter(true, false)); resetMasterFailoverData(); }
java
public void preExecute() throws SQLException { lastQueryNanos = System.nanoTime(); //if connection is closed or failed on slave if (this.currentProtocol != null && this.currentProtocol.isClosed()) { preAutoReconnect(); } }
java
@Override public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException { proxy.lock.lock(); try { if (!searchFilter.isInitialConnection() && (isExplicitClosed() || !isMasterHostFail())) { return; } currentConnectionAttempts.incrementAndGet(); ...
java
public void switchReadOnlyConnection(Boolean mustBeReadOnly) throws SQLException { if (urlParser.getOptions().assureReadOnly && currentReadOnlyAsked != mustBeReadOnly) { proxy.lock.lock(); try { // verify not updated now that hold lock, double check safe due to volatile if (currentReadOn...
java
@Override public void foundActiveMaster(Protocol protocol) throws SQLException { if (isExplicitClosed()) { proxy.lock.lock(); try { protocol.close(); } finally { proxy.lock.unlock(); } return; } syncConnection(this.currentProtocol, protocol); proxy.lock.lo...
java
public void reconnect() throws SQLException { boolean inTransaction = currentProtocol != null && currentProtocol.inTransaction(); reconnectFailedConnection(new SearchFilter(true, false)); handleFailLoop(); if (inTransaction) { throw new ReconnectDuringTransactionException( "Connection re...
java
public void authenticate(final PacketOutputStream out, final PacketInputStream in, final AtomicInteger sequence, final String servicePrincipalName, String mechanisms) throws SQLException, IOException { if ("".equals(servicePrincipalName)) { throw new SQLException("No principal name...
java
public static void send(final PacketOutputStream pos, final String username, final String password, final HostAddress currentHost, final String database, final long clientCapabilities, final long serverCapabilities, final byte serverLanguage, final byte packetSeq, f...
java
public static List<HostAddress> parse(String spec, HaMode haMode) { if (spec == null) { throw new IllegalArgumentException("Invalid connection URL, host address must not be empty "); } if ("".equals(spec)) { return new ArrayList<>(0); } String[] tokens = spec.trim().split(","); int s...
java
public void writeTo(final PacketOutputStream os) throws IOException { os.write(QUOTE); os.write(dateByteFormat()); os.write(QUOTE); }
java
public ServerPrepareResult read(PacketInputStream reader, boolean eofDeprecated) throws IOException, SQLException { Buffer buffer = reader.getPacket(true); byte firstByte = buffer.getByteAt(buffer.position); if (firstByte == ERROR) { throw buildErrorException(buffer); } if (firstByte =...
java
private static void resetHostList(MastersSlavesListener listener, Deque<HostAddress> loopAddresses) { //if all servers have been connected without result //add back all servers List<HostAddress> servers = new ArrayList<>(); servers.addAll(listener.getUrlParser().getHostAddresses()); Collection...
java
public void fireStatementClosed(Statement st) { if (st instanceof PreparedStatement) { StatementEvent event = new StatementEvent(this, (PreparedStatement) st); for (StatementEventListener listener : statementEventListeners) { listener.statementClosed(event); } } }
java
public void fireStatementErrorOccured(Statement st, SQLException ex) { if (st instanceof PreparedStatement) { StatementEvent event = new StatementEvent(this, (PreparedStatement) st, ex); for (StatementEventListener listener : statementEventListeners) { listener.statementErrorOccurred(event); ...
java
public void fireConnectionClosed() { ConnectionEvent event = new ConnectionEvent(this); for (ConnectionEventListener listener : connectionEventListeners) { listener.connectionClosed(event); } }
java
public void fireConnectionErrorOccured(SQLException ex) { ConnectionEvent event = new ConnectionEvent(this, ex); for (ConnectionEventListener listener : connectionEventListeners) { listener.connectionErrorOccurred(event); } }
java
protected void setTimerTask(boolean isBatch) { assert (timerTaskFuture == null); timerTaskFuture = timeoutScheduler.schedule(() -> { try { isTimedout = true; if (!isBatch) { protocol.cancelCurrentQuery(); } protocol.interrupt(); } catch (Throwable e) { ...
java
protected SQLException executeExceptionEpilogue(SQLException sqle) { //if has a failover, closing the statement if (sqle.getSQLState() != null && sqle.getSQLState().startsWith("08")) { try { close(); } catch (SQLException sqlee) { //eat exception } } if (isTimedout) { ...
java
@Override public long executeLargeUpdate(String sql) throws SQLException { if (executeInternal(sql, fetchSize, Statement.NO_GENERATED_KEYS)) { return 0; } return getLargeUpdateCount(); }
java
public int getUpdateCount() { if (results != null && results.getCmdInformation() != null && !results.isBatch()) { return results.getCmdInformation().getUpdateCount(); } return -1; }
java
@Override public long getLargeUpdateCount() { if (results != null && results.getCmdInformation() != null && !results.isBatch()) { return results.getCmdInformation().getLargeUpdateCount(); } return -1; }
java
private void internalBatchExecution(int size) throws SQLException { executeQueryPrologue(true); results = new Results(this, 0, true, size, false, resultSetScrollType, resultSetConcurrency, Statement.RETURN_GENERATED_KEYS, protocol.getAutoIncrement...
java
public void checkCloseOnCompletion(ResultSet resultSet) throws SQLException { if (mustCloseOnCompletion && !closed && results != null && resultSet.equals(results.getResultSet())) { close(); } }
java
public void initFunctionData(int parametersCount) { params = new CallParameter[parametersCount]; for (int i = 0; i < parametersCount; i++) { params[i] = new CallParameter(); if (i > 0) { params[i].setInput(true); } } // the query was in the form {?=call function()}, so the firs...
java
private void executeQueryPrologue(ServerPrepareResult serverPrepareResult) throws SQLException { executing = true; if (closed) { throw new SQLException("execute() is called on closed statement"); } protocol .prologProxy(serverPrepareResult, maxRows, protocol.getProxy() != null, connection,...
java
public static void printButtons(int buttonNumber){ boolean buttonPressed = false; System.out.print("Button Pressed: "); for(int i=0;i<7;i++){ if((buttonNumber & (1<<i)) != 0){ System.out.println(i+" "); buttonPressed = true; } } if(!buttonPressed){ System.out.println("None "); } }
java
public static void transaction(Runnable action, boolean readOnly) { Ctx ctx = Ctxs.get(); boolean newContext = ctx == null; if (newContext) { ctx = Ctxs.open("transaction"); } try { EntityManager em = ctx.persister(); JPA.with(em).transactional(action, readOnly); } finally { if (newContext) {...
java
public static synchronized void run(String[] args, String... extraArgs) { AppStarter.startUp(args, extraArgs); // no implicit classpath scanning here boot(); // finish initialization and start the application onAppReady(); boot(); }
java
public static synchronized void bootstrap(String[] args, String... extraArgs) { AppStarter.startUp(args, extraArgs); boot(); App.scan(); // scan classpath for beans // finish initialization and start the application onAppReady(); boot(); }
java
private V setValueInsideWriteLock(V newValue) { CachedValue<V> cached = cachedValue; // read the cached value V oldValue = cached != null ? cached.value : null; if (newValue != null) { long expiresAt = ttlInMs > 0 ? U.time() + ttlInMs : Long.MAX_VALUE; cachedValue = new CachedValue<>(newValue, expiresAt); ...
java
public static Factory newInstance() { ScheduledExecutorService scheduler = newSingleThreadScheduledExecutor(new ThreadFactory() { public Thread newThread(Runnable r) { Thread result = new Thread(r); result.setDaemon(true); return result; } ...
java
@SuppressWarnings("unchecked") public static <T extends Config> T remove(Object key) { return (T) CACHE.remove(key); }
java
public void parse(Class clazz, PrintWriter output, String headerName, String projectName) throws Exception { long startTime = System.currentTimeMillis(); Group[] groups = parseMethods(clazz); long finishTime = System.currentTimeMillis(); lastExecutionTime = finishTime - startTi...
java
private Group[] parseMethods(Class clazz) { List<Group> groups = new ArrayList(); Group unknownGroup = new Group(); groups.add(unknownGroup); String[] groupsOrder = new String[0]; for (Method method : clazz.getMethods()) { Property prop = new Property(); ...
java
private Group[] orderGroup(List<Group> groups, String[] groupsOrder) { LinkedList<Group> groupsOrdered = new LinkedList(); List<Group> remained = new ArrayList(groups); for (String order : groupsOrder) { for (Group remain : remained) { if (remain.title.equals(order)...
java
private String toPropertiesString(Group[] groups, String headerName, String projectName) { StringBuilder result = new StringBuilder(); result.append(format(header, headerName, projectName)); for (Group group : groups) { result.append(group.toString()); } result.app...
java
public BigInteger getBytes(){ return value.multiply(unit.getFactor()).setScale(0, RoundingMode.CEILING).toBigIntegerExact(); }
java
String replace(String source) { if (source == null) return null; Matcher m = PATTERN.matcher(source); StringBuffer sb = new StringBuffer(); while (m.find()) { String var = m.group(1); String value = values.getProperty(var); String replaceme...
java
public List<JApiClass> compare(JApiCmpArchive oldArchive, JApiCmpArchive newArchive) { return compare(Collections.singletonList(oldArchive), Collections.singletonList(newArchive)); }
java
public List<JApiClass> compare(List<JApiCmpArchive> oldArchives, List<JApiCmpArchive> newArchives) { return createAndCompareClassLists(toFileList(oldArchives), toFileList(newArchives)); }
java
List<JApiClass> compareClassLists(JarArchiveComparatorOptions options, List<CtClass> oldClasses, List<CtClass> newClasses) { List<CtClass> oldClassesFiltered = applyFilter(options, oldClasses); List<CtClass> newClassesFiltered = applyFilter(options, newClasses); ClassesComparator classesComparator = new ClassesCo...
java
public Optional<CtClass> loadClass(ArchiveType archiveType, String name) { Optional<CtClass> loadedClass = Optional.absent(); if (this.options.getClassPathMode() == JarArchiveComparatorOptions.ClassPathMode.ONE_COMMON_CLASSPATH) { try { loadedClass = Optional.of(commonClassPool.get(name)); } catch (NotFou...
java
private boolean isImplemented(JApiMethod jApiMethod) { JApiClass aClass = jApiMethod.getjApiClass(); while(aClass != null) { for (JApiMethod method : aClass.getMethods()) { if (jApiMethod.getName().equals(method.getName()) && jApiMethod.hasSameParameter(method) && ...
java
private void emitLoop() { for (;;) { AppendOnlyLinkedArrayList<T> q; synchronized (this) { q = queue; if (q == null) { emitting = false; return; } queue = null; } ...
java
public int geneCount() { int count = 0; for (int i = 0, n = _chromosomes.length(); i < n; ++i) { count += _chromosomes.get(i).length(); } return count; }
java
@Override public void accept(final C object) { _min = min(_comparator, _min, object); _max = max(_comparator, _max, object); ++_count; }
java
public int[] toArray(final int[] array) { final int[] a = array.length >= length() ? array : new int[length()]; for (int i = length(); --i >= 0;) { a[i] = intValue(i); } return a; }
java
public DoubleAdder add(final double[] values) { for (int i = values.length; --i >= 0;) { add(values[i]); } return this; }
java
public void draw(final Graphics2D g, final int width, final int height) { g.setColor(new Color(_data[0], _data[1], _data[2], _data[3])); final GeneralPath path = new GeneralPath(); path.moveTo(_data[4]*width, _data[5]*height); for (int j = 1; j < _length; ++j) { path.lineTo(_data[4 + j*2]*width, _data[5 + j...
java
public static Polygon newRandom(final int length, final Random random) { require.positive(length); final Polygon p = new Polygon(length); p._data[0] = random.nextFloat(); // r p._data[1] = random.nextFloat(); // g p._data[2] = random.nextFloat(); // b p._data[3] = max(0.2F, random.nextFloat()*random.nextFl...
java