id stringlengths 7 14 | text stringlengths 1 106k |
|---|---|
1307227_9 | public static LoggerStore createLoggerStore(final String configuratorType, final String resource) {
final InitialLoggerStoreFactory factory = new InitialLoggerStoreFactory();
final Map<String, Object> data = new HashMap<String, Object>();
data.put(INITIAL_FACTORY, getFactoryClassName(configuratorType));
data.put(FILE_LOCATION, resource);
return factory.createLoggerStore(data);
} |
1312627_0 | public void ping() throws IOException {
pingCount++;
StringBuffer uri = new StringBuffer("http://" + address + "/" + "?");
for (String key : usageDataMap.keySet()) {
uri.append(key);
uri.append("=");
uri.append(usageDataMap.get(key));
uri.append("+");
}
// append counts
if ( pingCount == 0 )
{
uri.append( "p=-1" );
pingCount++;
}
else
{
uri.append( "p=" ).append( pingCount );
}
URL url = new URL(uri.toString());
URLConnection con = url.openConnection();
con.setDoInput(true);
con.setDoOutput(false);
con.setUseCaches(false);
con.connect();
con.getInputStream();
} |
1312627_1 | public void ping() throws IOException {
pingCount++;
StringBuffer uri = new StringBuffer("http://" + address + "/" + "?");
for (String key : usageDataMap.keySet()) {
uri.append(key);
uri.append("=");
uri.append(usageDataMap.get(key));
uri.append("+");
}
// append counts
if ( pingCount == 0 )
{
uri.append( "p=-1" );
pingCount++;
}
else
{
uri.append( "p=" ).append( pingCount );
}
URL url = new URL(uri.toString());
URLConnection con = url.openConnection();
con.setDoInput(true);
con.setDoOutput(false);
con.setUseCaches(false);
con.connect();
con.getInputStream();
} |
1312627_2 | public void ping() throws IOException {
pingCount++;
StringBuffer uri = new StringBuffer("http://" + address + "/" + "?");
for (String key : usageDataMap.keySet()) {
uri.append(key);
uri.append("=");
uri.append(usageDataMap.get(key));
uri.append("+");
}
// append counts
if ( pingCount == 0 )
{
uri.append( "p=-1" );
pingCount++;
}
else
{
uri.append( "p=" ).append( pingCount );
}
URL url = new URL(uri.toString());
URLConnection con = url.openConnection();
con.setDoInput(true);
con.setDoOutput(false);
con.setUseCaches(false);
con.connect();
con.getInputStream();
} |
1312627_3 | public String getName()
{
return this.identifier.indexName;
} |
1312627_4 | public IndexHits<T> get( String key, Object value )
{
return query( type.get( key, value ), key, value, null );
} |
1312627_5 | public static String getKernelRevision()
{
return KERNEL_VERSION.getRevision();
} |
1312627_6 | public boolean contains( int id )
{
for ( int i = 0; i < arrayCount; i++ )
{
if ( rels[i] == id )
{
return true;
}
}
if ( arrayCount == -1 )
{
return relationshipSet.contains( id );
}
return false;
} |
1312627_7 | public ArrayMap()
{
useThreadSafeMap = false;
arrayEntries = new ArrayEntry[toMapThreshold];
} |
1312627_8 | public TxLog( String fileName ) throws IOException
{
if ( fileName == null )
{
throw new IllegalArgumentException( "Null filename" );
}
fileChannel = new RandomAccessFile( fileName, "rw" ).getChannel();
fileChannel.position( fileChannel.size() );
buffer = ByteBuffer.allocateDirect(
(3 + Xid.MAXGTRIDSIZE + Xid.MAXBQUALSIZE) * 1000 );
this.name = fileName;
} |
1312627_9 | public synchronized void resize( int newMaxSize )
{
if ( newMaxSize < 1 )
{
throw new IllegalArgumentException( "newMaxSize=" + newMaxSize );
}
resizeInternal( newMaxSize );
} |
1313372_0 | @Override
public void parse(Reader in) throws IOException {
texte = new StringBuilder(1024);
ParserDelegator delegator = new ParserDelegator();
delegator.parse(in, this, true);
} |
1313372_1 | public boolean isSpam() throws MessagingException {
String[] spamFlags = this.mimeMessage.getHeader(SPAM_FLAG_HEADER);
if (spamFlags != null) {
for (String flag : spamFlags) {
if ("YES".equalsIgnoreCase(flag)) {
return true;
}
}
}
return false;
} |
1313372_2 | public float getSpamLevel() throws MessagingException {
String[] spamScores = this.mimeMessage.getHeader(SPAM_LEVEL_HEADER);
if (spamScores != null && spamScores.length > 0) {
return Float.parseFloat(spamScores[0]);
}
return 0f;
} |
1313372_3 | public boolean isBounced() throws IOException, MessagingException {
if (isAutomaticMessage()) {
return true;
}
if (mimeMessage.getContent() instanceof Multipart) {
Multipart parts = (Multipart) this.mimeMessage.getContent();
for (int i = 0; i < parts.getCount(); i++) {
String contentType = parts.getBodyPart(i).getContentType();
if (isNotification(contentType)) {
return true;
}
}
}
return isNotification(this.mimeMessage.getContentType());
} |
1313372_4 | protected boolean isAutomaticMessage() throws MessagingException {
String[] autoSubmittedHeaders = this.mimeMessage.getHeader(AUTO_SUBMITTED_HEADER);
if (autoSubmittedHeaders != null) {
for (String autoSubmittedHeader : autoSubmittedHeaders) {
if ("auto-generated".equalsIgnoreCase(autoSubmittedHeader) ||
"auto-replied".equalsIgnoreCase(autoSubmittedHeader) ||
autoSubmittedHeader.startsWith("auto-notified")) {
return true;
}
}
}
return false;
} |
1313372_5 | protected boolean isNotification(String contentType) {
return isDeliveryStatus(contentType) || isMessageReport(contentType);
} |
1313372_6 | protected boolean isDeliveryStatus(String contentType) {
return "message/delivery-status".equalsIgnoreCase(contentType);
} |
1313372_7 | protected boolean isMessageReport(String contentType) {
return contentType.startsWith("multipart/report");
} |
1313372_8 | public boolean isVisible() {
Date today = DateUtil.getDate();
return isVisible(today);
} |
1313372_9 | public void addToAlbums(String... albumIds) {
MediaServiceProvider.getMediaService().addMediaToAlbums(this, albumIds);
} |
1318639_0 | @Override
public OrbTrackerMemberData[] getOrbTrackerMemberData() throws ZooKeeperConnectionException,
WatcherException,
NodeDoesNotExistException {
if (zk == null) {
try {
initializeZooKeeper();
memberDataContainer = new HashMap<String,OrbTrackerMemberData>();
} catch (Exception e) {
e.printStackTrace();
throw new ZooKeeperConnectionException(e);
}
}
// Initialize leader group watcher
if (leaderGroupWatcher == null) {
try {
initializeLeaderGroupMonitor();
} catch (OrbZKFailure e) {
throw new WatcherException(e);
}
}
return memberDataContainer.values().toArray(new OrbTrackerMemberData[0]);
} |
1318639_1 | @Override
public String[] getJobsInQueue() throws NodeDoesNotExistException,
ZooKeeperConnectionException,
WatcherException {
if (zk == null) {
try {
initializeZooKeeper();
} catch (Exception e) {
throw new ZooKeeperConnectionException(e);
}
}
if (jobQueueWatcher == null) {
try {
initializeJobMonitor("JobQueue");
} catch (OrbZKFailure e) {
throw new WatcherException(e);
}
}
return jobsInQueue;
} |
1318639_2 | @Override
public String[] getJobsInProgress() throws NodeDoesNotExistException,
ZooKeeperConnectionException,
WatcherException {
if (zk == null) {
try {
initializeZooKeeper();
} catch (Exception e) {
throw new ZooKeeperConnectionException(e);
}
}
if (jobsInProgressWatcher == null) {
try {
initializeJobMonitor("JobsInProgress");
} catch (OrbZKFailure e) {
throw new WatcherException(e);
}
}
return jobsInProgress;
} |
1319605_0 | InputStream getInputStream(final String path) throws IOException {
final List<URL> urls = Collections.list(loader.getResources(path));
Exceptions.raiseIf(urls.stream().distinct().count() > 1, ValidationException::new,
"More than one %s is found in the classpath", path);
return urls.isEmpty() ? null : urls.get(0).openStream();
} |
1319605_1 | InputStream getInputStream(final String path) throws IOException {
final List<URL> urls = Collections.list(loader.getResources(path));
Exceptions.raiseIf(urls.stream().distinct().count() > 1, ValidationException::new,
"More than one %s is found in the classpath", path);
return urls.isEmpty() ? null : urls.get(0).openStream();
} |
1319605_2 | public BootstrapConfiguration processValidationConfig(final String file,
final ConfigurationImpl targetConfig) {
final ValidationConfigType xmlConfig = parseXmlConfig(file);
if (xmlConfig == null) {
return null;
}
final boolean executableValidationEnabled;
final Set<ExecutableType> defaultValidatedExecutableTypes;
if (xmlConfig.getExecutableValidation() == null) {
defaultValidatedExecutableTypes = EnumSet.of(ExecutableType.IMPLICIT);
executableValidationEnabled = true;
} else {
final Optional<ExecutableValidationType> executableValidation =
Optional.of(xmlConfig).map(ValidationConfigType::getExecutableValidation);
executableValidationEnabled = executableValidation.map(ExecutableValidationType::getEnabled)
.filter(Predicate.isEqual(Boolean.TRUE)).isPresent();
defaultValidatedExecutableTypes = executableValidation.filter(x -> executableValidationEnabled)
.map(ExecutableValidationType::getDefaultValidatedExecutableTypes)
.map(DefaultValidatedExecutableTypesType::getExecutableType).map(EnumSet::copyOf)
.orElse(EnumSet.noneOf(ExecutableType.class));
}
return new BootstrapConfigurationImpl(xmlConfig.getDefaultProvider(), xmlConfig.getConstraintValidatorFactory(),
xmlConfig.getMessageInterpolator(), xmlConfig.getTraversableResolver(),
xmlConfig.getParameterNameProvider(), new HashSet<>(xmlConfig.getConstraintMapping()),
executableValidationEnabled, defaultValidatedExecutableTypes, toMap(xmlConfig.getProperty()),
xmlConfig.getClockProvider(), new HashSet<>(xmlConfig.getValueExtractor()));
} |
1319605_3 | public BootstrapConfiguration processValidationConfig(final String file,
final ConfigurationImpl targetConfig) {
final ValidationConfigType xmlConfig = parseXmlConfig(file);
if (xmlConfig == null) {
return null;
}
final boolean executableValidationEnabled;
final Set<ExecutableType> defaultValidatedExecutableTypes;
if (xmlConfig.getExecutableValidation() == null) {
defaultValidatedExecutableTypes = EnumSet.of(ExecutableType.IMPLICIT);
executableValidationEnabled = true;
} else {
final Optional<ExecutableValidationType> executableValidation =
Optional.of(xmlConfig).map(ValidationConfigType::getExecutableValidation);
executableValidationEnabled = executableValidation.map(ExecutableValidationType::getEnabled)
.filter(Predicate.isEqual(Boolean.TRUE)).isPresent();
defaultValidatedExecutableTypes = executableValidation.filter(x -> executableValidationEnabled)
.map(ExecutableValidationType::getDefaultValidatedExecutableTypes)
.map(DefaultValidatedExecutableTypesType::getExecutableType).map(EnumSet::copyOf)
.orElse(EnumSet.noneOf(ExecutableType.class));
}
return new BootstrapConfigurationImpl(xmlConfig.getDefaultProvider(), xmlConfig.getConstraintValidatorFactory(),
xmlConfig.getMessageInterpolator(), xmlConfig.getTraversableResolver(),
xmlConfig.getParameterNameProvider(), new HashSet<>(xmlConfig.getConstraintMapping()),
executableValidationEnabled, defaultValidatedExecutableTypes, toMap(xmlConfig.getProperty()),
xmlConfig.getClockProvider(), new HashSet<>(xmlConfig.getValueExtractor()));
} |
1319605_4 | public BootstrapConfiguration processValidationConfig(final String file,
final ConfigurationImpl targetConfig) {
final ValidationConfigType xmlConfig = parseXmlConfig(file);
if (xmlConfig == null) {
return null;
}
final boolean executableValidationEnabled;
final Set<ExecutableType> defaultValidatedExecutableTypes;
if (xmlConfig.getExecutableValidation() == null) {
defaultValidatedExecutableTypes = EnumSet.of(ExecutableType.IMPLICIT);
executableValidationEnabled = true;
} else {
final Optional<ExecutableValidationType> executableValidation =
Optional.of(xmlConfig).map(ValidationConfigType::getExecutableValidation);
executableValidationEnabled = executableValidation.map(ExecutableValidationType::getEnabled)
.filter(Predicate.isEqual(Boolean.TRUE)).isPresent();
defaultValidatedExecutableTypes = executableValidation.filter(x -> executableValidationEnabled)
.map(ExecutableValidationType::getDefaultValidatedExecutableTypes)
.map(DefaultValidatedExecutableTypesType::getExecutableType).map(EnumSet::copyOf)
.orElse(EnumSet.noneOf(ExecutableType.class));
}
return new BootstrapConfigurationImpl(xmlConfig.getDefaultProvider(), xmlConfig.getConstraintValidatorFactory(),
xmlConfig.getMessageInterpolator(), xmlConfig.getTraversableResolver(),
xmlConfig.getParameterNameProvider(), new HashSet<>(xmlConfig.getConstraintMapping()),
executableValidationEnabled, defaultValidatedExecutableTypes, toMap(xmlConfig.getProperty()),
xmlConfig.getClockProvider(), new HashSet<>(xmlConfig.getValueExtractor()));
} |
1319605_5 | public static PathImpl createPathFromString(String propertyPath) {
if (propertyPath == null || propertyPath.isEmpty()) {
return create();
}
return PathNavigation.navigateAndReturn(propertyPath, new Builder());
} |
1319605_6 | public static PathImpl createPathFromString(String propertyPath) {
if (propertyPath == null || propertyPath.isEmpty()) {
return create();
}
return PathNavigation.navigateAndReturn(propertyPath, new Builder());
} |
1319605_7 | public static PathImpl createPathFromString(String propertyPath) {
if (propertyPath == null || propertyPath.isEmpty()) {
return create();
}
return PathNavigation.navigateAndReturn(propertyPath, new Builder());
} |
1319605_8 | public static PathImpl createPathFromString(String propertyPath) {
if (propertyPath == null || propertyPath.isEmpty()) {
return create();
}
return PathNavigation.navigateAndReturn(propertyPath, new Builder());
} |
1319605_9 | @Override
public String toString() {
final StringBuilder builder = new StringBuilder();
for (Path.Node node : this) {
NodeImpl.appendNode(node, builder);
}
return builder.toString();
} |
1320181_0 | public static <T> T transportFromPersistence(final Class<T> clazz, final Object persistent)
throws Exception
{
return transform(clazz, clazz, persistent);
} |
1320181_1 | public Category findDefault()
{
return getSingleResult(createCriteria(isDefault()));
} |
1320181_2 | public Category findDefault()
{
return getSingleResult(createCriteria(isDefault()));
} |
1320181_3 | public Category findByNameAndEnterprise(final String categoryName, final Enterprise enterprise)
{
Query query;
if (enterprise == null)
{
query = getSession().createQuery(BY_NAME_AND_NO_ENTERPRISE);
}
else
{
query = getSession().createQuery(BY_NAME_AND_ENTERPRISE);
query.setParameter("idEnterprise", enterprise.getId());
}
query.setParameter("name", categoryName);
List<Category> results = query.list();
if (!results.isEmpty())
{
return results.get(0);
}
return null;
} |
1320181_4 | public Category findByNameAndEnterprise(final String categoryName, final Enterprise enterprise)
{
Query query;
if (enterprise == null)
{
query = getSession().createQuery(BY_NAME_AND_NO_ENTERPRISE);
}
else
{
query = getSession().createQuery(BY_NAME_AND_ENTERPRISE);
query.setParameter("idEnterprise", enterprise.getId());
}
query.setParameter("name", categoryName);
List<Category> results = query.list();
if (!results.isEmpty())
{
return results.get(0);
}
return null;
} |
1320181_5 | public boolean existsAnyWithName(final String name)
{
return existsAnyByCriterions(equalsName(name));
} |
1320181_6 | public List<VirtualMachineTemplate> findByEnterprise(final Enterprise enterprise)
{
Criteria criteria = createCriteria(sameEnterpriseOrShared(enterprise));
criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
return getResultList(criteria);
} |
1320181_7 | public List<VirtualMachineTemplate> findByEnterpriseAndRepository(final Enterprise enterprise,
final com.abiquo.server.core.infrastructure.Repository repository)
{
Criteria criteria = createCriteria(sameEnterpriseOrSharedInRepo(enterprise, repository));
criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
return getResultList(criteria);
} |
1320181_8 | public VirtualMachineTemplate findByName(final String name)
{
return findUniqueByProperty(VirtualMachineTemplate.NAME_PROPERTY, name);
} |
1320181_9 | public VirtualMachineTemplate findByPath(final Enterprise enterprise,
final com.abiquo.server.core.infrastructure.Repository repository, final String path)
{
Criteria criteria =
createCriteria(sameEnterpriseOrSharedInRepo(enterprise, repository, path));
criteria.addOrder(Order.asc(VirtualMachine.NAME_PROPERTY));
return getSingleResult(criteria);
} |
1322545_0 | public static boolean validateUrl(String url) {
if (TextUtils.isEmpty(url)) {
return false;
}
pattern = Pattern.compile(URL_PATTERN);
matcher = pattern.matcher(url);
if (matcher.matches()) {
return true;
}
return false;
} |
1322545_1 | public static boolean validateUrl(String url) {
if (TextUtils.isEmpty(url)) {
return false;
}
pattern = Pattern.compile(URL_PATTERN);
matcher = pattern.matcher(url);
if (matcher.matches()) {
return true;
}
return false;
} |
1322545_2 | public static String capitalizeFirstLetter(String text) {
if (text == null) {
return null;
} else if (text.length() == 0) {
return "";
} else if (text.length() == 1) {
return text.toUpperCase();
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} |
1322545_3 | public static String capitalizeFirstLetter(String text) {
if (text == null) {
return null;
} else if (text.length() == 0) {
return "";
} else if (text.length() == 1) {
return text.toUpperCase();
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} |
1322545_4 | public static String capitalizeFirstLetter(String text) {
if (text == null) {
return null;
} else if (text.length() == 0) {
return "";
} else if (text.length() == 1) {
return text.toUpperCase();
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} |
1322545_5 | public static String capitalizeFirstLetter(String text) {
if (text == null) {
return null;
} else if (text.length() == 0) {
return "";
} else if (text.length() == 1) {
return text.toUpperCase();
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} |
1322545_6 | public static String capitalizeFirstLetter(String text) {
if (text == null) {
return null;
} else if (text.length() == 0) {
return "";
} else if (text.length() == 1) {
return text.toUpperCase();
}
return text.substring(0, 1).toUpperCase() + text.substring(1);
} |
1322545_7 | public boolean routeSms(Message message) {
Logger.log(TAG, "routeSms uuid: " + message.toString());
// Double check if SMSsync service is running
if (!mPrefsFactory.serviceEnabled().get()) {
return false;
}
// Send auto response from phone not server
if (mPrefsFactory.enableReply().get()) {
// send auto response as SMS to user's phone
logActivities(R.string.auto_response_sent);
Message msg = new Message();
msg.setMessageBody(mPrefsFactory.reply().get());
msg.setMessageFrom(message.getMessageFrom());
msg.setMessageType(message.getMessageType());
mProcessSms.sendSms(map(msg), false);
}
if (isConnected()) {
List<SyncUrl> syncUrlList = mWebServiceDataSource
.get(SyncUrl.Status.ENABLED);
List<Filter> filters = mFilterDataSource.getFilters();
for (SyncUrl syncUrl : syncUrlList) {
// Process if white-listing is enabled
if (mPrefsFactory.enableWhitelist().get()) {
// TODO: Check for potential NPE for filters
for (Filter filter : filters) {
// Make sure phone number matches and it's indeed whitelisted
if ((filter.getPhoneNumber().equals(message.getMessageFrom())) && (filter
.getStatus().equals(Filter.Status.WHITELIST))) {
if (postMessage(message, syncUrl)) {
postToSentBox(message);
deleteFromSmsInbox(message);
} else {
savePendingMessage(message);
}
}
}
}
if (mPrefsFactory.enableBlacklist().get()) {
// Process blacklist
// TODO: Check for potential NPE for filters
for (Filter filter : filters) {
// Make sure phone number doesn't match and not blacklisted
if ((filter.getPhoneNumber().equals(message.getMessageFrom())) && (!filter
.getStatus().equals(Filter.Status.BLACKLIST))) {
if (postMessage(message, syncUrl)) {
postToSentBox(message);
deleteFromSmsInbox(message);
} else {
savePendingMessage(message);
}
}
}
}
if ((!mPrefsFactory.enableBlacklist().get()) && (!mPrefsFactory.enableWhitelist()
.get())) {
if (postMessage(message, syncUrl)) {
postToSentBox(message);
deleteFromSmsInbox(message);
} else {
savePendingMessage(message);
}
}
}
return true;
}
// There is no internet save message
savePendingMessage(message);
return false;
} |
1322545_8 | public String getPhoneNumber() {
return Utility.getPhoneNumber(mContext, mPrefsFactory);
} |
1322545_9 | @Override
protected Observable buildUseCaseObservable() {
return mFilterRepository.getEntities();
} |
1328283_0 | @Override
public void hash(ByteBuffer value, int hashSize, byte[] hashBytes) {
int seed = INITIAL_SEED;
long hashValue;
for (int i = 0; i <= hashSize - 8; i += 8) {
hashValue = murmurHash64(value, seed);
seed = (int) hashValue;
hashBytes[i] = (byte) ((hashValue >> 56) & 0xff);
hashBytes[i + 1] = (byte) ((hashValue >> 48) & 0xff);
hashBytes[i + 2] = (byte) ((hashValue >> 40) & 0xff);
hashBytes[i + 3] = (byte) ((hashValue >> 32) & 0xff);
hashBytes[i + 4] = (byte) ((hashValue >> 24) & 0xff);
hashBytes[i + 5] = (byte) ((hashValue >> 16) & 0xff);
hashBytes[i + 6] = (byte) ((hashValue >> 8) & 0xff);
hashBytes[i + 7] = (byte) ((hashValue) & 0xff);
}
int shortHashBytes = hashSize % 8;
if (shortHashBytes > 0) {
hashValue = murmurHash64(value, seed);
int off = hashSize - 1;
switch (shortHashBytes) {
case 7:
hashBytes[off--] = (byte) ((hashValue >> 8) & 0xff);
case 6:
hashBytes[off--] = (byte) ((hashValue >> 16) & 0xff);
case 5:
hashBytes[off--] = (byte) ((hashValue >> 24) & 0xff);
case 4:
hashBytes[off--] = (byte) ((hashValue >> 32) & 0xff);
case 3:
hashBytes[off--] = (byte) ((hashValue >> 40) & 0xff);
case 2:
hashBytes[off--] = (byte) ((hashValue >> 48) & 0xff);
case 1:
hashBytes[off--] = (byte) ((hashValue >> 56) & 0xff);
}
}
} |
1328283_1 | @Override
public void hash(ByteBuffer value, int hashSize, byte[] hashBytes) {
int seed = INITIAL_SEED;
long hashValue;
for (int i = 0; i <= hashSize - 8; i += 8) {
hashValue = murmurHash64(value, seed);
seed = (int) hashValue;
hashBytes[i] = (byte) ((hashValue >> 56) & 0xff);
hashBytes[i + 1] = (byte) ((hashValue >> 48) & 0xff);
hashBytes[i + 2] = (byte) ((hashValue >> 40) & 0xff);
hashBytes[i + 3] = (byte) ((hashValue >> 32) & 0xff);
hashBytes[i + 4] = (byte) ((hashValue >> 24) & 0xff);
hashBytes[i + 5] = (byte) ((hashValue >> 16) & 0xff);
hashBytes[i + 6] = (byte) ((hashValue >> 8) & 0xff);
hashBytes[i + 7] = (byte) ((hashValue) & 0xff);
}
int shortHashBytes = hashSize % 8;
if (shortHashBytes > 0) {
hashValue = murmurHash64(value, seed);
int off = hashSize - 1;
switch (shortHashBytes) {
case 7:
hashBytes[off--] = (byte) ((hashValue >> 8) & 0xff);
case 6:
hashBytes[off--] = (byte) ((hashValue >> 16) & 0xff);
case 5:
hashBytes[off--] = (byte) ((hashValue >> 24) & 0xff);
case 4:
hashBytes[off--] = (byte) ((hashValue >> 32) & 0xff);
case 3:
hashBytes[off--] = (byte) ((hashValue >> 40) & 0xff);
case 2:
hashBytes[off--] = (byte) ((hashValue >> 48) & 0xff);
case 1:
hashBytes[off--] = (byte) ((hashValue >> 56) & 0xff);
}
}
} |
1328283_2 | @Override
public void hash(ByteBuffer value, int hashSize, byte[] hashBytes) {
int seed = INITIAL_SEED;
long hashValue;
for (int i = 0; i <= hashSize - 8; i += 8) {
hashValue = murmurHash64(value, seed);
seed = (int) hashValue;
hashBytes[i] = (byte) ((hashValue >> 56) & 0xff);
hashBytes[i + 1] = (byte) ((hashValue >> 48) & 0xff);
hashBytes[i + 2] = (byte) ((hashValue >> 40) & 0xff);
hashBytes[i + 3] = (byte) ((hashValue >> 32) & 0xff);
hashBytes[i + 4] = (byte) ((hashValue >> 24) & 0xff);
hashBytes[i + 5] = (byte) ((hashValue >> 16) & 0xff);
hashBytes[i + 6] = (byte) ((hashValue >> 8) & 0xff);
hashBytes[i + 7] = (byte) ((hashValue) & 0xff);
}
int shortHashBytes = hashSize % 8;
if (shortHashBytes > 0) {
hashValue = murmurHash64(value, seed);
int off = hashSize - 1;
switch (shortHashBytes) {
case 7:
hashBytes[off--] = (byte) ((hashValue >> 8) & 0xff);
case 6:
hashBytes[off--] = (byte) ((hashValue >> 16) & 0xff);
case 5:
hashBytes[off--] = (byte) ((hashValue >> 24) & 0xff);
case 4:
hashBytes[off--] = (byte) ((hashValue >> 32) & 0xff);
case 3:
hashBytes[off--] = (byte) ((hashValue >> 40) & 0xff);
case 2:
hashBytes[off--] = (byte) ((hashValue >> 48) & 0xff);
case 1:
hashBytes[off--] = (byte) ((hashValue >> 56) & 0xff);
}
}
} |
1328283_3 | @Override
public void hash(ByteBuffer value, int hashSize, byte[] hashBytes) {
int seed = INITIAL_SEED;
long hashValue;
for (int i = 0; i <= hashSize - 8; i += 8) {
hashValue = murmurHash64(value, seed);
seed = (int) hashValue;
hashBytes[i] = (byte) ((hashValue >> 56) & 0xff);
hashBytes[i + 1] = (byte) ((hashValue >> 48) & 0xff);
hashBytes[i + 2] = (byte) ((hashValue >> 40) & 0xff);
hashBytes[i + 3] = (byte) ((hashValue >> 32) & 0xff);
hashBytes[i + 4] = (byte) ((hashValue >> 24) & 0xff);
hashBytes[i + 5] = (byte) ((hashValue >> 16) & 0xff);
hashBytes[i + 6] = (byte) ((hashValue >> 8) & 0xff);
hashBytes[i + 7] = (byte) ((hashValue) & 0xff);
}
int shortHashBytes = hashSize % 8;
if (shortHashBytes > 0) {
hashValue = murmurHash64(value, seed);
int off = hashSize - 1;
switch (shortHashBytes) {
case 7:
hashBytes[off--] = (byte) ((hashValue >> 8) & 0xff);
case 6:
hashBytes[off--] = (byte) ((hashValue >> 16) & 0xff);
case 5:
hashBytes[off--] = (byte) ((hashValue >> 24) & 0xff);
case 4:
hashBytes[off--] = (byte) ((hashValue >> 32) & 0xff);
case 3:
hashBytes[off--] = (byte) ((hashValue >> 40) & 0xff);
case 2:
hashBytes[off--] = (byte) ((hashValue >> 48) & 0xff);
case 1:
hashBytes[off--] = (byte) ((hashValue >> 56) & 0xff);
}
}
} |
1328283_4 | @Override
public void hash(ByteBuffer value, int hashSize, byte[] hashBytes) {
if (value.remaining() > hashSize) {
throw new IllegalArgumentException("Cannot pad incoming item "+value+" to length "+hashSize+"!");
}
int bytesToPad = hashSize - value.remaining();
System.arraycopy(value.array(), value.arrayOffset() + value.position(), hashBytes, bytesToPad, value.remaining());
} |
1328283_5 | public static void encodeLittleEndianFixedWidthLong(long l, byte[] array) {
encodeLittleEndianFixedWidthLong(l, array, 0, array.length);
} |
1328283_6 | public static long decodeLittleEndianFixedWidthLong(ByteBuffer buffer) {
return decodeLittleEndianFixedWidthLong(buffer.array(),
buffer.arrayOffset() + buffer.position(),
buffer.remaining());
} |
1328283_7 | public static int encodeLittleEndianVarInt(int n, byte[] buffer) {
if (n == 0) {
buffer[0] = 0;
return 1;
}
int i = 0;
while (n > 0) {
byte b = (byte) (n & 0x7f);
n >>= 7;
if (n > 0) {
b |= 0x80;
}
buffer[i++] = b;
}
return i;
} |
1328283_8 | public static int decodeLittleEndianVarInt(ByteBuffer buffer) {
byte b = buffer.get();
int result = b & 0x7f;
if ((b & 0x80) > 0) {
b = buffer.get();
result |= ((b & 0x7f) << 7);
if ((b & 0x80) > 0) {
b = buffer.get();
result |= ((b & 0x7f) << 14);
if ((b & 0x80) > 0) {
b = buffer.get();
result |= ((b & 0x7f) << 21);
if ((b & 0x80) > 0) {
b = buffer.get();
result |= ((b & 0x07) << 28);
}
}
}
}
return result;
} |
1328283_9 | @Override
public boolean claimRingGroupConductor(RingGroupConductorMode mode) throws IOException {
try {
if (zk.exists(ringGroupConductorOnlinePath, false) == null) {
zk.create(ringGroupConductorOnlinePath, BytesUtils.stringToBytes(mode.toString()), CreateMode.EPHEMERAL);
return true;
}
return false;
} catch (Exception e) {
throw new IOException(e);
}
} |
1337781_0 | <T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) {
return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes);
} |
1337781_1 | <T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) {
return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes);
} |
1337781_2 | <T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) {
return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes);
} |
1337781_3 | <T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) {
return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes);
} |
1337781_4 | <T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) {
return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes);
} |
1337781_5 | @Override
public boolean canProvide(Class<?> type) {
return type.getName().equals(getReturnType());
} |
1337781_6 | @Override
public boolean canProvide(Class<?> type) {
return type.getName().equals(getReturnType());
} |
1337781_7 | @Override
public void enrich(final SearchContext searchContext, Object target) {
List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target);
for (Field field : fields) {
GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext)
.getGrapheneContext();
final SearchContext localSearchContext;
if (grapheneContext == null) {
grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations()));
localSearchContext = grapheneContext.getWebDriver(SearchContext.class);
} else {
localSearchContext = searchContext;
}
// Page fragment
if (isPageFragmentClass(field.getType(), target)) {
setupPageFragment(localSearchContext, target, field);
// List<Page fragment>
} else {
try {
if (field.getType().isAssignableFrom(List.class) && isPageFragmentClass(getListType(field), target)) {
setupPageFragmentList(localSearchContext, target, field);
}
} catch (ClassNotFoundException e) {
throw new PageFragmentInitializationException(e.getMessage(), e);
}
}
}
} |
1337781_8 | @Override
public void enrich(final SearchContext searchContext, Object target) {
List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target);
for (Field field : fields) {
GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext)
.getGrapheneContext();
final SearchContext localSearchContext;
if (grapheneContext == null) {
grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations()));
localSearchContext = grapheneContext.getWebDriver(SearchContext.class);
} else {
localSearchContext = searchContext;
}
// Page fragment
if (isPageFragmentClass(field.getType(), target)) {
setupPageFragment(localSearchContext, target, field);
// List<Page fragment>
} else {
try {
if (field.getType().isAssignableFrom(List.class) && isPageFragmentClass(getListType(field), target)) {
setupPageFragmentList(localSearchContext, target, field);
}
} catch (ClassNotFoundException e) {
throw new PageFragmentInitializationException(e.getMessage(), e);
}
}
}
} |
1337781_9 | @Override
public void enrich(final SearchContext searchContext, Object target) {
List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target);
for (Field field : fields) {
GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext)
.getGrapheneContext();
final SearchContext localSearchContext;
if (grapheneContext == null) {
grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations()));
localSearchContext = grapheneContext.getWebDriver(SearchContext.class);
} else {
localSearchContext = searchContext;
}
// Page fragment
if (isPageFragmentClass(field.getType(), target)) {
setupPageFragment(localSearchContext, target, field);
// List<Page fragment>
} else {
try {
if (field.getType().isAssignableFrom(List.class) && isPageFragmentClass(getListType(field), target)) {
setupPageFragmentList(localSearchContext, target, field);
}
} catch (ClassNotFoundException e) {
throw new PageFragmentInitializationException(e.getMessage(), e);
}
}
}
} |
1338456_0 | public static <T> byte[] fromObject(T value)
{
ON_MAPPER.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
ON_MAPPER.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
ON_MAPPER.getSerializationConfig().withSerializationInclusion(Include.NON_NULL);
JSON_MAPPER.getSerializationConfig().setDateFormat(myDateFormat);
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
JSON_MAPPER.writeValue(out, value);
return out.toByteArray();
} catch (Exception e) {
logger.error("Cannot map POJO to JSON: ", e);
hrow new IllegalStateException("Cannot map POJO to JSON: "
+ e.getMessage());
}
} |
1338456_1 | public void add(final LabelCounters diff)
{
if (diff.totalBytes != null) {
this.totalBytes += diff.totalBytes;
}
if (diff.totalMessages != null) {
this.totalMessages += diff.totalMessages;
}
if (diff.unreadMessages != null) {
this.unreadMessages += diff.unreadMessages;
}
} |
1338456_2 | static String getLabelKey(final String mailbox, final int label)
{
return getLabelKey(mailbox, Integer.toString(label));
} |
1338456_3 | static String getLabelKey(final String mailbox, final int label)
{
return getLabelKey(mailbox, Integer.toString(label));
} |
1341207_0 | @Override
@Nonnull
public List<L> getListeners() {
final List<L> result;
synchronized (listeners) {
result = new ArrayList<L>(listeners.size());
// copy listeners and remove garbage collected references
for (Iterator<R> it = listeners.iterator(); it.hasNext(); ) {
final R r = it.next();
final L l = r.get();
if (l == null) {
it.remove();
} else {
result.add(l);
}
}
}
return result;
} |
1341207_1 | @Nonnull
@Override
public <LE extends L> List<LE> getListenersOfType(@Nonnull Class<LE> type) {
final List<L> listeners = getListeners();
final List<LE> result = new ArrayList<LE>(listeners.size());
for (L listener : listeners) {
if (type.isAssignableFrom(listener.getClass())) {
result.add((LE) listener);
}
}
return result;
} |
1341207_2 | @Override
public void fireEvent(@Nonnull final E event) {
fireEvents(Arrays.asList(event));
} |
1341207_3 | @Override
public boolean addListener(@Nonnull L listener) {
if (!baseEventType.isAssignableFrom(listener.getEventType())) {
throw new IllegalArgumentException("Current listener cannot be added, because will never be fired!");
}
return listeners.addListener(listener);
} |
1341207_4 | @Override
public boolean removeListener(@Nonnull L listener) {
return listeners.removeListener(listener);
} |
1341207_5 | @Nonnull
public static <T extends Number & Comparable<T>> NumberIntervalMapper<T> of(@Nonnull Class<T> clazz) {
return new NumberIntervalMapper<T>(clazz);
} |
1341207_6 | @Nonnull
@Override
public SecretKey getSecretKey(@Nonnull String secret, @Nonnull byte[] salt) throws CiphererException {
final String secretKey = secret + Bytes.toHex(salt);
try {
final MessageDigest sha = MessageDigest.getInstance("SHA-1");
byte[] secretKeyHash = sha.digest(secretKey.getBytes(Charsets.UTF_8));
secretKeyHash = Arrays.copyOf(secretKeyHash, saltLength);
return new SecretKeySpec(secretKeyHash, ciphererAlgorithm);
} catch (NoSuchAlgorithmException e) {
throw new CiphererException(e);
}
} |
1341207_7 | @Override
public void removeNodeIf(@Nonnull JPredicate<? super TreeNode<T>> filter) {
Collections.removeIf(this.iterator(), filter);
} |
1341207_8 | @Nonnull
public PrefixTreeNode getRoot() {
return root;
} |
1341207_9 | public boolean containsString(@Nonnull String s) {
return root.containsString(s, 0);
} |
1342891_0 | public <T extends Mapping> T findMapping(MappingType type)
{
return this.findMapping(type, null);
} |
1342891_1 | @Override
public boolean equals(final Object o)
{
if (this == o) { return true; }
if (!(o instanceof InteractionUnit)) { return false; }
InteractionUnit that = (InteractionUnit) o;
if (!id.equals(that.id)) { return false; }
return true;
} |
1342891_2 | public void addMapping(Mapping mapping)
{
if (mapping != null)
{
mappings.put(mapping.getType(), mapping);
}
} |
1342891_3 | @Override
public void execute(final Dialog dialog, final Context context) throws ReificationException
{
IdVisitor idVisitor = new IdVisitor();
dialog.getInterfaceModel().accept(idVisitor);
boolean comma = false;
StringBuilder message = new StringBuilder();
Map<QName, Integer> idCount = idVisitor.getIdCount();
for (Map.Entry<QName, Integer> entry : idCount.entrySet())
{
if (entry.getValue() > 1)
{
if (comma) { message.append(", "); }
message.append(entry.getKey()).append(": ").append(entry.getValue());
comma = false;
}
}
if (message.length() != 0)
{
throw new ReificationException(
"The model contains interaction units with non-unique ids. The following interactions units are used more than once: " + message);
}
} |
1342891_4 | @Override
public void execute(final Dialog dialog, final Context context) throws ReificationException
{
IdVisitor idVisitor = new IdVisitor();
dialog.getInterfaceModel().accept(idVisitor);
boolean comma = false;
StringBuilder message = new StringBuilder();
Map<QName, Integer> idCount = idVisitor.getIdCount();
for (Map.Entry<QName, Integer> entry : idCount.entrySet())
{
if (entry.getValue() > 1)
{
if (comma) { message.append(", "); }
message.append(entry.getKey()).append(": ").append(entry.getValue());
comma = false;
}
}
if (message.length() != 0)
{
throw new ReificationException(
"The model contains interaction units with non-unique ids. The following interactions units are used more than once: " + message);
}
} |
1342891_5 | public CellTree parse(List<Property> model) {
stack.push(root);
parseSiblings(model, "");
return cellTree;
} |
1342891_6 | SingleSelectionModel<JndiEntry> getSelectionModel() {
return selectionModel;
} |
1342891_7 | @Override
public void loadEntities(String nameEditedOrAdded) {
loadEntities(nameEditedOrAdded, Baseadress.get());
} |
1342891_8 | @Override
public void loadEntities(String nameEditedOrAdded) {
loadEntities(nameEditedOrAdded, Baseadress.get());
} |
1346655_0 | public Image tomato() {
int size = tray.iconSize().height;
Image image = tomato(size);
if (image == null) {
image = tomato(DEFAULT_ICON_SIZE);
}
return image;
} |
1346655_1 | public Image tomato() {
int size = tray.iconSize().height;
Image image = tomato(size);
if (image == null) {
image = tomato(DEFAULT_ICON_SIZE);
}
return image;
} |
1346655_2 | public Image image(final String resourceName) {
final URL imageUrl = getClass().getResource(resourceName);
if (imageUrl != null) {
try {
return ImageIO.read(imageUrl);
} catch (IOException e) {
logger.error("Could not load image: " + resourceName, e);
}
}
return null;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.