id
stringlengths
7
14
text
stringlengths
1
106k
225211_1
public static <T> Class<? extends T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
225211_2
public static <T> Class<? extends T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
225211_3
public static <T> Class<? extends T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
229738_0
@Override public boolean accepts(Class<?> extensionType) { if (looksLikeSqlObject(extensionType)) { if (extensionType.getAnnotation(GenerateSqlObject.class) != null) { return true; } if (!extensionType.isInterface()) { throw new IllegalArgumentException("SQL Objects a...
229738_1
@Override public Optional<RowMapper<?>> build(Type type, ConfigRegistry config) { Class<?> erasedType = getErasedType(type); boolean emptyTupleType = Tuple0.class.equals(erasedType) || Tuple.class.equals(erasedType); boolean mappableTupleType = type instanceof ParameterizedType && Tuple.class.isAssignableFr...
229738_2
@Override public Optional<RowMapper<?>> build(Type type, ConfigRegistry config) { Class<?> erasedType = getErasedType(type); boolean emptyTupleType = Tuple0.class.equals(erasedType) || Tuple.class.equals(erasedType); boolean mappableTupleType = type instanceof ParameterizedType && Tuple.class.isAssignableFr...
229738_3
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_4
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_5
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_6
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_7
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_8
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
229738_9
@Override public Optional<Argument> build(Type type, Object value, ConfigRegistry config) { Class<?> rawType = GenericTypes.getErasedType(type); if (VALUE_CLASSES.stream().anyMatch(vc -> vc.isAssignableFrom(rawType))) { return buildValueArgument(type, config, (Value) value); } return Optional.em...
231990_0
public static List<String> parseArtist(String artist) { Pattern pattern = Pattern.compile("(.+)(( (F|f)eat(\\. |\\.| |uring ))(.+))"); Matcher matcher = pattern.matcher(artist); boolean matches = matcher.matches(); if (matches) { String lead = matcher.group(1).trim(); String featuring = ...
231990_1
public static List<String> parseTrack(String track) { Pattern pattern = Pattern.compile("(.+)(\\((F|f)eat(\\. |\\.| |uring )(.+))\\)"); Matcher matcher = pattern.matcher(track); boolean matches = matcher.matches(); if (matches) { String title = matcher.group(1).trim(); String featuring =...
231990_2
public static String formatContributors(String artist, List<String> contributors) { StringBuilder buffer = new StringBuilder(); buffer.append(artist); if (contributors.size() > 0) buffer.append(" featuring "); for (int i = 0, c = contributors.size(); i < c; i++) { String contributor = co...
235076_0
public JenaObjectWrapper() { super(); }
235076_1
public TemplateModel wrap(Object obj) throws TemplateModelException { if (obj instanceof Resource) { return new ResourceHashModel((Resource) obj); } else { return super.wrap(obj); } }
235076_2
@Override public int size() throws TemplateModelException { StmtIterator iterator = resource.listProperties(); return iterator.toList().size(); }
235076_3
@Override public int size() throws TemplateModelException { StmtIterator iterator = resource.listProperties(); return iterator.toList().size(); }
235076_4
@Override public TemplateCollectionModel keys() throws TemplateModelException { ArrayList<String> list = new ArrayList<String>(); StmtIterator iterator = resource.listProperties(); while (iterator.hasNext()) { list.add(iterator.next().getPredicate().getURI()); } return new SimpleCollection(l...
235076_5
@Override public TemplateCollectionModel values() throws TemplateModelException { ArrayList<String> list = new ArrayList<String>(); StmtIterator iterator = resource.listProperties(); while (iterator.hasNext()) { RDFNode node = iterator.next().getObject(); if (node.isLiteral()) { ...
235076_6
@Override public TemplateModel get(String s) throws TemplateModelException { String uri = prefixMapping.expandPrefix(s); Property property = ResourceFactory.createProperty(uri); if (!resource.hasProperty(property)) { return null; // bail } List<TemplateModel> list = new ArrayList<TemplateMod...
235076_7
@Override public boolean isEmpty() throws TemplateModelException { StmtIterator iterator = resource.listProperties(); return iterator.toList().size() == 0; }
235076_8
@Override public String getAsString() throws TemplateModelException { if (resource.getURI() == null) { return INVALID_URL; // b-nodes return null and their ids are useless } else { return resource.getURI(); } }
235076_9
@Override public String getAsString() throws TemplateModelException { if (resource.getURI() == null) { return INVALID_URL; // b-nodes return null and their ids are useless } else { return resource.getURI(); } }
237920_0
public void setProjects(Projects projects) { this.projects = projects; }
237920_1
public void setProjects(Projects projects) { this.projects = projects; }
240464_0
public static JsonProvider provider() { return CACHE.get(); }
240464_1
public static JsonProvider provider() { return CACHE.get(); }
240464_2
public String getMessage() { if (causeException == null) return super.getMessage(); StringBuilder sb = new StringBuilder(); if (super.getMessage() != null) { sb.append(super.getMessage()); sb.append("; "); } sb.append("nested exception is: "); sb.append(causeException.toString())...
240464_3
@Override public Throwable getCause() { return super.getCause() != null ? super.getCause() : getCausedByException(); }
240464_4
public Exception getCausedByException() { return causeException; }
240464_5
public void printStackTrace(PrintStream ps) { if (causeException == null || super.getCause() == null || causeException == super.getCause()) { super.printStackTrace(ps); } else synchronized (ps) { ps.println(this); causeException.printStackTrace(ps); super.printStackTrace(ps); ...
240466_0
public static boolean canConvert(final String type, final ClassLoader classLoader) { if (type == null) { throw new NullPointerException("type is null"); } if (classLoader == null) { throw new NullPointerException("classLoader is null"); } try { return REGISTRY.findConverter(C...
240466_1
public static Object getValue(final String type, final String value, final ClassLoader classLoader) throws PropertyEditorException { return REGISTRY.getValue(type, value, classLoader); }
240466_2
public static Object getValue(final String type, final String value, final ClassLoader classLoader) throws PropertyEditorException { return REGISTRY.getValue(type, value, classLoader); }
240466_3
public static Object getValue(final String type, final String value, final ClassLoader classLoader) throws PropertyEditorException { return REGISTRY.getValue(type, value, classLoader); }
240466_4
static List<Method> getCandidates(final Class type) { final List<Method> candidates = new ArrayList<Method>(); for (final Method method : type.getMethods()) { if (!Modifier.isStatic(method.getModifiers())) continue; if (!Modifier.isPublic(method.getModifiers())) continue; if (!method.get...
240466_5
static void sort(final List<Method> candidates) { Collections.sort(candidates, new Comparator<Method>() { public int compare(final Method a, final Method b) { int av = grade(a); int bv = grade(b); return (a.getName().compareTo(b.getName()) + (av - bv)); } }); ...
240466_6
public static boolean isConvertable(Type type, Object propertyValue, PropertyEditorRegistry registry) { if (propertyValue instanceof Recipe) { Recipe recipe = (Recipe) propertyValue; return recipe.canCreate(type); } return (propertyValue instanceof String && (registry == null ? PropertyEdito...
240466_7
public static Object convert(Type expectedType, Object value, boolean lazyRefAllowed, PropertyEditorRegistry registry) { if (value instanceof Recipe) { Recipe recipe = (Recipe) value; value = recipe.create(expectedType, lazyRefAllowed); } // some shortcuts for common string operations if...
240466_8
public InputStream getBytecode(String className) throws IOException, ClassNotFoundException { int pos = className.indexOf("<"); if (pos > -1) { className = className.substring(0, pos); } pos = className.indexOf(">"); if (pos > -1) { className = className.substring(0, pos); } ...
240466_9
public Class<?> loadClass(String className) throws ClassNotFoundException { // assume the loader knows how to handle mjar release if activated return loader.loadClass(className); }
247823_0
private HttpStatus(int code, String message, boolean register) { this.code = code; this.message = message; if (register) { valuesByInt.put(code, this); } }
247823_1
public static HttpStatus valueOf(int code) { return valuesByInt.get(code); }
247823_2
public String getStatusLine() { StringBuilder builder = new StringBuilder(SL_11_START.length() + 4 + message.length()); builder.append(SL_11_START).append(code).append(' ').append(message); return builder.toString(); }
247823_3
public boolean isError() { return code >= 400; }
247823_4
public Application generate(String baseURI, Set<Class<?>> classes) { /* * the idea is that classes comes from the Application subclass */ Application app = new Application(); if (classes == null || classes.isEmpty()) { return app; } Resources resources = new Resources(); resour...
247823_5
Set<ClassMetadata> buildClassMetdata(Set<Class<?>> classes) { Set<ClassMetadata> metadataSet = new HashSet<ClassMetadata>(classes.size()); for (Class<?> c : classes) { if (!isResource(c)) { /* not a resource, so skip it */ continue; } ClassMetadata metadata = Reso...
247823_6
Set<ClassMetadata> buildClassMetdata(Set<Class<?>> classes) { Set<ClassMetadata> metadataSet = new HashSet<ClassMetadata>(classes.size()); for (Class<?> c : classes) { if (!isResource(c)) { /* not a resource, so skip it */ continue; } ClassMetadata metadata = Reso...
247823_7
Set<ClassMetadata> buildClassMetdata(Set<Class<?>> classes) { Set<ClassMetadata> metadataSet = new HashSet<ClassMetadata>(classes.size()); for (Class<?> c : classes) { if (!isResource(c)) { /* not a resource, so skip it */ continue; } ClassMetadata metadata = Reso...
247823_8
Set<ClassMetadata> buildClassMetdata(Set<Class<?>> classes) { Set<ClassMetadata> metadataSet = new HashSet<ClassMetadata>(classes.size()); for (Class<?> c : classes) { if (!isResource(c)) { /* not a resource, so skip it */ continue; } ClassMetadata metadata = Reso...
247823_9
Resource buildResource(ClassMetadata metadata) { Resource r = new Resource(); if (metadata != null) { Class<?> resClass = metadata.getResourceClass(); if (resClass != null) { WADLDoc d = resClass.getAnnotation(WADLDoc.class); if (d != null) { r.getDoc().ad...
249855_0
public String receiveAndSaveToFile(String objectName, File toFile) { return receiveAndSaveToFile(defaultContainerName, objectName, toFile); }
249855_1
public void deleteContainer(String containerName) { try { restService.deleteContainer(containerName); } catch (AzureRestCommunicationException e) { throw new StorageCommunicationException(e, "Azure cloud storage request 'delete container' has failed [container: '%s'].", container...
249855_2
public void deleteObject(String objectName) { deleteObject(defaultContainerName, objectName); }
249855_3
public List<BlobDetails> filter(final List<BlobDetails> objects) { if (objects == null) { return null; } List<BlobDetails> accepted = new ArrayList<BlobDetails>(objects); for (int i = 0; i < blobDetailsFilters.size() && !accepted.isEmpty(); i++) { accepted = blobDetailsFilters.get(0).fil...
249855_4
public List<BlobDetails> filter(final List<BlobDetails> objects) { if (objects == null) { return null; } List<BlobDetails> accepted = new ArrayList<BlobDetails>(objects); for (int i = 0; i < blobDetailsFilters.size() && !accepted.isEmpty(); i++) { accepted = blobDetailsFilters.get(0).fil...
249855_5
public int compare(BlobDetails b1, BlobDetails b2) { Date b1LastModifiedDate = b1.getLastModified(); Date b2LastModifiedDate = b2.getLastModified(); if (b1LastModifiedDate.after(b2LastModifiedDate)) { return 1; } else if (b1LastModifiedDate.before(b2LastModifiedDate)) { return -1; ...
249855_6
public boolean createContainer(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); try { final S3Bucket bucket = s3Service.createBucket(new S3Bucket(containerName)); return bucket != null; } catch (S3ServiceException e) { throw new StorageCommunicationE...
249855_7
public boolean createContainer(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); try { final S3Bucket bucket = s3Service.createBucket(new S3Bucket(containerName)); return bucket != null; } catch (S3ServiceException e) { throw new StorageCommunicationE...
249855_8
public void deleteContainer(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Delete bucket '{}'", containerName); try { s3Service.deleteBucket(new S3Bucket(containerName)); } catch (S3ServiceException e) { throw new StorageCommunicationExcepti...
249855_9
public void deleteContainer(String containerName) { Assert.notNull(containerName, BUCKET_NAME_CANNOT_BE_NULL); LOG.debug("Delete bucket '{}'", containerName); try { s3Service.deleteBucket(new S3Bucket(containerName)); } catch (S3ServiceException e) { throw new StorageCommunicationExcepti...
279216_1
public static <T> T match(String URL, Visitor<T> matcher) { Matcher patternMatcher = pattern.matcher(URL); if (!patternMatcher.matches()) { throw new DespotifyException("Not a valid URL: " + URL); } URLtype urlType = patternMatcher.group(2) != null ? URLtype.httpURL : URLtype.spotifyURL; if (patternMatche...
279216_2
public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(...
279216_3
public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(...
279216_4
public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(...
279216_5
public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(...
279216_6
public Result send(DespotifyManager connectionManager) throws DespotifyException { /* Create channel callback */ ChannelCallback callback = new ChannelCallback(); byte[] utf8Bytes = query.getBytes(Charset.forName("UTF8")); /* Create channel and buffer. */ Channel channel = new Channel("Search-Channel", Channe...
279216_7
@Override public Artist send(DespotifyManager connectionManager) throws DespotifyException { Date now = new Date(); /* Create channel callback */ ChannelCallback callback = new ChannelCallback(); /* Send browse request. */ /* Create channel and buffer. */ Channel channel = new Channel("Browse-Channel", Chan...
279216_8
@Override public Album send(DespotifyManager connectionManager) throws DespotifyException { Create channel callback */ ChannelCallback callback = new ChannelCallback(); /* Send browse request. */ /* Create channel and buffer. */ Channel channel = new Channel("Browse-Channel", Channel.Type.TYPE_BROWSE, callback...
279216_9
@Override public Boolean send(DespotifyManager connectionManager) throws DespotifyException { ChannelCallback callback = new ChannelCallback(); Channel channel = new Channel("Playlist-Channel", Channel.Type.TYPE_PLAYLIST, callback); ByteBuffer buffer = ByteBuffer.allocate(2 + 16 + 1 + 4 + 4 + 4 + 1); buffer.pu...
283187_0
public static String pop() { int next = size(); if (next == 0) { return ""; } int last = next - 1; String key = PREFIX + last; String val = MDC.get(key); MDC.remove(key); return val; }
283187_1
public static String render(Object o) { if (o == null) { return String.valueOf(o); } Class<?> objectClass = o.getClass(); if (unrenderableClasses.containsKey(objectClass) == false) { try { if (objectClass.isArray()) { return renderArray(o, objectClass).toStrin...
283187_2
static DurationUnit selectDurationUnitForDisplay(StopWatch sw) { return selectDurationUnitForDisplay(sw.elapsedTime()); }
283187_3
String recursivelyComputeLevelString() { String tempName = name; String levelString = null; int indexOfLastDot = tempName.length(); while ((levelString == null) && (indexOfLastDot > -1)) { tempName = tempName.substring(0, indexOfLastDot); levelString = CONFIG_PARAMS.getStringProperty(SimpleLogger.LOG_KEY_PREFIX...
283187_4
String recursivelyComputeLevelString() { String tempName = name; String levelString = null; int indexOfLastDot = tempName.length(); while ((levelString == null) && (indexOfLastDot > -1)) { tempName = tempName.substring(0, indexOfLastDot); levelString = CONFIG_PARAMS.getStringProperty(SimpleLogger.LOG_KEY_PREFIX...
283187_5
String recursivelyComputeLevelString() { String tempName = name; String levelString = null; int indexOfLastDot = tempName.length(); while ((levelString == null) && (indexOfLastDot > -1)) { tempName = tempName.substring(0, indexOfLastDot); levelString = CONFIG_PARAMS.getStringProperty(SimpleLogger.LOG_KEY_PREFIX...
283187_6
String recursivelyComputeLevelString() { String tempName = name; String levelString = null; int indexOfLastDot = tempName.length(); while ((levelString == null) && (indexOfLastDot > -1)) { tempName = tempName.substring(0, indexOfLastDot); levelString = CONFIG_PARAMS.getStringProperty(SimpleLogger.LOG_KEY_PREFIX...
283187_7
static void init() { CONFIG_PARAMS = new SimpleLoggerConfiguration(); CONFIG_PARAMS.init(); }
283187_8
static void init() { CONFIG_PARAMS = new SimpleLoggerConfiguration(); CONFIG_PARAMS.init(); }
283187_9
synchronized public Logger getLogger(String name) { SubstituteLogger logger = loggers.get(name); if (logger == null) { logger = new SubstituteLogger(name, eventQueue, postInitialization); loggers.put(name, logger); } return logger; }
283325_0
public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; // First check if ThreadLocal has been set already LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { // We first try to find the name of our // environmen...
283325_1
public LoggerContext getLoggerContext() { String contextName = null; Context ctx = null; // First check if ThreadLocal has been set already LoggerContext lc = threadLocal.get(); if (lc != null) { return lc; } try { // We first try to find the name of our // environmen...
283325_2
public void remove(String key) { if (key == null) { return; } Map<String, String> oldMap = copyOnThreadLocal.get(); if (oldMap == null) return; Integer lastOp = getAndSetLastOperation(WRITE_OPERATION); if (wasLastOpReadOrNull(lastOp)) { Map<String, String> newMap = duplic...
283325_3
public void remove(String key) { if (key == null) { return; } Map<String, String> oldMap = copyOnThreadLocal.get(); if (oldMap == null) return; Integer lastOp = getAndSetLastOperation(WRITE_OPERATION); if (wasLastOpReadOrNull(lastOp)) { Map<String, String> newMap = duplic...
283325_4
public void put(String key, String val) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key cannot be null"); } Map<String, String> oldMap = copyOnThreadLocal.get(); Integer lastOp = getAndSetLastOperation(WRITE_OPERATION); if (wasLastOpReadOrNull(las...
283325_5
public void autoConfig() throws JoranException { StatusListenerConfigHelper.installIfAsked(loggerContext); URL url = findURLOfDefaultConfigurationFile(true); if (url != null) { configureByResource(url); } else { Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class); ...
283325_6
public void autoConfig() throws JoranException { StatusListenerConfigHelper.installIfAsked(loggerContext); URL url = findURLOfDefaultConfigurationFile(true); if (url != null) { configureByResource(url); } else { Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class); ...
283325_7
public void autoConfig() throws JoranException { StatusListenerConfigHelper.installIfAsked(loggerContext); URL url = findURLOfDefaultConfigurationFile(true); if (url != null) { configureByResource(url); } else { Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class); ...
283325_8
public static List<String> computeNameParts(String loggerName) { List<String> partList = new ArrayList<String>(); int fromIndex = 0; while (true) { int index = getSeparatorIndexOf(loggerName, fromIndex); if (index == -1) { partList.add(loggerName.substring(fromIndex)); ...
283325_9
public static List<String> computeNameParts(String loggerName) { List<String> partList = new ArrayList<String>(); int fromIndex = 0; while (true) { int index = getSeparatorIndexOf(loggerName, fromIndex); if (index == -1) { partList.add(loggerName.substring(fromIndex)); ...
291242_0
public String getBaseName() { BaseName rbnAnnotation = enumClass.getAnnotation(BaseName.class); if (rbnAnnotation == null) { return null; } return rbnAnnotation.value(); }
291242_1
List<Token> tokenize() { List<Token> tokenList = new ArrayList<Token>(); while (true) { String currentLine; try { currentLine = lineReader.readLine(); } catch (IOException e) { throw new MessageConveyorException("Failed to read input stream", e); } if (currentLine == null) { br...
291242_2
List<Token> tokenize() { List<Token> tokenList = new ArrayList<Token>(); while (true) { String currentLine; try { currentLine = lineReader.readLine(); } catch (IOException e) { throw new MessageConveyorException("Failed to read input stream", e); } if (currentLine == null) { br...
291242_3
List<Token> tokenize() { List<Token> tokenList = new ArrayList<Token>(); while (true) { String currentLine; try { currentLine = lineReader.readLine(); } catch (IOException e) { throw new MessageConveyorException("Failed to read input stream", e); } if (currentLine == null) { br...
291242_4
void parseAndPopulate() { E(); }
291242_5
void parseAndPopulate() { E(); }
291242_6
void parseAndPopulate() { E(); }