id
stringlengths
7
14
text
stringlengths
1
37.2k
960343_8
public boolean evaluate(Properties properties) { boolean result = true; for (int j = 0; j < getTiers().size(); j++) { for (ITripletValue tiplet : getTier(j)) { ITripletPermutation permutation = getTier(j); boolean aValue = parseBoolean(String.valueOf(prop...
960760_9
@Override public void bringToFront(final DrawingObject dob) { if (threadSafe) { synchronized (lock) { insertionOrder.put(dob, ++insertionOrderLargest); } } else { insertionOrder.put(dob, ++insertionOrderLargest); } }
990281_80
@Override public <T> BeanHolder<T> resolve(Class<T> typeReference) { Contracts.assertNotNull( typeReference, "typeReference" ); try { return beanProvider.forType( typeReference ); } catch (SearchException e) { try { return resolveSingleConfiguredBean( typeReference ); } catch (RuntimeException e2) { t...
991965_51
public static <T> Iterable<T> mix( final Iterable<T>... iterables ) { return new Iterable<T>() { @Override public Iterator<T> iterator() { final Iterable<Iterator<T>> iterators = toList(map( new Function<Iterable<T>, Iterator<T>>() { ...
992007_8
public static <S, T extends S> Type[] findTypeVariables( Class<T> type, Class<S> searchType ) { return ParameterizedTypes.findParameterizedType( type, searchType ).getActualTypeArguments(); }
992012_3
public Object getValueFromData( final Map<String, Object> rawData, final QualifiedName qualifiedName ) { String convertedIdentifier = convertIdentifier( qualifiedName ); if( rawData.containsKey( convertedIdentifier ) ) { return rawData.remove( convertedIdentifier ); } return null; }
992971_0
public Collection<Throwable> getCauseElements() { return Collections.unmodifiableCollection(this.causes); }
993994_1
public LoadedXml load(final String url, final int timeout) { try { final InputStream stream = loadAsStream(url, timeout); final DocumentBuilder builder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder(); final Document document = builder.parse(stream); return new LoadedXml(document); ...
994088_0
@Override public void setCacheDir(File dir) { // comment below as inmemory configuration does not require dir to be exists // this is relevant when deploy app on readonly file system like heroku and gae if (!dir.isDirectory() && !dir.mkdir()) throw new IllegalArgumentException("not a dir"); ...
1001284_61
public static Object defaultValueOf( Class<? extends Annotation> annotationType, String attribute) { try { return annotationType.getMethod(attribute).getDefaultValue(); } catch (Exception ex) { throw reflectionException(ex); } }
1006123_0
public Wavelet fetchWavelet(WaveId waveId, WaveletId waveletId) throws ClientWaveException { return fetchWavelet(waveId, waveletId, null); }
1007836_19
public List<List<String>> process() { List<List<String>> processed = new ArrayList<List<String>>(); Map<Integer,List<String>> buckets ; List<List<String>> returnArray ; buckets = separateInputBySize(_input); if(buckets == null) return processed; for(int size: buckets.keySet()) { ...
1014623_5
static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; }
1017889_4
public Path append(Path relative) { if (relative == null) { throw new IllegalArgumentException("Argument 'relative' cannot be null"); } if (relative.isAbsolute()) { throw new IllegalArgumentException("Cannot append an absolute path"); } StringBuilder appended = new StringBuilder(pat...
1020601_4
public Number convert(MappingContext<Object, Number> context) { Object source = context.getSource(); if (source == null) return null; Class<?> destinationType = Primitives.wrapperFor(context.getDestinationType()); if (source instanceof Number) return numberFor((Number) source, destinationType); if (...
1024699_26
public List<Item> getAlbumAndSubAlbums(int albumId) throws G3GalleryException { List<Item> items = new ArrayList<Item>(); Item item = getItems(albumId, items, "album"); // we add to the list the parent album items.add(0, item); return items; }
1025574_2
String toXMlFormatted() throws JAXBException, UnsupportedEncodingException { //Create marshaller Marshaller m = jc.createMarshaller(); m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); ByteArrayOutputStream bos = new ByteArrayOutputStream(); m.marshal(this, bos); return bos.toString("UTF-8"); }
1028034_7
public double[] getBasicFunctions(int i, double u) { double[] n = new double[degree + 1]; n[0] = 1.0; double[] left = new double[degree + 1]; double[] right = new double[degree + 1]; for (int j = 1; j <= degree; j++) { left[j] = u - this.knots[(i + 1) - j]; right[j] = this.knots[i ...
1031515_0
public Lookup createLookup(List<String> keys) { return new LookupImpl(keys); }
1050944_201
@Override public void validate() { if (pathPrefix == null || !pathPrefix.matches("\\w+")) { throw new IllegalArgumentException("Path is incorrect"); } }
1052717_4
static <X> Set<Field> camelInjectAnnotatedFieldsIn(final Class<X> type) { final Set<Field> camelInjectAnnotatedFields = new HashSet<Field>(); for (final Field fieldToInspect : allFieldsAndSuperclassFieldsIn(type)) { if (isAnnotatedWithOneOf(fieldToInspect, CAMEL)) { camelInjectAnnotatedFields.add(fieldToInspect)...
1057490_435
public static void unregister(String key) { SpaceUtil.wipe(sp, key); }
1068402_84
public boolean versionSupported(final String requiredVersion, final String publishedVersion) { if (requiredVersion == null) { throw new IllegalArgumentException("requiredVersion is null"); } if (publishedVersion == null) { throw new IllegalArgumentException("publishedVersion is null"); }...
1071043_0
@Override public QuestionSet processDocument( Document doc ) throws ParseException { Element root = doc.getRootElement(); if ( !root.getName().equalsIgnoreCase( "QuestionSet" ) ) throw new ParseException( "QuestionSet: Root not <QuestionSet>", 0 ); // Check version number String versionString ...
1071767_0
public IPNMessage parse() { IPNMessage.Builder builder = new IPNMessage.Builder(nvp); if(validated) builder.validated(); for(Map.Entry<String, String> param : nvp.entrySet()) { addVariable(builder, param); } return builder.build(); }
1072630_1
;
1076094_132
@Transactional @SuppressWarnings("unchecked") public Set<GatewayResponse> sendMessage(GatewayRequest gatewayRequest) { if ( gatewayRequest .getMessageRequest() .getMessageType() == MessageType.VOICE ) { return voiceGatewayManager.sendMessage(gatewayRequest); } if ( gatewayRequest .getMessageReq...
1076159_32
static AnalysisResult analyse( Class<?> klass, Constructor<?> constructor) throws IOException { Class<?>[] parameterTypes = constructor.getParameterTypes(); InputStream in = klass.getResourceAsStream("/" + klass.getName().replace('.', '/') + ".class"); if (in == null) { throw new IllegalArgumentException(...
1076632_14
public void sendStaffCareMessages(Date startDate, Date endDate, Date deliveryDate, Date deliveryTime, String[] careGroups, boolean sendUpcoming, boolean blackoutEnabled, ...
1077753_0
public static List<String> statementsFrom(Reader reader) throws IOException { SQLFile file = new SQLFile(); file.parse(reader); return file.getStatements(); }
1079636_7
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude....
1081751_1
@Nonnull public static XProperties from(@Nonnull @NonNull final String absolutePath) throws IOException { final Resource resource = new PathMatchingResourcePatternResolver() .getResource(absolutePath); try (final InputStream in = resource.getInputStream()) { final XProperties xprops ...
1081991_13
static void writeDependenciesFeature(Writer writer, ProvisionOption<?>... provisionOptions) { XMLOutputFactory xof = XMLOutputFactory.newInstance(); xof.setProperty("javax.xml.stream.isRepairingNamespaces", true); XMLStreamWriter sw = null; try { sw = xof.createXMLStreamWriter(writer); ...
1089023_0
@Override public void subscribe(Completable.Observer subscriber) { completionSignal.subscribe(subscriber); }
1090553_36
@Nullable public <V> V queryValue(@Nullable RegionAssociable subject, Flag<V> flag) { Collection<V> values = queryAllValues(subject, flag, true); return flag.chooseValue(values); }
1091655_1
public String getMBeanName() { return mBeanName; }
1091966_0
public Request read(InputStream in) throws IOException { String header = null; String body = null; byte[] headerBytes = new byte[headerLength]; int n = in.read(headerBytes); if (n > 0) { header = new String(headerBytes, encoding); log.debug("header: #{}# ", header); int len...
1095208_79
@Override public void activate (Instant time, int phaseNumber) { long msec = time.getMillis(); if (msec % (getWeatherReqInterval() * TimeService.HOUR) != 0) { log.info("WeatherService reports not time to grab weather data."); } else { log.info("Timeslot " + timeslotRepo.currentTimeslot().getId()...
1097987_0
@Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { // this shouldn't be possible, but be safe. if (numTerms <= 0) return 0; return ARR[numTerms]; return -0.00606f * numTerms + 0.35f; } //else return (float) (1.0 / Math....
1107344_0
static void printHelp(PrintWriter out) { out.println("Usage:"); out.println(" vark [-f FILE] [options] [targets...]"); out.println(); out.println("Options:"); IArgKeyList keys = Launch.factory().createArgKeyList(); for (IArgKey key : AardvarkOptions.getArgKeys()) { keys.register(key); } keys...
1109529_5
public void dbSelect() throws Exception { Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://localhost:5432/np"; Connection con = DriverManager.getConnection(url, "np", "npnpnp"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(getPlainSQL()); / PreparedStatement stm...
1110934_2
public List<String> extractCprNumbers(String soapResponse) throws CprAbbsException { int start = soapResponse.indexOf("<?xml"); if(start == -1) { throw new CprAbbsException("Invalid message body on call to CPR Abbs"); } String soapResponseWithoutHeader = soapResponse.substring(start); return...
1116314_32
public static <T extends HasTypes> Collector<T, ?, List<T>> closestTypes( T hasTypes ) { return hasTypesToListCollector( hasTypes, new HasAssignableToType<>( hasTypes ) ); }
1146205_24
@Override public int read() throws IOException { return remote.read(); }
1149947_21
@Override public void handleMessage(Exchange exchange) throws HandlerException { // identify ourselves exchange.getContext().setProperty(ExchangeCompletionEvent.GATEWAY_NAME, _bindingName, Scope.EXCHANGE) .addLabels(BehaviorLabel.TRANSIENT.label()); if (getState() != State.STARTED) { th...
1155836_1
@Override public LogLevel getLogLevel() { Level level = m_delegate.getEffectiveLevel(); return getLogLevel(level); }
1155961_9
public Study getByAccForUser(String acc, String userName) { Query query = entityManager.createQuery("SELECT s " + "FROM Study s join s.users user " + "WHERE " + "s.acc =:acc AND (user.userName =:userName" + " OR s.status =:status)" ) .setParameter("acc", acc) .setParameter("status", VisibilityStatu...
1156021_8
public void setStudyOwners(CommandLine cmdl) { String specs[] = cmdl.getOptionValues("o"); if (specs == null) { return; } for (String spec : specs) { setStudyOwners(spec); } }
1156136_4
@Override protected boolean invokeLogic(long keyId) throws Exception { Operation operation = getOperation(operationTypeRandom); OperationTimestampPair prevOperation = timestamps.get(keyId); // first we have to get the value PrivateLogValue prevValue = checkedGetValue(keyId); PrivateLogValue backupValue ...
1158118_0
public static String decrypt(String input) { if (isEmpty(input)) { return input; } char[] inputChars = input.toCharArray(); int length = inputChars.length; char[] inputCharsCopy = new char[length]; int j = 0; int i = 0; while (j < length) { inputCharsCopy[j] = ((char) ...
1158315_44
@Override public void computeEnhancements(ContentItem ci) throws EngineException { IRI contentItemId = ci.getUri(); Graph graph = ci.getMetadata(); LiteralFactory literalFactory = LiteralFactory.getInstance(); //get all the textAnnotations /* * this Map holds the name as key and all the text an...
1161604_0
@Override public TriplestoreReader getReader() { if (m_reader == null){ try{ open(); } catch(TrippiException e){ logger.error(e.toString(),e); } } return m_reader; }
1163141_15
private static void validateRELS(PID pid, String dsId, InputStream content) throws ValidationException { logger.debug("Validating " + dsId + " datastream"); new RelsValidator().validate(pid, dsId, content); logger.debug(dsId + " datastream is valid"); }
1163806_197
static String determineCheckoutPath(final FilePath workspacePath, final String localFolder) { final FilePath combinedPath = new FilePath(workspacePath, localFolder); final String result = combinedPath.getRemote(); return result; }
1164965_50
public WebClassesFinder(ServletContext servletContext, ClassLoader classLoader, PackageFilter packageFilter) { super(servletContext, classLoader, packageFilter); }
1165813_0
public static String extract(final String pem, final String passPhrase) throws IOException { final Object priv = PEMDecoder.decode(pem.toCharArray(), passPhrase); if (priv instanceof RSAPrivateKey) { return "ssh-rsa " + DatatypeConverter.printBase64Binary(RSASHA1Verify.encodeSSHRSAPublicKey(((RSAPrivate...
1167439_0
public void process(final MessageExchange messageExchange) throws Exception { final ContinuationData data = continuations.remove(messageExchange.getExchangeId()); if (data == null) { logger.error("Unexpected MessageExchange received: {}", messageExchange); } else { binding.runWithCamelConte...
1169309_3
public static boolean isFindBugs2x(final MojoExecution mojoExecution) { try { String[] versions = StringUtils.split(mojoExecution.getVersion(), "."); if (versions.length > 1) { int major = Integer.parseInt(versions[0]); int minor = Integer.parseInt(versions[1]); r...
1169697_65
static CommonTree parseHost(String s) throws RecognitionException { return (CommonTree) getDeployParser(s).host().getTree(); }
1171506_0
public void subscribe(Class<? extends Subscriber> subscriber) { try { monitor.lock(); if (subscriber.isAnnotationPresent(InterestedEvent.class)) { InterestedEvent ann = subscriber.getAnnotation(InterestedEvent.class); for (Class<? extends Event> interestedEvent : ann.events()) { if (!subscribers.contains...
1176274_2
boolean hasPlayerMoved() { final double MAX_MOVE_TOLERANCE = 1.5; return distance3D(player.getLocation(), originalLocation) > MAX_MOVE_TOLERANCE; }
1181284_260
@SuppressWarnings("unchecked") public void execute(TransformContext context) throws PluginTransformationException { XPath xpath = DocumentHelper.createXPath("//@class"); List<Attribute> attributes = xpath.selectNodes(context.getDescriptorDocument()); for (Attribute attr : attributes) { String classN...
1184582_8
public String parseOutput(String right) { return parseOutput(null, right); }
1193862_8
public void exportProfile(RulesProfile profile, Writer writer) { try { appendXmlHeader(writer); SortedMap<String, Rule> defaultRules = new TreeMap<String, Rule>(DefaultRules.get()); for (ActiveRule activeRule : profile.getActiveRulesByRepository(REPOSITORY_KEY)) { final Rule ...
1194243_15
public static void removeEntities(Reader reader, Writer writer) throws IOException { int curChar = -1; StringBuffer ent = null; if (reader == null) { throw new IllegalArgumentException("null reader arg"); } else if (writer == null) { throw new IllegalArgumentException("null writ...
1195109_0
public void setFullName(String fullName) { this.fullName = fullName; }
1204957_0
@SuppressWarnings("ConstantConditions") @Override public List<MovieInfo> parseMovieInfo(String content, int maxCount, int posterCount, int backdropCount) throws ParseException { // Minus if (posterCount < 0) { posterCount = Integer.MAX_VALUE; } if (backdropCount < 0) { backdropCount = In...
1205446_0
public static long calculateNotifTime(Long nowMillis, int hourToNotify) { DateTime now = new DateTime(nowMillis); DateTime timeToNotify = new DateTime(nowMillis); timeToNotify = timeToNotify.withHourOfDay(hourToNotify); if (timeToNotify.isBefore(now)) { timeToNotify = timeToNotify.plusDays(1); ...
1205842_1
@Override public List<String> getOperations(String state) { List<String> operationsList = new ArrayList<String>(); for (OperationsDefinition def : this.definition) { if (state.equals(def.getName())) { if ((def.getTransitions() != null)) { for (DestinationDefinition operations : def .getTransitions()) {...
1206855_188
public JQueryUiTooltip setPosition(JsOption... options) { this.widget.setOption("position", asString(options)); return this; }
1216286_1
public void execute(String script) throws QueryScriptException { try { Context cx = Context.enter(); Scriptable scope = cx.initStandardObjects(); scope.put(ARAS_SCRIPT_ENGINE_CONTEXT, scope, arasCtx); loadRhinoBinding(scope, cx); cx.evaluateString(scope, script, "queryscript"...
1228775_2
@Override public Class<?> getBeanClass(Element element) { return ApplicationDecorator.class; }
1229527_2
public static Properties parseInstructions( final String query ) throws MalformedURLException { final Properties instructions = new Properties(); if( query != null ) { try { // just ignore for the moment and try out if we have valid properties separated by "&" fin...
1231687_1
public boolean isBitSet(int bit) { long bitMask = Long.rotateLeft(1, bit); long result = this.bitMaskValue & bitMask; if (result != 0) { return true; } return false; }
1251091_0
public List<Float> getBinned() { if (last == -1) return null; return new ImmutableList.Builder<Float>().addAll(binned).build(); }
1251538_7
@SuppressWarnings("unchecked") @Override public <T extends EnvironmentService> T getEnvironmentService(Class<T> type) throws UnavailableServiceException { // force NullPointerException if type is null type.toString(); for (EnvironmentService s : this.globalEnvironmentServices) { if (type.isInstance(s)) { ret...
1251856_8
boolean isIgnored(File file){ boolean ignore = false; while(file != null){ String end = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(System.getProperty("file.separator")) + 1); for(String pathToIgnore: ignoredPaths){ ignore = end.matches(pathToIgnore); if(ignore){ return true; ...
1263661_9
public CSVFile downloadFile(CSVFile file) throws ServerCommunicationException, InvalidWriteEnablerException, ImmutableFileExistsException, RemoteFileDoesNotExistException, FailedToVerifySignatureException { return (CSVFile) downloadObject(file); }
1269176_202
public static Snapshot readSnapshot(IdReader reader, Snapshot oldSnapshot) throws IOException { assert reader.idManager == oldSnapshot.idManager; reader.readDiffs(); int snapshotId = reader.readInt(); boolean hasTool = reader.readBoolean(); Tool tool = hasTool ? reader.readTool() : null; Enviro...
1273791_99
@Override public List<Token> tokenize(String text) { return createTokenList(text); }
1274071_4
public static Result execute(List<AdaptationCommand> cmds) { Result result = new Result(); for (AdaptationCommand cmd : cmds) { try { cmd.execute(); result.executedCmds.add(cmd); } catch (KevoreeAdaptationException e) { result.error = e; return re...
1274332_10
public static BooleanValue ldap_unbind (LdapLinkResource linkIdentifier) { // Avoid NPEs from this being called on non-existent linkIdentifiers. if (linkIdentifier == null) { return BooleanValue.create(false); } boolean success = linkIdentifier.unbind(); return BooleanValue.create(success); ...
1287669_60
public static JsonAsserter with(String json) { return new JsonAsserterImpl(JsonPath.parse(json).json()); }
1290826_8
public static String getPublicId(String otp) { if ((otp == null) || (otp.length() < OTP_MIN_LEN)){ //not a valid OTP format, throw an exception throw new IllegalArgumentException("The OTP is too short to be valid"); } Integer len = otp.length(); /* The OTP part is always the last 32 bytes of otp. Whatever is...
1293378_2
public float getMutation() { return mutation; }
1294371_16
public static String getParentOf(String path) { int i = path.lastIndexOf(DELIM); if (i == -1) return ""; if (i == 0) i = 1; return path.substring(0, i); }
1302098_5
public static CompositeData parseComposite(URI uri) throws URISyntaxException { CompositeData rc = new CompositeData(); rc.scheme = uri.getScheme(); String ssp = stripPrefix(uri.getSchemeSpecificPart().trim(), "//").trim(); parseComposite(uri, rc, ssp); rc.fragment = uri.getFragment(); return...
1307005_0
public File newFolder(String folder) throws IOException { return newFolder(new String[]{folder}); }
1307227_2
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)); ...
1312627_5
public static String getKernelRevision() { return KERNEL_VERSION.getRevision(); }
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) || ...
1318639_2
@Override public String[] getJobsInProgress() throws NodeDoesNotExistException, ZooKeeperConnectionException, WatcherException { if (zk == null) { try { initializeZooKeeper(); } catch (Exception e) { throw new ZooKeeperConnectio...
1319605_35
@Override public boolean isValid(CharSequence domain, ConstraintValidatorContext context) { Matcher matcher = DOMAIN_NAME_REGEX.matcher(domain); if (matcher.matches()) { domain = matcher.group(1); return isValidTld(domain.toString()); } return allowLocal && DOMAIN_LABEL.matcher(domain).m...
1320181_158
public Datastore findDatastoreById(final Integer id) { assert id != null; return datastoreDao.findById(id); }
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; }
1328283_24
@Override public void get(ByteBuffer key, ReaderResult result) throws IOException { StringBuilder sb = new StringBuilder(); sb.append("Original value: "); sb.append(BytesUtils.bytesToHexString(key)); sb.append(" Assigned to partition number: "); sb.append(partNum); byte[] bytes = sb.toString().getBytes(); ...
1337781_11
@Override public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { StringBuffer errorMsgBegin = new StringBuffer(""); List<Object[]> paramCouple = new LinkedList<Object[]>(); paramCouple.addAll(ReflectionHelper.getParametersWithAnnotation(method, Page.class)); for ...
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; } }
1341207_31
@Nonnull Integer getMaxAbsNumber(@Nonnull Integer[] numbers) { Integer maxAbsNumber = 0; for (Integer number : numbers) { if (number >= 0) { if (number > maxAbsNumber) { maxAbsNumber = number; } } else if (number == Integer.MIN_VALUE) { maxAbsNumber = Integer.MAX_VALUE; } else { if (-number > ma...
1342891_5
public CellTree parse(List<Property> model) { stack.push(root); parseSiblings(model, ""); return cellTree; }