_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q177400 | MapperComplex.setFieldValueFromMap | test | private void setFieldValueFromMap( final Object parentObject,
final FieldAccess field, final Map mapInner ) {
Class<?> fieldClassType = field.type();
Object value = null;
/* Is the field not a map. */
if ( !Typ.isMap( fieldClassType ) ) {
... | java | {
"resource": ""
} |
q177401 | MapperComplex.toList | test | @Override
public List<?> toList(Object object) {
TypeType instanceType = TypeType.getInstanceType(object);
switch (instanceType) {
case NULL:
return Lists.list((Object)null);
case ARRAY:
case ARRAY_INT:
case ARRAY_BYTE:
... | java | {
"resource": ""
} |
q177402 | BaseVersionedMySQLSupport.createLoadAllVersionDataSQL | test | protected void createLoadAllVersionDataSQL(String table) {
CharBuf buf = CharBuf.create(100);
buf.add("select kv_key, 1, version, update_timestamp, create_timestamp from `");
buf.add(table);
buf.add("` where kv_key in (");
buf.multiply("?,", this.loadKeyCount);
buf.remo... | java | {
"resource": ""
} |
q177403 | Lists.deepCopy | test | @Universal
public static <V> List<V> deepCopy( List<V> list ) {
if ( list instanceof LinkedList ) {
return deepCopyToList( list, new LinkedList<V>( ) );
} else if ( list instanceof CopyOnWriteArrayList ) {
return deepCopyToList( list, new CopyOnWriteArrayList<V>( ));
... | java | {
"resource": ""
} |
q177404 | Fields.hasStringField | test | public static boolean hasStringField( final Object value1, final String name ) {
Class<?> clz = value1.getClass();
return classHasStringField( clz, name );
} | java | {
"resource": ""
} |
q177405 | Fields.classHasStringField | test | public static boolean classHasStringField( Class<?> clz, String name ) {
List<Field> fields = Reflection.getAllFields( clz );
for ( Field field : fields ) {
if (
field.getType().equals( Typ.string ) &&
field.getName().equals( name ) &&
... | java | {
"resource": ""
} |
q177406 | Fields.classHasField | test | public static boolean classHasField( Class<?> clz, String name ) {
List<Field> fields = Reflection.getAllFields( clz );
for ( Field field : fields ) {
if ( field.getName().equals( name )
&& !Modifier.isStatic( field.getModifiers() )
&& field.getDeclari... | java | {
"resource": ""
} |
q177407 | Fields.getFirstComparableOrPrimitiveFromClass | test | public static String getFirstComparableOrPrimitiveFromClass( Class<?> clz ) {
List<Field> fields = Reflection.getAllFields( clz );
for ( Field field : fields ) {
if ( ( field.getType().isPrimitive() || Typ.isComparable( field.getType() )
&& !Modifier.isStatic( field.getM... | java | {
"resource": ""
} |
q177408 | Fields.getSortableField | test | public static String getSortableField( Object value1 ) {
if (value1 instanceof Map) {
return getSortableFieldFromMap( (Map<String, ?>) value1);
} else {
return getSortableFieldFromClass( value1.getClass() );
}
} | java | {
"resource": ""
} |
q177409 | CacheEntry.compareTo | test | @Override
public final int compareTo( CacheEntry other ) {
switch ( type ) {
case LFU:
return compareToLFU( other );
case LRU:
return compareToLRU( other );
case FIFO:
return compareToFIFO( other );
default:
... | java | {
"resource": ""
} |
q177410 | CacheEntry.compareTime | test | private final int compareTime( CacheEntry other ) {
if ( time > other.time ) { //this time stamp is greater so it has higher priority
return 1;
} else if ( time < other.time ) {//this time stamp is lower so it has lower priority
return -1;
} else if ( time == other.tim... | java | {
"resource": ""
} |
q177411 | Sorting.sort | test | public static void sort(List list, Sort... sorts) {
Sort.sorts(sorts).sort(list);
} | java | {
"resource": ""
} |
q177412 | Sorting.sort | test | public static void sort( List list, String sortBy, boolean ascending, boolean nullsFirst ) {
if ( list == null || list.size() == 0 ) {
return;
}
if (sortBy.equals("this")) {
Collections.sort(list, thisUniversalComparator(ascending, nullsFirst));
return;
... | java | {
"resource": ""
} |
q177413 | Sorting.sortEntries | test | public static <K, V> Collection<Map.Entry<K, V>> sortEntries( Class<V> componentType, Map<K, V> map,
String sortBy, boolean ascending, boolean nullsFirst ) {
return sort ((Class) componentType, (Collection) map.entrySet() , sortBy, ascending, nullsFi... | java | {
"resource": ""
} |
q177414 | Sorting.sortValues | test | public static <K, V> Collection<Map.Entry<K, V>> sortValues( Class<V> componentType, Map<K, V> map,
String sortBy, boolean ascending, boolean nullsFirst ) {
return sort ((Class) componentType, (Collection) map.values() , sortBy, ascending, nul... | java | {
"resource": ""
} |
q177415 | Sorting.sortKeys | test | public static <K, V> Collection<Map.Entry<K, V>> sortKeys( Class<V> componentType, Map<K, V> map,
String sortBy, boolean ascending, boolean nullsFirst ) {
return sort ((Class) componentType, (Collection) map.keySet() , sortBy, ascending, nullsF... | java | {
"resource": ""
} |
q177416 | Sorting.sort | test | public static <T> void sort( T[] array, String sortBy, boolean ascending, boolean nullsFirst ) {
if ( array == null || array.length == 0 ) {
return;
}
if (sortBy.equals("this")) {
Arrays.sort(array, thisUniversalComparator(ascending, nullsFirst));
return;
... | java | {
"resource": ""
} |
q177417 | Sorting.universalComparator | test | public static Comparator universalComparator( final FieldAccess field, final boolean ascending,
final boolean nullsFirst) {
return new Comparator() {
@Override
public int compare( Object o1, Object o2 ) {
Object value1 = n... | java | {
"resource": ""
} |
q177418 | Sorting.thisUniversalComparator | test | public static Comparator thisUniversalComparator( final boolean ascending,
final boolean nullsFirst) {
return new Comparator() {
@Override
public int compare( Object o1, Object o2 ) {
Object value1;
Object ... | java | {
"resource": ""
} |
q177419 | FastConcurrentReadLruLfuFifoCache.get | test | public VALUE get( KEY key ) {
CacheEntry<KEY, VALUE> cacheEntry = map.get( key );
if ( cacheEntry != null ) {
cacheEntry.readCount.incrementAndGet();
return cacheEntry.value;
} else {
return null;
}
} | java | {
"resource": ""
} |
q177420 | FastConcurrentReadLruLfuFifoCache.getSilent | test | public VALUE getSilent( KEY key ) {
CacheEntry<KEY, VALUE> cacheEntry = map.get( key );
if ( cacheEntry != null ) {
return cacheEntry.value;
} else {
return null;
}
} | java | {
"resource": ""
} |
q177421 | FastConcurrentReadLruLfuFifoCache.order | test | private final int order() {
int order = count.incrementAndGet();
if ( order > Integer.MAX_VALUE - 100 ) {
count.set( 0 );
}
return order;
} | java | {
"resource": ""
} |
q177422 | FastConcurrentReadLruLfuFifoCache.evictIfNeeded | test | private final void evictIfNeeded() {
if ( list.size() > evictSize ) {
final List<CacheEntry<KEY, VALUE>> killList = list.sortAndReturnPurgeList( 0.1f );
for ( CacheEntry<KEY, VALUE> cacheEntry : killList ) {
map.remove( cacheEntry.key );
}
}
} | java | {
"resource": ""
} |
q177423 | LongRangeValidator.dynamicallyInitIfNeeded | test | private void dynamicallyInitIfNeeded( Object value ) {
/* Check to see if this class was already initialized,
* if not, initialize it based on the type of the value.
*/
if ( !isInitialized() ) {
if ( value instanceof Integer ) {
init( new Integer( min.intVal... | java | {
"resource": ""
} |
q177424 | CollectorManager.allocateBuffer | test | public final ByteBuffer allocateBuffer(int size) {
if (RECYCLE_BUFFER) {
ByteBuffer spentBuffer = recycleChannel.poll();
if (spentBuffer == null) {
spentBuffer = ByteBuffer.allocateDirect(size);
}
spentBuffer.clear();
return spentBuffe... | java | {
"resource": ""
} |
q177425 | CollectorManager.determineIfWeShouldExit | test | private boolean determineIfWeShouldExit() {
boolean shouldStop = stop.get();
if (!shouldStop) {
Thread.interrupted();
} else {
System.out.println("Exiting processing loop as requested");
return true;
}
return false;
} | java | {
"resource": ""
} |
q177426 | CollectorManager.manageInputWriterChannel | test | private void manageInputWriterChannel() throws InterruptedException {
try {
ByteBuffer dataToWriteToFile;
dataToWriteToFile = inputChannel.poll(); //no wait
//If it is null, it means the inputChannel is empty and we need to flush.
if (dataToWriteToFile == nul... | java | {
"resource": ""
} |
q177427 | CollectorManager.queueEmptyMaybeFlush | test | private void queueEmptyMaybeFlush() {
if (PERIODIC_FORCE_FLUSH) {
long currentTime = time.get();
/* Try not to flush more than once every x times per mili-seconds time period. */
if ((currentTime - lastFlushTime) > FORCE_FLUSH_AFTER_THIS_MANY_MILI_SECONDS) {
... | java | {
"resource": ""
} |
q177428 | CollectorManager.startMonitor | test | private void startMonitor() {
final ScheduledExecutorService monitor = Executors.newScheduledThreadPool(2,
new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
... | java | {
"resource": ""
} |
q177429 | CollectorManager.start | test | public void start(final TimeAware receiver) {
//This starts itself up again every 1/2 second if something really bad
//happens like disk full. As soon as the problem gets corrected
//then things start working again...happy day. Only
// one is running per instance of CollectionManager... | java | {
"resource": ""
} |
q177430 | LazyValueMap.get | test | @Override
public final Object get( Object key ) {
Object object=null;
/* if the map is null, then we create it. */
if ( map == null ) {
buildMap ();
}
object = map.get ( key );
lazyChopIfNeeded ( object );
return object;
} | java | {
"resource": ""
} |
q177431 | FilterDefault.mainQueryPlan | test | private ResultSet mainQueryPlan( Criteria[] expressions ) {
ResultSetInternal results = new ResultSetImpl( this.fields );
if (expressions == null || expressions.length == 0) {
results.addResults ( searchableCollection.all() );
}
/* I am sure this looked easy to read when... | java | {
"resource": ""
} |
q177432 | FilterDefault.doFilterGroup | test | private void doFilterGroup( Group group, ResultSetInternal results ) {
/* The group was n or group so handle it that way. */
if ( group.getGrouping() == Grouping.OR ) {
/* nice short method name, or. */
or( group.getExpressions(), fields, results );
} else {
/... | java | {
"resource": ""
} |
q177433 | BatchFileWriter.tick | test | public void tick(long time) {
this.time.set(time);
long startTime = fileStartTime.get();
long duration = time - startTime;
if (duration > FILE_TIMEOUT_MILISECONDS) {
fileTimeOut.set(true);
}
} | java | {
"resource": ""
} |
q177434 | BatchFileWriter.syncToDisk | test | public boolean syncToDisk() {
/** if we have a stream and we are dirty then flush. */
if (outputStream != null && dirty) {
try {
//outputStream.flush ();
if (outputStream instanceof FileChannel) {
FileChannel channel = (FileChannel) outp... | java | {
"resource": ""
} |
q177435 | BatchFileWriter.cleanupOutputStream | test | private void cleanupOutputStream() {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace(System.err);
} finally {
outputStream = null;
}
}
} | java | {
"resource": ""
} |
q177436 | BatchFileWriter.nextBufferToWrite | test | public void nextBufferToWrite(final ByteBuffer bufferOut) throws InterruptedException {
dirty = true;
final int size = bufferOut.limit();
write(bufferOut);
/* only increment bytes transferred after a successful write. */
if (!error.get()) {
totalBytesTransferred +=... | java | {
"resource": ""
} |
q177437 | BatchFileWriter.write | test | private void write(final ByteBuffer bufferOut) throws InterruptedException {
initOutputStream();
try {
if (outputStream != null) {
outputStream.write(bufferOut);
} else {
error.set(true);
}
if (bytesSinceLastFlush > FLUS... | java | {
"resource": ""
} |
q177438 | BatchFileWriter.initOutputStream | test | private void initOutputStream() {
long time = this.time.get();
if (error.get() || this.totalBytesTransferred == 0) {
cleanupOutputStream();
error.set(false);
time = System.nanoTime() / 1_000_000;
}
if (outputStream != null) {
return;
... | java | {
"resource": ""
} |
q177439 | BaseStringStringKeyValueStore.putAll | test | public void putAll(Map<K, V> values) {
Set<Map.Entry<K, V>> entries = values.entrySet();
Map<String, String> map = new HashMap<>(values.size());
for (Map.Entry<K, V> entry : entries) {
map.put(toKeyString(entry.getKey()), toValueString(entry.getValue()));
}
store.pu... | java | {
"resource": ""
} |
q177440 | BaseSimpleSerializationKeyValueStore.toKeyBytes | test | protected byte[] toKeyBytes(K key) {
byte[] keyBytes = keyCache.get(key);
if (keyBytes == null) {
keyBytes = this.keyToByteArrayConverter.apply(key);
keyCache.put(key, keyBytes);
}
return keyBytes;
} | java | {
"resource": ""
} |
q177441 | PropertiesFileValidatorMetaDataReader.readMetaData | test | public List<ValidatorMetaData> readMetaData( Class<?> clazz, String propertyName ) {
/* Load the properties file. */
Properties props = loadMetaDataPropsFile( clazz );
/* Get the raw validation data for the given property. */
String unparsedString = props.getProperty( propertyName ... | java | {
"resource": ""
} |
q177442 | PropertiesFileValidatorMetaDataReader.extractMetaDataFromString | test | private List<ValidatorMetaData> extractMetaDataFromString( Class<?> clazz,
String propertyName, String unparsedString ) {
String propertyKey = clazz.getName() + "." + propertyName;
/* See if we parsed this bad boy already. */
L... | java | {
"resource": ""
} |
q177443 | AnnotationValidatorMetaDataReader.readMetaData | test | public List<ValidatorMetaData> readMetaData( Class<?> clazz, String propertyName ) {
/* Generate a key to the cache based on the classname and the propertyName. */
String propertyKey = clazz.getName() + "." + propertyName;
/* Look up the validation meta data in the cache. */
List... | java | {
"resource": ""
} |
q177444 | AnnotationValidatorMetaDataReader.extractValidatorMetaData | test | private List<ValidatorMetaData> extractValidatorMetaData( Class<?> clazz, String propertyName, List<ValidatorMetaData> validatorMetaDataList ) {
/* If the meta-data was not found, then generate it. */
if ( validatorMetaDataList == null ) { // if not found
/* Read the annotation from the c... | java | {
"resource": ""
} |
q177445 | AnnotationValidatorMetaDataReader.extractMetaDataFromAnnotations | test | private List<ValidatorMetaData> extractMetaDataFromAnnotations(
Collection<AnnotationData> annotations ) {
List<ValidatorMetaData> list = new ArrayList<ValidatorMetaData>();
for ( AnnotationData annotationData : annotations ) {
ValidatorMetaData validatorMetaData = convertA... | java | {
"resource": ""
} |
q177446 | AnnotationValidatorMetaDataReader.convertAnnotationDataToValidatorMetaData | test | private ValidatorMetaData convertAnnotationDataToValidatorMetaData(
AnnotationData annotationData ) {
ValidatorMetaData metaData = new ValidatorMetaData();
metaData.setName( annotationData.getName() );
metaData.setProperties( annotationData.getValues() );
return me... | java | {
"resource": ""
} |
q177447 | StringScanner.split | test | public static String[] split( final String string,
final char split, final int limit ) {
char[][] comps = CharScanner.split( FastStringUtils.toCharArray( string ), split, limit );
return Str.fromCharArrayOfArrayToStringArray( comps );
} | java | {
"resource": ""
} |
q177448 | StringScanner.splitByWhiteSpace | test | public static String[] splitByWhiteSpace( final String string
) {
char[][] comps = CharScanner.splitByChars( FastStringUtils.toCharArray( string ), WHITE_SPACE );
return Str.fromCharArrayOfArrayToStringArray( comps );
} | java | {
"resource": ""
} |
q177449 | StringScanner.splitByDelimiters | test | public static String[] splitByDelimiters( final String string,
final String delimiters ) {
char[][] comps = CharScanner.splitByChars( FastStringUtils.toCharArray( string ), delimiters.toCharArray() );
return Str.fromCharArrayOfArrayToStringArray( comps );
... | java | {
"resource": ""
} |
q177450 | StringScanner.removeChars | test | public static String removeChars( final String string, final char... delimiters ) {
char[][] comps = CharScanner.splitByCharsNoneEmpty( FastStringUtils.toCharArray( string ), delimiters );
return new String(Chr.add ( comps ));
} | java | {
"resource": ""
} |
q177451 | StringScanner.splitByCharsNoneEmpty | test | public static String[] splitByCharsNoneEmpty( final String string, int start, int end, final char... delimiters ) {
Exceptions.requireNonNull( string );
char[][] comps = CharScanner.splitByCharsNoneEmpty( FastStringUtils.toCharArray( string ), start, end, delimiters );
return Str.fromCharArrayO... | java | {
"resource": ""
} |
q177452 | StringScanner.parseDouble | test | public static double parseDouble( String buffer, int from, int to ) {
return CharScanner.parseDouble( FastStringUtils.toCharArray(buffer), from , to );
} | java | {
"resource": ""
} |
q177453 | StringScanner.parseInt | test | public static int parseInt( String buffer, int from, int to ) {
return CharScanner.parseInt( FastStringUtils.toCharArray(buffer), from , to );
} | java | {
"resource": ""
} |
q177454 | StringScanner.parseLong | test | public static long parseLong( String buffer, int from, int to ) {
return CharScanner.parseLong( FastStringUtils.toCharArray(buffer), from , to );
} | java | {
"resource": ""
} |
q177455 | BeanUtils.getPropByPath | test | public static Object getPropByPath( Object item, String... path ) {
Object o = item;
for ( int index = 0; index < path.length; index++ ) {
String propName = path[ index ];
if ( o == null ) {
return null;
} else if ( o.getClass().isArray() || o instanc... | java | {
"resource": ""
} |
q177456 | BeanUtils.getFieldsFromObject | test | public static Map<String, FieldAccess> getFieldsFromObject( Object object ) {
try {
Map<String, FieldAccess> fields;
if ( object instanceof Map ) {
fields = getFieldsFromMap( ( Map<String, Object> ) object );
} else {
fields = getPropertyFiel... | java | {
"resource": ""
} |
q177457 | BeanUtils.getPropertyType | test | public static Class<?> getPropertyType( final Object root, final String property ) {
Map<String, FieldAccess> fields = getPropertyFieldAccessMap( root.getClass() );
FieldAccess field = fields.get( property );
return field.type();
} | java | {
"resource": ""
} |
q177458 | BeanUtils.injectIntoProperty | test | public static void injectIntoProperty( Object object, String path, Object value ) {
String[] properties = propertyPathAsStringArray(path);
setPropertyValue( object, value, properties );
} | java | {
"resource": ""
} |
q177459 | BeanUtils.idx | test | public static void idx( Class<?> cls, String path, Object value ) {
String[] properties = propertyPathAsStringArray(path);
setPropertyValue( cls, value, properties );
} | java | {
"resource": ""
} |
q177460 | BeanUtils.getCollectionProp | test | private static Object getCollectionProp(Object o, String propName, int index, String[] path
) {
o = _getFieldValuesFromCollectionOrArray(o, propName);
if ( index + 1 == path.length ) {
return o;
} else {
index++;
ret... | java | {
"resource": ""
} |
q177461 | BeanUtils.getProp | test | public static Object getProp( Object object, final String property ) {
if ( object == null ) {
return null;
}
if ( isDigits( property ) ) {
/* We can index numbers and names. */
object = idx(object, StringScanner.parseInt(property));
}
C... | java | {
"resource": ""
} |
q177462 | BeanUtils.getPropertyInt | test | public static int getPropertyInt( final Object root, final String... properties ) {
final String lastProperty = properties[ properties.length - 1 ];
if ( isDigits( lastProperty ) ) {
return Conversions.toInt(getPropertyValue(root, properties));
}
Object object = bas... | java | {
"resource": ""
} |
q177463 | MessageSpecification.init | test | public void init() {
/* If the parent and name are equal to null,
* use the classname to load listFromClassLoader.
* */
if ( name == null && parent == null ) {
this.setDetailMessage( "{" + this.getClass().getName() + DETAIL_KEY + "}" );
this.setSummaryMessage( "{" ... | java | {
"resource": ""
} |
q177464 | MessageSpecification.createMessage | test | public String createMessage( String key, List<String> argKeys, Object... args ) {
/* Look up the message. */
String message = getMessage( key );
/* Holds the actual arguments. */
Object[] actualArgs;
/* If they passed arguments,
* then use this as the actual arguments. */
... | java | {
"resource": ""
} |
q177465 | MessageSpecification.doCreateMessage | test | @SuppressWarnings ( "unchecked" )
private String doCreateMessage( String message, Object[] actualArgs ) {
return ValidationContext.get().createMessage( message, getSubject(), actualArgs );
} | java | {
"resource": ""
} |
q177466 | MessageSpecification.keysToValues | test | private Object[] keysToValues( List<String> argKeys ) {
List<String> values = new ArrayList<>();
for ( String key : argKeys ) {
values.add( getMessage( key ) );
}
return values.toArray();
} | java | {
"resource": ""
} |
q177467 | MessageSpecification.getSubject | test | public String getSubject() {
return ValidationContext.get().getCurrentSubject() == null ? this.subject :
ValidationContext.get().getCurrentSubject();
} | java | {
"resource": ""
} |
q177468 | JsonSlurper.parseText | test | public Object parseText(String text) {
if (text == null || text.length() == 0) {
throw new IllegalArgumentException("The JSON input text should neither be null nor empty.");
}
return JsonFactory.create().fromJson ( text );
} | java | {
"resource": ""
} |
q177469 | EtcdClient.sendHttpRequest | test | private void sendHttpRequest(final Request request, final org.boon.core.Handler<Response> responseHandler) {
final HttpClientRequest httpClientRequest = httpClient.request(request.getMethod(), request.uri(),
handleResponse(request, responseHandler));
final Runnable runnable = new Runn... | java | {
"resource": ""
} |
q177470 | CouchDbContext.deleteDB | test | public void deleteDB(String dbName, String confirm) {
assertNotEmpty(dbName, "dbName");
if(!"delete database".equals(confirm))
throw new IllegalArgumentException("Invalid confirm!");
dbc.delete(buildUri(dbc.getBaseUri()).path(dbName).build());
} | java | {
"resource": ""
} |
q177471 | CouchDbContext.createDB | test | public void createDB(String dbName) {
assertNotEmpty(dbName, "dbName");
InputStream getresp = null;
HttpResponse putresp = null;
final URI uri = buildUri(dbc.getBaseUri()).path(dbName).build();
try {
getresp = dbc.get(uri);
} catch (NoDocumentException e) { // db doesn't exist
final HttpPut put = new ... | java | {
"resource": ""
} |
q177472 | CouchDbContext.uuids | test | public List<String> uuids(long count) {
final String uri = String.format("%s_uuids?count=%d", dbc.getBaseUri(), count);
final JsonObject json = dbc.findAny(JsonObject.class, uri);
return dbc.getGson().fromJson(json.get("uuids").toString(), new TypeToken<List<String>>(){}.getType());
} | java | {
"resource": ""
} |
q177473 | CouchDbUtil.listResources | test | public static List<String> listResources(String path) {
try {
Class<CouchDbUtil> clazz = CouchDbUtil.class;
URL dirURL = clazz.getClassLoader().getResource(path);
if (dirURL != null && dirURL.getProtocol().equals("file")) {
return Arrays.asList(new File(dirURL.toURI()).list());
}
if (dirURL != nul... | java | {
"resource": ""
} |
q177474 | Replication.trigger | test | public ReplicationResult trigger() {
assertNotEmpty(source, "Source");
assertNotEmpty(target, "Target");
HttpResponse response = null;
try {
JsonObject json = createJson();
if(log.isDebugEnabled()) {
log.debug(json);
}
final URI uri = buildUri(dbc.getBaseUri()).path("_replicate").build();
res... | java | {
"resource": ""
} |
q177475 | View.queryValue | test | private <V> V queryValue(Class<V> classOfV) {
InputStream instream = null;
try {
Reader reader = new InputStreamReader(instream = queryForStream(), Charsets.UTF_8);
JsonArray array = new JsonParser().parse(reader).
getAsJsonObject().get("rows").getAsJsonArray();
if(array.size() != 1) {
throw ... | java | {
"resource": ""
} |
q177476 | View.descending | test | public View descending(Boolean descending) {
this.descending = Boolean.valueOf(gson.toJson(descending));
uriBuilder.query("descending", this.descending);
return this;
} | java | {
"resource": ""
} |
q177477 | CouchDbDesign.synchronizeAllWithDb | test | public void synchronizeAllWithDb() {
List<DesignDocument> documents = getAllFromDesk();
for (DesignDocument dd : documents) {
synchronizeWithDb(dd);
}
} | java | {
"resource": ""
} |
q177478 | CouchDbDesign.getFromDb | test | public DesignDocument getFromDb(String id) {
assertNotEmpty(id, "id");
final URI uri = buildUri(dbc.getDBUri()).path(id).build();
return dbc.get(uri, DesignDocument.class);
} | java | {
"resource": ""
} |
q177479 | CouchDbDesign.getAllFromDesk | test | public List<DesignDocument> getAllFromDesk() {
final List<DesignDocument> designDocsList = new ArrayList<DesignDocument>();
for (String docName : listResources(format("%s/", DESIGN_DOCS_DIR))) {
designDocsList.add(getFromDesk(docName));
}
return designDocsList;
} | java | {
"resource": ""
} |
q177480 | CouchDbDesign.getFromDesk | test | public DesignDocument getFromDesk(String id) {
assertNotEmpty(id, "id");
final DesignDocument dd = new DesignDocument();
final String rootPath = format("%s/%s/", DESIGN_DOCS_DIR, id);
final List<String> elements = listResources(rootPath);
if(elements == null) {
throw new IllegalArgumentException("Design do... | java | {
"resource": ""
} |
q177481 | Replicator.save | test | public Response save() {
assertNotEmpty(replicatorDoc.getSource(), "Source");
assertNotEmpty(replicatorDoc.getTarget(), "Target");
if(userCtxName != null) {
UserCtx ctx = replicatorDoc.new UserCtx();
ctx.setName(userCtxName);
ctx.setRoles(userCtxRoles);
replicatorDoc.setUserCtx(ctx);
}
return dbc.... | java | {
"resource": ""
} |
q177482 | Replicator.find | test | public ReplicatorDocument find() {
assertNotEmpty(replicatorDoc.getId(), "Doc id");
final URI uri = buildUri(dbURI).path(replicatorDoc.getId()).query("rev", replicatorDoc.getRevision()).build();
return dbc.get(uri, ReplicatorDocument.class);
} | java | {
"resource": ""
} |
q177483 | Replicator.findAll | test | public List<ReplicatorDocument> findAll() {
InputStream instream = null;
try {
final URI uri = buildUri(dbURI).path("_all_docs").query("include_docs", "true").build();
final Reader reader = new InputStreamReader(instream = dbc.get(uri), Charsets.UTF_8);
final JsonArray jsonArray = new JsonParser().parse(... | java | {
"resource": ""
} |
q177484 | Replicator.remove | test | public Response remove() {
assertNotEmpty(replicatorDoc.getId(), "Doc id");
assertNotEmpty(replicatorDoc.getRevision(), "Doc rev");
final URI uri = buildUri(dbURI).path(replicatorDoc.getId()).query("rev", replicatorDoc.getRevision()).build();
return dbc.delete(uri);
} | java | {
"resource": ""
} |
q177485 | CouchDbClientBase.find | test | public <T> T find(Class<T> classType, String id, Params params) {
assertNotEmpty(classType, "Class");
assertNotEmpty(id, "id");
final URI uri = buildUri(getDBUri()).pathEncoded(id).query(params).build();
return get(uri, classType);
} | java | {
"resource": ""
} |
q177486 | CouchDbClientBase.findDocs | test | public <T> List<T> findDocs(String jsonQuery, Class<T> classOfT) {
assertNotEmpty(jsonQuery, "jsonQuery");
HttpResponse response = null;
try {
response = post(buildUri(getDBUri()).path("_find").build(), jsonQuery);
Reader reader = new InputStreamReader(getStream(response), Charsets.UTF_8);
JsonArray json... | java | {
"resource": ""
} |
q177487 | CouchDbClientBase.contains | test | public boolean contains(String id) {
assertNotEmpty(id, "id");
HttpResponse response = null;
try {
response = head(buildUri(getDBUri()).pathEncoded(id).build());
} catch (NoDocumentException e) {
return false;
} finally {
close(response);
}
return true;
} | java | {
"resource": ""
} |
q177488 | CouchDbClientBase.bulk | test | public List<Response> bulk(List<?> objects, boolean newEdits) {
assertNotEmpty(objects, "objects");
HttpResponse response = null;
try {
final String newEditsVal = newEdits ? "\"new_edits\": true, " : "\"new_edits\": false, ";
final String json = String.format("{%s%s%s}", newEditsVal, "\"docs\": ", getGson(... | java | {
"resource": ""
} |
q177489 | CouchDbClientBase.put | test | Response put(URI uri, Object object, boolean newEntity) {
assertNotEmpty(object, "object");
HttpResponse response = null;
try {
final JsonObject json = getGson().toJsonTree(object).getAsJsonObject();
String id = getAsString(json, "_id");
String rev = getAsString(json, "_rev");
if(newEntity) { // sav... | java | {
"resource": ""
} |
q177490 | CouchDbClientBase.put | test | Response put(URI uri, InputStream instream, String contentType) {
HttpResponse response = null;
try {
final HttpPut httpPut = new HttpPut(uri);
final InputStreamEntity entity = new InputStreamEntity(instream, -1);
entity.setContentType(contentType);
httpPut.setEntity(entity);
response = executeReques... | java | {
"resource": ""
} |
q177491 | CouchDbClientBase.post | test | HttpResponse post(URI uri, String json) {
HttpPost post = new HttpPost(uri);
setEntity(post, json);
return executeRequest(post);
} | java | {
"resource": ""
} |
q177492 | CouchDbClientBase.delete | test | Response delete(URI uri) {
HttpResponse response = null;
try {
HttpDelete delete = new HttpDelete(uri);
response = executeRequest(delete);
return getResponse(response);
} finally {
close(response);
}
} | java | {
"resource": ""
} |
q177493 | CouchDbClientBase.validate | test | void validate(HttpResponse response) throws IOException {
final int code = response.getStatusLine().getStatusCode();
if(code == 200 || code == 201 || code == 202) { // success (ok | created | accepted)
return;
}
String reason = response.getStatusLine().getReasonPhrase();
switch (code) {
case HttpStatus.... | java | {
"resource": ""
} |
q177494 | CouchDbClientBase.setEntity | test | private void setEntity(HttpEntityEnclosingRequestBase httpRequest, String json) {
StringEntity entity = new StringEntity(json, "UTF-8");
entity.setContentType("application/json");
httpRequest.setEntity(entity);
} | java | {
"resource": ""
} |
q177495 | Document.addAttachment | test | public void addAttachment(String name, Attachment attachment) {
if(attachments == null)
attachments = new HashMap<String, Attachment>();
attachments.put(name, attachment);
} | java | {
"resource": ""
} |
q177496 | Changes.getChanges | test | public ChangesResult getChanges() {
final URI uri = uriBuilder.query("feed", "normal").build();
return dbc.get(uri, ChangesResult.class);
} | java | {
"resource": ""
} |
q177497 | Changes.readNextRow | test | private boolean readNextRow() {
boolean hasNext = false;
try {
if(!stop) {
String row = "";
do {
row = getReader().readLine();
} while(row.length() == 0);
if(!row.startsWith("{\"last_seq\":")) {
setNextRow(gson.fromJson(row, Row.class));
hasNext = true;
}
}
} cat... | java | {
"resource": ""
} |
q177498 | MoneyToStr.convert | test | public String convert(Double theMoney) {
if (theMoney == null) {
throw new IllegalArgumentException("theMoney is null");
}
Long intPart = theMoney.longValue();
Long fractPart = Math.round((theMoney - intPart) * NUM100);
if (currency == Currency.PER1000) {
... | java | {
"resource": ""
} |
q177499 | LockManager.shutdown | test | public void shutdown() {
try {
locksExecutor.shutdown();
locksExecutor.awaitTermination(5, TimeUnit.SECONDS);
CountDownLatch latch = new CountDownLatch(1);
activeLocksLock.writeLock().lock();
Observable.from(activeLocks.entrySet())
... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.