_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q154300 | PathService.toUri | train | public URI toUri(URI fileSystemUri, JimfsPath path) {
checkArgument(path.isAbsolute(), "path (%s) must be absolute", path);
String root = String.valueOf(path.root());
Iterable<String> names = Iterables.transform(path.names(), Functions.toStringFunction());
return type.toUri(fileSystemUri, root, names, F... | java | {
"resource": ""
} |
q154301 | Directory.get | train | @Nullable
public DirectoryEntry get(Name name) {
int index = bucketIndex(name, table.length);
DirectoryEntry entry = table[index];
while (entry != null) {
if (name.equals(entry.name())) {
return entry;
}
entry = entry.next;
}
return null;
} | java | {
"resource": ""
} |
q154302 | Directory.link | train | public void link(Name name, File file) {
DirectoryEntry entry = new DirectoryEntry(this, checkNotReserved(name, "link"), file);
put(entry);
file.linked(entry);
} | java | {
"resource": ""
} |
q154303 | Directory.unlink | train | public void unlink(Name name) {
DirectoryEntry entry = remove(checkNotReserved(name, "unlink"));
entry.file().unlinked();
} | java | {
"resource": ""
} |
q154304 | Directory.snapshot | train | public ImmutableSortedSet<Name> snapshot() {
ImmutableSortedSet.Builder<Name> builder =
new ImmutableSortedSet.Builder<>(Name.displayOrdering());
for (DirectoryEntry entry : this) {
if (!isReserved(entry.name())) {
builder.add(entry.name());
}
}
return builder.build();
} | java | {
"resource": ""
} |
q154305 | DirectoryEntry.requireDirectory | train | public DirectoryEntry requireDirectory(Path pathForException)
throws NoSuchFileException, NotDirectoryException {
requireExists(pathForException);
if (!file().isDirectory()) {
throw new NotDirectoryException(pathForException.toString());
}
return this;
} | java | {
"resource": ""
} |
q154306 | DirectoryEntry.requireSymbolicLink | train | public DirectoryEntry requireSymbolicLink(Path pathForException)
throws NoSuchFileException, NotLinkException {
requireExists(pathForException);
if (!file().isSymbolicLink()) {
throw new NotLinkException(pathForException.toString());
}
return this;
} | java | {
"resource": ""
} |
q154307 | JimfsAsynchronousFileChannel.closedChannelFuture | train | private static <V> ListenableFuture<V> closedChannelFuture() {
SettableFuture<V> future = SettableFuture.create();
future.setException(new ClosedChannelException());
return future;
} | java | {
"resource": ""
} |
q154308 | Jimfs.newFileSystem | train | public static FileSystem newFileSystem(String name, Configuration configuration) {
try {
URI uri = new URI(URI_SCHEME, name, null, null);
return newFileSystem(uri, configuration);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
} | java | {
"resource": ""
} |
q154309 | File.getAttributeNames | train | public final synchronized ImmutableSet<String> getAttributeNames(String view) {
if (attributes == null) {
return ImmutableSet.of();
}
return ImmutableSet.copyOf(attributes.row(view).keySet());
} | java | {
"resource": ""
} |
q154310 | File.getAttributeKeys | train | @VisibleForTesting
final synchronized ImmutableSet<String> getAttributeKeys() {
if (attributes == null) {
return ImmutableSet.of();
}
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
for (Table.Cell<String, String, Object> cell : attributes.cellSet()) {
builder.add(cell.getR... | java | {
"resource": ""
} |
q154311 | File.getAttribute | train | @Nullable
public final synchronized Object getAttribute(String view, String attribute) {
if (attributes == null) {
return null;
}
return attributes.get(view, attribute);
} | java | {
"resource": ""
} |
q154312 | File.setAttribute | train | public final synchronized void setAttribute(String view, String attribute, Object value) {
if (attributes == null) {
attributes = HashBasedTable.create();
}
attributes.put(view, attribute, value);
} | java | {
"resource": ""
} |
q154313 | File.deleteAttribute | train | public final synchronized void deleteAttribute(String view, String attribute) {
if (attributes != null) {
attributes.remove(view, attribute);
}
} | java | {
"resource": ""
} |
q154314 | AttributeProvider.unsettable | train | protected static RuntimeException unsettable(String view, String attribute, boolean create) {
// This matches the behavior of the real file system implementations: if the attempt to set the
// attribute is being made during file creation, throw UOE even though the attribute is one
// that cannot be set unde... | java | {
"resource": ""
} |
q154315 | AttributeProvider.checkNotCreate | train | protected static void checkNotCreate(String view, String attribute, boolean create) {
if (create) {
throw new UnsupportedOperationException(
"cannot set attribute '" + view + ":" + attribute + "' during file creation");
}
} | java | {
"resource": ""
} |
q154316 | AttributeProvider.checkType | train | protected static <T> T checkType(String view, String attribute, Object value, Class<T> type) {
checkNotNull(value);
if (type.isInstance(value)) {
return type.cast(value);
}
throw invalidType(view, attribute, value, type);
} | java | {
"resource": ""
} |
q154317 | AttributeProvider.invalidType | train | protected static IllegalArgumentException invalidType(
String view, String attribute, Object value, Class<?>... expectedTypes) {
Object expected =
expectedTypes.length == 1 ? expectedTypes[0] : "one of " + Arrays.toString(expectedTypes);
throw new IllegalArgumentException(
"invalid type "
... | java | {
"resource": ""
} |
q154318 | WindowsPathType.parseUncRoot | train | private String parseUncRoot(String path, String original) {
Matcher uncMatcher = UNC_ROOT.matcher(path);
if (uncMatcher.find()) {
String host = uncMatcher.group(2);
if (host == null) {
throw new InvalidPathException(original, "UNC path is missing hostname");
}
String share = uncM... | java | {
"resource": ""
} |
q154319 | JimfsFileChannel.endBlocking | train | private void endBlocking(boolean completed) throws AsynchronousCloseException {
synchronized (blockingThreads) {
blockingThreads.remove(Thread.currentThread());
}
end(completed);
} | java | {
"resource": ""
} |
q154320 | Name.simple | train | @VisibleForTesting
static Name simple(String name) {
switch (name) {
case ".":
return SELF;
case "..":
return PARENT;
default:
return new Name(name, name);
}
} | java | {
"resource": ""
} |
q154321 | RegularFile.expandIfNecessary | train | private void expandIfNecessary(int minBlockCount) {
if (minBlockCount > blocks.length) {
this.blocks = Arrays.copyOf(blocks, nextPowerOf2(minBlockCount));
}
} | java | {
"resource": ""
} |
q154322 | RegularFile.prepareForWrite | train | private void prepareForWrite(long pos, long len) throws IOException {
long end = pos + len;
// allocate any additional blocks needed
int lastBlockIndex = blockCount - 1;
int endBlockIndex = blockIndex(end - 1);
if (endBlockIndex > lastBlockIndex) {
int additionalBlocksNeeded = endBlockIndex ... | java | {
"resource": ""
} |
q154323 | RegularFile.blockForWrite | train | private byte[] blockForWrite(int index) throws IOException {
if (index >= blockCount) {
int additionalBlocksNeeded = index - blockCount + 1;
disk.allocate(this, additionalBlocksNeeded);
}
return blocks[index];
} | java | {
"resource": ""
} |
q154324 | RegularFile.zero | train | private static int zero(byte[] block, int offset, int len) {
Util.zero(block, offset, len);
return len;
} | java | {
"resource": ""
} |
q154325 | RegularFile.put | train | private static int put(byte[] block, int offset, byte[] b, int off, int len) {
System.arraycopy(b, off, block, offset, len);
return len;
} | java | {
"resource": ""
} |
q154326 | RegularFile.put | train | private static int put(byte[] block, int offset, ByteBuffer buf) {
int len = Math.min(block.length - offset, buf.remaining());
buf.get(block, offset, len);
return len;
} | java | {
"resource": ""
} |
q154327 | RegularFile.get | train | private static int get(byte[] block, int offset, byte[] b, int off, int len) {
System.arraycopy(block, offset, b, off, len);
return len;
} | java | {
"resource": ""
} |
q154328 | RegularFile.get | train | private static int get(byte[] block, int offset, ByteBuffer buf, int len) {
buf.put(block, offset, len);
return len;
} | java | {
"resource": ""
} |
q154329 | FileSystemState.register | train | public <C extends Closeable> C register(C resource) {
// Initial open check to avoid incrementing registering if we already know it's closed.
// This is to prevent any possibility of a weird pathalogical situation where the do/while
// loop in close() keeps looping as register() is called repeatedly from mu... | java | {
"resource": ""
} |
q154330 | Util.nextPowerOf2 | train | public static int nextPowerOf2(int n) {
if (n == 0) {
return 1;
}
int b = Integer.highestOneBit(n);
return b == n ? n : b << 1;
} | java | {
"resource": ""
} |
q154331 | Util.checkNoneNull | train | static void checkNoneNull(Iterable<?> objects) {
if (!(objects instanceof ImmutableCollection)) {
for (Object o : objects) {
checkNotNull(o);
}
}
} | java | {
"resource": ""
} |
q154332 | FileSystemView.lookUpWithLock | train | DirectoryEntry lookUpWithLock(JimfsPath path, Set<? super LinkOption> options)
throws IOException {
store.readLock().lock();
try {
return lookUp(path, options);
} finally {
store.readLock().unlock();
}
} | java | {
"resource": ""
} |
q154333 | FileSystemView.lookUp | train | private DirectoryEntry lookUp(JimfsPath path, Set<? super LinkOption> options)
throws IOException {
return store.lookUp(workingDirectory, path, options);
} | java | {
"resource": ""
} |
q154334 | FileSystemView.snapshotWorkingDirectoryEntries | train | public ImmutableSortedSet<Name> snapshotWorkingDirectoryEntries() {
store.readLock().lock();
try {
ImmutableSortedSet<Name> names = workingDirectory.snapshot();
workingDirectory.updateAccessTime();
return names;
} finally {
store.readLock().unlock();
}
} | java | {
"resource": ""
} |
q154335 | FileSystemView.snapshotModifiedTimes | train | public ImmutableMap<Name, Long> snapshotModifiedTimes(JimfsPath path) throws IOException {
ImmutableMap.Builder<Name, Long> modifiedTimes = ImmutableMap.builder();
store.readLock().lock();
try {
Directory dir = (Directory) lookUp(path, Options.FOLLOW_LINKS).requireDirectory(path).file();
// TOD... | java | {
"resource": ""
} |
q154336 | FileSystemView.isSameFile | train | public boolean isSameFile(JimfsPath path, FileSystemView view2, JimfsPath path2)
throws IOException {
if (!isSameFileSystem(view2)) {
return false;
}
store.readLock().lock();
try {
File file = lookUp(path, Options.FOLLOW_LINKS).fileOrNull();
File file2 = view2.lookUp(path2, Opti... | java | {
"resource": ""
} |
q154337 | FileSystemView.createDirectory | train | public Directory createDirectory(JimfsPath path, FileAttribute<?>... attrs) throws IOException {
return (Directory) createFile(path, store.directoryCreator(), true, attrs);
} | java | {
"resource": ""
} |
q154338 | FileSystemView.createSymbolicLink | train | public SymbolicLink createSymbolicLink(
JimfsPath path, JimfsPath target, FileAttribute<?>... attrs) throws IOException {
if (!store.supportsFeature(Feature.SYMBOLIC_LINKS)) {
throw new UnsupportedOperationException();
}
return (SymbolicLink) createFile(path, store.symbolicLinkCreator(target), t... | java | {
"resource": ""
} |
q154339 | FileSystemView.getOrCreateRegularFile | train | public RegularFile getOrCreateRegularFile(
JimfsPath path, Set<OpenOption> options, FileAttribute<?>... attrs) throws IOException {
checkNotNull(path);
if (!options.contains(CREATE_NEW)) {
// assume file exists unless we're explicitly trying to create a new file
RegularFile file = lookUpRegul... | java | {
"resource": ""
} |
q154340 | FileSystemView.lookUpRegularFile | train | @Nullable
private RegularFile lookUpRegularFile(JimfsPath path, Set<OpenOption> options)
throws IOException {
store.readLock().lock();
try {
DirectoryEntry entry = lookUp(path, options);
if (entry.exists()) {
File file = entry.file();
if (!file.isRegularFile()) {
th... | java | {
"resource": ""
} |
q154341 | FileSystemView.open | train | private static RegularFile open(RegularFile file, Set<OpenOption> options) {
if (options.contains(TRUNCATE_EXISTING) && options.contains(WRITE)) {
file.writeLock().lock();
try {
file.truncate(0);
} finally {
file.writeLock().unlock();
}
}
// must be opened while hold... | java | {
"resource": ""
} |
q154342 | FileSystemView.readSymbolicLink | train | public JimfsPath readSymbolicLink(JimfsPath path) throws IOException {
if (!store.supportsFeature(Feature.SYMBOLIC_LINKS)) {
throw new UnsupportedOperationException();
}
SymbolicLink symbolicLink =
(SymbolicLink)
lookUpWithLock(path, Options.NOFOLLOW_LINKS).requireSymbolicLink(pat... | java | {
"resource": ""
} |
q154343 | FileSystemView.checkAccess | train | public void checkAccess(JimfsPath path) throws IOException {
// just check that the file exists
lookUpWithLock(path, Options.FOLLOW_LINKS).requireExists(path);
} | java | {
"resource": ""
} |
q154344 | FileSystemView.link | train | public void link(JimfsPath link, FileSystemView existingView, JimfsPath existing)
throws IOException {
checkNotNull(link);
checkNotNull(existingView);
checkNotNull(existing);
if (!store.supportsFeature(Feature.LINKS)) {
throw new UnsupportedOperationException();
}
if (!isSameFileSy... | java | {
"resource": ""
} |
q154345 | FileSystemView.deleteFile | train | public void deleteFile(JimfsPath path, DeleteMode deleteMode) throws IOException {
store.writeLock().lock();
try {
DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS).requireExists(path);
delete(entry, deleteMode, path);
} finally {
store.writeLock().unlock();
}
} | java | {
"resource": ""
} |
q154346 | FileSystemView.delete | train | private void delete(DirectoryEntry entry, DeleteMode deleteMode, JimfsPath pathForException)
throws IOException {
Directory parent = entry.directory();
File file = entry.file();
checkDeletable(file, deleteMode, pathForException);
parent.unlink(entry.name());
parent.updateModifiedTime();
... | java | {
"resource": ""
} |
q154347 | FileSystemView.checkDeletable | train | private void checkDeletable(File file, DeleteMode mode, Path path) throws IOException {
if (file.isRootDirectory()) {
throw new FileSystemException(path.toString(), null, "can't delete root directory");
}
if (file.isDirectory()) {
if (mode == DeleteMode.NON_DIRECTORY_ONLY) {
throw new F... | java | {
"resource": ""
} |
q154348 | FileSystemView.copy | train | public void copy(
JimfsPath source,
FileSystemView destView,
JimfsPath dest,
Set<CopyOption> options,
boolean move)
throws IOException {
checkNotNull(source);
checkNotNull(destView);
checkNotNull(dest);
checkNotNull(options);
boolean sameFileSystem = isSameFileSy... | java | {
"resource": ""
} |
q154349 | FileSystemView.checkNotAncestor | train | private void checkNotAncestor(File source, Directory destParent, FileSystemView destView)
throws IOException {
// if dest is not in the same file system, it couldn't be in source's subdirectories
if (!isSameFileSystem(destView)) {
return;
}
Directory current = destParent;
while (true) {... | java | {
"resource": ""
} |
q154350 | FileSystemView.lockSourceAndCopy | train | private void lockSourceAndCopy(File sourceFile, File copyFile) {
sourceFile.opened();
ReadWriteLock sourceLock = sourceFile.contentLock();
if (sourceLock != null) {
sourceLock.readLock().lock();
}
ReadWriteLock copyLock = copyFile.contentLock();
if (copyLock != null) {
copyLock.write... | java | {
"resource": ""
} |
q154351 | FileSystemView.unlockSourceAndCopy | train | private void unlockSourceAndCopy(File sourceFile, File copyFile) {
ReadWriteLock sourceLock = sourceFile.contentLock();
if (sourceLock != null) {
sourceLock.readLock().unlock();
}
ReadWriteLock copyLock = copyFile.contentLock();
if (copyLock != null) {
copyLock.writeLock().unlock();
... | java | {
"resource": ""
} |
q154352 | FileSystemView.getFileAttributeView | train | @Nullable
public <V extends FileAttributeView> V getFileAttributeView(FileLookup lookup, Class<V> type) {
return store.getFileAttributeView(lookup, type);
} | java | {
"resource": ""
} |
q154353 | FileSystemView.getFileAttributeView | train | @Nullable
public <V extends FileAttributeView> V getFileAttributeView(
final JimfsPath path, Class<V> type, final Set<? super LinkOption> options) {
return store.getFileAttributeView(
new FileLookup() {
@Override
public File lookup() throws IOException {
return lookUp... | java | {
"resource": ""
} |
q154354 | FileSystemView.readAttributes | train | public <A extends BasicFileAttributes> A readAttributes(
JimfsPath path, Class<A> type, Set<? super LinkOption> options) throws IOException {
File file = lookUpWithLock(path, options).requireExists(path).file();
return store.readAttributes(file, type);
} | java | {
"resource": ""
} |
q154355 | FileSystemView.readAttributes | train | public ImmutableMap<String, Object> readAttributes(
JimfsPath path, String attributes, Set<? super LinkOption> options) throws IOException {
File file = lookUpWithLock(path, options).requireExists(path).file();
return store.readAttributes(file, attributes);
} | java | {
"resource": ""
} |
q154356 | FileSystemView.setAttribute | train | public void setAttribute(
JimfsPath path, String attribute, Object value, Set<? super LinkOption> options)
throws IOException {
File file = lookUpWithLock(path, options).requireExists(path).file();
store.setAttribute(file, attribute, value);
} | java | {
"resource": ""
} |
q154357 | AttributeService.setInitialAttributes | train | public void setInitialAttributes(File file, FileAttribute<?>... attrs) {
// default values should already be sanitized by their providers
for (int i = 0; i < defaultValues.size(); i++) {
FileAttribute<?> attribute = defaultValues.get(i);
int separatorIndex = attribute.name().indexOf(':');
Str... | java | {
"resource": ""
} |
q154358 | AttributeService.copyAttributes | train | public void copyAttributes(File file, File copy, AttributeCopyOption copyOption) {
switch (copyOption) {
case ALL:
file.copyAttributes(copy);
break;
case BASIC:
file.copyBasicAttributes(copy);
break;
default:
// don't copy
}
} | java | {
"resource": ""
} |
q154359 | AttributeService.setAttribute | train | public void setAttribute(File file, String attribute, Object value, boolean create) {
String view = getViewName(attribute);
String attr = getSingleAttribute(attribute);
setAttributeInternal(file, view, attr, value, create);
} | java | {
"resource": ""
} |
q154360 | JimfsFileStore.lookUp | train | DirectoryEntry lookUp(File workingDirectory, JimfsPath path, Set<? super LinkOption> options)
throws IOException {
state.checkOpen();
return tree.lookUp(workingDirectory, path, options);
} | java | {
"resource": ""
} |
q154361 | JimfsFileStore.symbolicLinkCreator | train | Supplier<SymbolicLink> symbolicLinkCreator(JimfsPath target) {
state.checkOpen();
return factory.symbolicLinkCreator(target);
} | java | {
"resource": ""
} |
q154362 | JimfsFileStore.setInitialAttributes | train | void setInitialAttributes(File file, FileAttribute<?>... attrs) {
state.checkOpen();
attributes.setInitialAttributes(file, attrs);
} | java | {
"resource": ""
} |
q154363 | JimfsFileStore.readAttributes | train | ImmutableMap<String, Object> readAttributes(File file, String attributes) {
state.checkOpen();
return this.attributes.readAttributes(file, attributes);
} | java | {
"resource": ""
} |
q154364 | JimfsFileStore.setAttribute | train | void setAttribute(File file, String attribute, Object value) {
state.checkOpen();
// TODO(cgdecker): Change attribute stuff to avoid the sad boolean parameter
attributes.setAttribute(file, attribute, value, false);
} | java | {
"resource": ""
} |
q154365 | UnixAttributeProvider.getUniqueId | train | private Integer getUniqueId(Object object) {
Integer id = idCache.get(object);
if (id == null) {
id = uidGenerator.incrementAndGet();
Integer existing = idCache.putIfAbsent(object, id);
if (existing != null) {
return existing;
}
}
return id;
} | java | {
"resource": ""
} |
q154366 | Configuration.forCurrentPlatform | train | public static Configuration forCurrentPlatform() {
String os = System.getProperty("os.name");
if (os.contains("Windows")) {
return windows();
} else if (os.contains("OS X")) {
return osX();
} else {
return unix();
}
} | java | {
"resource": ""
} |
q154367 | Types.getSuperParameterizedType | train | public static ParameterizedType getSuperParameterizedType(Type type, Class<?> superClass) {
if (type instanceof Class<?> || type instanceof ParameterizedType) {
outer:
while (type != null && type != Object.class) {
Class<?> rawType;
if (type instanceof Class<?>) {
// type is a ... | java | {
"resource": ""
} |
q154368 | Types.isAssignableToOrFrom | train | public static boolean isAssignableToOrFrom(Class<?> classToCheck, Class<?> anotherClass) {
return classToCheck.isAssignableFrom(anotherClass)
|| anotherClass.isAssignableFrom(classToCheck);
} | java | {
"resource": ""
} |
q154369 | Types.newInstance | train | public static <T> T newInstance(Class<T> clazz) {
// TODO(yanivi): investigate "sneaky" options for allocating the class that GSON uses, like
// setting the constructor to be accessible, or possibly provide a factory method of a special
// name
try {
return clazz.newInstance();
} catch (Illega... | java | {
"resource": ""
} |
q154370 | Types.getBound | train | public static Type getBound(WildcardType wildcardType) {
Type[] lowerBounds = wildcardType.getLowerBounds();
if (lowerBounds.length != 0) {
return lowerBounds[0];
}
return wildcardType.getUpperBounds()[0];
} | java | {
"resource": ""
} |
q154371 | Types.resolveTypeVariable | train | public static Type resolveTypeVariable(List<Type> context, TypeVariable<?> typeVariable) {
// determine where the type variable was declared
GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
if (genericDeclaration instanceof Class<?>) {
Class<?> rawGenericDeclaration = (Cla... | java | {
"resource": ""
} |
q154372 | Types.iterableOf | train | @SuppressWarnings("unchecked")
public static <T> Iterable<T> iterableOf(final Object value) {
if (value instanceof Iterable<?>) {
return (Iterable<T>) value;
}
Class<?> valueClass = value.getClass();
Preconditions.checkArgument(valueClass.isArray(), "not an array or Iterable: %s", valueClass);
... | java | {
"resource": ""
} |
q154373 | SslUtils.initSslContext | train | public static SSLContext initSslContext(
SSLContext sslContext, KeyStore trustStore, TrustManagerFactory trustManagerFactory)
throws GeneralSecurityException {
trustManagerFactory.init(trustStore);
sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
return sslContext;
} | java | {
"resource": ""
} |
q154374 | Base64.decodeBase64 | train | public static byte[] decodeBase64(String base64String) {
try {
return BaseEncoding.base64().decode(base64String);
} catch (IllegalArgumentException e) {
if (e.getCause() instanceof DecodingException) {
return BaseEncoding.base64Url().decode(base64String);
}
throw e;
}
} | java | {
"resource": ""
} |
q154375 | ApacheHttpTransport.newDefaultHttpParams | train | static HttpParams newDefaultHttpParams() {
HttpParams params = new BasicHttpParams();
// Turn off stale checking. Our connections break all the time anyway,
// and it's not worth it to pay the penalty of checking every time.
HttpConnectionParams.setStaleCheckingEnabled(params, false);
HttpConnection... | java | {
"resource": ""
} |
q154376 | AbstractAtomFeedParser.parseFeed | train | public T parseFeed() throws IOException, XmlPullParserException {
boolean close = true;
try {
this.feedParsed = true;
T result = Types.newInstance(feedClass);
Xml.parseElement(parser, result, namespaceDictionary, Atom.StopAtAtomEntry.INSTANCE);
close = false;
return result;
} f... | java | {
"resource": ""
} |
q154377 | JsonParser.parseAndClose | train | public final <T> T parseAndClose(Class<T> destinationClass) throws IOException {
return parseAndClose(destinationClass, null);
} | java | {
"resource": ""
} |
q154378 | JsonParser.skipToKey | train | public final String skipToKey(Set<String> keysToFind) throws IOException {
JsonToken curToken = startParsingObjectOrArray();
while (curToken == JsonToken.FIELD_NAME) {
String key = getText();
nextToken();
if (keysToFind.contains(key)) {
return key;
}
skipChildren();
c... | java | {
"resource": ""
} |
q154379 | JsonParser.startParsingObjectOrArray | train | private JsonToken startParsingObjectOrArray() throws IOException {
JsonToken currentToken = startParsing();
switch (currentToken) {
case START_OBJECT:
currentToken = nextToken();
Preconditions.checkArgument(
currentToken == JsonToken.FIELD_NAME || currentToken == JsonToken.END_... | java | {
"resource": ""
} |
q154380 | JsonParser.parse | train | private void parse(
ArrayList<Type> context, Object destination, CustomizeJsonParser customizeParser)
throws IOException {
if (destination instanceof GenericJson) {
((GenericJson) destination).setFactory(getFactory());
}
JsonToken curToken = startParsingObjectOrArray();
Class<?> destin... | java | {
"resource": ""
} |
q154381 | JsonParser.parseArray | train | private <T> void parseArray(
Field fieldContext,
Collection<T> destinationCollection,
Type destinationItemType,
ArrayList<Type> context,
CustomizeJsonParser customizeParser)
throws IOException {
JsonToken curToken = startParsingObjectOrArray();
while (curToken != JsonToken.EN... | java | {
"resource": ""
} |
q154382 | JsonParser.parseMap | train | private void parseMap(
Field fieldContext,
Map<String, Object> destinationMap,
Type valueType,
ArrayList<Type> context,
CustomizeJsonParser customizeParser)
throws IOException {
JsonToken curToken = startParsingObjectOrArray();
while (curToken == JsonToken.FIELD_NAME) {
... | java | {
"resource": ""
} |
q154383 | AtomFeedParser.create | train | public static <T, E> AtomFeedParser<T, E> create(
HttpResponse response,
XmlNamespaceDictionary namespaceDictionary,
Class<T> feedClass,
Class<E> entryClass)
throws IOException, XmlPullParserException {
InputStream content = response.getContent();
try {
Atom.checkContentType(... | java | {
"resource": ""
} |
q154384 | ArrayValueMap.setValues | train | public void setValues() {
for (Map.Entry<String, ArrayValueMap.ArrayValue> entry : keyMap.entrySet()) {
@SuppressWarnings("unchecked")
Map<String, Object> destinationMap = (Map<String, Object>) destination;
destinationMap.put(entry.getKey(), entry.getValue().toArray());
}
for (Map.Entry<Fi... | java | {
"resource": ""
} |
q154385 | ArrayValueMap.put | train | public void put(Field field, Class<?> arrayComponentType, Object value) {
ArrayValueMap.ArrayValue arrayValue = fieldMap.get(field);
if (arrayValue == null) {
arrayValue = new ArrayValue(arrayComponentType);
fieldMap.put(field, arrayValue);
}
arrayValue.addValue(arrayComponentType, value);
... | java | {
"resource": ""
} |
q154386 | ArrayValueMap.put | train | public void put(String keyName, Class<?> arrayComponentType, Object value) {
ArrayValueMap.ArrayValue arrayValue = keyMap.get(keyName);
if (arrayValue == null) {
arrayValue = new ArrayValue(arrayComponentType);
keyMap.put(keyName, arrayValue);
}
arrayValue.addValue(arrayComponentType, value)... | java | {
"resource": ""
} |
q154387 | HttpRequest.handleRedirect | train | public boolean handleRedirect(int statusCode, HttpHeaders responseHeaders) {
String redirectLocation = responseHeaders.getLocation();
if (getFollowRedirects()
&& HttpStatusCodes.isRedirect(statusCode)
&& redirectLocation != null) {
// resolve the redirect location relative to the current l... | java | {
"resource": ""
} |
q154388 | AtomContent.forEntry | train | public static AtomContent forEntry(XmlNamespaceDictionary namespaceDictionary, Object entry) {
return new AtomContent(namespaceDictionary, entry, true);
} | java | {
"resource": ""
} |
q154389 | AtomContent.forFeed | train | public static AtomContent forFeed(XmlNamespaceDictionary namespaceDictionary, Object feed) {
return new AtomContent(namespaceDictionary, feed, false);
} | java | {
"resource": ""
} |
q154390 | HttpMediaType.setParameter | train | public HttpMediaType setParameter(String name, String value) {
if (value == null) {
removeParameter(name);
return this;
}
Preconditions.checkArgument(
TOKEN_REGEX.matcher(name).matches(), "Name contains reserved characters");
cachedBuildResult = null;
parameters.put(name.toLower... | java | {
"resource": ""
} |
q154391 | HttpMediaType.removeParameter | train | public HttpMediaType removeParameter(String name) {
cachedBuildResult = null;
parameters.remove(name.toLowerCase(Locale.US));
return this;
} | java | {
"resource": ""
} |
q154392 | HttpMediaType.build | train | public String build() {
if (cachedBuildResult != null) {
return cachedBuildResult;
}
StringBuilder str = new StringBuilder();
str.append(type);
str.append('/');
str.append(subType);
if (parameters != null) {
for (Entry<String, String> entry : parameters.entrySet()) {
Str... | java | {
"resource": ""
} |
q154393 | HttpMediaType.setCharsetParameter | train | public HttpMediaType setCharsetParameter(Charset charset) {
setParameter("charset", charset == null ? null : charset.name());
return this;
} | java | {
"resource": ""
} |
q154394 | UriTemplate.expand | train | public static String expand(
String baseUrl, String uriTemplate, Object parameters, boolean addUnusedParamsAsQueryParams) {
String pathUri;
if (uriTemplate.startsWith("/")) {
// Remove the base path from the base URL.
GenericUrl url = new GenericUrl(baseUrl);
url.setRawPath(null);
... | java | {
"resource": ""
} |
q154395 | HttpResponseException.computeMessageBuffer | train | public static StringBuilder computeMessageBuffer(HttpResponse response) {
StringBuilder builder = new StringBuilder();
int statusCode = response.getStatusCode();
if (statusCode != 0) {
builder.append(statusCode);
}
String statusMessage = response.getStatusMessage();
if (statusMessage != nu... | java | {
"resource": ""
} |
q154396 | BackOffUtils.next | train | public static boolean next(Sleeper sleeper, BackOff backOff)
throws InterruptedException, IOException {
long backOffTime = backOff.nextBackOffMillis();
if (backOffTime == BackOff.STOP) {
return false;
}
sleeper.sleep(backOffTime);
return true;
} | java | {
"resource": ""
} |
q154397 | MultipartContent.setContentParts | train | public MultipartContent setContentParts(Collection<? extends HttpContent> contentParts) {
this.parts = new ArrayList<Part>(contentParts.size());
for (HttpContent contentPart : contentParts) {
addPart(new Part(contentPart));
}
return this;
} | java | {
"resource": ""
} |
q154398 | HttpHeaders.toStringValue | train | private static String toStringValue(Object headerValue) {
return headerValue instanceof Enum<?>
? FieldInfo.of((Enum<?>) headerValue).getName()
: headerValue.toString();
} | java | {
"resource": ""
} |
q154399 | HttpHeaders.getFirstHeaderValue | train | private <T> T getFirstHeaderValue(List<T> internalValue) {
return internalValue == null ? null : internalValue.get(0);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.