code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected void acquireAccessToken(final OAuthCallback cb) {
if (isAccessTokenCached()) {
// Execute the callback immediately with cached OAuth credentials
if (VERBOSE) Log.d(TAG, "Access token cached");
if (cb != null) {
// Ensure networking occurs off the mai... | java |
protected void executeQueuedCallbacks() {
if (VERBOSE)
Log.i(TAG, String.format("Executing %d queued callbacks", mCallbackQueue.size()));
for (OAuthCallback cb : mCallbackQueue) {
cb.onSuccess(getRequestFactoryFromCachedCredentials());
}
} | java |
private void captureH264MetaData(ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo) {
mH264MetaSize = bufferInfo.size;
mH264Keyframe = ByteBuffer.allocateDirect(encodedData.capacity());
byte[] videoConfig = new byte[bufferInfo.size];
encodedData.get(videoConfig, bufferInfo.offset,... | java |
private void packageH264Keyframe(ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo) {
mH264Keyframe.position(mH264MetaSize);
mH264Keyframe.put(encodedData); // BufferOverflow
} | java |
public void handleTouchEvent(MotionEvent ev){
if(ev.getAction() == MotionEvent.ACTION_MOVE){
// A finger is dragging about
if(mTexHeight != 0 && mTexWidth != 0){
mSummedTouchPosition[0] += (2 * (ev.getX() - mLastTouchPosition[0])) / mTexWidth;
mSummedTouch... | java |
public void setKernel(float[] values, float colorAdj) {
if (values.length != KERNEL_SIZE) {
throw new IllegalArgumentException("Kernel size is " + values.length +
" vs. " + KERNEL_SIZE);
}
System.arraycopy(values, 0, mKernel, 0, KERNEL_SIZE);
mColorAdjust ... | java |
public void setTexSize(int width, int height) {
mTexHeight = height;
mTexWidth = width;
float rw = 1.0f / width;
float rh = 1.0f / height;
// Don't need to create a new array here, but it's syntactically convenient.
mTexOffset = new float[] {
-rw, -rh, ... | java |
public void draw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
int vertexCount, int coordsPerVertex, int vertexStride,
float[] texMatrix, FloatBuffer texBuffer, int textureId, int texStride) {
GlUtil.checkGlError("draw start");
// Select the pro... | java |
public static void getLastKnownLocation(Context context, boolean waitForGpsFix, final LocationResult cb) {
DeviceLocation deviceLocation = new DeviceLocation();
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Location last_loc;
last_loc = lm.ge... | java |
public static KickflipApiClient getApiClient(Context context, KickflipCallback callback) {
checkNotNull(sClientKey);
checkNotNull(sClientSecret);
if (sKickflip == null || !sKickflip.getConfig().getClientId().equals(sClientKey)) {
sKickflip = new KickflipApiClient(context, sClientKey,... | java |
public void loginUser(String username, final String password, final KickflipCallback cb) {
GenericData data = new GenericData();
data.put("username", username);
data.put("password", password);
post(GET_USER_PRIVATE, new UrlEncodedContent(data), User.class, new KickflipCallback() {
... | java |
public void setUserInfo(final String newPassword, String email, String displayName, Map extraInfo, final KickflipCallback cb) {
if (!assertActiveUserAvailable(cb)) return;
GenericData data = new GenericData();
final String finalPassword;
if (newPassword != null){
data.put("ne... | java |
public void getUserInfo(String username, final KickflipCallback cb) {
if (!assertActiveUserAvailable(cb)) return;
GenericData data = new GenericData();
data.put("username", username);
post(GET_USER_PUBLIC, new UrlEncodedContent(data), User.class, new KickflipCallback() {
@Ov... | java |
private void stopStream(User user, Stream stream, final KickflipCallback cb) {
checkNotNull(stream);
// TODO: Add start / stop lat lon to Stream?
GenericData data = new GenericData();
data.put("stream_id", stream.getStreamId());
data.put("uuid", user.getUUID());
if (strea... | java |
private void handleKickflipResponse(HttpResponse response, Class<? extends Response> responseClass, KickflipCallback cb) throws IOException {
if (cb == null) return;
HashMap responseMap = null;
Response kickFlipResponse = response.parseAs(responseClass);
if (VERBOSE)
Log.i(TA... | java |
public static File getRootStorageDirectory(Context c, String directory_name){
File result;
// First, try getting access to the sdcard partition
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
Log.d(TAG,"Using sdcard");
result = new File(Enviro... | java |
public static File getStorageDirectory(File parent_directory, String new_child_directory_name){
File result = new File(parent_directory, new_child_directory_name);
if(!result.exists())
if(result.mkdir())
return result;
else{
Log.e("getStorageDirec... | java |
public static File createTempFile(Context c, File root, String filename, String extension){
File output = null;
try {
if(filename != null){
if(!extension.contains("."))
extension = "." + extension;
output = new File(root, filename + extensi... | java |
public static String tail2( File file, int lines) {
lines++; // Read # lines inclusive
java.io.RandomAccessFile fileHandler = null;
try {
fileHandler =
new java.io.RandomAccessFile( file, "r" );
long fileLength = fileHandler.length() - 1;
... | java |
public static void deleteDirectory(File fileOrDirectory) {
if (fileOrDirectory.isDirectory())
for (File child : fileOrDirectory.listFiles())
deleteDirectory(child);
fileOrDirectory.delete();
} | java |
protected long getNextRelativePts(long absPts, int trackIndex) {
if (mFirstPts == 0) {
mFirstPts = absPts;
return 0;
}
return getSafePts(absPts - mFirstPts, trackIndex);
} | java |
private long getSafePts(long pts, int trackIndex) {
if (mLastPts[trackIndex] >= pts) {
// Enforce a non-zero minimum spacing
// between pts
mLastPts[trackIndex] += 9643;
return mLastPts[trackIndex];
}
mLastPts[trackIndex] = pts;
return pts;... | java |
public static void updateFilter(FullFrameRect rect, int newFilter) {
Texture2dProgram.ProgramType programType;
float[] kernel = null;
float colorAdj = 0.0f;
if (VERBOSE) Log.d(TAG, "Updating filter to " + newFilter);
switch (newFilter) {
case FILTER_NONE:
... | java |
public void drawFrame(int textureId, float[] texMatrix) {
// Use the identity matrix for MVP so our 2x2 FULL_RECTANGLE covers the viewport.
mProgram.draw(IDENTITY_MATRIX, mRectDrawable.getVertexArray(), 0,
mRectDrawable.getVertexCount(), mRectDrawable.getCoordsPerVertex(),
... | java |
protected boolean isOneShotQuery(CachedQuery cachedQuery) {
if (cachedQuery == null) {
return true;
}
cachedQuery.increaseExecuteCount();
if ((mPrepareThreshold == 0 || cachedQuery.getExecuteCount() < mPrepareThreshold)
&& !getForceBinaryTransfer()) {
return true;
}
return fa... | java |
public void setQueryTimeoutMs(long millis) throws SQLException {
checkClosed();
if (millis < 0) {
throw new PSQLException(GT.tr("Query timeout must be a value greater than or equals to 0."),
PSQLState.INVALID_PARAMETER_VALUE);
}
timeout = millis;
} | java |
@Override
public void close() throws SQLException {
if (last != null) {
last.close();
if (!con.isClosed()) {
if (!con.getAutoCommit()) {
try {
con.rollback();
} catch (SQLException ignored) {
}
}
}
}
try {
con.close();
}... | java |
@Override
public Connection getConnection() throws SQLException {
if (con == null) {
// Before throwing the exception, let's notify the registered listeners about the error
PSQLException sqlException =
new PSQLException(GT.tr("This PooledConnection has already been closed."),
P... | java |
void fireConnectionClosed() {
ConnectionEvent evt = null;
// Copy the listener list so the listener can remove itself during this method call
ConnectionEventListener[] local =
listeners.toArray(new ConnectionEventListener[0]);
for (ConnectionEventListener listener : local) {
if (evt == nul... | java |
public int read() throws java.io.IOException {
checkClosed();
try {
if (limit > 0 && apos >= limit) {
return -1;
}
if (buffer == null || bpos >= buffer.length) {
buffer = lo.read(bsize);
bpos = 0;
}
// Handle EOF
if (bpos >= buffer.length) {
r... | java |
public synchronized Value borrow(Key key) throws SQLException {
Value value = cache.remove(key);
if (value == null) {
return createAction.create(key);
}
currentSize -= value.getSize();
return value;
} | java |
public synchronized void put(Key key, Value value) {
long valueSize = value.getSize();
if (maxSizeBytes == 0 || maxSizeEntries == 0 || valueSize * 2 > maxSizeBytes) {
// Just destroy the value if cache is disabled or if entry would consume more than a half of
// the cache
evictValue(value);
... | java |
public synchronized void putAll(Map<Key, Value> m) {
for (Map.Entry<Key, Value> entry : m.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
} | java |
private void lock(Object obtainer) throws PSQLException {
if (lockedFor == obtainer) {
throw new PSQLException(GT.tr("Tried to obtain lock while already holding it"),
PSQLState.OBJECT_NOT_IN_STATE);
}
waitOnLock();
lockedFor = obtainer;
} | java |
private void unlock(Object holder) throws PSQLException {
if (lockedFor != holder) {
throw new PSQLException(GT.tr("Tried to break lock on database connection"),
PSQLState.OBJECT_NOT_IN_STATE);
}
lockedFor = null;
this.notify();
} | java |
private void waitOnLock() throws PSQLException {
while (lockedFor != null) {
try {
this.wait();
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new PSQLException(
GT.tr("Interrupted while waiting to obtain lock on database connection"),
... | java |
public synchronized CopyOperation startCopy(String sql, boolean suppressBegin)
throws SQLException {
waitOnLock();
if (!suppressBegin) {
doSubprotocolBegin();
}
byte[] buf = Utils.encodeUTF8(sql);
try {
LOGGER.log(Level.FINEST, " FE=> Query(CopyStart)");
pgStream.sendChar('... | java |
private synchronized void initCopy(CopyOperationImpl op) throws SQLException, IOException {
pgStream.receiveInteger4(); // length not used
int rowFormat = pgStream.receiveChar();
int numFields = pgStream.receiveInteger2();
int[] fieldFormats = new int[numFields];
for (int i = 0; i < numFields; i++)... | java |
public void cancelCopy(CopyOperationImpl op) throws SQLException {
if (!hasLock(op)) {
throw new PSQLException(GT.tr("Tried to cancel an inactive copy operation"),
PSQLState.OBJECT_NOT_IN_STATE);
}
SQLException error = null;
int errors = 0;
try {
if (op instanceof CopyIn) {
... | java |
public synchronized long endCopy(CopyOperationImpl op) throws SQLException {
if (!hasLock(op)) {
throw new PSQLException(GT.tr("Tried to end inactive copy"), PSQLState.OBJECT_NOT_IN_STATE);
}
try {
LOGGER.log(Level.FINEST, " FE=> CopyDone");
pgStream.sendChar('c'); // CopyDone
pgSt... | java |
public synchronized void writeToCopy(CopyOperationImpl op, byte[] data, int off, int siz)
throws SQLException {
if (!hasLock(op)) {
throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"),
PSQLState.OBJECT_NOT_IN_STATE);
}
LOGGER.log(Level.FINEST, " FE=> CopyData... | java |
public static String toHexString(byte[] data) {
StringBuilder sb = new StringBuilder(data.length * 2);
for (byte element : data) {
sb.append(Integer.toHexString((element >> 4) & 15));
sb.append(Integer.toHexString(element & 15));
}
return sb.toString();
} | java |
private static void doAppendEscapedIdentifier(Appendable sbuf, String value) throws SQLException {
try {
sbuf.append('"');
for (int i = 0; i < value.length(); ++i) {
char ch = value.charAt(i);
if (ch == '\0') {
throw new PSQLException(GT.tr("Zero bytes may not occur in identif... | java |
public int getInteger(String name, FastpathArg[] args) throws SQLException {
byte[] returnValue = fastpath(name, args);
if (returnValue == null) {
throw new PSQLException(
GT.tr("Fastpath call {0} - No result was returned and we expected an integer.", name),
PSQLState.NO_DATA);
}
... | java |
public long getOID(String name, FastpathArg[] args) throws SQLException {
long oid = getInteger(name, args);
if (oid < 0) {
oid += NUM_OIDS;
}
return oid;
} | java |
public static FastpathArg createOIDArg(long oid) {
if (oid > Integer.MAX_VALUE) {
oid -= NUM_OIDS;
}
return new FastpathArg((int) oid);
} | java |
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws Exception {
Reference ref = (Reference) obj;
String className = ref.getClassName();
// Old names are here for those who still use them
if (className.equals("org.postgresql.ds.PGSimpleDataSou... | java |
public void setDataSourceName(String dataSourceName) {
if (initialized) {
throw new IllegalStateException(
"Cannot set Data Source properties after DataSource has been used");
}
if (this.dataSourceName != null && dataSourceName != null
&& dataSourceName.equals(this.dataSourceName)) {... | java |
public void initialize() throws SQLException {
synchronized (lock) {
source = createConnectionPool();
try {
source.initializeFrom(this);
} catch (Exception e) {
throw new PSQLException(GT.tr("Failed to setup DataSource."), PSQLState.UNEXPECTED_ERROR,
e);
}
... | java |
public void close() {
synchronized (lock) {
while (!available.isEmpty()) {
PooledConnection pci = available.pop();
try {
pci.close();
} catch (SQLException e) {
}
}
available = null;
while (!used.isEmpty()) {
PooledConnection pci = used.pop()... | java |
private Connection getPooledConnection() throws SQLException {
PooledConnection pc = null;
synchronized (lock) {
if (available == null) {
throw new PSQLException(GT.tr("DataSource has been closed."),
PSQLState.CONNECTION_DOES_NOT_EXIST);
}
while (true) {
if (!availa... | java |
public Reference getReference() throws NamingException {
Reference ref = super.getReference();
ref.add(new StringRefAddr("dataSourceName", dataSourceName));
if (initialConnections > 0) {
ref.add(new StringRefAddr("initialConnections", Integer.toString(initialConnections)));
}
if (maxConnection... | java |
void setFields(Field[] fields) {
this.fields = fields;
this.resultSetColumnNameIndexMap = null;
this.cachedMaxResultRowSize = null;
this.needUpdateFieldFormats = fields != null;
this.hasBinaryFields = false; // just in case
} | java |
public synchronized Timestamp toTimestamp(Calendar cal, String s) throws SQLException {
if (s == null) {
return null;
}
int slen = s.length();
// convert postgres's infinity values to internal infinity magic value
if (slen == 8 && s.equals("infinity")) {
return new Timestamp(PGStatemen... | java |
public LocalTime toLocalTime(String s) throws SQLException {
if (s == null) {
return null;
}
if (s.equals("24:00:00")) {
return LocalTime.MAX;
}
try {
return LocalTime.parse(s);
} catch (DateTimeParseException nfe) {
throw new PSQLException(
GT.tr("Bad value f... | java |
public LocalDateTime toLocalDateTime(String s) throws SQLException {
if (s == null) {
return null;
}
int slen = s.length();
// convert postgres's infinity values to internal infinity magic value
if (slen == 8 && s.equals("infinity")) {
return LocalDateTime.MAX;
}
if (slen == 9... | java |
public Calendar getSharedCalendar(TimeZone timeZone) {
if (timeZone == null) {
timeZone = getDefaultTz();
}
Calendar tmp = calendarWithUserTz;
tmp.setTimeZone(timeZone);
return tmp;
} | java |
public Date convertToDate(long millis, TimeZone tz) {
// no adjustments for the inifity hack values
if (millis <= PGStatement.DATE_NEGATIVE_INFINITY
|| millis >= PGStatement.DATE_POSITIVE_INFINITY) {
return new Date(millis);
}
if (tz == null) {
tz = getDefaultTz();
}
if (isS... | java |
public Time convertToTime(long millis, TimeZone tz) {
if (tz == null) {
tz = getDefaultTz();
}
if (isSimpleTimeZone(tz.getID())) {
// Leave just time part of the day.
// Suppose the input date is 2015 7 Jan 15:40 GMT+02:00 (that is 13:40 UTC)
// We want it to become 1970 1 Jan 15:40 ... | java |
public String timeToString(java.util.Date time, boolean withTimeZone) {
Calendar cal = null;
if (withTimeZone) {
cal = calendarWithUserTz;
cal.setTimeZone(timeZoneProvider.get());
}
if (time instanceof Timestamp) {
return toString(cal, (Timestamp) time, withTimeZone);
}
if (tim... | java |
public XAConnection getXAConnection(String user, String password) throws SQLException {
Connection con = super.getConnection(user, password);
return new PGXAConnection((BaseConnection) con);
} | java |
public long copyOut(final String sql, Writer to) throws SQLException, IOException {
byte[] buf;
CopyOut cp = copyOut(sql);
try {
while ((buf = cp.readFromCopy()) != null) {
to.write(encoding.decode(buf));
}
return cp.getHandledRowCount();
} catch (IOException ioEX) {
// i... | java |
public String getColumnClassName(int column) throws SQLException {
Field field = getField(column);
String result = connection.getTypeInfo().getJavaClass(field.getOID());
if (result != null) {
return result;
}
int sqlType = getSQLType(column);
switch (sqlType) {
case Types.ARRAY:
... | java |
private static Connection makeConnection(String url, Properties props) throws SQLException {
return new PgConnection(hostSpecs(props), user(props), database(props), props, url);
} | java |
public static SQLFeatureNotSupportedException notImplemented(Class<?> callClass,
String functionName) {
return new SQLFeatureNotSupportedException(
GT.tr("Method {0} is not yet implemented.", callClass.getName() + "." + functionName),
PSQLState.NOT_IMPLEMENTED.getState());
} | java |
public void setValue(int years, int months, int days, int hours, int minutes, double seconds) {
setYears(years);
setMonths(months);
setDays(days);
setHours(hours);
setMinutes(minutes);
setSeconds(seconds);
} | java |
public String getValue() {
return years + " years "
+ months + " mons "
+ days + " days "
+ hours + " hours "
+ minutes + " mins "
+ secondsFormat.format(seconds) + " secs";
} | java |
public void add(Calendar cal) {
// Avoid precision loss
// Be aware postgres doesn't return more than 60 seconds - no overflow can happen
final int microseconds = (int) (getSeconds() * 1000000.0);
final int milliseconds = (microseconds + ((microseconds < 0) ? -500 : 500)) / 1000;
cal.add(Calendar.M... | java |
public void add(Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
add(cal);
date.setTime(cal.getTime().getTime());
} | java |
public void add(PGInterval interval) {
interval.setYears(interval.getYears() + getYears());
interval.setMonths(interval.getMonths() + getMonths());
interval.setDays(interval.getDays() + getDays());
interval.setHours(interval.getHours() + getHours());
interval.setMinutes(interval.getMinutes() + getMi... | java |
public void addWarning(SQLWarning warn) {
// Add the warning to the chain
if (firstWarning != null) {
firstWarning.setNextWarning(warn);
} else {
firstWarning = warn;
}
} | java |
private void initObjectTypes(Properties info) throws SQLException {
// Add in the types that come packaged with the driver.
// These can be overridden later if desired.
addDataType("box", org.postgresql.geometric.PGbox.class);
addDataType("circle", org.postgresql.geometric.PGcircle.class);
addDataTy... | java |
public int getServerMajorVersion() {
try {
StringTokenizer versionTokens = new StringTokenizer(queryExecutor.getServerVersion(), "."); // aaXbb.ccYdd
return integerPart(versionTokens.nextToken()); // return X
} catch (NoSuchElementException e) {
return 0;
}
} | java |
private static int integerPart(String dirtyString) {
int start = 0;
while (start < dirtyString.length() && !Character.isDigit(dirtyString.charAt(start))) {
++start;
}
int end = start;
while (end < dirtyString.length() && Character.isDigit(dirtyString.charAt(end))) {
++end;
}
i... | java |
public static LogSequenceNumber valueOf(String strValue) {
int slashIndex = strValue.lastIndexOf('/');
if (slashIndex <= 0) {
return INVALID_LSN;
}
String logicalXLogStr = strValue.substring(0, slashIndex);
int logicalXlog = (int) Long.parseLong(logicalXLogStr, 16);
String segmentStr = s... | java |
public synchronized long position(String pattern, long start) throws SQLException {
checkFreed();
throw org.postgresql.Driver.notImplemented(this.getClass(), "position(String,long)");
} | java |
static boolean castToBoolean(final Object in) throws PSQLException {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Cast to boolean: \"{0}\"", String.valueOf(in));
}
if (in instanceof Boolean) {
return (Boolean) in;
}
if (in instanceof String) {
return fromString((Str... | java |
private static void checkByte(int ch, int pos, int len) throws IOException {
if ((ch & 0xc0) != 0x80) {
throw new IOException(
GT.tr("Illegal UTF-8 sequence: byte {0} of {1} byte sequence is not 10xxxxxx: {2}",
pos, len, ch));
}
} | java |
protected int getMaxIndexKeys() throws SQLException {
if (indexMaxKeys == 0) {
String sql;
sql = "SELECT setting FROM pg_catalog.pg_settings WHERE name='max_index_keys'";
Statement stmt = connection.createStatement();
ResultSet rs = null;
try {
rs = stmt.executeQuery(sql);
... | java |
protected String escapeQuotes(String s) throws SQLException {
StringBuilder sb = new StringBuilder();
if (!connection.getStandardConformingStrings()) {
sb.append("E");
}
sb.append("'");
sb.append(connection.escapeString(s));
sb.append("'");
return sb.toString();
} | java |
private static List<String> parseACLArray(String aclString) {
List<String> acls = new ArrayList<String>();
if (aclString == null || aclString.isEmpty()) {
return acls;
}
boolean inQuotes = false;
// start at 1 because of leading "{"
int beginIndex = 1;
char prevChar = ' ';
for (int... | java |
public static Object instantiate(String classname, Properties info, boolean tryString,
String stringarg) throws ClassNotFoundException, SecurityException, NoSuchMethodException,
IllegalArgumentException, InstantiationException, IllegalAccessException,
InvocationTargetException {
Object[] a... | java |
boolean isUpdateable() throws SQLException {
checkClosed();
if (resultsetconcurrency == ResultSet.CONCUR_READ_ONLY) {
throw new PSQLException(
GT.tr("ResultSets with concurrency CONCUR_READ_ONLY cannot be updated."),
PSQLState.INVALID_CURSOR_STATE);
}
if (updateable) {
... | java |
private double readDoubleValue(byte[] bytes, int oid, String targetType) throws PSQLException {
// currently implemented binary encoded fields
switch (oid) {
case Oid.INT2:
return ByteConverter.int2(bytes, 0);
case Oid.INT4:
return ByteConverter.int4(bytes, 0);
case Oid.INT8:
... | java |
private static String createPostgresTimeZone() {
String tz = TimeZone.getDefault().getID();
if (tz.length() <= 3 || !tz.startsWith("GMT")) {
return tz;
}
char sign = tz.charAt(3);
String start;
switch (sign) {
case '+':
start = "GMT-";
break;
case '-':
s... | java |
public void close() throws SQLException {
if (!closed) {
// flush any open output streams
if (os != null) {
try {
// we can't call os.close() otherwise we go into an infinite loop!
os.flush();
} catch (IOException ioe) {
throw new PSQLException("Exception fl... | java |
public int read(byte[] buf, int off, int len) throws SQLException {
byte[] b = read(len);
if (b.length < len) {
len = b.length;
}
System.arraycopy(b, 0, buf, off, len);
return len;
} | java |
public void write(byte[] buf, int off, int len) throws SQLException {
FastpathArg[] args = new FastpathArg[2];
args[0] = new FastpathArg(fd);
args[1] = new FastpathArg(buf, off, len);
fp.fastpath("lowrite", args);
} | java |
@Override
public String getNativeSql() {
if (sql != null) {
return sql;
}
sql = buildNativeSql(null);
return sql;
} | java |
protected void checkIndex(int parameterIndex, int type1, int type2, String getName)
throws SQLException {
checkIndex(parameterIndex);
if (type1 != this.testReturn[parameterIndex - 1]
&& type2 != this.testReturn[parameterIndex - 1]) {
throw new PSQLException(
GT.tr("Parameter of typ... | java |
public LargeObject open(int oid, int mode, boolean commitOnClose) throws SQLException {
return open((long) oid, mode, commitOnClose);
} | java |
public long createLO(int mode) throws SQLException {
if (conn.getAutoCommit()) {
throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."),
PSQLState.NO_ACTIVE_SQL_TRANSACTION);
}
FastpathArg[] args = new FastpathArg[1];
args[0] = new FastpathArg(mode);
retu... | java |
public void delete(long oid) throws SQLException {
FastpathArg[] args = new FastpathArg[1];
args[0] = Fastpath.createOIDArg(oid);
fp.fastpath("lo_unlink", args);
} | java |
public boolean ensureBytes(int n) throws IOException {
int required = n - endIndex + index;
while (required > 0) {
if (!readMore(required)) {
return false;
}
required = n - endIndex + index;
}
return true;
} | java |
private boolean readMore(int wanted) throws IOException {
if (endIndex == index) {
index = 0;
endIndex = 0;
}
int canFit = buffer.length - endIndex;
if (canFit < wanted) {
// would the wanted bytes fit if we compacted the buffer
// and still leave some slack
if (index + can... | java |
private void moveBufferTo(byte[] dest) {
int size = endIndex - index;
System.arraycopy(buffer, index, dest, 0, size);
index = 0;
endIndex = size;
} | java |
public String getRawPropertyValue(String key) {
String value = super.getProperty(key);
if (value != null) {
return value;
}
for (Properties properties : defaults) {
value = properties.getProperty(key);
if (value != null) {
return value;
}
}
return null;
} | java |
public synchronized void truncate(long len) throws SQLException {
checkFreed();
if (!conn.haveMinimumServerVersion(ServerVersion.v8_3)) {
throw new PSQLException(
GT.tr("Truncation of large objects is only implemented in 8.3 and later servers."),
PSQLState.NOT_IMPLEMENTED);
}
... | java |
public synchronized long position(byte[] pattern, long start) throws SQLException {
assertPosition(start, pattern.length);
int position = 1;
int patternIdx = 0;
long result = -1;
int tmpPosition = 1;
for (LOIterator i = new LOIterator(start - 1); i.hasNext(); position++) {
byte b = i.nex... | java |
protected void assertPosition(long pos, long len) throws SQLException {
checkFreed();
if (pos < 1) {
throw new PSQLException(GT.tr("LOB positioning offsets start at 1."),
PSQLState.INVALID_PARAMETER_VALUE);
}
if (pos + len - 1 > Integer.MAX_VALUE) {
throw new PSQLException(GT.tr("P... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.