id stringlengths 7 14 | text stringlengths 1 37.2k |
|---|---|
13899_11 | public static String readString(InputStream in, String charset) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
int c;
while ((c = in.read()) > 0) {
out.write(c);
}
return new String(out.toByteArray(), charset);
} |
32578_0 | public List<LabelValue> getAllRoles() {
List<Role> roles = dao.getRoles();
List<LabelValue> list = new ArrayList<LabelValue>();
for (Role role1 : roles) {
list.add(new LabelValue(role1.getName(), role1.getName()));
}
return list;
} |
56670_0 | protected String getPackage() {
return pkg;
} |
56904_58 | public List<U> get() {
if (this.loaded == null) {
if (this.parent.isNew() || UnitTesting.isEnabled()) {
// parent is brand new, so don't bother hitting the database
this.loaded = new ArrayList<U>();
} else {
if (!UoW.isOpen()) {
throw new DisconnectedException();
}
if (!E... |
74217_5 | public List<Class<?>> scan(List<String> packages) {
List<Class<?>> classes = new ArrayList<Class<?>>();
for (String packageName : packages) {
for (Class clazz : findClassesInPackage(packageName)) {
if (hasRecordAnnoation(clazz))
classes.add(clazz);
}
}
return ... |
88960_47 | public String format(JSLintResult result) {
StringBuilder sb = new StringBuilder();
for (Issue issue : result.getIssues()) {
sb.append(outputOneIssue(issue));
}
return sb.toString();
} |
97620_0 | public String get() {
return this.fullClassNameWithGenerics;
} |
103035_6 | public static boolean unregisterMBean(ObjectName oName) {
boolean unregistered = false;
if (null != oName) {
try {
if (mbs.isRegistered(oName)) {
log.debug("Mbean is registered");
mbs.unregisterMBean(oName);
//set flag based on registration status
unregistered = !mbs.isRegistered(oName);
} els... |
116547_7 | @Override
public void load_code_file(String classFile) throws Throwable {
Class<?> clazz = loadClass(classFile);
addClass(clazz);
} |
121672_32 | public Fields appendSelector( Fields fields )
{
return appendInternal( fields, true );
} |
123235_12 | public static KeyPair recoverKeyPair(byte[] encoded) throws NoSuchAlgorithmException,
InvalidKeySpecException {
final String algo = getAlgorithmForOid(getOidFromPkcs8Encoded(encoded));
final KeySpec privKeySpec = new PKCS8EncodedKeySpec(encoded);
final KeyFactory kf = KeyFactory.getInstance(algo);
final Private... |
135867_7 | @SuppressWarnings("unchecked")
public ModelAndView logIn(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
BindException errors) throws Exception {
// Checking whether logged in
ApplicationState state = getApplicationState(request);
LOG.debug("logIn() state=" + state);
... |
149511_10 | public boolean isUnderRevisionControl() {
return true;
} |
152134_28 | public User findByUsername(String username) {
Query query = em.createNamedQuery("findUserByUsername");
query.setParameter("username", username);
return (User) query.getSingleResult();
} |
152812_18 | @Nonnull
public static MemcachedNodesManager createFor(final String memcachedNodes, final String failoverNodes, final StorageKeyFormat storageKeyFormat,
final StorageClientCallback storageClientCallback) {
if ( memcachedNodes == null || memcachedNodes.trim().isEmpty() ) {
throw new IllegalArgumentExcep... |
160996_95 | public void transportMessage( Who recipient, Message msg ) throws Exception
{
if (msg.getMessageId() != null)
throw new IllegalStateException( "message has already been sent" );
msg.setMessageId( idGen.next() );
//Log.report( "MailboxManager.send", "msg", msg );
transport.transportMessage( recipient, msg );... |
160999_86 | public File create(String path) {
File file = new File(path);
return validate(file);
} |
161005_337 | public String toString()
{
return "(\"" + this.getClass().getName() + "\",\"" + m_wiki + "\",\"" + getActions() + "\")";
} |
161180_0 | public static final byte[] toBytes(int i){
if(i < INT_N_65535 || i > INT_P_65535) {
return Integer.toString(i).getBytes();
}
final int absi = Math.abs(i);
final byte[] cachedData = i2b_65535[absi];
final byte[] data;
if(cachedData == null) {
data = Integer.toString(absi).getBytes();
i2b_65535[absi] = data;
... |
168535_2 | public Entry getPrevious() {
Entry previous = null;
for (Entry entry : entryDao.readAll()) {
if (entry.getId().equals(current.getId()) && previous != null) {
return previous;
}
previous = entry;
}
return null;
} |
169928_3 | public int sizeOfToDoList() {
return toDoList.size();
} |
175376_3 | Expr parseYieldExpr() {
return new Expr.Yield(parseOptionalTestList());
} |
184604_0 | public static int count(String text) {
return text.length();
} |
200121_6 | @Override
public InputStream getInputStream() {
try {
URL url = new URL(path);
return url.openStream();
} catch (MalformedURLException ex) {
throw new ConstrettoException("Could not load URL. Path tried: [" + path + "]", ex);
} catch (IOException e) {
throw new ConstrettoExce... |
206318_8 | protected static void writeChunksToStream(byte[] data, byte[] dataHeader,
int lengthOffset, int maxChunkLength, OutputStream os) throws IOException {
int dataLength = data.length;
int numFullChunks = dataLength / maxChunkLength;
int lastChunkLength = dataLength % maxChunkLength;
int headerLen =... |
206320_1 | public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
throws ScmException
{
return (RemoveScmResult) execute( repository, fileSet, parameters );
} |
206322_31 | @Nullable
public static String getLineEndingCharacters( @Nullable String lineEnding )
throws AssemblyFormattingException
{
String value = lineEnding;
if ( lineEnding != null )
{
try
{
value = LineEndings.valueOf( lineEnding ).getLineEndingCharacters();
}
ca... |
206350_846 | public LifecycleEvent getCallbackType() {
return callbackType;
} |
206364_39 | public String toSnakeCase(final String name) {
final StringBuilder out = new StringBuilder(name.length() + 3);
final boolean isDelimited = name.startsWith(getLeadingDelimiter()) && name.endsWith(getTrailingDelimiter());
final String toConvert;
if (isDelimited) {
toConvert = name.substring(2, nam... |
206402_426 | public boolean isResponseCacheable(final String httpMethod, final HttpResponse response) {
boolean cacheable = false;
if (!HeaderConstants.GET_METHOD.equals(httpMethod) && !HeaderConstants.HEAD_METHOD.equals(httpMethod)) {
if (LOG.isDebugEnabled()) {
LOG.debug("{} method response is not cac... |
206403_0 | void write(Node node, int maxLevels) throws RepositoryException, IOException {
write(node, 0, maxLevels);
} |
206418_92 | public void checkoutProject( int projectId, String projectName, File workingDirectory, String scmRootUrl,
String scmUsername, String scmPassword, BuildDefinition defaultBuildDefinition,
List<Project> subProjects )
throws BuildManagerException
{
try
{... |
206437_62 | public byte[] decrypt( EncryptionKey key, EncryptedData data, KeyUsage usage ) throws KerberosException
{
LOG_KRB.debug( "Decrypting data using key {} and usage {}", key.getKeyType(), usage );
EncryptionEngine engine = getEngine( key );
return engine.getDecryptedData( key, data, usage );
} |
206444_108 | @Override
public void run() {
TxnStore.MutexAPI.LockHandle handle = null;
try {
handle = txnHandler.getMutexAPI().acquireLock(TxnStore.MUTEX_KEY.TxnCleaner.name());
long start = System.currentTimeMillis();
txnHandler.cleanEmptyAbortedAndCommittedTxns();
LOG.debug("Txn cleaner service took: {} second... |
206451_6 | @SuppressWarnings("unchecked")
public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
List result;
Object someRes = null;
try {
someRes = evaluate(cexp, ctx, XPathConstants.NODESET);
} catch (Exception e) {
someRes = evaluate(cexp, ctx,... |
206452_15 | public static String cleanTextKey(String s) {
if (s == null || s.isEmpty()) {
return s;
}
// escape HTML
return StringEscapeUtils.escapeHtml4(cleanExpressions(s));
} |
206459_27 | @Override
public int readEnum() throws IOException {
return readInt();
} |
206478_75 | @Override
public void definedTerm()
{
// nop
} |
206483_66 | protected void mergeContributor_Roles( Contributor target, Contributor source, boolean sourceDominant,
Map<Object, Object> context )
{
target.setRoles( merge( target.getRoles(), source.getRoles(), sourceDominant, e -> e ) );
} |
206633_1000 | public Object createFilteredBean(Object data, Set<String> fields) {
return createFilteredBean(data, fields, "");
} |
206635_4 | public Set<MojoDescriptor> parseMojoDescriptors( File metadataFile )
throws PluginMetadataParseException
{
Set<MojoDescriptor> descriptors = new HashSet<>();
try ( Reader reader = ReaderFactory.newXmlReader( metadataFile ) )
{
PluginMetadataXpp3Reader metadataReader = new PluginMetadataXpp3Rea... |
209853_134 | @Override
public String geraCodigoDeBarrasPara(Boleto boleto) {
Beneficiario beneficiario = boleto.getBeneficiario();
String numeroConvenio = beneficiario.getNumeroConvenio();
if (numeroConvenio == null
|| numeroConvenio.isEmpty() ) {
throw new IllegalArgumentEx... |
213337_470 | ; |
219850_20 | public void setUseCanonicalFormat(boolean useCanonicalFormat) {
this.useCanonicalFormat = useCanonicalFormat;
} |
223355_338 | public InputStream locate(final String uri)
throws IOException {
notNull(uri, "uri cannot be NULL!");
if (getWildcardStreamLocator().hasWildcard(uri)) {
final String fullPath = FilenameUtils.getFullPath(uri);
final URL url = new URL(fullPath);
return getWildcardStreamLocator().locateStream(uri, new Fi... |
225207_7 | public void handleMessage(NMRMessage message) throws Fault {
message.put(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
NSStack nsStack = new NSStack();
nsStack.push();
try {
XMLStreamWriter writer = getWriter(message);
Fault fault = getFault(message);
... |
225211_0 | public static <T> Class<? extends T> locate(Class<T> factoryId) {
return locate(factoryId, factoryId.getName());
} |
229738_123 | @CheckReturnValue
@Nonnull
public static DummyException throwAnyway(Throwable t) {
if (t instanceof Error) {
throw (Error) t;
}
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
if (t instanceof IOException) {
throw new UncheckedIOException((IOException) t)... |
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 =... |
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_1 | public void setProjects(Projects projects) {
this.projects = projects;
} |
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.toStrin... |
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(... |
247823_30 | public String toString(NewCookie cookie) {
if (cookie == null) {
throw new IllegalArgumentException(Messages.getMessage("cookieIsNull")); //$NON-NLS-1$
}
return buildCookie(cookie.getName(), cookie.getValue(), cookie.getPath(), cookie
.getDomain(), cookie.getVersion(), cookie.getComment(), c... |
249855_17 | public List<BlobDetails> listContainerObjectDetails() {
return listContainerObjectDetails(getDefaultContainerName());
} |
279216_19 | public Result send(Connection connection) 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", Channel.Type.TYPE... |
283187_21 | public static void install() {
LogManager.getLogManager().getLogger("").addHandler(new SLF4JBridgeHandler());
} |
283325_37 | public String abbreviate(String fqClassName) {
StringBuilder buf = new StringBuilder(targetLength);
if (fqClassName == null) {
throw new IllegalArgumentException("Class name may not be null");
}
int inLen = fqClassName.length();
if (inLen < targetLength) {
return fqClassName;
}
... |
291242_13 | public <E extends Enum<?>> String getMessage(E key, Object... args)
throws MessageConveyorException {
Class<? extends Enum<?>> declaringClass = key.getDeclaringClass();
String declaringClassName = declaringClass.getName();
CAL10NBundle rb = cache.get(declaringClassName);
if (rb == null || rb.hasChange... |
291570_20 | public final AuthenticationInfo authenticate(AuthenticationToken token) throws AuthenticationException {
if (token == null) {
throw new IllegalArgumentException("Method argument (authentication token) cannot be null.");
}
log.trace("Authentication attempt received for token [{}]", token);
Aut... |
293812_0 | @Override
public void close() {
out.close();
} |
298328_9 | public static String render(final String input) throws IllegalArgumentException {
try {
return render(input, new StringBuilder(input.length())).toString();
} catch (IOException e) {
// Cannot happen because StringBuilder does not throw IOException
throw new IllegalArgumentException(e);
... |
309964_37 | public void add(Link content) {
_contents.add(content);
} |
314299_10 | public ExtensionModel getExtensionModel( String extension )
{
return extensionModels.get( extension );
} |
315033_36 | public Object invoke(MethodInvocation invocation) throws Throwable {
final Method method = invocation.getMethod();
if(method == null) {
return null;
}
Transactional txa = method.getAnnotation(Transactional.class);
if (txa == null) {
return invocation.proceed();
}
Transaction tx = manager.getCurren... |
320367_0 | public static int times(int x, int y)
{
return new HelloWorldJNI().timesHello(x, y);
} |
320690_7 | @Override
public SourceProperty getSourceProperty( String expression ) {
if ( isIdentifier( expression ) ) {
return new ReflectionSourceProperty( expression );
} else {
return null;
}
} |
324985_0 | public boolean hasAssociatedFailures(Description d) {
List<Failure> failureList = result.getFailures();
for (Failure f : failureList) {
if (f.getDescription().equals(d)) {
return true;
}
if (description.isTest()) {
return false;
}
List<Description> descriptionList = d.getChildren();... |
327391_1 | @SuppressWarnings({"unchecked"})
public ArrayBuilder<T> add(T... elements) {
if (elements == null) return this;
if (array == null) {
array = elements;
return this;
}
T[] newArray = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length + elements.length);
System.ar... |
327472_155 | @Override
public boolean accept(final ConsoleState state) {
Assertions.checkNotNull("state", state);
if (state.getActiveCommand() == null && state.getInput().trim().startsWith("save ")) { return true; }
return false;
} |
331792_7 | @Nullable
public NodePath parent() {
int i = path.lastIndexOf(Node.SEPARATOR);
if (i == 0) {
return this;
}
else if (i == -1) {
return null;
}
else {
return new NodePath(path.substring(0, i));
}
} |
335218_30 | public static Satz getSatz(final int satzart) {
return getSatz(new SatzTyp(satzart));
} |
336330_27 | @Override
public Matrix viewPart(int[] offset, int[] size) {
if (offset[ROW] < ROW) {
throw new IndexException(offset[ROW], ROW);
}
if (offset[ROW] + size[ROW] > rowSize()) {
throw new IndexException(offset[ROW] + size[ROW], rowSize());
}
if (offset[COL] < ROW) {
throw new IndexException(offset[CO... |
338815_32 | protected boolean isCurrentRevisionSelected() {
return myRightRevisionIndex == 0;
} |
339284_3 | public Model load() throws Exception {
if (name == null) {
throw new MissingPropertyException("name");
}
String value = System.getProperty(name);
if (value == null) {
log.trace("Unable to load; property not set: {}", name);
return null;
}
URL url = null;
try {
url = new URL(value);
}
... |
339856_0 | @Splitter
public List<TripNotification> generateTripNotificationsFrom(FlightNotification flightNotification,
@Header("affectedTrips") List<Trip> affectedTrips) {
List<TripNotification> notifications = new ArrayList<TripNotification>(affectedTrips.size());
for (Trip trip : affectedTrips) {
notificati... |
342505_0 | public AttributeCollection() {
this.map = Collections.synchronizedMap(new HashMap<AttributeIdentifier, Map<EntityAttributes, Attribute<?>>>());
} |
343996_8 | public ImmutableList<String> extractNames(ImmutableList<NamePart> nameParts) {
nameParts.size() < 3) {
throw new IllegalArgumentException("There should be 3 NameParts : a Country, a first-order administrative division, and a name");
urn ImmutableList.of(
untryName(nameParts),
m1Name(nameParts),
atureName(nameParts... |
357827_0 | public static Long getString2Duration(String time) throws ParseException {
String[] timeArray = time.split(":");
if (timeArray.length != C_THREE) {
throw new ParseException("", 0);
}
try {
long millis;
millis = Integer.parseInt(timeArray[0]) * C_THREETHOUSANDSIXHUNDRET;
m... |
358370_14 | @Override
@SuppressWarnings({"PMD.AvoidInstantiatingObjectsInLoops", "PMD.CloseResource"})
public Long call()
throws Exception
{
if(!inputFile.isFile())
{
throw new IllegalArgumentException("'" + inputFile.getAbsolutePath() + "' is not a file!");
}
if(!inputFile.canRead())
{
throw new IllegalArgumentException... |
358381_11 | public Map<String, Object> getLocalResourceMap(final String bundleBaseName, final Locale locale)
{
if(object != null)
{
return ResourceMaps.getLocalResourceMap(clazz, bundleBaseName, resolveLocale(locale));
}
return ResourceMaps.getLocalResourceMap(clazz, bundleBaseName, locale);
} |
363849_3 | public static HttpParameters decodeForm(String form) {
HttpParameters params = new HttpParameters();
if (isEmpty(form)) {
return params;
}
for (String nvp : form.split("\\&")) {
int equals = nvp.indexOf('=');
String name;
String value;
if (equals < 0) {
... |
369176_0 | public URI getLocation() {
try {
String location = getHeaders().getFirst("Location");
if(location == null || location.equals(""))
return getRequest().getURI();
else
return new URI(location);
} catch (URISyntaxException e) {
throw new RestfulieException("Invalid URI received as a response", e);
}
} |
376975_19 | public static boolean isEmpty(Collection<?> collection) {
return collection == null || collection.isEmpty();
} |
394387_0 | public Collection getBaseCollection() throws XMLDBException {
baseCollection = DatabaseManager.getCollection(baseCollectionURI);
return baseCollection;
} |
403568_5 | @Override
protected void add(Geometry geometry) {
if (result == null) {
result = geometry;
} else {
if (geometry != null) {
result = result.union(geometry);
}
}
} |
446195_3 | public static boolean isBetween(long reading, long floor, long ceiling) {
return reading < ceiling && reading > floor;
} |
457158_6 | public void search(Set<String> keywords) {
for (AuctionHouse auctionHouse : auctionHouses) {
search(auctionHouse, keywords);
}
consumer.auctionSearchFinished();
} |
459348_101 | public void setHeaders(final Message message,
final Map<String, String> msgMap,
final DataType dataType,
final String address,
final @NonNull PersonRecord contact,
final Date sentDate,
... |
466802_0 | public String getBiography() {
return biography;
} |
473362_6 | @Override
public void reduce(GramKey key,
Iterator<Gram> values,
OutputCollector<Gram,Gram> output,
Reporter reporter) throws IOException {
Gram.Type keyType = key.getType();
if (keyType == Gram.Type.UNIGRAM) {
// sum frequencies for unigrams.
pro... |
474905_0 | public void setName(String name) {
this.name = name;
} |
478661_36 | public String[] parseLine(String nextLine) throws IOException {
return parseLine(nextLine, false);
} |
489859_415 | @Override
public GeneratedHttpRequest apply(Invocation invocation) {
checkNotNull(invocation, "invocation");
inputParamValidator.validateMethodParametersOrThrow(invocation);
Optional<URI> endpoint = Optional.absent();
HttpRequest r = findOrNull(invocation.getArgs(), HttpRequest.class);
if (r != null) {
... |
500697_95 | public boolean getDefined() {
return d_isDefined;
} |
500806_607 | @Override
protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) {
JmsEndpoint endpoint;
if (resourcePath.startsWith("sync:")) {
endpoint = new JmsSyncEndpoint();
} else {
endpoint = new JmsEndpoint();
}
if (resourcePath.contains... |
502000_35 | public TaskQueue createTaskQueue() {
if (isShutdown) {
throw new IllegalStateException("Scheduler is shutdown");
}
return new TaskQueueImpl();
} |
505113_0 | public void setUseLevelAsKey(final boolean useLevelAsKey)
{
this.useLevelAsKey = useLevelAsKey;
} |
508590_3 | void setFirstClassEdges(final boolean firstClassEdges) {
this.firstClassEdges = firstClassEdges;
} |
511297_48 | public CassandraHost[] buildCassandraHosts() {
if (this.hosts == null) {
throw new IllegalArgumentException("Need to define at least one host in order to apply configuration.");
}
String[] hostVals = hosts.split(",");
CassandraHost[] cassandraHosts = new CassandraHost[hostVals.length];
for (int x=0; x<hos... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.