_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q152100 | EncryptionUtil.getPemPublicKey | train | private PublicKey getPemPublicKey(final String keyString) throws EncryptionException {
try {
final String publicKeyPEM = keyString.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").replaceAll("\\v", "");
final Base64 b64 = new Base64();
final byte[] deco... | java | {
"resource": ""
} |
q152101 | EncryptionUtil.decrypt | train | public String decrypt(final byte[] text, final KeyType keyType) throws EncryptionException {
final Key key = keyType == KeyType.PRIVATE ? privateKey : publicKey;
try {
// get an RSA cipher object and print the provider
final Cipher cipher = Cipher.getInstance(ALGORITHM);
// decry... | java | {
"resource": ""
} |
q152102 | EncryptionUtil.sign | train | public String sign(final String message) throws EncryptionException {
try {
Signature sign = Signature.getInstance("SHA1withRSA");
sign.initSign(privateKey);
sign.update(message.getBytes(DEFAULT_CHARSET));
return new String(Base64.encodeBase64(sign.sign()), DEFAULT_CHARSET);
... | java | {
"resource": ""
} |
q152103 | EncryptionUtil.verify | train | public boolean verify(final String message, final String signature) throws EncryptionException {
try {
Signature sign = Signature.getInstance("SHA1withRSA");
sign.initVerify(publicKey);
sign.update(message.getBytes(DEFAULT_CHARSET));
return sign.verify(Base64.decodeBase64(signa... | java | {
"resource": ""
} |
q152104 | DbCloser.close | train | public static PreparedStatement close(PreparedStatement stmt, Logger logExceptionTo, Object name)
{
if(stmt == null)
return null;
try
{
stmt.clearParameters();
}
catch(SQLException e)
{
(logExceptionTo==null ? logger : logExceptionTo).warn("SQLException clearing parameters for " + (name == null ? ... | java | {
"resource": ""
} |
q152105 | DbCloser.close | train | public static ResultSet close(ResultSet rs, Logger logExceptionTo, Object name)
{
if(rs == null)
return null;
try
{
rs.close();
}
catch(SQLException e)
{
(logExceptionTo==null ? logger : logExceptionTo).warn("SQLException closing " + (name == null ? rs.toString() : name) + " ignored.", e);
}
r... | java | {
"resource": ""
} |
q152106 | DbCloser.close | train | public static Connection close(Connection conn, Logger logExceptionTo, Object name)
{
if(conn == null)
return null;
try
{
conn.close();
}
catch(SQLException e)
{
(logExceptionTo==null ? logger : logExceptionTo).warn("SQLException closing " + (name == null ? conn.toString() : name) + " ignored.", e... | java | {
"resource": ""
} |
q152107 | Deferrers.defer | train | @Weight(Weight.Unit.NORMAL)
public static <T extends Closeable> T defer(@Nullable final T closeable) {
if (closeable != null) {
defer(new Deferred() {
private static final long serialVersionUID = 2265124256013043847L;
@Override
public void executeDeferred() throws Exception {
... | java | {
"resource": ""
} |
q152108 | SeleniumJT.verifyElementContains | train | @LogExecTime
public void verifyElementContains(String locator, String value)
{
jtCore.verifyElementContains(locator, value);
} | java | {
"resource": ""
} |
q152109 | SeleniumJT.verifyElementText | train | @LogExecTime
public void verifyElementText(String locator, String value, String message)
{
jtCore.verifyElementText(locator, value, message);
} | java | {
"resource": ""
} |
q152110 | SeleniumJT.typeTinyMceEditor | train | @LogExecTime
public void typeTinyMceEditor(String locator, String value)
{
jtTinyMce.typeTinyMceEditor(locator, value);
} | java | {
"resource": ""
} |
q152111 | SeleniumJT.attachFile | train | @LogExecTime
public void attachFile(String locator, String fileUrl)
{
jtInput.attachFile(locator, fileUrl);
} | java | {
"resource": ""
} |
q152112 | SeleniumJT.verifyTextPresent | train | @LogExecTime
public void verifyTextPresent(String text, String msg)
{
jtCore.verifyTextPresent(text, msg);
} | java | {
"resource": ""
} |
q152113 | ConsumerPoolThread.addObject | train | public void addObject(E object){
if(stopped==true){
log.warn("Adding a new object ignored, the pool is stopped");
return ;
}
// add to the end
objectList.add(object);
// if (log.isDebugEnabled()){
// log.debug("ADD, size:'"+objectListSize()+"' "+object.hashCode()+" stopped:"+stopedThreadNumber+" "+obj... | java | {
"resource": ""
} |
q152114 | ConsumerPoolThread.waitUntilWorkDone | train | public void waitUntilWorkDone(){
while(objectListSize()>0 || getRunningThreadNumber()>0){
if (stopped){
log.fatal("El pool se ha parado de forma anormal. List Size:"+objectListSize()+" running threads:"+getRunningThreadNumber()+"/"+getThreadPoolSize());
return ;
}
if (log.isDebugEnabled()){
log.d... | java | {
"resource": ""
} |
q152115 | AbstractRoxListener.getName | train | private String getName(Description description, RoxableTest mAnnotation) {
if (mAnnotation == null || mAnnotation.name() == null || mAnnotation.name().isEmpty()) {
return Inflector.getHumanName(description.getMethodName());
}
else {
return mAnnotation.name();
}
} | java | {
"resource": ""
} |
q152116 | AbstractRoxListener.getCategory | train | protected String getCategory(RoxableTestClass classAnnotation, RoxableTest methodAnnotation) {
if (methodAnnotation != null && methodAnnotation.category() != null && !methodAnnotation.category().isEmpty()) {
return methodAnnotation.category();
}
else if (classAnnotation != null && classAnnotation.category() !=... | java | {
"resource": ""
} |
q152117 | AbstractRoxListener.getTags | train | private Set<String> getTags(RoxableTest methodAnnotation, RoxableTestClass classAnnotation) {
Set<String> tags = CollectionHelper.getTags(configuration.getTags(), methodAnnotation, classAnnotation);
if (!tags.contains(DEFAULT_TAG)) {
tags.add(DEFAULT_TAG);
}
return tags;
} | java | {
"resource": ""
} |
q152118 | AbstractRoxListener.getTickets | train | private Set<String> getTickets(RoxableTest methodAnnotation, RoxableTestClass classAnnotation) {
return CollectionHelper.getTickets(configuration.getTickets(), methodAnnotation, classAnnotation);
} | java | {
"resource": ""
} |
q152119 | Selectable.child | train | public final ChildSelector<T> child(ElementConstraint...constraints) {
return new ChildSelector<T>(getContext(), getCurrentSelector(),
Arrays.asList(constraints));
} | java | {
"resource": ""
} |
q152120 | Selectable.descendant | train | public final ElementSelector<T> descendant(ElementConstraint...constraints) {
return new DescendantSelector<T>(getContext(), getCurrentSelector(),
Arrays.asList(constraints));
} | java | {
"resource": ""
} |
q152121 | Selectable.descendant | train | public final ElementSelector<T> descendant(QName qname, ElementConstraint...constraints) {
ElementEqualsConstraint nameConstraint = new ElementEqualsConstraint(qname);
return new DescendantSelector<T>(getContext(), getCurrentSelector(),
ElementSelector.gatherConstraints(nameConstraint, ... | java | {
"resource": ""
} |
q152122 | Static.offerArray | train | public static <T> T[] offerArray(T[] prepend, T[] tail) {
if (prepend == null || prepend.length < 1) {
return tail;
} else if (tail == null || tail.length < 1) {
return prepend;
} else {
T[] result = newArrayInstance(tail, prepend.length + tail.length);
... | java | {
"resource": ""
} |
q152123 | Static.getLoggingClass | train | public static Class<?> getLoggingClass(Object object) {
Class<?> result = object.getClass();
if (result.getSimpleName().matches(".*[$].*CGLIB.*")) {
result = result.getSuperclass();
}
return result;
} | java | {
"resource": ""
} |
q152124 | Static.join | train | public static String join(String separator, String[] parts) {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (String part : parts) {
if (first) {
first = false;
} else {
builder.append(separator);
}
... | java | {
"resource": ""
} |
q152125 | Key.cat | train | public static String cat (Object... components) {
StringBuilder stringBuilder = new StringBuilder ();
if (components.length > 0) {
stringBuilder.append (components[0]);
for (int i = 1; i < components.length; ++i) {
stringBuilder.append (BagObject.PATH_SEPARAT... | java | {
"resource": ""
} |
q152126 | JcromBundleContext.addCrudService | train | public void addCrudService(Class clazz, BundleContext bundleContext, JcrRepository repository) throws RepositoryException {
jcrom.map(clazz);
JcrCrudService<? extends Object> jcromCrudService;
jcromCrudService = new JcrCrudService<>(repository, jcrom, clazz);
crudServiceRegistrations.put... | java | {
"resource": ""
} |
q152127 | JcromBundleContext.registerCrud | train | private ServiceRegistration registerCrud(BundleContext context, JcrCrudService crud) {
Dictionary prop = jcromConfiguration.toDictionary();
prop.put(Crud.ENTITY_CLASS_PROPERTY, crud.getEntityClass());
prop.put(Crud.ENTITY_CLASSNAME_PROPERTY, crud.getEntityClass().getName());
ServiceRegis... | java | {
"resource": ""
} |
q152128 | ServletContainer.getConnectors | train | protected Connector[] getConnectors(Server server) {
ServerConnector http = new ServerConnector(server);
http.setPort(DEFAULT_HTTP_PORT);
return new Connector[] { http };
} | java | {
"resource": ""
} |
q152129 | ServletContainer.start | train | public void start() {
stop(); // <-- If server is not running nothing happens.
if (!isInitialized()) {
onInit();
server = __buildServer();
}
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
... | java | {
"resource": ""
} |
q152130 | ServletContainer.registerServletContextListener | train | public SC registerServletContextListener(Class<? extends ServletContextListener> servletContextListener) {
__throwIfInitialized();
if (servletContextListener == null)
throw new IllegalArgumentException("Event listener cannot be null");
servletContextListenerSet.add(servletContextLi... | java | {
"resource": ""
} |
q152131 | Sets.dup | train | public static <T> Set<T> dup(Collection<T> collection)
{
if(isEmpty(collection))
return new HashSet<T>();
return new HashSet<T>(collection);
} | java | {
"resource": ""
} |
q152132 | Sets.newSet | train | public static <T> Set<T> newSet(T...contents)
{
Set<T> set;
if(contents == null || contents.length==0)
return newSet();
set = newSet(contents.length);
Collections.addAll(set, contents);
return set;
} | java | {
"resource": ""
} |
q152133 | DynamicPrefixConfig.addPrefix | train | protected synchronized void addPrefix(final String prefixString) {
if (prefixString != null) {
final Set<String> prefixes = getPrefixes();
prefixes.add(prefixString);
setPrefixes(prefixes);
}
} | java | {
"resource": ""
} |
q152134 | Sha1Hasher.createSha1Urn | train | public static URI createSha1Urn(final File file) throws IOException
{
LOG.debug("Creating SHA1 URN.");
if (file.length() == 0L)
{
throw new IOException("Cannot publish empty files!!");
}
return createSha1Urn(new FileInputStream(file));
} | java | {
"resource": ""
} |
q152135 | Sha1Hasher.hash | train | public static String hash(final String str)
{
try
{
final MessageDigest md = new Sha1();
final byte[] hashed = md.digest(str.getBytes("UTF-8"));
final byte[] encoded = Base64.encodeBase64(hashed);
return new String(encoded, "UTF-8");
... | java | {
"resource": ""
} |
q152136 | Preset.authenticate | train | public boolean authenticate(String appId, String apiKey) throws MnoConfigurationException {
return appId != null && apiKey != null && appId.equals(api.getId()) && apiKey.equals(api.getKey());
} | java | {
"resource": ""
} |
q152137 | Preset.authenticate | train | public boolean authenticate(HttpServletRequest request) throws MnoException {
String authHeader = request.getHeader("Authorization");
if (authHeader == null || authHeader.isEmpty()) {
return false;
}
String[] auth = authHeader.trim().split("\\s+");
if (auth == null || auth.length != 2 || !auth[0].equalsIg... | java | {
"resource": ""
} |
q152138 | Preset.toMetadataHash | train | public Map<String, Object> toMetadataHash() {
Map<String, Object> hash = new LinkedHashMap<String, Object>();
hash.put("marketplace", marketplace);
hash.put("app", app.toMetadataHash());
hash.put("api", api.toMetadataHash());
hash.put("sso", sso.toMetadataHash());
hash.put("connec", connec.toMetadataHash())... | java | {
"resource": ""
} |
q152139 | MnoMapHelper.toUnderscoreHash | train | @SuppressWarnings("unchecked")
public static <V> Map<String,V> toUnderscoreHash(Map<String,V> hash) {
if (hash == null) return null;
Map<String,V> newHash = new HashMap<String,V>();
for (Map.Entry<String, V> entry : hash.entrySet())
{
V value = entry.getValue();
// Apply toUnderscoreHash recurs... | java | {
"resource": ""
} |
q152140 | XhtmlTemplateEngine.loadTemplateDocument | train | private static Document loadTemplateDocument(String templateName, DocumentBuilder builder, Reader reader) throws IOException
{
final int READ_AHEAD_SIZE = 5;
BufferedReader bufferedReader = new BufferedReader(reader);
bufferedReader.mark(READ_AHEAD_SIZE);
char[] cbuf = new char[READ_AHEAD_SIZE]... | java | {
"resource": ""
} |
q152141 | InvocationProxy.create | train | public static <T> T create(final InterfaceDescriptor<T> descriptor, final Invoker invoker) {
if (descriptor == null) throw new NullPointerException("descriptor");
if (invoker == null) throw new NullPointerException("invocationHandler");
InvocationProxy<T> invocationProxy = new InvocationProxy<T>(descriptor, invo... | java | {
"resource": ""
} |
q152142 | FileSystemManager.createLibFolder | train | private void createLibFolder() throws IOException {
if(!Files.exists(libLocation.toPath()))
Files.createDirectories(libLocation.toPath());
} | java | {
"resource": ""
} |
q152143 | FileSystemManager.createResourceFolder | train | private void createResourceFolder() throws IOException {
if(!Files.exists(resourceLocation.toPath()))
Files.createDirectories(resourceLocation.toPath());
} | java | {
"resource": ""
} |
q152144 | FileSystemManager.createPropertiesFolder | train | private void createPropertiesFolder() throws IOException {
if(!Files.exists(propertiesLocation.toPath()))
Files.createDirectories(propertiesLocation.toPath());
} | java | {
"resource": ""
} |
q152145 | FileSystemManager.createLogsFolder | train | private void createLogsFolder() throws IOException {
if(!Files.exists(logsLocation.toPath()))
Files.createDirectories(logsLocation.toPath());
} | java | {
"resource": ""
} |
q152146 | FileSystemManager.createSystemFolder | train | private void createSystemFolder() throws IOException {
if(!Files.exists(systemLocation.toPath()))
Files.createDirectories(systemLocation.toPath());
} | java | {
"resource": ""
} |
q152147 | BagObject.has | train | public boolean has (String key) {
String[] path = Key.split (key);
int index = binarySearch (path[0]);
try {
return (index >= 0) &&
((path.length == 1) ||
((BagObject) container[index].value).has (path[1]));
} catch (Clas... | java | {
"resource": ""
} |
q152148 | BagObject.keys | train | public String[] keys () {
String[] keys = new String[count];
for (int i = 0; i < count; ++i) {
keys[i] = container[i].key;
}
return keys;
} | java | {
"resource": ""
} |
q152149 | RelayingSocketHandler.copyLarge | train | private long copyLarge(final InputStream input, final OutputStream output,
final int bufferSize) throws IOException {
final byte[] buffer = new byte[bufferSize];
long count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
... | java | {
"resource": ""
} |
q152150 | AbstractExtractor.getAnnotationTypes | train | public AnnotationType[] getAnnotationTypes() {
if (annotationType.isEmpty()) {
return new AnnotationType[]{Types.TOKEN};
}
return annotationType.toArray(new AnnotationType[annotationType.size()]);
} | java | {
"resource": ""
} |
q152151 | SensorIoHandler.exceptionCaught | train | @Override
public void exceptionCaught(IoSession session, Throwable cause)
throws Exception {
log.error("Unhandled exception caught in session {}: {}", session,
cause);
this.sensorIoAdapter.exceptionCaught(session, cause);
} | java | {
"resource": ""
} |
q152152 | SensorIoHandler.messageReceived | train | @Override
public void messageReceived(IoSession session, Object message)
throws Exception {
log.debug("{} <-- {}", session, message);
if (this.sensorIoAdapter == null) {
log.warn(
"No SensorIoAdapter defined. Ignoring message from {}: {}",
session, message);
return;
}
if (message instanceof... | java | {
"resource": ""
} |
q152153 | SensorIoHandler.messageSent | train | @Override
public void messageSent(IoSession session, Object message) throws Exception {
log.debug("{} --> {}", message, session);
if (this.sensorIoAdapter == null) {
log.warn("No SensorIoAdapter defined. Ignoring message to {}: {}",
session, message);
return;
}
if (message instanceof HandshakeMessa... | java | {
"resource": ""
} |
q152154 | SensorIoHandler.sessionClosed | train | @Override
public void sessionClosed(IoSession session) throws Exception {
log.debug("Session closed for sensor {}.", session);
if (this.sensorIoAdapter != null) {
this.sensorIoAdapter.sensorDisconnected(session);
}
} | java | {
"resource": ""
} |
q152155 | SensorIoHandler.sessionOpened | train | @Override
public void sessionOpened(IoSession session) throws Exception {
log.debug("Session opened for sensor {}.", session);
if (this.sensorIoAdapter != null) {
this.sensorIoAdapter.sensorConnected(session);
}
} | java | {
"resource": ""
} |
q152156 | TermExtractionProcessor.onComplete | train | protected Corpus onComplete(Corpus corpus, ProcessorContext context, Counter<String> counts) {
return corpus;
} | java | {
"resource": ""
} |
q152157 | RestBinaryHandlerImpl.getDefaultMimeType | train | @Override
public String getDefaultMimeType(Property binaryProperty) throws RepositoryException {
try {
Binary binary = binaryProperty.getBinary();
return binary instanceof org.modeshape.jcr.api.Binary ? ((org.modeshape.jcr.api.Binary) binary)
.getMimeType() : DEFA... | java | {
"resource": ""
} |
q152158 | CharSequenceUtil.ltrim | train | public static CharSequence ltrim(CharSequence str)
{
int len;
int i;
if(str == null || (len = str.length()) <= 0)
return "";
for(i=0;i<len;i++)
if(!Character.isWhitespace(str.charAt(i)))
break;
if(i>=len)
return "";
return str.subSequence(i, len);
} | java | {
"resource": ""
} |
q152159 | TrackingExecutorService.createTrackingExecutorService | train | public static TrackingExecutorService createTrackingExecutorService(ExecutorService executorService,
Identifiable identifiable) throws IllegalIDException {
return new TrackingExecutorService(executorService, identifiable);
} | java | {
"resource": ""
} |
q152160 | DefaultController.getComponent | train | @SuppressWarnings("unchecked")
public V getComponent() {
if (this.component == null) {
try {
this.component =
(V) Application.getControllerManager().getComponentBuilder()
.build(this);
} catch (Exception e) {
throw new ControllerException("Component Build Error", e);
}
if (this.component == n... | java | {
"resource": ""
} |
q152161 | DefaultController.getRoot | train | @Override
public final Controller getRoot() {
Controller superController = this;
while (superController.getParent() != null) {
superController = superController.getParent();
}
return superController;
} | java | {
"resource": ""
} |
q152162 | Range.valueOf | train | public static Range valueOf(final String value) {
final Optional<Integer[]> vals = parse(value);
if (vals.isPresent()) {
return new Range(vals.get()[0], vals.get()[1]);
}
return null;
} | java | {
"resource": ""
} |
q152163 | MnoStringHelper.toCamelCase | train | public static String toCamelCase(String str) {
String[] wordList = str.toLowerCase().split("_");
String finalStr = "";
for (String word : wordList) {
finalStr += capitalize(word);
}
return finalStr;
} | java | {
"resource": ""
} |
q152164 | AppEngineUpdate.set | train | @Override
public <T> AppEngineUpdate<E> set(Property<?, T> property, T value) {
if (property == null) {
throw new IllegalArgumentException("'property' must not be [" + property + "]");
}
properties.put(property, value);
return this;
} | java | {
"resource": ""
} |
q152165 | AppEngineUpdate.set | train | @Override
public <T> Update<E> set(Property<?, T> property, Modification<T> modification) {
if (property == null) {
throw new IllegalArgumentException("'property' must not be [" + property + "]");
}
properties.put(property, modification);
return this;
} | java | {
"resource": ""
} |
q152166 | EncryptingOutputStream.write | train | @Override
synchronized public void write(final byte data[], final int off,
final int len) throws IOException {
// TODO: Ideally we'd make sure to fill up each message as much as
// we can, but this will work for now!
final byte[] encoded = CommonUtils.encode(this.key, data,... | java | {
"resource": ""
} |
q152167 | FogbugzManager.mapToFogbugzUrl | train | private String mapToFogbugzUrl(Map<String, String> params) throws UnsupportedEncodingException {
String output = this.getFogbugzUrl();
for (String key : params.keySet()) {
String value = params.get(key);
if (!value.isEmpty()) {
output += "&" + URLEncoder.encode(ke... | java | {
"resource": ""
} |
q152168 | FogbugzManager.getFogbugzDocument | train | private Document getFogbugzDocument(Map<String, String> parameters) throws IOException, ParserConfigurationException, SAXException {
URL uri = new URL(this.mapToFogbugzUrl(parameters));
HttpURLConnection con = (HttpURLConnection) uri.openConnection();
DocumentBuilderFactory dbFactory = DocumentB... | java | {
"resource": ""
} |
q152169 | FogbugzManager.getCaseById | train | public FogbugzCase getCaseById(int id) throws InvalidResponseException, NoSuchCaseException {
List<FogbugzCase> caseList = this.searchForCases(Integer.toString(id));
if (caseList.size() > 1) {
throw new InvalidResponseException("Expected one case, found multiple, aborting.");
}
... | java | {
"resource": ""
} |
q152170 | FogbugzManager.searchForCases | train | public List<FogbugzCase> searchForCases(String query) throws InvalidResponseException, NoSuchCaseException {
HashMap<String, String> params = new HashMap<String, String>(); // Hashmap defaults to <String, String>
params.put("cmd", "search");
params.put("q", query);
params.put("cols", "i... | java | {
"resource": ""
} |
q152171 | FogbugzManager.getEventsForCase | train | public List<FogbugzEvent> getEventsForCase(int id) {
try {
HashMap<String, String> params = new HashMap<String, String>(); // Hashmap defaults to <String, String>
params.put("cmd", "search");
params.put("q", Integer.toString(id));
params.put("cols", "events");
... | java | {
"resource": ""
} |
q152172 | FogbugzManager.saveCase | train | public boolean saveCase(FogbugzCase fbCase, String comment) {
try {
HashMap<String, String> params = new HashMap<String, String>();
// If id = 0, create new case.
if (fbCase.getId() == 0) {
params.put("cmd", "new");
params.put("sTitle", fbCase.... | java | {
"resource": ""
} |
q152173 | FogbugzManager.getCustomFieldsCSV | train | private String getCustomFieldsCSV() {
String toReturn = "";
if (this.featureBranchFieldname != null && !this.featureBranchFieldname.isEmpty()) {
toReturn += "," + this.featureBranchFieldname;
}
if (this.originalBranchFieldname != null && !this.originalBranchFieldname.isEmpty(... | java | {
"resource": ""
} |
q152174 | FogbugzManager.getMilestones | train | public List<FogbugzMilestone> getMilestones() {
try {
HashMap<String, String> params = new HashMap<String, String>(); // Hashmap defaults to <String, String>
params.put("cmd", "listFixFors");
Document doc = this.getFogbugzDocument(params);
List<FogbugzMilestone... | java | {
"resource": ""
} |
q152175 | FogbugzManager.createMilestone | train | public boolean createMilestone(FogbugzMilestone milestone) {
try {
HashMap<String, String> params = new HashMap<String, String>();
// If id = 0, create new case.
if (milestone.getId() != 0) {
throw new Exception("Editing existing milestones is not supported, p... | java | {
"resource": ""
} |
q152176 | FileRetriever.getAsStream | train | public InputStream getAsStream() throws CacheException {
try {
if(file.exists() && file.isFile()) {
logger.debug("retrieving file as a stream");
return new FileInputStream(file);
}
} catch(IOException e) {
logger.error("file '{}' does not exist or is not a file", file.getAbsolutePath());
thro... | java | {
"resource": ""
} |
q152177 | FootprintGenerator.footprint | train | public static String footprint(String stringToFootprint) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
return byteArrayToHexString(md.digest(stringToFootprint.getBytes()));
}
catch (NoSuchAlgorithmException nsae) {
LOGGER.warn("Unable to calculate the footprint for string [{}].", stringT... | java | {
"resource": ""
} |
q152178 | ObjectId.toHexString | train | public String toHexString() {
final StringBuilder buf = new StringBuilder(24);
for (final byte b : toByteArray()) {
buf.append(String.format("%02x", b & 0xff));
}
return buf.toString();
} | java | {
"resource": ""
} |
q152179 | Util.firstNotNull | train | @SafeVarargs
public static <T> T firstNotNull(T... args) {
for (T arg : args) {
if (arg != null)
return arg;
}
return null;
} | java | {
"resource": ""
} |
q152180 | Multisets.removeOccurrencesImpl | train | private static <E> boolean removeOccurrencesImpl(
Multiset<E> multisetToModify, Multiset<?> occurrencesToRemove) {
// TODO(user): generalize to removing an Iterable, perhaps
checkNotNull(multisetToModify);
checkNotNull(occurrencesToRemove);
boolean changed = false;
Iterator<Entry<E>> entryIte... | java | {
"resource": ""
} |
q152181 | DaJLabModule.launch | train | public final Thread launch() {
if (state != RUN) {
onLaunch();
state = RUN;
Thread thread = (new Thread(this));
thread.start();
return thread;
} else {
return null;
}
} | java | {
"resource": ""
} |
q152182 | StandardConnectionPool.obtainConnection | train | ConnectionWrapper obtainConnection() {
synchronized (allConnections) {
//fails if connection pool not started
if (!availableConnections.isEmpty()) {
//retrieve and remove first connection from list
// since released connections are added to the back, connections will rotate
ConnectionWrapper connWr... | java | {
"resource": ""
} |
q152183 | StandardConnectionPool.replaceConnection | train | void replaceConnection(ConnectionWrapper connWrap) {
synchronized (allConnections) {
try {
if (usedConnections.remove(connWrap)) {
nrofReset++;
//the object was indeed locked
allConnections.remove(connWrap);
//IMPORTANT does this result in an SQL error which breaks off the connection?
... | java | {
"resource": ""
} |
q152184 | StandardConnectionPool.stop | train | public void stop() {
isStarted = false;
Iterator i = allConnections.iterator();
while (i.hasNext()) {
ConnectionWrapper connWrap = (ConnectionWrapper) i.next();
try {
connWrap.getConnection().close();
} catch (SQLException e) {
nrofErrors++;
System.out.println(new LogEntry(e));
}
}
al... | java | {
"resource": ""
} |
q152185 | StandardConnectionPool.setProperties | train | public void setProperties(Properties properties) throws ConfigurationException {
String dbDriver = properties.getProperty("dbdriver").toString();
if (dbDriver == null) {
throw new ConfigurationException("please specify dbDriver for connectionpool");
}
dbUrl = properties.getProperty("dburl").toString();
db... | java | {
"resource": ""
} |
q152186 | TypeTemplates.getFunctions | train | public HashMap<String, Object> getFunctions(ClassModel classModel) {
HashMap<String, Object> result = newHashMap();
for (String name : functions.keySet()) {
result.put(name, new TemplateFunction(functions.get(name), classModel));
}
return result;
} | java | {
"resource": ""
} |
q152187 | SpringHttpClientImpl._newRestTemplate | train | private RestTemplate _newRestTemplate()
{
RestTemplate template = new RestTemplate();
List<HttpMessageConverter<?>> converters = getMessageConverters();
if (converters != null) {
template.setMessageConverters( getMessageConverters() );
}
return template;
} | java | {
"resource": ""
} |
q152188 | Files.copyFile | train | public static void copyFile(File sourceFile, File destinationFile) throws FileNotFoundException, IOException {
Streams.copyStream(new FileInputStream(sourceFile), new FileOutputStream(destinationFile), true);
} | java | {
"resource": ""
} |
q152189 | RegistryFinder.startRmiRegistryProcess | train | private Registry startRmiRegistryProcess(Configuration configuration, final int port) {
try {
final String javaHome = System.getProperty(JAVA_HOME);
String command = null;
if (javaHome == null) {
command = "rmiregistry";
} else {
i... | java | {
"resource": ""
} |
q152190 | LocalEventManager.registerCaller | train | @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"})
public Optional<EventCallable> registerCaller(Identification identification) throws IllegalIDException {
if(identification == null ||
callers.containsKey(identification)) return Optional.empty();
EventCaller eventCall... | java | {
"resource": ""
} |
q152191 | LocalEventManager.unregisterCaller | train | @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
public void unregisterCaller(Identification identification) {
if(!callers.containsKey(identification)) return;
callers.get(identification).localEvents = null;
callers.remove(identification);
} | java | {
"resource": ""
} |
q152192 | LocalEventManager.fireEvent | train | public void fireEvent(EventModel event) throws IllegalIDException, org.intellimate.izou.events.MultipleEventsException {
if(events == null) return;
if(events.isEmpty()) {
events.add(event);
} else {
throw new org.intellimate.izou.events.MultipleEventsException();
... | java | {
"resource": ""
} |
q152193 | StringConverter.hexToByte | train | public static byte[] hexToByte(String s) throws IOException {
int l = s.length() / 2;
byte data[] = new byte[l];
int j = 0;
if (s.length() % 2 != 0) {
throw new IOException(
"hexadecimal string with odd number of characters");
... | java | {
"resource": ""
} |
q152194 | PhynixxXAResourceFactory.close | train | @Override
public void close() {
// copy all resources as the close of a resource modifies the
// xaresources ...
Set<PhynixxXAResource<T>> tmpXAResources = new HashSet<PhynixxXAResource<T>>();
synchronized (xaresources) {
if (this.xaresources.size() > 0) {
tmpXAResources.addAll(xaresources);
}
}
... | java | {
"resource": ""
} |
q152195 | PooledPhynixxManagedConnectionFactory.setGenericPoolConfig | train | public void setGenericPoolConfig(GenericObjectPoolConfig cfg) throws Exception {
if (this.genericObjectPool != null) {
this.genericObjectPool.close();
}
if (cfg == null) {
cfg = new GenericObjectPoolConfig();
}
this.genericObjectPool = new GenericObjectPoo... | java | {
"resource": ""
} |
q152196 | PooledPhynixxManagedConnectionFactory.releaseConnection | train | public void releaseConnection(IPhynixxManagedConnection<C> connection) {
if (connection == null || !connection.hasCoreConnection()) {
return;
}
try {
//StringBuilder builder= new StringBuilder(Thread.currentThread().getId()+".releaseConnection starting from "+this.generic... | java | {
"resource": ""
} |
q152197 | PooledPhynixxManagedConnectionFactory.connectionReleased | train | public void connectionReleased(IManagedConnectionEvent<C> event) {
IPhynixxManagedConnection<C> proxy = event.getManagedConnection();
if (!proxy.hasCoreConnection()) {
return;
} else {
this.releaseConnection(proxy);
}
if (LOG.isDebugEnabled()) {
... | java | {
"resource": ""
} |
q152198 | PooledPhynixxManagedConnectionFactory.connectionFreed | train | public void connectionFreed(IManagedConnectionEvent<C> event) {
IPhynixxManagedConnection<C> proxy = event.getManagedConnection();
if (!proxy.hasCoreConnection()) {
return;
} else {
this.freeConnection(proxy);
}
if (LOG.isDebugEnabled()) {
LOG.... | java | {
"resource": ""
} |
q152199 | MapConstraints.constrainedMultimap | train | public static <K, V> Multimap<K, V> constrainedMultimap(
Multimap<K, V> multimap, MapConstraint<? super K, ? super V> constraint) {
return new ConstrainedMultimap<K, V>(multimap, constraint);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.